Hilko Bengen
2020-Oct-17 17:38 UTC
[Libguestfs] [PATCH] Use guestfsd binary to auto-generate library dependencies for appliance
The ELF NEEDED are used to determine guestfsd's library dependencies with help from the dynamic linker and the package manager. This was prompted by Debian bug #972241 which was caused by a libtirpc package renaming in Debian/unstable because the SONAME had been changed. --- appliance/Makefile.am | 26 ++++++++++++++++- appliance/packagelist.in | 62 ++-------------------------------------- m4/guestfs-appliance.m4 | 9 ++++++ 3 files changed, 36 insertions(+), 61 deletions(-) diff --git a/appliance/Makefile.am b/appliance/Makefile.am index bad5d9d9eb..a213e12be4 100644 --- a/appliance/Makefile.am +++ b/appliance/Makefile.am @@ -79,7 +79,30 @@ make.sh: make.sh.in $(top_builddir)/config.log $(top_builddir)/config.status PACKAGELIST_CPP_FLAGS = -D$(DISTRO)=1 -DEXTRA_PACKAGES="$(EXTRA_PACKAGES)" -packagelist: packagelist.in Makefile + +if HAVE_RPM +QUERY_FILES_CMD := xargs rpm -qf --qf '%{name}\n' +endif +if HAVE_DPKG +QUERY_FILES_CMD := xargs dpkg -S | cut -d: -f1 +endif +if HAVE_PACMAN +QUERY_FILES_CMD := xargs pacman -Qo | sed -r 's/.* is owned by ([^ ]+) .*/\1/' +endif + +# Automatically generate library dependency list +guestfsd.deps: ../daemon/guestfsd + /sbin/ldconfig -p > ld.so.cache.txt + objdump -p $^ |\ + sed -ne '/NEEDED/{s/ *NEEDED *//; p;}' |\ + xargs -i grep -F {} ld.so.cache.txt |\ + sed -ne '/ => /{s/.* => *//; p;}' |\ + $(QUERY_FILES_CMD) |\ + sort -u > $@.t + rm -f ld.so.cache.txt + mv $@.t $@ + +packagelist: packagelist.in Makefile guestfsd.deps m4 $(PACKAGELIST_CPP_FLAGS) $< | \ grep -v '^[[:space:]]*$$' | grep -v '^#' > $@-t cmp -s $@ $@-t || mv $@-t $@ @@ -153,5 +176,6 @@ stamp-libguestfs-make-fixed-appliance.pod: libguestfs-make-fixed-appliance.pod DISTCLEANFILES += \ make.sh \ + guestfsd.deps \ packagelist \ supermin.d/* diff --git a/appliance/packagelist.in b/appliance/packagelist.in index 13c83d8e45..68ed16a415 100644 --- a/appliance/packagelist.in +++ b/appliance/packagelist.in @@ -23,7 +23,6 @@ dnl Basically the same with a few minor tweaks. ifelse(UBUNTU,1,`define(`DEBIAN',1)') ifelse(REDHAT,1, - augeas-libs cryptsetup cryptsetup-luks dnl old name used before Fedora 17 dhclient @@ -32,28 +31,20 @@ ifelse(REDHAT,1, gfs2-utils grub hfsplus-tools - hivex iproute iputils - jansson kernel - libcap - libldm - libtirpc nilfs-utils ntfsprogs ntfs-3g ntfs-3g-system-compression openssh-clients - pcre policycoreutils reiserfs-utils - libselinux syslinux-extlinux systemd dnl for /sbin/reboot and udevd vim-minimal xz - yara zfs-fuse ) @@ -79,17 +70,7 @@ dnl iproute has been renamed to iproute2 iputils-tracepath isc-dhcp-client ldmtool - libaugeas0 libc-bin - libcap2 - libhivex0 - libjansson4 - libpcre3 - libsystemd0 - libsystemd-id128-0 - libsystemd-journal0 - libtirpc1 - libyara3 linux-image dnl syslinux 'suggests' mtools, but in reality it's a hard dependency: mtools @@ -107,19 +88,14 @@ dnl iproute has been renamed to iproute2 ) ifelse(ARCHLINUX,1, - augeas cdrkit cdrtools cryptsetup dhcpcd gptfdisk grub - hivex iproute2 iputils - jansson - libcap - libtirpc linux lrzip dnl syslinux has mtools as optional dependency, but in reality it's @@ -129,16 +105,13 @@ ifelse(ARCHLINUX,1, nilfs-utils ntfs-3g ntfs-3g-system-compression - pcre reiserfsprogs systemd vim xz - yara ) ifelse(SUSE,1, - augeas dnl It seems no other augeas package depends on it. augeas-lenses btrfsprogs @@ -149,16 +122,9 @@ ifelse(SUSE,1, genisoimage glibc-locale gptfdisk - hivex initviocons iproute2 iputils - libcap2 - libhivex0 - libjansson4 - libselinux1 - libtirpc3 - libyara3 mkisofs ntfsprogs ntfs-3g @@ -167,11 +133,9 @@ ifelse(SUSE,1, systemd vim xz - yara ) ifelse(FRUGALWARE,1, - augeas cryptsetup-luks cdrkit dhclient @@ -179,14 +143,10 @@ ifelse(FRUGALWARE,1, hfsplus iproute2 iputils - jansson kernel - libcap - libtirpc ntfsprogs ntfs-3g openssh - pcre reiserfsprogs systemd vim @@ -197,7 +157,6 @@ ifelse(FRUGALWARE,1, ) ifelse(MAGEIA,1, - augeas cryptsetup chkconfig /* for /etc/init.d */ cdrkit-genisoimage @@ -207,30 +166,21 @@ ifelse(MAGEIA,1, gfs2-utils grub hfsplus-tools - hivex iproute2 iputils - libcap - libjansson4 - lib64jansson4 /* lib64jansson4 does not provide libjansson4 */ - libldm - libtirpc dnl syslinux uses mtools without depending on it mtools nilfs-utils ntfsprogs ntfs-3g openssh-clients - pcre reiserfs-utils - libselinux systemd /* for /sbin/reboot and udevd */ vim-minimal xz ) ifelse(OPENMANDRIVA,1, - augeas cryptsetup chkconfig /* for /etc/init.d */ cdrkit-genisoimage @@ -238,27 +188,20 @@ ifelse(OPENMANDRIVA,1, dhcp-client extlinux grub2 - lib64hivex0 - hivex iproute2 iputils - libcap - libjansson4 - lib64jansson4 /* lib64jansson4 does not provide libjansson4 */ - libldm - libtirpc dnl syslinux uses mtools without depending on it mtools nilfs-utils ntfs-3g openssh-clients - pcre - libselinux systemd /* for /sbin/reboot and udevd */ vim-minimal xz ) +include(guestfsd.deps) + acl attr bash @@ -280,7 +223,6 @@ gzip jfsutils kmod less -libxml2 lsof lsscsi lvm2 diff --git a/m4/guestfs-appliance.m4 b/m4/guestfs-appliance.m4 index a7f7d8321a..b0a6ab40f0 100644 --- a/m4/guestfs-appliance.m4 +++ b/m4/guestfs-appliance.m4 @@ -114,6 +114,15 @@ AC_ARG_WITH([distro], AC_MSG_ERROR([/etc/os-release not available, please specify the distro using --with-distro=DISTRO]) fi ] + AM_CONDITIONAL([HAVE_RPM], + [AS_CASE([$DISTRO], [REDHAT | SUSE | OPENMANDRIVA | MAGEIA ], [true], + [*], [false])]) + AM_CONDITIONAL([HAVE_DPKG], + [AS_CASE([$DISTRO], [DEBIAN | UBUNTU ], [true], + [*], [false])]) + AM_CONDITIONAL([HAVE_PACMAN], + [AS_CASE([$DISTRO], [ARCHLINUX | FRUGALWARE ], [true], + [*], [false])]) ) AC_SUBST([DISTRO]) -- 2.28.0
Richard W.M. Jones
2020-Oct-19 11:13 UTC
Re: [Libguestfs] [PATCH] Use guestfsd binary to auto-generate library dependencies for appliance
Looks good, I pushed this, thanks. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org