update-alternatives: introduce new package as a opkg-utils spin-off
PATCH 1/1 update-alternatives: introduce new package as a opkg-utils spin-off
In some cases there is a need for update-alternatives script which gets built within opkg-utils recipe into a standalone package. However, this causes to many unnecessary dependencies, including Python, bc, OpenSSL etc. to be built.
In this commit a standalone lightweight recipe for update-alternatives that shouldn't be dependent on nothing other than bash.
https://bugzilla.yoctoproject.org/show_bug.cgi?id=8879
--- .../conf/distro/include/default-providers.inc | 6 +-- meta/conf/layer.conf | 3 +- .../packagegroups/packagegroup-self-hosted.bb | 1 + .../opkg-utils/opkg-utils_0.4.2.bb | 25 +--------- .../update-alternatives_0.4.2.bb | 49 +++++++++++++++++++ 5 files changed, 56 insertions(+), 28 deletions(-) create mode 100644 meta/recipes-devtools/update-alternatives/update-alternatives_0.4.2.bb
meta/conf/distro/include/default-providers.inc +3 -3
@@ -10,8 +10,8 @@ PREFERRED_PROVIDER_virtual/nativesdk-libgl ?= "nativesdk-mesa" PREFERRED_PROVIDER_virtual/libgles1 ?= "mesa" PREFERRED_PROVIDER_virtual/libgles2 ?= "mesa" PREFERRED_PROVIDER_virtual/mesa ?= "mesa" -PREFERRED_PROVIDER_virtual/update-alternatives ?= "opkg-utils" -PREFERRED_PROVIDER_virtual/update-alternatives-native ?= "opkg-utils-native" +PREFERRED_PROVIDER_virtual/update-alternatives ?= "update-alternatives" +PREFERRED_PROVIDER_virtual/update-alternatives-native ?= "update-alternatives-native" PREFERRED_PROVIDER_virtual/libx11 ?= "libx11" PREFERRED_PROVIDER_virtual/base-utils ?= "busybox" PREFERRED_PROVIDER_xf86-video-intel ?= "xf86-video-intel"
@@ -21,7 +21,7 @@ PREFERRED_PROVIDER_virtual/make-native ?= "make-native" # # Default virtual runtime providers # -VIRTUAL-RUNTIME_update-alternatives ?= "update-alternatives-opkg" +VIRTUAL-RUNTIME_update-alternatives ?= "update-alternatives" VIRTUAL-RUNTIME_apm ?= "apm" VIRTUAL-RUNTIME_alsa-state ?= "alsa-state" VIRTUAL-RUNTIME_getopt ?= "util-linux-getopt"
meta/conf/layer.conf +1 -2
@@ -19,7 +19,6 @@ BBLAYERS_LAYERINDEX_NAME_core = "openembedded-core" # Set a variable to get to the top of the metadata location COREBASE = '${@os.path.normpath("${LAYERDIR}/../")}' -# opkg-utils is for update-alternatives :( SIGGEN_EXCLUDERECIPES_ABISAFE += " \ sysvinit-inittab \ busybox-inittab \
@@ -40,7 +39,7 @@ SIGGEN_EXCLUDERECIPES_ABISAFE += " \ shadow \ shadow-sysroot \ base-passwd \ - opkg-utils \ + update-alternatives \ gstreamer1.0-meta-base \ ca-certificates \ shared-mime-info \
meta/recipes-core/packagegroups/packagegroup-self-hosted.bb +1 -0
@@ -166,6 +166,7 @@ RDEPENDS_packagegroup-self-hosted-extended = "\ tcl \ texinfo \ unzip \ + update-alternatives \ usbutils \ watchdog \ wget \
meta/recipes-devtools/opkg-utils/opkg-utils_0.4.2.bb +2 -23
@@ -1,13 +1,11 @@ SUMMARY = "Additional utilities for the opkg package manager" -SUMMARY_update-alternatives-opkg = "Utility for managing the alternatives system" SECTION = "base" HOMEPAGE = "http://git.yoctoproject.org/cgit/cgit.cgi/opkg-utils" LICENSE = "GPLv2+" LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \ file://opkg.py;beginline=2;endline=18;md5=ffa11ff3c15eb31c6a7ceaa00cc9f986" -PROVIDES += "${@bb.utils.contains('PACKAGECONFIG', 'update-alternatives', 'virtual/update-alternatives', '', d)}" -SRC_URI = "http://git.yoctoproject.org/cgit/cgit.cgi/${BPN}/snapshot/${BPN}-${PV}.tar.gz \ +SRC_URI = "http://git.yoctoproject.org/cgit/cgit.cgi/${BPN}/snapshot/${BPN}-${PV}.tar.gz \ file://fix-reproducibility.patch \ " UPSTREAM_CHECK_URI = "http://git.yoctoproject.org/cgit/cgit.cgi/opkg-utils/refs/"
@@ -25,42 +23,23 @@ inherit perlnative PYTHONRDEPS = "python3 python3-shell python3-io python3-math python3-crypt python3-logging python3-fcntl python3-pickle python3-compression python3-stringold" PYTHONRDEPS_class-native = "" -PACKAGECONFIG = "python update-alternatives" +PACKAGECONFIG = "python" PACKAGECONFIG[python] = ",,,${PYTHONRDEPS}" -PACKAGECONFIG[update-alternatives] = ",,," do_install() { oe_runmake PREFIX=${prefix} DESTDIR=${D} install - if ! ${@bb.utils.contains('PACKAGECONFIG', 'update-alternatives', 'true', 'false', d)}; then - rm -f "${D}${bindir}/update-alternatives" - fi } do_install_append_class-target() { if ! ${@bb.utils.contains('PACKAGECONFIG', 'python', 'true', 'false', d)}; then grep -lZ "/usr/bin/env.*python" ${D}${bindir}/* | xargs -0 rm fi - - if [ -e "${D}${bindir}/update-alternatives" ]; then - sed -i ${D}${bindir}/update-alternatives -e 's,/usr/bin,${bindir},g; s,/usr/lib,${nonarch_libdir},g' - fi } # These are empty and will pull python3-dev into images where it wouldn't # have been otherwise, so don't generate them. PACKAGES_remove = "${PN}-dev ${PN}-staticdev" -PACKAGES =+ "update-alternatives-opkg" -FILES_update-alternatives-opkg = "${bindir}/update-alternatives" -RPROVIDES_update-alternatives-opkg = "update-alternatives update-alternatives-cworth" -RREPLACES_update-alternatives-opkg = "update-alternatives-cworth" -RCONFLICTS_update-alternatives-opkg = "update-alternatives-cworth" - -pkg_postrm_update-alternatives-opkg() { - rm -rf $D${nonarch_libdir}/opkg/alternatives - rmdir $D${nonarch_libdir}/opkg || true -} - BBCLASSEXTEND = "native nativesdk" CLEANBROKEN = "1"
meta/recipes-devtools/update-alternatives/update-alternatives_0.4.2.bb new file +49 -0
49 lines not on this page · raw message
Signature · 1 line
2.26.2
Quoted 6 lines · Gregor Zatko
In some cases there is a need for update-alternatives script which gets built within opkg-utils recipe into a standalone package. However, this causes to many unnecessary dependencies, including Python, bc, OpenSSL etc. to be built.
In this commit a standalone lightweight recipe for update-alternatives that shouldn't be dependent on nothing other than bash.
(R)Depending on bash doesn't make it lightweight anymore. This means you cannot do tiny bash-less images with alternatives?
Quoted 192 lines
https://bugzilla.yoctoproject.org/show_bug.cgi?id=8879
Signed-off-by Gregor Zatko <[email protected]>--- .../conf/distro/include/default-providers.inc | 6 +-- meta/conf/layer.conf | 3 +- .../packagegroups/packagegroup-self-hosted.bb | 1 + .../opkg-utils/opkg-utils_0.4.2.bb | 25 +--------- .../update-alternatives_0.4.2.bb | 49 +++++++++++++++++++ 5 files changed, 56 insertions(+), 28 deletions(-) create mode 100644 meta/recipes-devtools/update-alternatives/update-alternatives_0.4.2.bbmeta/conf/distro/include/default-providers.inc +3
-3@@ -10,8 +10,8 @@ PREFERRED_PROVIDER_virtual/nativesdk-libgl ?= "nativesdk-mesa" PREFERRED_PROVIDER_virtual/libgles1 ?= "mesa" PREFERRED_PROVIDER_virtual/libgles2 ?= "mesa" PREFERRED_PROVIDER_virtual/mesa ?= "mesa" -PREFERRED_PROVIDER_virtual/update-alternatives ?= "opkg-utils" -PREFERRED_PROVIDER_virtual/update-alternatives-native ?= "opkg-utils-native" +PREFERRED_PROVIDER_virtual/update-alternatives ?= "update-alternatives" +PREFERRED_PROVIDER_virtual/update-alternatives-native ?= "update-alternatives-native" PREFERRED_PROVIDER_virtual/libx11 ?= "libx11" PREFERRED_PROVIDER_virtual/base-utils ?= "busybox" PREFERRED_PROVIDER_xf86-video-intel ?= "xf86-video-intel"@@ -21,7 +21,7 @@ PREFERRED_PROVIDER_virtual/make-native ?= "make-native" # # Default virtual runtime providers # -VIRTUAL-RUNTIME_update-alternatives ?= "update-alternatives-opkg" +VIRTUAL-RUNTIME_update-alternatives ?= "update-alternatives" VIRTUAL-RUNTIME_apm ?= "apm" VIRTUAL-RUNTIME_alsa-state ?= "alsa-state" VIRTUAL-RUNTIME_getopt ?= "util-linux-getopt"meta/conf/layer.conf +1
-2@@ -19,7 +19,6 @@ BBLAYERS_LAYERINDEX_NAME_core = "openembedded-core" # Set a variable to get to the top of the metadata location COREBASE = '${@os.path.normpath("${LAYERDIR}/../")}' -# opkg-utils is for update-alternatives :( SIGGEN_EXCLUDERECIPES_ABISAFE += " \ sysvinit-inittab \ busybox-inittab \@@ -40,7 +39,7 @@ SIGGEN_EXCLUDERECIPES_ABISAFE += " \ shadow \ shadow-sysroot \ base-passwd \ - opkg-utils \ + update-alternatives \ gstreamer1.0-meta-base \ ca-certificates \ shared-mime-info \meta/recipes-core/packagegroups/packagegroup-self-hosted.bb +1
-0@@ -166,6 +166,7 @@ RDEPENDS_packagegroup-self-hosted-extended = "\ tcl \ texinfo \ unzip \ + update-alternatives \ usbutils \ watchdog \ wget \meta/recipes-devtools/opkg-utils/opkg-utils_0.4.2.bb +2
-23@@ -1,13 +1,11 @@ SUMMARY = "Additional utilities for the opkg package manager" -SUMMARY_update-alternatives-opkg = "Utility for managing the alternatives system" SECTION = "base" HOMEPAGE = "http://git.yoctoproject.org/cgit/cgit.cgi/opkg-utils" LICENSE = "GPLv2+" LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \ file://opkg.py;beginline=2;endline=18;md5=ffa11ff3c15eb31c6a7ceaa00cc9f986" -PROVIDES += "${@bb.utils.contains('PACKAGECONFIG', 'update-alternatives', 'virtual/update-alternatives', '', d)}" -SRC_URI = "http://git.yoctoproject.org/cgit/cgit.cgi/${BPN}/snapshot/${BPN}-${PV}.tar.gz \ +SRC_URI = "http://git.yoctoproject.org/cgit/cgit.cgi/${BPN}/snapshot/${BPN}-${PV}.tar.gz \ file://fix-reproducibility.patch \ " UPSTREAM_CHECK_URI = "http://git.yoctoproject.org/cgit/cgit.cgi/opkg-utils/refs/"@@ -25,42 +23,23 @@ inherit perlnative PYTHONRDEPS = "python3 python3-shell python3-io python3-math python3-crypt python3-logging python3-fcntl python3-pickle python3-compression python3-stringold" PYTHONRDEPS_class-native = "" -PACKAGECONFIG = "python update-alternatives" +PACKAGECONFIG = "python" PACKAGECONFIG[python] = ",,,${PYTHONRDEPS}" -PACKAGECONFIG[update-alternatives] = ",,," do_install() { oe_runmake PREFIX=${prefix} DESTDIR=${D} install - if ! ${@bb.utils.contains('PACKAGECONFIG', 'update-alternatives', 'true', 'false', d)}; then - rm -f "${D}${bindir}/update-alternatives" - fi } do_install_append_class-target() { if ! ${@bb.utils.contains('PACKAGECONFIG', 'python', 'true', 'false', d)}; then grep -lZ "/usr/bin/env.*python" ${D}${bindir}/* | xargs -0 rm fi - - if [ -e "${D}${bindir}/update-alternatives" ]; then - sed -i ${D}${bindir}/update-alternatives -e 's,/usr/bin,${bindir},g; s,/usr/lib,${nonarch_libdir},g' - fi } # These are empty and will pull python3-dev into images where it wouldn't # have been otherwise, so don't generate them. PACKAGES_remove = "${PN}-dev ${PN}-staticdev" -PACKAGES =+ "update-alternatives-opkg" -FILES_update-alternatives-opkg = "${bindir}/update-alternatives" -RPROVIDES_update-alternatives-opkg = "update-alternatives update-alternatives-cworth" -RREPLACES_update-alternatives-opkg = "update-alternatives-cworth" -RCONFLICTS_update-alternatives-opkg = "update-alternatives-cworth" - -pkg_postrm_update-alternatives-opkg() { - rm -rf $D${nonarch_libdir}/opkg/alternatives - rmdir $D${nonarch_libdir}/opkg || true -} - BBCLASSEXTEND = "native nativesdk" CLEANBROKEN = "1"meta/recipes-devtools/update-alternatives/update-alternatives_0.4.2.bb new file +49
-0@@ -0,0 +1,49 @@ +SUMMARY = "Utility for managing the alternatives system" +DESCRIPTION = "This program was inspired by the Debian update-alternatives program which is Copyright (C) 1995 Ian Jackson. This version of update-alternatives is command-line compatible with Debian's for a subset of the options, (only --install, --remove, and --help)" +SECTION = "base" +HOMEPAGE = "http://git.yoctoproject.org/cgit/cgit.cgi/opkg-utils" +LICENSE = "GPLv2+" +LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \ + file://opkg.py;beginline=2;endline=18;md5=ffa11ff3c15eb31c6a7ceaa00cc9f986" + +SRC_ARCHIVE_NAME = "opkg-utils" +SRC_URI = "http://git.yoctoproject.org/cgit/cgit.cgi/${SRC_ARCHIVE_NAME}/snapshot/${SRC_ARCHIVE_NAME}-${PV}.tar.gz" +UPSTREAM_CHECK_URI = "http://git.yoctoproject.org/cgit/cgit.cgi/opkg-utils/refs/" +S = "${WORKDIR}/${SRC_ARCHIVE_NAME}-${PV}" + +SRC_URI[md5sum] = "cc210650644fcb9bba06ad5ec95a63ec" +SRC_URI[sha256sum] = "5929ad87d541789e0b82d626db01a1201ac48df6f49f2262fcfb86cf815e5d6c" + +TARGET_CC_ARCH += "${LDFLAGS}" + +RDEPENDS_${PN} += "bash" + +do_compile[noexec] = "1" + +do_install() { + + install -D -m 755 ${S}/update-alternatives ${D}${bindir}/update-alternatives +} + +do_install_append_class-target() { + + sed -i ${D}${bindir}/update-alternatives -e 's,/usr/bin,${bindir},g; s,/usr/lib,${nonarch_libdir},g' +} + +FILES_${PN} = "${bindir}/update-alternatives" +RPROVIDES_${PN} = "${PN} update-alternatives-cworth" +RREPLACES_${PN} = "update-alternatives-cworth" +RCONFLICTS_${PN} = "update-alternatives-cworth" + +PROVIDES_class-target += "virtual/update-alternatives" +RPROVIDES_${PN}_class-target += "update-alternatives" +PROVIDES_class-native += "virtual/update-alternatives-native" +RPROVIDES_${PN}_class-native += "update-alternatives-native" + +pkg_postrm_${PN}() { + + rm -rf $D${nonarch_libdir}/opkg/alternatives + rmdir $D${nonarch_libdir}/opkg || true +} + +BBCLASSEXTEND = "native nativesdk"Signature · 1 line
2.26.2
Quoted 10 lines · Denys Dmytriyenko
Quoted 6 lines · Gregor Zatko
In some cases there is a need for update-alternatives script which gets built within opkg-utils recipe into a standalone package. However, this causes to many unnecessary dependencies, including Python, bc, OpenSSL etc. to be built.
In this commit a standalone lightweight recipe for update-alternatives that shouldn't be dependent on nothing other than bash.
(R)Depending on bash doesn't make it lightweight anymore. This means you cannot do tiny bash-less images with alternatives?
Well, if I understand everyting correct then yes, it's not possible. However, I've
mostly been a user of Yocto so please check my reasoning:
- first, I made a comment here
https://bugzilla.yoctoproject.org/show_bug.cgi?id=8879#c4
- if you take a look at
http://git.yoctoproject.org/cgit/cgit.cgi/opkg-utils/tree/update-alternatives
you'll simply see it's a shellscript; if we wanted to have it without bash we'd need a C++
implementation, am I right?
Quoted 5 lines · Gregor Zatko
- if you take a look at
http://git.yoctoproject.org/cgit/cgit.cgi/opkg-utils/tree/update-alternatives
you'll simply see it's a shellscript; if we wanted to have it without bash we'd need a C++
implementation, am I right?
No, I think the point is that the shell script only needs /bin/sh. If it required bash specifically then it would have #!/bin/bash at the top.
But, isn't rpmdeps supposed to sort that out automatically in any case?
p.
Quoted 9 lines · Phil Blundell via lists.openembedded.org
Quoted 5 lines · Gregor Zatko
- if you take a look at
http://git.yoctoproject.org/cgit/cgit.cgi/opkg-utils/tree/update-alternatives
you'll simply see it's a shellscript; if we wanted to have it without bash we'd need a C++
implementation, am I right?No, I think the point is that the shell script only needs
/bin/sh. If it required bash specifically then it would have #!/bin/bash at the top.
The original opkg-utils recipe has this:
RDEPENDS_${PN} += "bash"
Note that update-alternatives goes into own package and doesn't have such RDEPS.
Quoted 6 lines
But, isn't rpmdeps supposed to sort that out automatically in any case?
p.
Quoted 3 lines · Gregor Zatko
In some cases there is a need for update-alternatives script which gets built within opkg-utils recipe into a standalone package. However, this causes to many unnecessary dependencies, including Python, bc, OpenSSL etc. to be built.
Funny, it's almost as if 44b538eedab7c255051fa3375f9f2439cd2db3dd never happened... :-)
p.
Hello Gregor,
Quoted 9 lines · On Tue, 2 Jun 2020 21:09:25 +0200 "Gregor Zatko" <[email protected]> wrote:
In some cases there is a need for update-alternatives script which gets built within opkg-utils recipe into a standalone package. However, this causes to many unnecessary dependencies, including Python, bc, OpenSSL etc. to be built.
In this commit a standalone lightweight recipe for update-alternatives that shouldn't be dependent on nothing other than bash.
Quoted 7 lines
Signed-off-by Gregor Zatko <[email protected]>--- .../conf/distro/include/default-providers.inc | 6 +-- meta/conf/layer.conf | 3 +- .../packagegroups/packagegroup-self-hosted.bb | 1 + .../opkg-utils/opkg-utils_0.4.2.bb | 25 +--------- .../update-alternatives_0.4.2.bb | 49 +++++++++++++++++++
why did you change the name from update-alternatives-opkg to update-alternatives? I would prefer to keep the suffix in order to be able to distinguish it more easily from other implementations, e.g. dpkg's.
Best regards,
Andreas
Quoted 18 lines · Andreas Oberritter
Hello Gregor,
Quoted 8 lines · On Tue, 2 Jun 2020 21:09:25 +0200"Gregor Zatko" <[email protected]> wrote:
In some cases there is a need for update-alternatives script which gets builtwithin opkg-utils recipe into a standalone package. However, this causes tomany unnecessary dependencies, including Python, bc, OpenSSL etc. to be built.
In this commit a standalone lightweight recipe for update- alternatives thatshouldn't be dependent on nothing other than bash.
https://bugzilla.yoctoproject.org/show_bug.cgi?id=8879Quoted 6 lines
Signed-off-by Gregor Zatko <[email protected]>---.../conf/distro/include/default-providers.inc | 6 +-- meta/conf/layer.conf | 3 +- .../packagegroups/packagegroup-self-hosted.bb | 1 + .../opkg-utils/opkg-utils_0.4.2.bb | 25 +--------- .../update-
alternatives_0.4.2.bb | 49 +++++++++++++++++++
Quoted 5 lines
why did you change the name from update-alternatives-opkg to update- alternatives? I would prefer to keep the suffix in order to be able to distinguish it more easily from other implementations, e.g. dpkg's.
Best regards,Andreas
I have no problem to revert the name back to original. However, I'm not sure whether this patch will be accepted because it seems to solve only a minimal part of the problem or nothing at all :-)
Quoted 25 lines · Gregor Zatko
Quoted 18 lines · Andreas Oberritter
Hello Gregor,
Quoted 8 lines · On Tue, 2 Jun 2020 21:09:25 +0200"Gregor Zatko" <[email protected]> wrote:
In some cases there is a need for update-alternatives script which gets builtwithin opkg-utils recipe into a standalone package. However, this causes tomany unnecessary dependencies, including Python, bc, OpenSSL etc. to be built.
In this commit a standalone lightweight recipe for update- alternatives thatshouldn't be dependent on nothing other than bash.
https://bugzilla.yoctoproject.org/show_bug.cgi?id=8879Quoted 6 lines
Signed-off-by Gregor Zatko <[email protected]>---.../conf/distro/include/default-providers.inc | 6 +-- meta/conf/layer.conf | 3 +- .../packagegroups/packagegroup-self-hosted.bb | 1 + .../opkg-utils/opkg-utils_0.4.2.bb | 25 +--------- .../update-
alternatives_0.4.2.bb | 49 +++++++++++++++++++Quoted 5 lines
why did you change the name from update-alternatives-opkg to update- alternatives? I would prefer to keep the suffix in order to be able to distinguish it more easily from other implementations, e.g. dpkg's.
Best regards,Andreas
Quoted 3 lines
I have no problem to revert the name back to original. However, I'm not sure whether this patch will be accepted because it seems to solve only a minimal part of the problem or nothing at all :-)
And what exactly are you trying to solve then?
It seems you are more concerned with build-time dependencies than you are with run-time ones. Building opkg-utils is a drop in the bucket (it is quite small) and can usually be ignored, as long as it's not installed when you don't need it. The resulting update-alternatives-opkg package is a tiny one with no extra RDEPENDS and that's what matters.
If your concern is that it builds opkg-utils and its dependencies even though you may be using rpm, then it is also true in the other direction - rpm gets built when IPK/opkg is the default package manager...
Signature · 1 line
Denys