On Tue, Jun 02, 2020 at 09:09:25PM +0200, Gregor Zatko 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.

(R)Depending on bash doesn't make it lightweight anymore. This means you 
cannot do tiny bash-less images with alternatives?


> 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.bb
> 
> diff --git a/meta/conf/distro/include/default-providers.inc 
> b/meta/conf/distro/include/default-providers.inc
> index ea88bd4876..035877af59 100644
> --- a/meta/conf/distro/include/default-providers.inc
> +++ b/meta/conf/distro/include/default-providers.inc
> @@ -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"
> diff --git a/meta/conf/layer.conf b/meta/conf/layer.conf
> index da93d64e0a..85fb945f11 100644
> --- a/meta/conf/layer.conf
> +++ b/meta/conf/layer.conf
> @@ -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 \
> diff --git a/meta/recipes-core/packagegroups/packagegroup-self-hosted.bb 
> b/meta/recipes-core/packagegroups/packagegroup-self-hosted.bb
> index 9a70b189a4..4a494f1578 100644
> --- a/meta/recipes-core/packagegroups/packagegroup-self-hosted.bb
> +++ b/meta/recipes-core/packagegroups/packagegroup-self-hosted.bb
> @@ -166,6 +166,7 @@ RDEPENDS_packagegroup-self-hosted-extended = "\
>      tcl \
>      texinfo \
>      unzip \
> +    update-alternatives \
>      usbutils \
>      watchdog \
>      wget \
> diff --git a/meta/recipes-devtools/opkg-utils/opkg-utils_0.4.2.bb 
> b/meta/recipes-devtools/opkg-utils/opkg-utils_0.4.2.bb
> index 9315240190..5ebe3d8e60 100644
> --- a/meta/recipes-devtools/opkg-utils/opkg-utils_0.4.2.bb
> +++ b/meta/recipes-devtools/opkg-utils/opkg-utils_0.4.2.bb
> @@ -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"
> diff --git 
> a/meta/recipes-devtools/update-alternatives/update-alternatives_0.4.2.bb 
> b/meta/recipes-devtools/update-alternatives/update-alternatives_0.4.2.bb
> new file mode 100644
> index 0000000000..8cbf8c4889
> --- /dev/null
> +++ b/meta/recipes-devtools/update-alternatives/update-alternatives_0.4.2.bb
> @@ -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"
> -- 
> 2.26.2
> 

> 

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#139112): 
https://lists.openembedded.org/g/openembedded-core/message/139112
Mute This Topic: https://lists.openembedded.org/mt/74635039/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub  
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to