diff --git a/xCAT-genesis-builder/builddeb-genesis-base b/xCAT-genesis-builder/builddeb-genesis-base index 5c4091a69..0195f672d 100755 --- a/xCAT-genesis-builder/builddeb-genesis-base +++ b/xCAT-genesis-builder/builddeb-genesis-base @@ -30,15 +30,29 @@ REQUIRED_PACKAGES=" nfs-common rpcbind pciutils usbutils parted dosfstools e2fsprogs lvm2 mdadm net-tools bc psmisc rsync wget cpio - isc-dhcp-client ifenslave util-linux-extra + isc-dhcp-client ifenslave dpkg-dev debhelper fakeroot devscripts vim-tiny " if [ "$BUILDARCH" = "amd64" ]; then REQUIRED_PACKAGES="$REQUIRED_PACKAGES dmidecode efibootmgr" fi +# Keep only the packages this release actually has. hwclock moved out of util-linux into +# util-linux-extra, so focal and jammy have no such package and naming it there fails the +# whole install. util-linux only Suggests it, and --no-install-recommends is passed, so the +# releases that did split it must name it. +optional_packages() { + local package + for package in "$@"; do + if apt-cache show "$package" >/dev/null 2>&1; then + echo "$package" + fi + done +} + echo "Installing build dependencies..." apt-get update -qq +REQUIRED_PACKAGES="$REQUIRED_PACKAGES $(optional_packages util-linux-extra)" apt-get install -y --no-install-recommends $REQUIRED_PACKAGES # Set up dracut module @@ -142,11 +156,6 @@ fi echo "Adding kernel $KERNEL_IMAGE" cp "$KERNEL_IMAGE" "$GENESIS_ROOT/kernel" -# dracut_install reports a missing command and returns, so a hole reaches the .deb with -# nothing in the log but one line. Read the commands back from the module and check them -# against the payload, the way xCAT-genesis-base.spec does for EL. -bash "$DIR/verify-genesis-payload" --commands-from "$DRACUTMODDIR/module-setup.sh" "$GENESIS_FS" - find "$GENESIS_TMPDIR" -type c -delete # Stage for dpkg-buildpackage diff --git a/xCAT-test/unit/genesis_ubuntu_build_root.t b/xCAT-test/unit/genesis_ubuntu_build_root.t index 3486094d8..fb598ccd9 100755 --- a/xCAT-test/unit/genesis_ubuntu_build_root.t +++ b/xCAT-test/unit/genesis_ubuntu_build_root.t @@ -20,7 +20,7 @@ my $builder = repo_path('xCAT-genesis-builder/builddeb-genesis-base'); my $module = repo_path('xCAT-genesis-builder/dracut_105/ubuntu/module-setup.sh'); plan skip_all => 'builddeb-genesis-base not found' unless -f $builder; plan skip_all => 'ubuntu module-setup.sh not found' unless -f $module; -plan tests => 10; +plan tests => 9; # Mandatory commands a minimal Ubuntu server root does NOT already provide, and the package # that supplies each one on every release xCAT builds for. @@ -58,11 +58,9 @@ ok(!scalar(grep { $_ eq 'util-linux-extra' } @packages), # What the script does instead: keep a package only where apt has a candidate for it. { - my @present = optional_packages($builder, 'util-linux-extra', 0); - my @absent = optional_packages($builder, 'util-linux-extra', 1); - is_deeply(\@present, ['util-linux-extra'], + is_deeply(optional_packages($builder, 'util-linux-extra', 0), ['util-linux-extra'], 'a release that carries util-linux-extra installs it'); - is_deeply(\@absent, [], + is_deeply(optional_packages($builder, 'util-linux-extra', 1), [], 'a release without it installs nothing in its place'); }