Unfortunately after some testing it seems this simple thing causes a horrible, horrible problem: TMPDIR is passed on to qemu which means when packages are installed, they are fed to a TMPDIR that possibly does not exist on the target system. In my case I have a large disk mounted at /build and errors such as:
debconf: apt-extracttemplates failed: Illegal seek
Extracting templates from packages: 15%E: Could not open file /build/rootstock/tmp/man-db.template.48360 - open (2: No such file or directory)
E: Unable to write to /build/rootstock/tmp/man-db.template.48360 - ofstream::ofstream (2: No such file or directory)
E: Could not open file /build/rootstock/tmp/man-db.config.48361 - open (2: No such file or directory)
E: Unable to write to /build/rootstock/tmp/man-db.config.48361 - ofstream::ofstream (2: No such file or directory)
Inside the "chroot" this directory obviously does not exist.
Possibly the correct solution is to pass -p as well (even though it is deprecated it is the best solution) such as
mktemp -d -p ${ROOTSTOCKTEMP} -t
This way the temporary directory base can be passed as a new rootstock argument (--tmpdir?) without overriding the TMPDIR environment variable and accidentally passing it to the VM. Alternatively, passing TMPDIR=/tmp before qemu-arm-static would make sure it uses the chroot's /tmp directory.
Unfortunately after some testing it seems this simple thing causes a horrible, horrible problem: TMPDIR is passed on to qemu which means when packages are installed, they are fed to a TMPDIR that possibly does not exist on the target system. In my case I have a large disk mounted at /build and errors such as:
debconf: apt-extracttemp lates failed: Illegal seek rootstock/ tmp/man- db.template. 48360 - open (2: No such file or directory) rootstock/ tmp/man- db.template. 48360 - ofstream::ofstream (2: No such file or directory) rootstock/ tmp/man- db.config. 48361 - open (2: No such file or directory) rootstock/ tmp/man- db.config. 48361 - ofstream::ofstream (2: No such file or directory)
Extracting templates from packages: 15%E: Could not open file /build/
E: Unable to write to /build/
E: Could not open file /build/
E: Unable to write to /build/
Inside the "chroot" this directory obviously does not exist.
Possibly the correct solution is to pass -p as well (even though it is deprecated it is the best solution) such as
mktemp -d -p ${ROOTSTOCKTEMP} -t
This way the temporary directory base can be passed as a new rootstock argument (--tmpdir?) without overriding the TMPDIR environment variable and accidentally passing it to the VM. Alternatively, passing TMPDIR=/tmp before qemu-arm-static would make sure it uses the chroot's /tmp directory.
Either solution seems good..