Re: rmdir: failed to remove '/var/lock': Directory not empty
On Thu, May 12, 2022 at 07:12:27AM +0200, Johannes Schauer Marin Rodrigues wrote:
Quoting Bo YU (2022-05-12 05:57:56)
Thanks for your explanations. I created chroot with below:
sudo sbuild-createchroot --arch=riscv64 --foreign --keyring="" \
--include=debian-ports-archive-keyring --make-sbuild-tarball=/srv/sid-riscv64-sbuild.tgz \
sid /tmp/chroots/sid-riscv64-sbuild/ http://ftp.ports.debian.org/debian-ports/
Maybe one of these parameters prevents some essential packages from being installed.
And I happened to miss to execute `sbuild-update -ud sid-riscv64-sbuild` to check
the dependency integrity of the chroot.
It is easy to fix it as you said. I entered into the chroot with `sbuild-shell` and
installing necessary packages by manual and to execute `sbuild-update` again.
That is ok.
okay, I now understand what happened. You ran sbuild-createchroot with the
--foreign switch. I guess this means that the machine you are running this one
is of a different architecture than riscv64, correct? The sbuild-createchroot
yes. I built Debian riscv64 chroot on amd64 indeed.
script is essentially only a very thin wrapper around other tools that create a
Debian chroot and its main purpose is to set up a working schroot
configuration. Schroot is the default sbuild chroot backend. The default chroot
builder in Debian and in sbuild-createchroot is debootstrap. If you call
sbuild-createchroot as above, then debootstrap will be run with the --foreign
option. From the debootstrap man page:
Do the initial unpack phase of bootstrapping only, for example if the tar‐
get architecture does not match the host architecture. A copy of deboot‐
strap sufficient for completing the bootstrap process will be installed as
/debootstrap/debootstrap in the target filesystem. You can run it with the
--second-stage option to complete the bootstrapping process.
This is also documented in the sbuild-createchroot man page:
Only perform the initial unpack phase of bootstrapping. This is required
if the target and host architectures do not match. Note that debootstrap
requires running by hand to complete installation; run the debootstrap /de‐
bootstrap/debootstrap installed in TARGET-DIRECTORY to complete the instal‐
So a chroot you create that way is not complete yet and more steps are needed.
To fix this, you could either run /debootstrap/debootstrap inside your chroot
with --second-stage as suggested by the man page, but then you cannot let
sbuild-createchroot create a tarball for you but you have to pack the tarball
manually once you are done.
Another option is to just run this instead of sbuild-createchroot:
$ mmdebstrap --arch=riscv64 --variant=buildd \
--include=debian-ports-archive-keyring unstable riscv64-chroot.tar \
"deb http://ftp.ports.debian.org/debian-ports/ sid main" \
"deb http://ftp.ports.debian.org/debian-ports/ unreleased main"
$ sudo mv riscv64-chroot.tar /srv/sid-riscv64-sbuild.tgz
This will work because you successfully ran sbuild-createchroot before, so you
already have a working schroot configuration which expects your tarball at
/srv/sid-riscv64-sbuild.tgz. Advantages for you are:
* create a foreign architecture chroot in a single step
* no manual fiddling to run /debootstrap/debootstrap --second-stage
* doesn't require superuser privileges (except to move stuff to /srv)
* supports multiple mirrors
The latter used to be necessary for riscv64 in its early stages and is
generally necessary for young Debian ports architectures because required
packages will be in the "unreleased" suite in addition to "sid". Using
mmdebstrap is also recommended by the riscv64 wiki page:
If, on the other hand, you start off from scratch and you want to use sbuild
with the schroot chroot backend and you don't want to create the schroot
configuration by hand, then you can also run sbuild-createchroot with some
different options to produce the same thing like this:
$ sudo sbuild-createchroot --debootstrap=mmdebstrap --arch=riscv64 \
sid /tmp/chroots/sid-riscv64-sbuild/ \
This tells sbuild-createchroot to use mmdebstrap as a debootstrap replacement
which is able to create a foreign architecture chroot that is ready to use from
the beginning without having to use the --foreign option.
Excellent! It is easy to understand what happened behind sbuild-createchroot now.
I learn more about how to setup appropriately chroot environments and its usgae
with your help.