Stop using update-alternatives for init scripts
cover Stop using update-alternatives for init scripts
This patchset does away with the usage of update-alternatives for managing init scripts. Using u-a for initscripts cause race/ordering issues with package scriptlets doing daemon stop/start/enable at package installation time. The patchset also reverts a kludge that was introduced in update-alternatives.bbclass and update-rc.d.bbclass to work around the aforementioned problems. Finally, it introduces sanity check to update-alternatives.bbclass to prevent usage of u-a for init scripts in the future.
[YOCTO #10944]
The following changes since commit 3b413a80578caacd9a7f405f3c51a3921d78a60d:
README.qemu: qemuppc64 is not supported (2017-10-16 23:54:27 +0100)
are available in the git repository at:
git://git.openembedded.org/openembedded-core-contrib marquiz/fixes-10944
http://cgit.openembedded.org/openembedded-core-contrib/log/?h=marquiz/fixes-10944
Markus Lehtonen (6):
sysklogd: don't use update-alternatives
initscripts: don't use update-alternatives
lsbinitscripts: don't use update-alternatives
initscripts: rrecommend initscripts-functions
Revert "classes: Fix alternatives and rc.d ordering" update-alternatives.bbclass: refuse to manage SysV init scripts
meta/classes/update-alternatives.bbclass | 33 ++++++++---------------- meta/classes/update-rc.d.bbclass | 23 +++-------------- meta/conf/distro/include/default-providers.inc | 1 + meta/recipes-core/initscripts/initscripts_1.0.bb | 11 ++++---- meta/recipes-core/sysvinit/sysvinit_2.88dsf.bb | 2 +- meta/recipes-extended/lsb/lsbinitscripts_9.72.bb | 8 ++---- meta/recipes-extended/sysklogd/sysklogd.inc | 12 +-------- 7 files changed, 24 insertions(+), 66 deletions(-)
Signature · 1 line
2.13.6
PATCH 1/6 sysklogd: don't use update-alternatives
Using update-alternatives for managing init scripts has proved to be problematic. And, sysklogd rconflicts with other syslog daemons so there is no point in using update-alternatives from this perspective, either.
[YOCTO #10944]
--- meta/recipes-extended/sysklogd/sysklogd.inc | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
meta/recipes-extended/sysklogd/sysklogd.inc +1 -11
@@ -11,7 +11,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=8ca43cbc842c2336e835926c2166c28b \ file://klogd.c;beginline=2;endline=19;md5=7e87ed0ae6142de079bce738c10c899d \ " -inherit update-rc.d update-alternatives systemd +inherit update-rc.d systemd SRC_URI = "http://www.infodrom.org/projects/sysklogd/download/sysklogd-${PV}.tar.gz \ file://no-strip-install.patch \
@@ -58,16 +58,6 @@ do_install () { FILES_${PN} += "${@bb.utils.contains('DISTRO_FEATURES','systemd','${exec_prefix}/lib/tmpfiles.d/sysklogd.conf', '', d)}" -ALTERNATIVE_PRIORITY = "100" - -ALTERNATIVE_${PN} = "syslogd klogd" - -ALTERNATIVE_${PN}-doc = "syslogd.8" -ALTERNATIVE_LINK_NAME[syslogd.8] = "${mandir}/man8/syslogd.8" - -ALTERNATIVE_LINK_NAME[syslogd] = "${base_sbindir}/syslogd" -ALTERNATIVE_LINK_NAME[klogd] = "${base_sbindir}/klogd" - pkg_prerm_${PN} () { if test "x$D" = "x"; then if test "$1" = "upgrade" -o "$1" = "remove"; then
Signature · 1 line
2.13.6
PATCH 2/6 initscripts: don't use update-alternatives
In reply to Markus LehtonenStop using update-alternatives for managing /etc/init.d/functions. Also, make the initscripts-functions subpackage to (runtime) conflict with lsbinitscripts.
[YOCTO #10944]
--- meta/classes/update-rc.d.bbclass | 3 +-- meta/conf/distro/include/default-providers.inc | 1 + meta/recipes-core/initscripts/initscripts_1.0.bb | 9 +++------ meta/recipes-core/sysvinit/sysvinit_2.88dsf.bb | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-)
meta/classes/update-rc.d.bbclass +1 -2
@@ -95,8 +95,7 @@ python populate_packages_updatercd () { return statement = "grep -q -w '/etc/init.d/functions' %s" % path if subprocess.call(statement, shell=True) == 0: - mlprefix = d.getVar('MLPREFIX') or "" - d.appendVar('RDEPENDS_' + pkg, ' %sinitscripts-functions' % (mlprefix)) + d.appendVar('RDEPENDS_' + pkg, ' initd-functions') def update_rcd_package(pkg): bb.debug(1, 'adding update-rc.d calls to preinst/postinst/prerm/postrm for %s' % pkg)
meta/conf/distro/include/default-providers.inc +1 -0
@@ -56,3 +56,4 @@ PREFERRED_PROVIDER_nativesdk-openssl ?= "nativesdk-openssl" PREFERRED_PROVIDER_pkgconfig ?= "pkgconfig" PREFERRED_PROVIDER_nativesdk-pkgconfig ?= "nativesdk-pkgconfig" PREFERRED_PROVIDER_pkgconfig-native ?= "pkgconfig-native" +PREFERRED_RPROVIDER_initd-functions ?= "initscripts"
meta/recipes-core/initscripts/initscripts_1.0.bb +3 -6
@@ -43,21 +43,18 @@ SRC_URI_append_arm = " file://alignment.sh" KERNEL_VERSION = "" -inherit update-alternatives DEPENDS_append = " update-rc.d-native" PACKAGE_WRITE_DEPS_append = " ${@bb.utils.contains('DISTRO_FEATURES','systemd','systemd-systemctl-native','',d)}" PACKAGES =+ "${PN}-functions ${PN}-sushell" -RDEPENDS_${PN} = "${PN}-functions \ +RDEPENDS_${PN} = "initd-functions \ ${@bb.utils.contains('DISTRO_FEATURES','selinux','${PN}-sushell','',d)} \ " +RPROVIDES_${PN}-functions = "initd-functions" +RCONFLICTS_${PN}-functions = "lsbinitscripts" FILES_${PN}-functions = "${sysconfdir}/init.d/functions*" FILES_${PN}-sushell = "${base_sbindir}/sushell" -ALTERNATIVE_PRIORITY_${PN}-functions = "90" -ALTERNATIVE_${PN}-functions = "functions" -ALTERNATIVE_LINK_NAME[functions] = "${sysconfdir}/init.d/functions" - HALTARGS ?= "-d -f" do_configure() {
meta/recipes-core/sysvinit/sysvinit_2.88dsf.bb +1 -1
@@ -68,7 +68,7 @@ FILES_${PN} += "${base_sbindir}/* ${base_bindir}/*" FILES_sysvinit-pidof = "${base_bindir}/pidof.sysvinit ${base_sbindir}/killall5" FILES_sysvinit-sulogin = "${base_sbindir}/sulogin.sysvinit" -RDEPENDS_${PN} += "sysvinit-pidof initscripts-functions" +RDEPENDS_${PN} += "sysvinit-pidof initd-functions" CFLAGS_prepend = "-D_GNU_SOURCE " export LCRYPT = "-lcrypt"
Signature · 1 line
2.13.6
PATCH 3/6 lsbinitscripts: don't use update-alternatives
In reply to Markus LehtonenMake lsbinitscripts (r)conflict with initscripts-functions package.
[YOCTO #10944]
--- meta/recipes-extended/lsb/lsbinitscripts_9.72.bb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
meta/recipes-extended/lsb/lsbinitscripts_9.72.bb +2 -6
@@ -4,7 +4,9 @@ SECTION = "base" LICENSE = "GPLv2" DEPENDS = "popt glib-2.0" +RPROVIDES_${PN} += "initd-functions" RDEPENDS_${PN} += "util-linux" +RCONFLICTS_${PN} = "initscripts-functions" LIC_FILES_CHKSUM = "file://COPYING;md5=ebf4e8b49780ab187d51bd26aaa022c6"
@@ -17,12 +19,6 @@ SRC_URI = "http://pkgs.fedoraproject.org/repo/pkgs/initscripts/initscripts-${PV} SRC_URI[md5sum] = "d6c798f40dceb117e12126d94cb25a9a" SRC_URI[sha256sum] = "1793677bdd1f7ee4cb00878ce43346196374f848a4c8e4559e086040fc7487db" -inherit update-alternatives - -ALTERNATIVE_PRIORITY = "100" -ALTERNATIVE_${PN} = "functions" -ALTERNATIVE_LINK_NAME[functions] = "${sysconfdir}/init.d/functions" - # Since we are only taking the patched version of functions, no need to # configure or compile anything so do not execute these do_configure[noexec] = "1"
Signature · 1 line
2.13.6
PATCH 4/6 initscripts: rrecommend initscripts-functions
In reply to Markus LehtonenIn order to make that the default provider for initd-functions.
[YOCTO #10944]
--- meta/recipes-core/initscripts/initscripts_1.0.bb | 2 ++ 1 file changed, 2 insertions(+)
meta/recipes-core/initscripts/initscripts_1.0.bb +2 -0
@@ -50,6 +50,8 @@ PACKAGES =+ "${PN}-functions ${PN}-sushell" RDEPENDS_${PN} = "initd-functions \ ${@bb.utils.contains('DISTRO_FEATURES','selinux','${PN}-sushell','',d)} \ " +# Recommend pn-functions so that it will be a preferred default provider for initd-functions +RRECOMMENDS_${PN} = "${PN}-functions" RPROVIDES_${PN}-functions = "initd-functions" RCONFLICTS_${PN}-functions = "lsbinitscripts" FILES_${PN}-functions = "${sysconfdir}/init.d/functions*"
Signature · 1 line
2.13.6
PATCH 5/6 Revert "classes: Fix alternatives and rc.d ordering"
In reply to Markus LehtonenThis kludge is not needed anymore, now that syslog packages (or any other package) don't use update-alternatives for managing SysV init scripts.
This reverts commit fc89a3f739ff25306ea91d9bdb424fc8389bdf72.
[YOCTO #10944]
--- meta/classes/update-alternatives.bbclass | 29 +++++++---------------------- meta/classes/update-rc.d.bbclass | 20 ++------------------ 2 files changed, 9 insertions(+), 40 deletions(-)
meta/classes/update-alternatives.bbclass +7 -22
@@ -201,8 +201,8 @@ python populate_packages_updatealternatives () { pkgdest = d.getVar('PKGD') for pkg in (d.getVar('PACKAGES') or "").split(): # Create post install/removal scripts - alt_setup_links = "# Begin section update-alternatives\n" - alt_remove_links = "# Begin section update-alternatives\n" + alt_setup_links = "" + alt_remove_links = "" for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg) or "").split(): alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name) alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name)
@@ -225,13 +225,10 @@ python populate_packages_updatealternatives () { # Default to generate shell script.. eventually we may want to change this... alt_target = os.path.normpath(alt_target) - alt_setup_links += 'update-alternatives --install %s %s %s %s\n' % (alt_link, alt_name, alt_target, alt_priority) - alt_remove_links += 'update-alternatives --remove %s %s\n' % (alt_name, alt_target) + alt_setup_links += '\tupdate-alternatives --install %s %s %s %s\n' % (alt_link, alt_name, alt_target, alt_priority) + alt_remove_links += '\tupdate-alternatives --remove %s %s\n' % (alt_name, alt_target) - alt_setup_links += "# End section update-alternatives\n" - alt_remove_links += "# End section update-alternatives\n" - - if len(alt_setup_links.splitlines()) > 2: + if alt_setup_links: # RDEPENDS setup provider = d.getVar('VIRTUAL-RUNTIME_update-alternatives') if provider:
@@ -241,24 +238,12 @@ python populate_packages_updatealternatives () { bb.note('adding update-alternatives calls to postinst/prerm for %s' % pkg) bb.note('%s' % alt_setup_links) postinst = d.getVar('pkg_postinst_%s' % pkg) or '#!/bin/sh\n' - postinst = postinst.splitlines(True) - try: - index = postinst.index('# Begin section update-rc.d\n') - postinst.insert(index, alt_setup_links) - except ValueError: - postinst.append(alt_setup_links) - postinst = ''.join(postinst) + postinst += alt_setup_links d.setVar('pkg_postinst_%s' % pkg, postinst) bb.note('%s' % alt_remove_links) prerm = d.getVar('pkg_prerm_%s' % pkg) or '#!/bin/sh\n' - prerm = prerm.splitlines(True) - try: - index = prerm.index('# End section update-rc.d\n') - prerm.insert(index + 1, alt_remove_links) - except ValueError: - prerm.append(alt_remove_links) - prerm = ''.join(prerm) + prerm += alt_remove_links d.setVar('pkg_prerm_%s' % pkg, prerm) }
meta/classes/update-rc.d.bbclass +2 -18
@@ -37,7 +37,6 @@ fi PACKAGE_WRITE_DEPS += "update-rc.d-native" updatercd_postinst() { -# Begin section update-rc.d if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then if [ -n "$D" ]; then OPT="-r $D"
@@ -46,15 +45,12 @@ if ${@use_updatercd(d)} && type update-rc.d >/dev/null 2>/dev/null; then fi update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS} fi -# End section update-rc.d } updatercd_prerm() { -# Begin section update-rc.d if ${@use_updatercd(d)} && [ -z "$D" -a -x "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then ${INIT_D_DIR}/${INITSCRIPT_NAME} stop || : fi -# End section update-rc.d } updatercd_postrm() {
@@ -115,25 +111,13 @@ python populate_packages_updatercd () { postinst = d.getVar('pkg_postinst_%s' % pkg) if not postinst: postinst = '#!/bin/sh\n' - postinst = postinst.splitlines(True) - try: - index = postinst.index('# End section update-alternatives\n') - postinst.insert(index + 1, localdata.getVar('updatercd_postinst')) - except ValueError: - postinst.append(localdata.getVar('updatercd_postinst')) - postinst = ''.join(postinst) + postinst += localdata.getVar('updatercd_postinst') d.setVar('pkg_postinst_%s' % pkg, postinst) prerm = d.getVar('pkg_prerm_%s' % pkg) if not prerm: prerm = '#!/bin/sh\n' - prerm = prerm.splitlines(True) - try: - index = prerm.index('# Begin section update-alternatives\n') - prerm.insert(index, localdata.getVar('updatercd_prerm')) - except ValueError: - prerm.append(localdata.getVar('updatercd_prerm')) - prerm = ''.join(prerm) + prerm += localdata.getVar('updatercd_prerm') d.setVar('pkg_prerm_%s' % pkg, prerm) postrm = d.getVar('pkg_postrm_%s' % pkg)
Signature · 1 line
2.13.6
PATCH 6/6 update-alternatives.bbclass: refuse to manage SysV init scripts
In reply to Markus LehtonenSanity check for future packages.
[YOCTO #10944]
--- meta/classes/update-alternatives.bbclass | 4 ++++ 1 file changed, 4 insertions(+)
meta/classes/update-alternatives.bbclass +4 -0
@@ -143,6 +143,10 @@ python perform_packagecopy_append () { if not alt_link: alt_link = "%s/%s" % (d.getVar('bindir'), alt_name) d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link) + if alt_link.startswith(os.path.join(d.getVar('sysconfdir', True), 'init.d')): + # Managing init scripts does not work (bug #10433), foremost + # because of a race with update-rc.d + bb.fatal("Using update-alternatives for managing SysV init scripts is not supported") alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name) alt_target = alt_target or d.getVar('ALTERNATIVE_TARGET_%s' % pkg) or d.getVar('ALTERNATIVE_TARGET') or alt_link
Signature · 1 line
2.13.6