scripts/kernel-test: adjust to usr-merge

In debian bookworm, the /usr merge has been implemented:

  /bin → /usr/bin
  /sbin → /usr/sbin
  /lib → /usr/lib
  /lib64 → /usr/lib64

The initramfs filesystem layout is derived from the paths of the
binaries and libraries in the full system. Create the same symlinks and
adjust initrd_add_bin so it does not trip over the symlinks.

I've also considered to change all input for initrd_add_bin to point at
the /usr/… paths. But this is not possible, for example ldd/lddtree will
point at libraries in /lib and /lib64, and this gets passed to
initrd_add_bin.

Without this patch, the init script and all binaries called from it
cannot be executed.

Related: OS#6057
Related: https://wiki.debian.org/UsrMerge
Change-Id: I975d3af0fa88869688673936a08189de800fba29
This commit is contained in:
Oliver Smith 2023-07-18 12:21:12 +02:00
parent 94f8a8147e
commit 0660fc4e4b
1 changed files with 19 additions and 3 deletions

View File

@ -1,9 +1,22 @@
#!/bin/sh -ex
# Add one or more files to the initramfs, with parent directories
# Add one or more files to the initramfs, with parent directories.
# usr-merge: resolve symlinks for /lib -> /usr/lib etc. so "cp --parents" does
# not fail with "cp: cannot make directory '/tmp/initrd/lib': File exists"
# $@: path to files
initrd_add_file() {
cp -a --parents "$@" /tmp/initrd
local i
for i in "$@"; do
case "$i" in
/bin/*|/sbin/*|/lib/*|/lib64/*)
cp -a --parents "$@" /tmp/initrd/usr
;;
*)
cp -a --parents "$@" /tmp/initrd
;;
esac
done
}
# Add kernel module files with dependencies
@ -82,10 +95,13 @@ initrd_add_cmd() {
mkdir -p /tmp/initrd
cd /tmp/initrd
for dir in bin sbin lib lib64; do
ln -s usr/"$dir" "$dir"
done
mkdir -p \
dev/net \
proc \
sbin \
sys \
tmp \
usr/bin \