Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | SUMMARY = "Inittab configuration for SysVinit" |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 2 | LICENSE = "GPL-2.0-only" |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 3 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4 | |
| 5 | PR = "r10" |
| 6 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 7 | SRC_URI = "file://inittab \ |
| 8 | file://start_getty" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9 | |
| 10 | S = "${WORKDIR}" |
| 11 | |
| 12 | INHIBIT_DEFAULT_DEPS = "1" |
| 13 | |
| 14 | do_compile() { |
| 15 | : |
| 16 | } |
| 17 | |
| 18 | do_install() { |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 19 | install -d ${D}${sysconfdir} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 20 | install -m 0644 ${WORKDIR}/inittab ${D}${sysconfdir}/inittab |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 21 | install -d ${D}${base_bindir} |
| 22 | install -m 0755 ${WORKDIR}/start_getty ${D}${base_bindir}/start_getty |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 23 | sed -e 's,/usr/bin,${bindir},g' -i ${D}${base_bindir}/start_getty |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 24 | |
| 25 | set -x |
| 26 | tmp="${SERIAL_CONSOLES}" |
| 27 | for i in $tmp |
| 28 | do |
| 29 | j=`echo ${i} | sed s/\;/\ /g` |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 30 | l=`echo ${i} | sed -e 's/tty//' -e 's/^.*;//' -e 's/;.*//'` |
| 31 | label=`echo $l | sed 's/.*\(....\)/\1/'` |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 32 | echo "$label:12345:respawn:${base_bindir}/start_getty ${j} vt102" >> ${D}${sysconfdir}/inittab |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 33 | done |
| 34 | |
| 35 | if [ "${USE_VT}" = "1" ]; then |
| 36 | cat <<EOF >>${D}${sysconfdir}/inittab |
| 37 | # ${base_sbindir}/getty invocations for the runlevels. |
| 38 | # |
| 39 | # The "id" field MUST be the same as the last |
| 40 | # characters of the device (after "tty"). |
| 41 | # |
| 42 | # Format: |
| 43 | # <id>:<runlevels>:<action>:<process> |
| 44 | # |
| 45 | |
| 46 | EOF |
| 47 | |
| 48 | for n in ${SYSVINIT_ENABLED_GETTYS} |
| 49 | do |
| 50 | echo "$n:12345:respawn:${base_sbindir}/getty 38400 tty$n" >> ${D}${sysconfdir}/inittab |
| 51 | done |
| 52 | echo "" >> ${D}${sysconfdir}/inittab |
| 53 | fi |
| 54 | } |
| 55 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 56 | pkg_postinst:${PN} () { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 57 | # run this on host and on target |
| 58 | if [ "${SERIAL_CONSOLES_CHECK}" = "" ]; then |
| 59 | exit 0 |
| 60 | fi |
| 61 | } |
| 62 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 63 | pkg_postinst_ontarget:${PN} () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 64 | # run this on the target |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 65 | if [ -e /proc/consoles ]; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 66 | tmp="${SERIAL_CONSOLES_CHECK}" |
| 67 | for i in $tmp |
| 68 | do |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 69 | j=`echo ${i} | sed -e s/^.*\;//g -e s/\:.*//g` |
| 70 | k=`echo ${i} | sed s/^.*\://g` |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 71 | if [ -z "`grep ${j} /proc/consoles`" ]; then |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 72 | if [ -z "${k}" ] || [ -z "`grep ${k} /proc/consoles`" ] || [ ! -e /dev/${j} ]; then |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 73 | sed -i -e /^.*${j}\ /d -e /^.*${j}$/d /etc/inittab |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 74 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 75 | fi |
| 76 | done |
| 77 | kill -HUP 1 |
| 78 | else |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 79 | exit 1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 80 | fi |
| 81 | } |
| 82 | |
| 83 | # USE_VT and SERIAL_CONSOLES are generally defined by the MACHINE .conf. |
| 84 | # Set PACKAGE_ARCH appropriately. |
| 85 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 86 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 87 | FILES:${PN} = "${sysconfdir}/inittab ${base_bindir}/start_getty" |
| 88 | CONFFILES:${PN} = "${sysconfdir}/inittab" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 89 | |
| 90 | USE_VT ?= "1" |
| 91 | SYSVINIT_ENABLED_GETTYS ?= "1" |
| 92 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 93 | RCONFLICTS:${PN} = "busybox-inittab" |