I am working with the Yocto build system and have encountered an issue with a recipe that manages /etc/inittab
. Specifically, I am using the Karo Q93 board and the Karo layers in my build. One of the supplier's (Karo) appended recipes, sysvinit-inittab
, adds some lines to /etc/inittab
as shown below:
do_install () {
install -d ${D}${sysconfdir}
install -m 0644 ${WORKDIR}/inittab ${D}${sysconfdir}/inittab
i=0
cons="${SERIAL_CONSOLES}"
for c in ${cons}; do
if [ $i = 0 ]; then
grep -q '# Serial consoles on the standard serial ports' ${D}${sysconfdir}/inittab && break
cat <<EOF >> ${D}${sysconfdir}/inittab
#
# Serial consoles on the standard serial ports
EOF
fi
j=`echo ${c} | sed 's/;/ /g'`
l=`echo ${c} | sed 's/tty//;s/^.*;//;s/;.*//'`
echo "s$i:123:respawn:${base_sbindir}/getty -L ${j} linux" >> ${D}${sysconfdir}/inittab
i=`expr $i + 1`
done
if [ "${USE_VT}" = "1" ]; then
cat <<EOF >> ${D}${sysconfdir}/inittab
In my application, I use the serial port (/dev/ttyLP2
) for some communication, but the recipe above adds the line s2:123:respawn:/sbin/getty -L 115200 ttyLP2 linux
to /etc/inittab
, which causes a getty
process to attach to /dev/ttyLP2
. I want to remove or skip adding that line into /etc/inittab
during the build process.
I attempted to append to the same recipe from my custom layer with a file that comments out the problematic line, but it didn't work as expected. This approach ended up corrupting the /etc/inittab
file, resulting in the removal of other necessary lines. Below is the content of my custom append file sysvinit-inittab_%.bbappend
:
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI += "file://inittab"
And the content of the inittab
file is:
#s2:123:respawn:/sbin/getty -L 115200 ttyLP2 linux
Unfortunately, this solution didn't resolve the issue and caused additional problems with the /etc/inittab
file. Could anyone suggest an efficient way to solve this problem without affecting other configurations in /etc/inittab
?
I've solved it by updating the custom append file sysvinit-inittab_%.bbappend
to comment out the specific line using sed
in do_install
:
do_install:append() {
# Comment out the line
sed -i 's|^s2:123:respawn:/sbin/getty -L 115200 ttyLP2 linux|#s2:123:respawn:/sbin/getty -L 115200 ttyLP2 linux|' ${D}${sysconfdir}/inittab
}
Additionally, I made sure that my custom layer is prioritized in the conf/layer.conf
to ensure that my changes take effect.