package/util-linux: build programs and libraries in separate packages
RFC PATCH v5 1/1 package/util-linux: build programs and libraries in separate packages
From: Carlos Santos <[email protected]>
The different tools and libraries in util-linux have a lot of optional dependencies. When we want to support those optional dependencies, we can easily generate dependency cycles. For instance, findmount and lsblk need udev to work correctly, but eudev and systemd both depend libblkid, which comes from util-linux.
Normal distros (e.g. Debian) solve this by first building a minimal package that has no dependencies at all, then build the packages that depend on util-linux, and finally rebuild util-linux with all bells and whistles. Solve it in Buildroot by means of the following changes:
- Split util-linux into two packages:
- util-linux-libs, providing lib{blkid,fdisk,mount,smartcols,uuid}.
- util-linux, providing both the aforementioned libs and the programs.
- Add a blind selection for util-linux-libs, i.e. it is indirectly selected according to the util-linux options.
- Make host and target util-linux have a build dependencies on the -libs packages.
- Make eudev and systemd have build dependencies on util-linux-libs. This can be extended to other packages in the future but is not needed right now because the configuration options are backward-compatible.
- Make util-linux have an optional build dependency on the package that provides libudev (either eudev or systemd), if it is selected.
Installing util-linux overrides files installed by util-linux-libs but this is not a problem: it's allowed for a package to overwrite files from another package, as long as there is a dependency between the two.
The build dependency of util-linux on util-linux-libs ensures that util-linux overwrites the files installed by util-linux-libs and not vice versa. In practice this dependency shouldn't be needed: the only reason for util-linux-libs to be built is to break a circular dependency. In that case, there is already a transitive dependency of util-linux on util-linux-libs, so adding it explicitly is redundant. Still, better safe than sorry.
We can't do the same for host-util-linux-libs, since there is no config symbol for it. However, host-util-linux-libs is not used at the moment, so we can ignore that issue for the time being.
With this approach we don't need to patch configuration files neither change packages other than eudev and systemd.
Other packages that require util-linux libraries and whose libraries may be used by util-linux programs can be updated later. We also don't need to change any existing defconfig, since all configuration options are kept in the util-linux package.
---
CC: Yann E. MORIN <[email protected]>
CC: Thomas Petazzoni <[email protected]>
CC: Pete Morici <[email protected]>
---
Changes v1->v2:
- Prevent double installation of the libraries.
- Drop the intrusive patches and AUTORECONF
- Move the the programs to a separate package
- Convert util-linux into a dummy package that drives the other ones.
- Keep configurations and dependencies backward-compatible, except for eudev and systemd.
- Make BR2_PACKAGE_UTIL_LINUX_LIBS a blind option
Changes v2->v3:
- Fix typos that ruined the conditional installations on TARGET_DIR and STAGING_DIR, as pointed by Yann E. Morin.
Changes v3->v4:
- Rebase after upgrading util-linux to version 2.34.
- Merge util-linux-programs back into util-linux.
- Make eudev and systemd depend on util-linux-libs.
- Build util-linux with systemd support.
Changes v4->v5:
- Fix python test in util-linux-libs.mk (missing 'else')
--- package/eudev/Config.in | 1 + package/eudev/eudev.mk | 3 +- package/systemd/Config.in | 1 + package/systemd/systemd.mk | 2 +- package/util-linux/Config.in | 3 + .../util-linux-libs/util-linux-libs.hash | 1 + .../util-linux-libs/util-linux-libs.mk | 91 +++++++++++++++++++ package/util-linux/util-linux.mk | 29 ++++-- 8 files changed, 122 insertions(+), 9 deletions(-) create mode 120000 package/util-linux/util-linux-libs/util-linux-libs.hash create mode 100644 package/util-linux/util-linux-libs/util-linux-libs.mk
package/eudev/Config.in +1 -0
@@ -6,6 +6,7 @@ config BR2_PACKAGE_EUDEV depends on !BR2_STATIC_LIBS # kmod select BR2_PACKAGE_HAS_UDEV select BR2_PACKAGE_UTIL_LINUX + select BR2_PACKAGE_UTIL_LINUX_LIBS select BR2_PACKAGE_UTIL_LINUX_LIBBLKID select BR2_PACKAGE_KMOD help
package/eudev/eudev.mk +2 -1
@@ -18,7 +18,8 @@ EUDEV_CONF_OPTS = \ --enable-kmod \ --enable-blkid -EUDEV_DEPENDENCIES = host-gperf host-pkgconf util-linux kmod +# eudev requires only the util-linux libraries at build time +EUDEV_DEPENDENCIES = host-gperf host-pkgconf util-linux-libs kmod EUDEV_PROVIDES = udev ifeq ($(BR2_ROOTFS_MERGED_USR),)
package/systemd/Config.in +1 -0
@@ -23,6 +23,7 @@ menuconfig BR2_PACKAGE_SYSTEMD select BR2_PACKAGE_DBUS # runtime dependency only select BR2_PACKAGE_LIBCAP select BR2_PACKAGE_UTIL_LINUX + select BR2_PACKAGE_UTIL_LINUX_LIBS select BR2_PACKAGE_UTIL_LINUX_LIBBLKID select BR2_PACKAGE_UTIL_LINUX_LIBMOUNT select BR2_PACKAGE_UTIL_LINUX_BINARIES
package/systemd/systemd.mk +1 -1
@@ -14,7 +14,7 @@ SYSTEMD_DEPENDENCIES = \ host-gperf \ kmod \ libcap \ - util-linux \ + util-linux-libs \ $(TARGET_NLS_DEPENDENCIES) SYSTEMD_PROVIDES = udev
package/util-linux/Config.in +3 -0
@@ -9,6 +9,9 @@ menuconfig BR2_PACKAGE_UTIL_LINUX if BR2_PACKAGE_UTIL_LINUX +config BR2_PACKAGE_UTIL_LINUX_LIBS + bool + config BR2_PACKAGE_UTIL_LINUX_LIBBLKID bool "libblkid" depends on BR2_USE_MMU # fork()
package/util-linux/util-linux-libs/util-linux-libs.hash new file +1 -0
@@ -0,0 +1 @@ +../util-linux.hash
package/util-linux/util-linux-libs/util-linux-libs.mk new file +91 -0
91 lines not on this page · raw message
package/util-linux/util-linux.mk +22 -7
@@ -19,18 +19,15 @@ UTIL_LINUX_LICENSE_FILES = README.licensing \ Documentation/licenses/COPYING.ISC \ Documentation/licenses/COPYING.LGPL-2.1-or-later UTIL_LINUX_INSTALL_STAGING = YES -UTIL_LINUX_DEPENDENCIES = host-pkgconf $(TARGET_NLS_DEPENDENCIES) +UTIL_LINUX_DEPENDENCIES = \ + host-pkgconf \ + $(if $(BR2_PACKAGE_UTIL_LINUX_LIBS),util-linux-libs) \ + $(TARGET_NLS_DEPENDENCIES) UTIL_LINUX_CONF_OPTS += \ --disable-rpath \ --disable-makeinstall-chown UTIL_LINUX_LIBS = $(TARGET_NLS_LIBS) -# system depends on util-linux so we enable systemd support -# (which needs systemd to be installed) -UTIL_LINUX_CONF_OPTS += \ - --without-systemd \ - --with-systemdsystemunitdir=no - HOST_UTIL_LINUX_DEPENDENCIES = host-pkgconf # We also don't want the host-python dependency
@@ -43,6 +40,20 @@ ifeq ($(BR2_ROOTFS_MERGED_USR),y) UTIL_LINUX_CONF_OPTS += --bindir=/usr/bin --sbindir=/usr/sbin --libdir=/usr/lib endif +ifeq ($(BR2_PACKAGE_SYSTEMD),y) +UTIL_LINUX_CONF_OPTS += --with-systemd --with-systemdsystemunitdir=/usr/lib/systemd/system +UTIL_LINUX_DEPENDENCIES += systemd +else +UTIL_LINUX_CONF_OPTS += --without-systemd --with-systemdsystemunitdir=no +endif + +ifeq ($(BR2_PACKAGE_HAS_UDEV),y) +UTIL_LINUX_CONF_OPTS += --with-udev +UTIL_LINUX_DEPENDENCIES += udev +else +UTIL_LINUX_CONF_OPTS += --without-udev +endif + ifeq ($(BR2_PACKAGE_NCURSES),y) UTIL_LINUX_DEPENDENCIES += ncurses ifeq ($(BR2_PACKAGE_NCURSES_WCHAR),y)
@@ -258,3 +269,7 @@ UTIL_LINUX_POST_INSTALL_TARGET_HOOKS += UTIL_LINUX_GETTY_SYMLINK $(eval $(autotools-package)) $(eval $(host-autotools-package)) + +# Must be included after the autotools-package call, to make sure all variables +# are available +include package/util-linux/util-linux-libs/util-linux-libs.mk
Signature · 1 line
2.18.1
RFC PATCH v5 1/1 package/util-linux: build programs and libraries in separate packages
Quoted 7 lines · unixmania at gmail.com
From: Carlos Santos <[email protected]>
The different tools and libraries in util-linux have a lot of optional dependencies. When we want to support those optional dependencies, we can easily generate dependency cycles. For instance, findmount and lsblk need udev to work correctly, but eudev and systemd both depend libblkid, which comes from util-linux.
Finally committed to next, with a few additional small changes. I also pushed
two follow-up patches to util-linux.mk itself, to make sure they stay as similar as possible.
Regards,
Arnout
Quoted 46 lines
Normal distros (e.g. Debian) solve this by first building a minimal package that has no dependencies at all, then build the packages that depend on util-linux, and finally rebuild util-linux with all bells and whistles. Solve it in Buildroot by means of the following changes:
- Split util-linux into two packages:
- util-linux-libs, providing lib{blkid,fdisk,mount,smartcols,uuid}.
- util-linux, providing both the aforementioned libs and the programs.
- Add a blind selection for util-linux-libs, i.e. it is indirectly selected according to the util-linux options.
- Make host and target util-linux have a build dependencies on the -libs packages.
- Make eudev and systemd have build dependencies on util-linux-libs. This can be extended to other packages in the future but is not needed right now because the configuration options are backward-compatible.
- Make util-linux have an optional build dependency on the package that provides libudev (either eudev or systemd), if it is selected.Installing util-linux overrides files installed by util-linux-libs but this is not a problem: it's allowed for a package to overwrite files from another package, as long as there is a dependency between the two.
The build dependency of util-linux on util-linux-libs ensures that util-linux overwrites the files installed by util-linux-libs and not vice versa. In practice this dependency shouldn't be needed: the only reason for util-linux-libs to be built is to break a circular dependency. In that case, there is already a transitive dependency of util-linux on util-linux-libs, so adding it explicitly is redundant. Still, better safe than sorry.
We can't do the same for host-util-linux-libs, since there is no config symbol for it. However, host-util-linux-libs is not used at the moment, so we can ignore that issue for the time being.
With this approach we don't need to patch configuration files neither change packages other than eudev and systemd.
Other packages that require util-linux libraries and whose libraries may be used by util-linux programs can be updated later. We also don't need to change any existing defconfig, since all configuration options are kept in the util-linux package.
Signed-off-by Carlos Santos <[email protected]>
[snip]