[LEDE-DEV] [PATCH 00/12] alternatives support
Matthias Schiffer
mschiffer at universe-factory.net
Sun Mar 5 07:06:29 PST 2017
On 03/05/2017 10:31 AM, Yousong Zhou wrote:
> This patch set tries to make it possible that files serving the same purpose
> and installed to different locations can be available under the same name
> through a symbolic link
>
> The idea is from alternatives of debian system [1,2]. "ip" command is a good
> example of the problem it tries to solve [3]. Files provided by different
> packages cannot be installed to the same location, so we have busybox ip,
> ip-tiny, ip-full all installed to different locations
>
> It works by first adding to CONTROL file of each ipkg a new field "Alternatives",
> which is a list of specs of the following form seprated by commas to describe
> alternatives provided by this package
>
> <prio>:<path>:<altpath>
>
> The new field will be interpreted by postinst and prerm script. <path> will be
> a symbolic link to <altpath> of the highest <prio>, and updates will be made to
> UCI config "opkg"
>
> Several patches for uci are also included here to support usage at build-time.
> The whole series is available in my staging tree [4]
>
> [1] https://wiki.debian.org/DebianAlternatives
> [2] https://debian-administration.org/article/91/Using_the_Debian_alternatives_system
> [3] https://bugs.lede-project.org/index.php?do=details&task_id=428
> [4] https://git.lede-project.org/?p=lede/yousong/staging.git;a=summary
First of all, thank you very much for working on this, I've been missing
this feature for a long time. I have some comments though:
I see that the opkg UCI config contains a lot of redundant data when many
alternatives are installed (for example, many busybox applets and their
corresponding coreutils/util-linux/... variants); AFAICT, the same
information is also available in the opkg status files.
I think I'd opt for not making this list of alternatives configurable
independently of opkg. Adding configuration to UCI would only be necessary
when a user overrides the automatic selection. This could also avoid adding
host UCI support to the build system, making the whole patchset a lot smaller.
Matthias
>
> Content of UCI config file "opkg" when busybox and ip-tiny are installed
>
> root at LEDE:/# uci export opkg
> package opkg
>
> config alternatives
> option path '/sbin/ip'
> list altpath '100:/bin/busybox'
> list altpath '200:/sbin/ip-tiny'
>
> Install ip-full
>
> root at LEDE:/# opkg install /tmp/ip-full_4.4.0-9_mips_24kc.ipk
> Installing ip-full (4.4.0-9) to root...
> Configuring ip-full.
> /usr/sbin/update-alternatives: link /sbin/ip -> /sbin/ip-full
> root at LEDE:/# uci export opkg
> package opkg
>
> config alternatives
> option path '/sbin/ip'
> list altpath '100:/bin/busybox'
> list altpath '200:/sbin/ip-tiny'
> list altpath '300:/sbin/ip-full'
>
> Remove ip-full
>
> root at LEDE:/# opkg remove ip-full
> Removing package ip-full from root...
> /usr/sbin/update-alternatives: link /sbin/ip -> /sbin/ip-tiny
> root at LEDE:/# uci export opkg
> package opkg
>
> config alternatives
> option path '/sbin/ip'
> list altpath '100:/bin/busybox'
> list altpath '200:/sbin/ip-tiny'
>
> Remove ip-tiny
>
> root at LEDE:/# opkg remove ip-tiny
> Removing package ip-tiny from root...
> /usr/sbin/update-alternatives: link /sbin/ip -> /bin/busybox
> root at LEDE:/# uci export opkg
> package opkg
>
> config alternatives
> option path '/sbin/ip'
> list altpath '100:/bin/busybox'
>
> The "opkg" file and update-alternatives are not intended for interactive use,
> but let's a demo can be useful for understanding
>
> root at LEDE:/# update-alternatives remove --spec 100:/sbin/ip:/bin/busybox
> /usr/sbin/update-alternatives: remove empty alternatives section for /sbin/ip
> root at LEDE:/# uci export opkg
> package opkg
>
> root at LEDE:/# ip
> /bin/ash: ip: not found
> root at LEDE:/# update-alternatives update --spec 100:/sbin/ip:/bin/busybox
> /usr/sbin/update-alternatives: link /sbin/ip -> /bin/busybox
> root at LEDE:/# uci export opkg
> package opkg
>
> config alternatives
> option path '/sbin/ip'
> list altpath '100:/bin/busybox'
>
> root at LEDE:/#
>
> Yousong Zhou (12):
> opkg: add update-alternatives support
> uci: patch for static host build
> uci: add host build
> build: prepare_rootfs: preserve prerm script
> build: cleanup tmp/ dir of target rootfs
> build: opkg: enable presence of uci
> build: ipkg: new field Alternatives
> base-files: link /var to tmp instead of /tmp
> base-files: enable presence of uci when IPKG_INSTROOT is set
> base-files: add update-alternatives call to default_{postinst,prerm}
> busybox: add as an alternative of /sbin/ip
> iproute2: add ip-tiny, ip-full as alternatives of /sbin/ip
>
> include/package-ipkg.mk | 1 +
> include/rootfs.mk | 20 ++-
> package/Makefile | 3 +-
> package/base-files/Makefile | 4 +-
> package/base-files/files/lib/functions.sh | 21 ++-
> package/network/utils/iproute2/Makefile | 28 ++--
> package/system/opkg/Makefile | 5 +-
> package/system/opkg/files/update-alternatives | 163 +++++++++++++++++++++
> package/system/uci/Makefile | 15 +-
> package/system/uci/files/lib/config/uci.sh | 31 ++--
> .../uci/patches/0001-build-fix-BUILD_STATIC.patch | 63 ++++++++
> ...-redundant-NULL-check-on-return-value-of-.patch | 29 ++++
> ...w-setting-confdir-and-savedir-with-enviro.patch | 58 ++++++++
> package/utils/busybox/Makefile | 3 +-
> 14 files changed, 407 insertions(+), 37 deletions(-)
> create mode 100755 package/system/opkg/files/update-alternatives
> create mode 100644 package/system/uci/patches/0001-build-fix-BUILD_STATIC.patch
> create mode 100644 package/system/uci/patches/0002-file-remove-redundant-NULL-check-on-return-value-of-.patch
> create mode 100644 package/system/uci/patches/0003-libuci-allow-setting-confdir-and-savedir-with-enviro.patch
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/lede-dev/attachments/20170305/8fa599d2/attachment-0001.sig>
More information about the Lede-dev
mailing list