Hi, I run through this at DebConf when I tried to set up my new laptop for debian work. The problem is, that vmdebootsrap is actually just create a file, mount it through a loop device and after bootsrapping it it will run the customizer script in the HOST environment. And if we think about it, it is logical, because this allows the customizer script to copy any file from the host os to the disk image if it want.
The mentioned customizer script (/usr/share/autopkgtest/setup- commands/setup-testbed) also uses this feature when, for example, tries to detect the used apt proxy. So, all commands (especially installing packages) which the script want to run inside the new image is run by/through the chroot command. For example: # install some necessary packages # some tests use a lot of /dev/random, avoid hangs; eatmydata for fast dpkg, a # lot of tests expect a logind session chroot "$root" apt-get install -y eatmydata dbus < /dev/null And yes, the problem is, that in some cases the /etc/resolv.conf just a symlink and point to a file which does not exists until the qemu guest is booted up. I'm not 100% sure, but I have the feeling that this depends on your host environment. Because, I think, the debootstrap copies the /etc/resolv.cong file as-is to the chroot environment. My first idea was to use the AUTOPKGTEST_APT_PROXY environment variable, but that did not work because the proxy only set at the end of the customization script and all the apt-get install command already run. So, my solution was, as a dirty hack, to copy the content of the /etc/resolv.conf into the chroot. Something like this what is attached to this email.
--- /usr/share/autopkgtest/setup-commands/setup-testbed~ 2017-04-30 13:09:57.000000000 -0400 +++ /usr/share/autopkgtest/setup-commands/setup-testbed 2017-08-06 17:22:16.942392522 -0400 @@ -196,6 +196,11 @@ fi fi +if [ "$root" != "/" ]; then + chroot "$root" mv /etc/resolv.conf /etc/resolv.conf.backup + cat /etc/resolv.conf > "$root/etc/resolv.conf" +fi + if [ -z "${AUTOPKGTEST_IS_SETUP_COMMAND:-}" ]; then chroot "$root" apt-get update || (sleep 15; chroot "$root" apt-get update) fi @@ -288,3 +293,8 @@ # avoid cron interference with apt-get update echo 'APT::Periodic::Enable "0";' > "$root/etc/apt/apt.conf.d/02periodic" + + +if [ "$root" != "/" ]; then + chroot "$root" mv /etc/resolv.conf.backup /etc/resolv.conf +fi
signature.asc
Description: This is a digitally signed message part