1SUMMARY = "System-V like init"
2DESCRIPTION = "This package is required to boot in most configurations.  It provides the /sbin/init program.  This is the first process started on boot, and the last process terminated before the system halts."
3HOMEPAGE = "http://savannah.nongnu.org/projects/sysvinit/"
4SECTION = "base"
5LICENSE = "GPL-2.0-or-later"
6LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe \
7                    file://COPYRIGHT;endline=15;md5=a1d3b3526501d3546d530bbe6ab6cdbe \
8                    "
9
10RDEPENDS:${PN} = "${PN}-inittab"
11
12GITHUB_BASE_URI = "https://github.com/slicer69/${BPN}/releases/"
13SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/${BP}.tar.xz \
14           file://install.patch \
15           file://crypt-lib.patch \
16           file://pidof-add-m-option.patch \
17           file://realpath.patch \
18           file://0001-include-sys-sysmacros.h-for-major-minor-defines-in-g.patch \
19           file://rcS-default \
20           file://rc \
21           file://rcS \
22           file://bootlogd.init \
23           file://01_bootlogd \
24           "
25SRC_URI[sha256sum] = "04f1b7d67413af1c09c41acc1e3ce946f2d0f7a1e47c9978744bc542864e13d4"
26
27S = "${WORKDIR}/sysvinit-${PV}"
28
29inherit update-alternatives features_check github-releases
30DEPENDS:append = " update-rc.d-native base-passwd virtual/crypt"
31do_package_setscene[depends] = "${MLPREFIX}base-passwd:do_populate_sysroot"
32
33PACKAGECONFIG[psplash-text-updates] = ",,"
34
35REQUIRED_DISTRO_FEATURES = "sysvinit"
36
37ALTERNATIVE:${PN} = "init mountpoint halt reboot runlevel shutdown poweroff last lastb mesg utmpdump wall"
38
39ALTERNATIVE_PRIORITY = "200"
40
41ALTERNATIVE_LINK_NAME[init] = "${base_sbindir}/init"
42ALTERNATIVE_PRIORITY[init] = "50"
43
44ALTERNATIVE_LINK_NAME[mountpoint] = "${base_bindir}/mountpoint"
45ALTERNATIVE_PRIORITY[mountpoint] = "20"
46
47ALTERNATIVE_LINK_NAME[halt] = "${base_sbindir}/halt"
48ALTERNATIVE_LINK_NAME[reboot] = "${base_sbindir}/reboot"
49ALTERNATIVE_LINK_NAME[runlevel] = "${base_sbindir}/runlevel"
50ALTERNATIVE_LINK_NAME[shutdown] = "${base_sbindir}/shutdown"
51ALTERNATIVE_LINK_NAME[poweroff] = "${base_sbindir}/poweroff"
52
53ALTERNATIVE:${PN}-pidof = "pidof"
54ALTERNATIVE_LINK_NAME[pidof] = "${base_bindir}/pidof"
55
56ALTERNATIVE:${PN}-sulogin = "sulogin"
57ALTERNATIVE_LINK_NAME[sulogin] = "${base_sbindir}/sulogin"
58
59ALTERNATIVE:${PN}-doc = "mountpoint.1 last.1 lastb.1 mesg.1 wall.1 sulogin.8 utmpdump.1"
60
61ALTERNATIVE_LINK_NAME[last.1] = "${mandir}/man1/last.1"
62ALTERNATIVE_LINK_NAME[lastb.1] = "${mandir}/man1/lastb.1"
63ALTERNATIVE_LINK_NAME[mesg.1] = "${mandir}/man1/mesg.1"
64ALTERNATIVE_LINK_NAME[mountpoint.1] = "${mandir}/man1/mountpoint.1"
65ALTERNATIVE_LINK_NAME[sulogin.8] = "${mandir}/man8/sulogin.8"
66ALTERNATIVE_LINK_NAME[utmpdump.1] = "${mandir}/man1/utmpdump.1"
67ALTERNATIVE_LINK_NAME[wall.1] = "${mandir}/man1/wall.1"
68
69PACKAGES =+ "sysvinit-pidof sysvinit-sulogin"
70FILES:${PN} += "${base_sbindir}/* ${base_bindir}/*"
71FILES:sysvinit-pidof = "${base_bindir}/pidof.sysvinit ${base_sbindir}/killall5"
72FILES:sysvinit-sulogin = "${base_sbindir}/sulogin.sysvinit"
73
74RDEPENDS:${PN} += "sysvinit-pidof initd-functions base-passwd"
75
76CFLAGS:prepend = "-D_GNU_SOURCE "
77export LCRYPT = "-lcrypt"
78EXTRA_OEMAKE += "'base_bindir=${base_bindir}' \
79		 'base_sbindir=${base_sbindir}' \
80		 'bindir=${bindir}' \
81		 'sbindir=${sbindir}' \
82		 'sysconfdir=${sysconfdir}' \
83		 'includedir=${includedir}' \
84		 'mandir=${mandir}' \
85                 MNTPOINT=yes"
86
87do_install () {
88	oe_runmake 'ROOT=${D}' install
89
90	install -d ${D}${sysconfdir} \
91		   ${D}${sysconfdir}/default \
92		   ${D}${sysconfdir}/init.d
93	for level in S 0 1 2 3 4 5 6; do
94		install -d ${D}${sysconfdir}/rc$level.d
95	done
96
97	sed -e \
98		's:#PSPLASH_TEXT#:${@bb.utils.contains("PACKAGECONFIG","psplash-text-updates","yes","no", d)}:g' \
99		${UNPACKDIR}/rcS-default > ${D}${sysconfdir}/default/rcS
100	chmod 0644 ${D}${sysconfdir}/default/rcS
101	install -m 0755    ${UNPACKDIR}/rc		${D}${sysconfdir}/init.d
102	install -m 0755    ${UNPACKDIR}/rcS		${D}${sysconfdir}/init.d
103	install -m 0755    ${UNPACKDIR}/bootlogd.init     ${D}${sysconfdir}/init.d/bootlogd
104	ln -sf bootlogd ${D}${sysconfdir}/init.d/stop-bootlogd
105
106	update-rc.d -r ${D} bootlogd start 07 S .
107	update-rc.d -r ${D} stop-bootlogd start 99 2 3 4 5 .
108
109	install -d ${D}${sysconfdir}/default/volatiles
110	install -m 0644 ${UNPACKDIR}/01_bootlogd ${D}${sysconfdir}/default/volatiles
111
112	chown root:shutdown ${D}${base_sbindir}/halt ${D}${base_sbindir}/shutdown
113	chmod o-x,u+s ${D}${base_sbindir}/halt ${D}${base_sbindir}/shutdown
114
115        # Already provided by e2fsprogs; sysvinit's version is a copy from there
116        rm ${D}${base_sbindir}/logsave
117        rm ${D}${mandir}/man8/logsave.8
118}
119