coverage.sh: test eatmydata and merged-usr hooks

This commit is contained in:
Johannes 'josch' Schauer 2020-08-25 16:05:10 +02:00
parent 0920f72996
commit 74725ac451
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1
3 changed files with 77 additions and 21 deletions

View file

@ -73,9 +73,20 @@ fi
if [ ! -e shared/tarfilter ] || [ tarfilter -nt shared/tarfilter ]; then if [ ! -e shared/tarfilter ] || [ tarfilter -nt shared/tarfilter ]; then
cp -a tarfilter shared cp -a tarfilter shared
fi fi
mkdir -p shared/hooks
if [ ! -e shared/hooks/setup00-merged-usr.sh ] || [ hooks/setup00-merged-usr.sh -nt shared/hooks/setup00-merged-usr.sh ]; then
cp -a hooks/setup00-merged-usr.sh shared/hooks/setup00-merged-usr.sh
fi
mkdir -p shared/hooks/eatmydata
if [ ! -e shared/hooks/eatmydata/extract.sh ] || [ hooks/eatmydata/extract.sh -nt shared/hooks/eatmydata/extract.sh ]; then
cp -a hooks/eatmydata/extract.sh shared/hooks/eatmydata/extract.sh
fi
if [ ! -e shared/hooks/eatmydata/customize.sh ] || [ hooks/eatmydata/customize.sh -nt shared/hooks/eatmydata/customize.sh ]; then
cp -a hooks/eatmydata/customize.sh shared/hooks/eatmydata/customize.sh
fi
starttime= starttime=
total=149 total=150
skipped=0 skipped=0
runtests=0 runtests=0
i=1 i=1
@ -1802,20 +1813,40 @@ else
runtests=$((runtests+1)) runtests=$((runtests+1))
fi fi
print_header "mode=root,variant=apt: test --setup-hook" print_header "mode=root,variant=apt: test merged-usr via --setup-hook"
cat << END > shared/test.sh cat << END > shared/test.sh
#!/bin/sh #!/bin/sh
set -eu set -eu
export LC_ALL=C.UTF-8 export LC_ALL=C.UTF-8
cat << 'SCRIPT' > customize.sh $CMD --mode=root --variant=apt \
#!/bin/sh --setup-hook=./hooks/setup00-merged-usr.sh \
for d in sbin lib; do ln -s usr/\$d "\$1/\$d"; mkdir -p "\$1/usr/\$d"; done --customize-hook='[ -L "\$1"/bin -a -L "\$1"/sbin -a -L "\$1"/lib ]' \
SCRIPT $DEFAULT_DIST /tmp/debian-chroot $mirror
chmod +x customize.sh
$CMD --mode=root --variant=apt --setup-hook='ln -s usr/bin "\$1/bin"; mkdir -p "\$1/usr/bin"' --setup-hook=./customize.sh $DEFAULT_DIST /tmp/debian-chroot $mirror
tar -C /tmp/debian-chroot --one-file-system -c . | tar -t | sort > tar2.txt tar -C /tmp/debian-chroot --one-file-system -c . | tar -t | sort > tar2.txt
{ sed -e 's/^\.\/bin\//.\/usr\/bin\//;s/^\.\/lib\//.\/usr\/lib\//;s/^\.\/sbin\//.\/usr\/sbin\//;' tar1.txt; echo ./bin; echo ./lib; echo ./sbin; } | sort -u | diff -u - tar2.txt {
rm customize.sh sed -e 's/^\.\/bin\//.\/usr\/bin\//;s/^\.\/lib\//.\/usr\/lib\//;s/^\.\/sbin\//.\/usr\/sbin\//;' tar1.txt | {
case $HOSTARCH in
amd64) sed -e 's/^\.\/lib32\//.\/usr\/lib32\//;s/^\.\/lib64\//.\/usr\/lib64\//;s/^\.\/libx32\//.\/usr\/libx32\//;';;
ppc64el) sed -e 's/^\.\/lib64\//.\/usr\/lib64\//;';;
*) cat;;
esac
};
echo ./bin;
echo ./lib;
echo ./sbin;
case $HOSTARCH in
amd64)
echo ./lib32;
echo ./lib64;
echo ./libx32;
echo ./usr/lib32/;
echo ./usr/libx32/;
;;
ppc64el)
echo ./lib64;
;;
esac
} | sort -u | diff -u - tar2.txt
rm -r /tmp/debian-chroot rm -r /tmp/debian-chroot
END END
if [ "$HAVE_QEMU" = "yes" ]; then if [ "$HAVE_QEMU" = "yes" ]; then
@ -1999,6 +2030,40 @@ else
runtests=$((runtests+1)) runtests=$((runtests+1))
fi fi
print_header "mode=root,variant=apt: test eatmydata via --hook-dir"
cat << END > shared/test.sh
#!/bin/sh
set -eu
export LC_ALL=C.UTF-8
cat << SCRIPT > checkeatmydata.sh
#!/bin/sh
set -exu
cat << EOF | diff - "\\\$1"/usr/bin/dpkg
#!/bin/sh
exec /usr/bin/eatmydata /usr/bin/dpkg.distrib "\\\\\\\$@"
EOF
[ -e "\\\$1"/usr/bin/eatmydata ]
SCRIPT
chmod +x checkeatmydata.sh
$CMD --mode=root --variant=apt \
--customize-hook=./checkeatmydata.sh \
--essential-hook=./checkeatmydata.sh \
--extract-hook='printf "\\177ELF\\002\\001\\001\\000" | cmp --bytes=8 - "\$1"/usr/bin/dpkg' \
--hook-dir=./hooks/eatmydata \
--customize-hook='printf "\\177ELF\\002\\001\\001\\000" | cmp --bytes=8 - "\$1"/usr/bin/dpkg' \
$DEFAULT_DIST /tmp/debian-chroot $mirror
tar -C /tmp/debian-chroot --one-file-system -c . | tar -t | sort | diff -u tar1.txt -
rm checkeatmydata.sh
rm -r /tmp/debian-chroot
END
if [ "$HAVE_QEMU" = "yes" ]; then
./run_qemu.sh
runtests=$((runtests+1))
else
./run_null.sh SUDO
runtests=$((runtests+1))
fi
print_header "mode=root,variant=apt: test special hooks using helpers" print_header "mode=root,variant=apt: test special hooks using helpers"
cat << END > shared/test.sh cat << END > shared/test.sh
#!/bin/sh #!/bin/sh

View file

@ -237,9 +237,9 @@ END
| grep-dctrl --no-field-names --show-field=Package --exact-match \ | grep-dctrl --no-field-names --show-field=Package --exact-match \
\( --field=Essential yes --or --field=Priority required \ \( --field=Essential yes --or --field=Priority required \
--or --field=Priority important --or --field=Priority standard \ --or --field=Priority important --or --field=Priority standard \
--or --field=Package build-essential \) --and --not --field Package python ) \) --and --not --field Package python )
pkgs="$(echo $pkgs) build-essential busybox gpg" pkgs="$(echo $pkgs) build-essential busybox gpg eatmydata"
APT_CONFIG="$rootdir/etc/apt/apt.conf" apt-get --yes install $pkgs APT_CONFIG="$rootdir/etc/apt/apt.conf" apt-get --yes install $pkgs

View file

@ -1526,15 +1526,6 @@ sub run_setup() {
} }
} }
## setup merged usr
#my @amd64_dirs = ('lib32', 'lib64', 'libx32'); # only amd64 for now
#foreach my $dir ("bin", "sbin", "lib", @amd64_dirs) {
# symlink "usr/$dir", "$options->{root}/$dir"
# or die "cannot create symlink: $!";
# make_path("$options->{root}/usr/$dir")
# or die "cannot create /usr/$dir: $!";
#}
{ {
open my $fh, '>', "$options->{root}/etc/fstab" open my $fh, '>', "$options->{root}/etc/fstab"
or error "cannot open fstab: $!"; or error "cannot open fstab: $!";