tests/check-against-debootstrap-dist: avoid code duplication by using a loop

This commit is contained in:
Johannes Schauer Marin Rodrigues 2022-10-18 10:51:22 +02:00
parent eb7cf54155
commit 43ba07e790
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -166,22 +166,21 @@ for log in faillog lastlog; do
done done
# workaround for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=917773 # workaround for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=917773
if ! cmp /tmp/debian-{{ DIST }}-debootstrap/etc/shadow /tmp/debian-{{ DIST }}-mm/etc/shadow >&2; then # also needed for users that are created by systemd-sysusers before systemd 252
echo patching /etc/shadow on {{ DIST }} {{ VARIANT }} >&2 # https://github.com/systemd/systemd/pull/24534
awk -v FS=: -v OFS=: -v SDE={{ SOURCE_DATE_EPOCH }} '{ print $1,$2,int(SDE/60/60/24),$4,$5,$6,$7,$8,$9 }' < /tmp/debian-{{ DIST }}-mm/etc/shadow > /tmp/debian-{{ DIST }}-mm/etc/shadow.bak for f in shadow shadow-; do
cat /tmp/debian-{{ DIST }}-mm/etc/shadow.bak > /tmp/debian-{{ DIST }}-mm/etc/shadow if [ ! -e /tmp/debian-{{ DIST }}-mm/etc/$f ]; then
rm /tmp/debian-{{ DIST }}-mm/etc/shadow.bak continue
else fi
echo no difference for /etc/shadow on {{ DIST }} {{ VARIANT }} >&2 if ! cmp /tmp/debian-{{ DIST }}-debootstrap/etc/$f /tmp/debian-{{ DIST }}-mm/etc/$f >&2; then
fi echo patching /etc/$f on {{ DIST }} {{ VARIANT }} >&2
if ! cmp /tmp/debian-{{ DIST }}-debootstrap/etc/shadow- /tmp/debian-{{ DIST }}-mm/etc/shadow- >&2; then awk -v FS=: -v OFS=: -v SDE={{ SOURCE_DATE_EPOCH }} '{ print $1,$2,int(SDE/60/60/24),$4,$5,$6,$7,$8,$9 }' < /tmp/debian-{{ DIST }}-mm/etc/$f > /tmp/debian-{{ DIST }}-mm/etc/$f.bak
echo patching /etc/shadow- on {{ DIST }} {{ VARIANT }} >&2 cat /tmp/debian-{{ DIST }}-mm/etc/$f.bak > /tmp/debian-{{ DIST }}-mm/etc/$f
awk -v FS=: -v OFS=: -v SDE={{ SOURCE_DATE_EPOCH }} '{ print $1,$2,int(SDE/60/60/24),$4,$5,$6,$7,$8,$9 }' < /tmp/debian-{{ DIST }}-mm/etc/shadow- > /tmp/debian-{{ DIST }}-mm/etc/shadow-.bak rm /tmp/debian-{{ DIST }}-mm/etc/$f.bak
cat /tmp/debian-{{ DIST }}-mm/etc/shadow-.bak > /tmp/debian-{{ DIST }}-mm/etc/shadow- else
rm /tmp/debian-{{ DIST }}-mm/etc/shadow-.bak echo no difference for /etc/$f on {{ DIST }} {{ VARIANT }} >&2
else fi
echo no difference for /etc/shadow- on {{ DIST }} {{ VARIANT }} >&2 done
fi
# check if the file content differs # check if the file content differs
diff --unified --no-dereference --recursive /tmp/debian-{{ DIST }}-debootstrap /tmp/debian-{{ DIST }}-mm >&2 diff --unified --no-dereference --recursive /tmp/debian-{{ DIST }}-debootstrap /tmp/debian-{{ DIST }}-mm >&2