On Fri, 31 Jan 2020 06:28:07 +0100 Johannes Schauer wrote: [...] > Quoting Francesco Poli (2020-01-30 23:41:11) [...] > > Wait, does this change the result? [...] > in your case, TMPDIR was a relative path. [...] > Your expectation was, that when you set TMPDIR, the only one who would consume > that environment variable would be mmdebstrap itself. I think that thought is > not unreasonable. That's why I think it's important that mmdebstrap unsets > that > variable before it executes processes inside the chroot.
All your reasoning makes sense to me.
I agree that TMPDIR should be unset by mmdebstrap before running hooks.
I tried to check that the resulting .tar file is not affected by this
TMPDIR unsetting.
I did the following:
$ cat ABSTMPDIR/test.sh
#!/bin/sh
SETUP_TESTBED="/usr/share/autopkgtest/setup-commands/setup-testbed"
LIMAVAR="amd64"
SUITE="sid"
SIZE="2GiB"
TMPDIR=$(pwd)
export TMPDIR
mmdebstrap --variant=important --include=linux-image-"$LIMAVAR" \
--customize-hook='chroot "$1" passwd --delete root' \
--customize-hook='chroot "$1" useradd --home-dir /home/user --create-home
user' \
--customize-hook='chroot "$1" passwd --delete user' \
--customize-hook='echo host > "$1/etc/hostname"' \
--customize-hook='echo "127.0.0.1 localhost host" > "$1/etc/hosts"' \
--customize-hook="$SETUP_TESTBED" \
"$SUITE" debian-unstable.tar
$ cat NOTMPDIR/test.sh
#!/bin/sh
SETUP_TESTBED="/usr/share/autopkgtest/setup-commands/setup-testbed"
LIMAVAR="amd64"
SUITE="sid"
SIZE="2GiB"
TMPDIR='.'
export TMPDIR
mmdebstrap --variant=important --include=linux-image-"$LIMAVAR" \
--customize-hook='chroot "$1" passwd --delete root' \
--customize-hook='chroot "$1" useradd --home-dir /home/user --create-home
user' \
--customize-hook='chroot "$1" passwd --delete user' \
--customize-hook='echo host > "$1/etc/hostname"' \
--customize-hook='echo "127.0.0.1 localhost host" > "$1/etc/hosts"' \
--customize-hook='env --unset=TMPDIR
/usr/share/autopkgtest/setup-commands/setup-testbed "$1"' \
"$SUITE" debian-unstable.tar
After running the two test.sh scripts within their respective
directories, I used diffoscope to highlight the differences between the
two resulting .tar files:
$ TMPDIR=/run/shm diffoscope \
--max-diff-block-lines 15000 \
--max-page-diff-block-lines 1500 \
--html report_diffoscope.html \
ABSTMPDIR/debian-unstable.tar \
NOTMPDIR/debian-unstable.tar
The only differences shown in the resulting report_diffoscope.html file
seem to be:
• the generated files in the content
of ./boot/initrd.img-5.4.0-3-amd64 have differing creation
timestamps (but this is obvious, since the two initrd were not
created exactly at the same time!)
• ./var/lib/initramfs-tools/5.4.0-3-amd64 files differ (but they seem
to include some checksum of the initrd, hence the difference should
be consequence of the first point)
• ./etc/machine-id and ./var/lib/dbus/machine-id files differ (but I
think this should not be surprising...)
• ./usr/lib/python3.7/__pycache__/hashlib.cpython-37.pyc files have
some different hex values (I am not sure why, but it's compiled
Python code, maybe it includes a compilation timestamp or
something?!?)
I am under the impression that the two .tar files are to be considered
equivalent.
Do you agree?
P.S.: I still have to find the time to check the .qcow2 file I obtained
on last Wednesday... :-(
--
http://www.inventati.org/frx/
There's not a second to spare! To the laboratory!
..................................................... Francesco Poli .
GnuPG key fpr == CA01 1147 9CD2 EFDF FB82 3925 3E1C 27E1 1F69 BFFE
pgpbwUbL69RDJ.pgp
Description: PGP signature

