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.
This commit is contained in:
Hilko Bengen
2020-10-17 19:38:34 +02:00
committed by Richard W.M. Jones
parent 3f4a529ab7
commit 133a491677
4 changed files with 37 additions and 61 deletions

1
.gitignore vendored
View File

@@ -38,6 +38,7 @@ Makefile.in
/align/stamp-virt-alignment-scan.pod /align/stamp-virt-alignment-scan.pod
/align/virt-alignment-scan /align/virt-alignment-scan
/align/virt-alignment-scan.1 /align/virt-alignment-scan.1
/appliance/guestfsd.deps
/appliance/libguestfs-make-fixed-appliance /appliance/libguestfs-make-fixed-appliance
/appliance/libguestfs-make-fixed-appliance.1 /appliance/libguestfs-make-fixed-appliance.1
/appliance/make.sh /appliance/make.sh

View File

@@ -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_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) $< | \ m4 $(PACKAGELIST_CPP_FLAGS) $< | \
grep -v '^[[:space:]]*$$' | grep -v '^#' > $@-t grep -v '^[[:space:]]*$$' | grep -v '^#' > $@-t
cmp -s $@ $@-t || mv $@-t $@ cmp -s $@ $@-t || mv $@-t $@
@@ -153,5 +176,6 @@ stamp-libguestfs-make-fixed-appliance.pod: libguestfs-make-fixed-appliance.pod
DISTCLEANFILES += \ DISTCLEANFILES += \
make.sh \ make.sh \
guestfsd.deps \
packagelist \ packagelist \
supermin.d/* supermin.d/*

View File

@@ -23,7 +23,6 @@ dnl Basically the same with a few minor tweaks.
ifelse(UBUNTU,1,`define(`DEBIAN',1)') ifelse(UBUNTU,1,`define(`DEBIAN',1)')
ifelse(REDHAT,1, ifelse(REDHAT,1,
augeas-libs
cryptsetup cryptsetup
cryptsetup-luks dnl old name used before Fedora 17 cryptsetup-luks dnl old name used before Fedora 17
dhclient dhclient
@@ -32,28 +31,20 @@ ifelse(REDHAT,1,
gfs2-utils gfs2-utils
grub grub
hfsplus-tools hfsplus-tools
hivex
iproute iproute
iputils iputils
jansson
kernel kernel
libcap
libldm
libtirpc
nilfs-utils nilfs-utils
ntfsprogs ntfsprogs
ntfs-3g ntfs-3g
ntfs-3g-system-compression ntfs-3g-system-compression
openssh-clients openssh-clients
pcre
policycoreutils policycoreutils
reiserfs-utils reiserfs-utils
libselinux
syslinux-extlinux syslinux-extlinux
systemd dnl for /sbin/reboot and udevd systemd dnl for /sbin/reboot and udevd
vim-minimal vim-minimal
xz xz
yara
zfs-fuse zfs-fuse
) )
@@ -79,17 +70,7 @@ dnl iproute has been renamed to iproute2
iputils-tracepath iputils-tracepath
isc-dhcp-client isc-dhcp-client
ldmtool ldmtool
libaugeas0
libc-bin libc-bin
libcap2
libhivex0
libjansson4
libpcre3
libsystemd0
libsystemd-id128-0
libsystemd-journal0
libtirpc1
libyara3
linux-image linux-image
dnl syslinux 'suggests' mtools, but in reality it's a hard dependency: dnl syslinux 'suggests' mtools, but in reality it's a hard dependency:
mtools mtools
@@ -107,19 +88,14 @@ dnl iproute has been renamed to iproute2
) )
ifelse(ARCHLINUX,1, ifelse(ARCHLINUX,1,
augeas
cdrkit cdrkit
cdrtools cdrtools
cryptsetup cryptsetup
dhcpcd dhcpcd
gptfdisk gptfdisk
grub grub
hivex
iproute2 iproute2
iputils iputils
jansson
libcap
libtirpc
linux linux
lrzip lrzip
dnl syslinux has mtools as optional dependency, but in reality it's dnl syslinux has mtools as optional dependency, but in reality it's
@@ -129,16 +105,13 @@ ifelse(ARCHLINUX,1,
nilfs-utils nilfs-utils
ntfs-3g ntfs-3g
ntfs-3g-system-compression ntfs-3g-system-compression
pcre
reiserfsprogs reiserfsprogs
systemd systemd
vim vim
xz xz
yara
) )
ifelse(SUSE,1, ifelse(SUSE,1,
augeas
dnl It seems no other augeas package depends on it. dnl It seems no other augeas package depends on it.
augeas-lenses augeas-lenses
btrfsprogs btrfsprogs
@@ -149,16 +122,9 @@ ifelse(SUSE,1,
genisoimage genisoimage
glibc-locale glibc-locale
gptfdisk gptfdisk
hivex
initviocons initviocons
iproute2 iproute2
iputils iputils
libcap2
libhivex0
libjansson4
libselinux1
libtirpc3
libyara3
mkisofs mkisofs
ntfsprogs ntfsprogs
ntfs-3g ntfs-3g
@@ -167,11 +133,9 @@ ifelse(SUSE,1,
systemd systemd
vim vim
xz xz
yara
) )
ifelse(FRUGALWARE,1, ifelse(FRUGALWARE,1,
augeas
cryptsetup-luks cryptsetup-luks
cdrkit cdrkit
dhclient dhclient
@@ -179,14 +143,10 @@ ifelse(FRUGALWARE,1,
hfsplus hfsplus
iproute2 iproute2
iputils iputils
jansson
kernel kernel
libcap
libtirpc
ntfsprogs ntfsprogs
ntfs-3g ntfs-3g
openssh openssh
pcre
reiserfsprogs reiserfsprogs
systemd systemd
vim vim
@@ -197,7 +157,6 @@ ifelse(FRUGALWARE,1,
) )
ifelse(MAGEIA,1, ifelse(MAGEIA,1,
augeas
cryptsetup cryptsetup
chkconfig /* for /etc/init.d */ chkconfig /* for /etc/init.d */
cdrkit-genisoimage cdrkit-genisoimage
@@ -207,30 +166,21 @@ ifelse(MAGEIA,1,
gfs2-utils gfs2-utils
grub grub
hfsplus-tools hfsplus-tools
hivex
iproute2 iproute2
iputils iputils
libcap
libjansson4
lib64jansson4 /* lib64jansson4 does not provide libjansson4 */
libldm
libtirpc
dnl syslinux uses mtools without depending on it dnl syslinux uses mtools without depending on it
mtools mtools
nilfs-utils nilfs-utils
ntfsprogs ntfsprogs
ntfs-3g ntfs-3g
openssh-clients openssh-clients
pcre
reiserfs-utils reiserfs-utils
libselinux
systemd /* for /sbin/reboot and udevd */ systemd /* for /sbin/reboot and udevd */
vim-minimal vim-minimal
xz xz
) )
ifelse(OPENMANDRIVA,1, ifelse(OPENMANDRIVA,1,
augeas
cryptsetup cryptsetup
chkconfig /* for /etc/init.d */ chkconfig /* for /etc/init.d */
cdrkit-genisoimage cdrkit-genisoimage
@@ -238,27 +188,20 @@ ifelse(OPENMANDRIVA,1,
dhcp-client dhcp-client
extlinux extlinux
grub2 grub2
lib64hivex0
hivex
iproute2 iproute2
iputils iputils
libcap
libjansson4
lib64jansson4 /* lib64jansson4 does not provide libjansson4 */
libldm
libtirpc
dnl syslinux uses mtools without depending on it dnl syslinux uses mtools without depending on it
mtools mtools
nilfs-utils nilfs-utils
ntfs-3g ntfs-3g
openssh-clients openssh-clients
pcre
libselinux
systemd /* for /sbin/reboot and udevd */ systemd /* for /sbin/reboot and udevd */
vim-minimal vim-minimal
xz xz
) )
include(guestfsd.deps)
acl acl
attr attr
bash bash
@@ -280,7 +223,6 @@ gzip
jfsutils jfsutils
kmod kmod
less less
libxml2
lsof lsof
lsscsi lsscsi
lvm2 lvm2

View File

@@ -114,6 +114,15 @@ AC_ARG_WITH([distro],
AC_MSG_ERROR([/etc/os-release not available, please specify the distro using --with-distro=DISTRO]) AC_MSG_ERROR([/etc/os-release not available, please specify the distro using --with-distro=DISTRO])
fi 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]) AC_SUBST([DISTRO])