diff --git a/xCAT-test/bats/helpers/dracut_module.bash b/xCAT-test/bats/helpers/dracut_module.bash new file mode 100644 index 0000000000..64b683e0d9 --- /dev/null +++ b/xCAT-test/bats/helpers/dracut_module.bash @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +load "${BASH_SOURCE[0]%/*}/shell_source.bash" + +stage_dracut_module() +{ + local variant=$1 destination=$2 helper source + mkdir -p "$destination" + cp -a "$(repo_path "xCAT-server/share/xcat/netboot/$variant")/." "$destination/" + for helper in xcat-rootimg-checksum.sh xcat-rootimg-install.sh; do + source=$(repo_path "xCAT-server/share/xcat/netboot/imgutils/$helper") + [ ! -f "$source" ] || cp "$source" "$destination/" + done +} diff --git a/xCAT-test/bats/ubuntu_netboot_initqueue.bats b/xCAT-test/bats/ubuntu_netboot_initqueue.bats index 785838c6c5..92588b7022 100644 --- a/xCAT-test/bats/ubuntu_netboot_initqueue.bats +++ b/xCAT-test/bats/ubuntu_netboot_initqueue.bats @@ -5,12 +5,12 @@ # - the boot NIC gets a DHCPv4 lease, and # - the initqueue has a finished condition, or it ends before it runs the settled hooks. -load 'helpers/shell_source' +load 'helpers/dracut_module' setup() { - INSTALL="$(require_repo_file 'xCAT-server/share/xcat/netboot/ubuntu/dracut/install.netboot')" - MOD="$(dirname "$INSTALL")" + MOD="${BATS_TEST_TMPDIR}/module" + stage_dracut_module ubuntu/dracut "$MOD" LOG="${BATS_TEST_TMPDIR}/installed" : >"$LOG" HOOKS="${BATS_TEST_TMPDIR}/hooks" diff --git a/xCAT-test/bats/ubuntu_netboot_root_handler.bats b/xCAT-test/bats/ubuntu_netboot_root_handler.bats index a542636a40..84dfd7b8cf 100644 --- a/xCAT-test/bats/ubuntu_netboot_root_handler.bats +++ b/xCAT-test/bats/ubuntu_netboot_root_handler.bats @@ -5,12 +5,12 @@ # On 26.04 the initramfs then fetches no root: measured on xcat32-cn, zero DHCP from the initrd, # zero httpd requests for rootimg.cpio.gz, and dracut in emergency mode 3.3 seconds in. -load 'helpers/shell_source' +load 'helpers/dracut_module' setup() { - INSTALL="$(require_repo_file 'xCAT-server/share/xcat/netboot/ubuntu/dracut/install.netboot')" - MOD="$(dirname "$INSTALL")" + MOD="${BATS_TEST_TMPDIR}/module" + stage_dracut_module ubuntu/dracut "$MOD" LOG="${BATS_TEST_TMPDIR}/installed" : >"$LOG" } diff --git a/xCAT-test/bats/xcatroot_rootimg_checksum.bats b/xCAT-test/bats/xcatroot_rootimg_checksum.bats index ac58729e37..42b7329c50 100644 --- a/xCAT-test/bats/xcatroot_rootimg_checksum.bats +++ b/xCAT-test/bats/xcatroot_rootimg_checksum.bats @@ -162,16 +162,27 @@ run_xcatroot() local script="$1" shell="$2" shift 2 local sandbox=("$bwrap" --unshare-all --die-with-parent --new-session - --ro-bind /usr /usr --ro-bind /etc /etc --symlink usr/bin /bin --symlink usr/sbin /sbin + --ro-bind /usr /usr --ro-bind /etc /etc --dir /lib --proc /proc --dev /dev --tmpfs /tmp --dir /sysroot --bind "$FX" /fx --ro-bind "$FX/lib/dracut-lib.sh" /lib/dracut-lib.sh --ro-bind "$(repo_path "$script")" /xcatroot --chdir / --setenv PATH /fx/bin:/usr/bin:/bin --setenv imgurl "$URL" --setenv XCAT 192.0.2.1:3001 --setenv rootimgchecksum "${CMDLINE#rootimgchecksum=}" --setenv XCAT_UFTP_POLL 60 "$@") - [ ! -e /usr/lib64 ] || sandbox+=(--symlink usr/lib64 /lib64) + local directory + for directory in bin sbin; do + if [ -L "/$directory" ]; then + sandbox+=(--symlink "usr/$directory" "/$directory") + else + sandbox+=(--ro-bind "/$directory" "/$directory") + fi + done + [ ! -e /lib64 ] || sandbox+=(--ro-bind /lib64 /lib64) for multiarch in /usr/lib/*-linux-gnu; do [ ! -d "$multiarch" ] || sandbox+=(--ro-bind "$multiarch" "/lib/${multiarch##*/}") done + local checksum_helper + checksum_helper=$(repo_path xCAT-server/share/xcat/netboot/imgutils/xcat-rootimg-checksum.sh) + [ ! -f "$checksum_helper" ] || sandbox+=(--ro-bind "$checksum_helper" /lib/xcat-rootimg-checksum.sh) # genimage puts the helper in every initial ramdisk that can receive the root image over UFTP. [ -n "$NO_UFTP_HELPER" ] || sandbox+=(--ro-bind "$(repo_path xCAT-server/share/xcat/netboot/imgutils/xcat-rootimg-fetch.sh)" /lib/xcat-rootimg-fetch.sh) echo "imgurl=$URL XCAT=192.0.2.1:3001 nonodestatus $CMDLINE $UFTP $KERNEL_ARGS" >"$FX/cmdline" diff --git a/xCAT-test/native/openeuler_xcatroot.t b/xCAT-test/native/openeuler_xcatroot.t index 478365134a..923599d6fb 100644 --- a/xCAT-test/native/openeuler_xcatroot.t +++ b/xCAT-test/native/openeuler_xcatroot.t @@ -74,6 +74,9 @@ getarg() } SH copy($source, "$root/xcatroot") or die $!; + my $checksum_helper = "$netboot/../imgutils/xcat-rootimg-checksum.sh"; + copy($checksum_helper, "$root/lib/xcat-rootimg-checksum.sh") or die $! + if -f $checksum_helper; my $archive = "$root/rootimg.$method.gz"; my @pack = $method eq 'cpio' ? ('/bin/bash', '-o', 'pipefail', '-c', 'cd "$1" && find . -print0 | cpio -0 -o -H newc | gzip > "$2"', 'pack', $payload, $archive)