blob: b1f9cb4caa6f4f3e8d174aa91b3a4b24c7b7f1c9 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "Inittab configuration for SysVinit"
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00002LICENSE = "GPL-2.0-only"
Andrew Geissler90fd73c2021-03-05 15:25:55 -06003LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05004
Patrick Williamsc124f4f2015-09-15 14:41:29 -05005
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05006SRC_URI = "file://inittab \
7 file://start_getty"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05008
9S = "${WORKDIR}"
10
11INHIBIT_DEFAULT_DEPS = "1"
12
13do_compile() {
14 :
15}
16
17do_install() {
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050018 install -d ${D}${sysconfdir}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019 install -m 0644 ${WORKDIR}/inittab ${D}${sysconfdir}/inittab
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050020 install -d ${D}${base_bindir}
21 install -m 0755 ${WORKDIR}/start_getty ${D}${base_bindir}/start_getty
Brad Bishop19323692019-04-05 15:28:33 -040022 sed -e 's,/usr/bin,${bindir},g' -i ${D}${base_bindir}/start_getty
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023
24 set -x
25 tmp="${SERIAL_CONSOLES}"
26 for i in $tmp
27 do
28 j=`echo ${i} | sed s/\;/\ /g`
Patrick Williamsc0f7c042017-02-23 20:41:17 -060029 l=`echo ${i} | sed -e 's/tty//' -e 's/^.*;//' -e 's/;.*//'`
30 label=`echo $l | sed 's/.*\(....\)/\1/'`
Brad Bishop6e60e8b2018-02-01 10:27:11 -050031 echo "$label:12345:respawn:${base_bindir}/start_getty ${j} vt102" >> ${D}${sysconfdir}/inittab
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032 done
33
34 if [ "${USE_VT}" = "1" ]; then
35 cat <<EOF >>${D}${sysconfdir}/inittab
36# ${base_sbindir}/getty invocations for the runlevels.
37#
38# The "id" field MUST be the same as the last
39# characters of the device (after "tty").
40#
41# Format:
42# <id>:<runlevels>:<action>:<process>
43#
44
45EOF
46
47 for n in ${SYSVINIT_ENABLED_GETTYS}
48 do
49 echo "$n:12345:respawn:${base_sbindir}/getty 38400 tty$n" >> ${D}${sysconfdir}/inittab
50 done
51 echo "" >> ${D}${sysconfdir}/inittab
52 fi
53}
54
Patrick Williams213cb262021-08-07 19:21:33 -050055pkg_postinst:${PN} () {
Brad Bishop316dfdd2018-06-25 12:45:53 -040056# run this on host and on target
57if [ "${SERIAL_CONSOLES_CHECK}" = "" ]; then
58 exit 0
59fi
60}
61
Patrick Williams213cb262021-08-07 19:21:33 -050062pkg_postinst_ontarget:${PN} () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063# run this on the target
Brad Bishop316dfdd2018-06-25 12:45:53 -040064if [ -e /proc/consoles ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050065 tmp="${SERIAL_CONSOLES_CHECK}"
66 for i in $tmp
67 do
Patrick Williamsc0f7c042017-02-23 20:41:17 -060068 j=`echo ${i} | sed -e s/^.*\;//g -e s/\:.*//g`
69 k=`echo ${i} | sed s/^.*\://g`
Patrick Williamsc124f4f2015-09-15 14:41:29 -050070 if [ -z "`grep ${j} /proc/consoles`" ]; then
Patrick Williamsc0f7c042017-02-23 20:41:17 -060071 if [ -z "${k}" ] || [ -z "`grep ${k} /proc/consoles`" ] || [ ! -e /dev/${j} ]; then
Brad Bishop6e60e8b2018-02-01 10:27:11 -050072 sed -i -e /^.*${j}\ /d -e /^.*${j}$/d /etc/inittab
Patrick Williamsc0f7c042017-02-23 20:41:17 -060073 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074 fi
75 done
76 kill -HUP 1
77else
Brad Bishop316dfdd2018-06-25 12:45:53 -040078 exit 1
Patrick Williamsc124f4f2015-09-15 14:41:29 -050079fi
80}
81
82# USE_VT and SERIAL_CONSOLES are generally defined by the MACHINE .conf.
83# Set PACKAGE_ARCH appropriately.
84PACKAGE_ARCH = "${MACHINE_ARCH}"
85
Patrick Williams213cb262021-08-07 19:21:33 -050086FILES:${PN} = "${sysconfdir}/inittab ${base_bindir}/start_getty"
87CONFFILES:${PN} = "${sysconfdir}/inittab"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088
89USE_VT ?= "1"
90SYSVINIT_ENABLED_GETTYS ?= "1"
91
Patrick Williams213cb262021-08-07 19:21:33 -050092RCONFLICTS:${PN} = "busybox-inittab"