On Sat, 26 Sep 2020 23:18:54 +0200 Johannes Schauer <[email protected]> wrote: > Quoting Josh Triplett (2020-09-26 22:47:50) > > On Sat, 26 Sep 2020 22:09:57 +0200 Johannes Schauer <[email protected]> > > wrote: > > > Quoting Josh Triplett (2020-09-26 21:47:56) > > > > > so... you want something like this: > > > > > > > > > > $ mmdebstrap --customize-hook='sync-out /var/cache/apt/archives > > > > > ./cache' unstable /dev/null > > > > > $ mmdebstrap --variant=apt --setup-hook='mkdir -p > > > > > "$1"/var/cache/apt/archives' --setup-hook='sync-in ./cache > > > > > /var/cache/apt/archives' unstable output.tar > > > > > > > > > > The first command fills your local directory "./cache" with the > > > > > contents of > > > > > /var/cache/apt/archives from the first run while the second > > > > > invocation gets the > > > > > contents from that directory and thus is able to operate a bit faster. > > > > > > > > By the time customize-hook runs, mmdebstrap has already cleared > > > > /var/cache/apt/archives, so there's nothing to copy out. > > > > > > then why is my ./cache directory filled with lots of *.deb files? I tried > > > out > > > the commands above before hitting the send button. > > > > Try this: > > > > sudo mmdebstrap \ > > --mode=sudo \ > > --variant=apt \ > > --include='systemd-sysv udev' \ > > --setup-hook='mkdir -p cache "$1"/var/cache/apt/archives' \ > > --setup-hook='sync-in ./cache /var/cache/apt/archives' \ > > --customize-hook='ls -l "$1"/var/cache/apt/archives' \ > > --customize-hook='sync-out /var/cache/apt/archives ./cache' \ > > --customize-hook='rm -rf "$1/var/log/journal"' \ > > --dpkgopt='path-exclude=/lib/systemd/system/fstrim.*' \ > > --dpkgopt='path-exclude=/lib/systemd/system/*.timer' \ > > --dpkgopt='path-exclude=/usr/share/bash-completion/*' \ > > --dpkgopt='path-exclude=/usr/share/bug/*' \ > > --dpkgopt='path-exclude=/usr/share/doc/*' \ > > --dpkgopt='path-exclude=/usr/share/info/*' \ > > --dpkgopt='path-exclude=/usr/share/lintian/*' \ > > --dpkgopt='path-exclude=/usr/share/locale/*' \ > > --dpkgopt='path-exclude=/usr/share/man/*' \ > > --dpkgopt='path-include=/usr/share/man/man[0-9]/' \ > > --dpkgopt='path-exclude=/usr/share/zsh/*' \ > > sid target > > > > Try running that twice. The first time, the ls at the end does show some > > archives (though only for the subset of packages installed later by > > --include and its dependencies, not the essential packages). The second > > time, apt still does the download, and the ls shows nothing. > > > > Is there something wrong with the above? > > Yes, one bit is missing. For the initial Essential:yes package set, mmdebstrap > deletes the *.deb files itself after installing them. So you have to copy them > out of the chroot before the deletion happens, so between downloading and > extracting. Like so: > > $ sudo mmdebstrap --variant=apt --include='systemd-sysv udev' \ > > --setup-hook='mkdir -p cache "$1"/var/cache/apt/archives' \ > > --setup-hook='sync-in ./cache /var/cache/apt/archives' \ > > --extract-hook="sync-out /var/cache/apt/archives ./cache" \ > > --customize-hook='sync-out /var/cache/apt/archives ./cache' \ > > unstable debian-unstable
Ah! That was indeed what I was missing, thank you. Is it documented somewhere that mmdebstrap deletes those files after installing them? Also, does mmdebstrap *use* the cache for the initial Essential package set? > > > This will not work with all modes. I guess you are using root or > > > fakechroot > > > mode? > > > > Yes, I'm using root mode, as I need a directory of files I can feed to > > `mkfs.ext4 -d`. In theory I might be able to use fakechroot mode and > > run mkfs.ext4 underneath mmdebstrap; I may try that once I've gotten the > > existing setup to do everything I need it to. > > Maybe the ability of mmdebstrap to produce ext2 filesystems directly can be > useful for you. You will then not need root privileges. I did see that, but it looks like that uses genext2fs, and I need to use mkfs.ext4 so that I can generate an ext4 filesystem with specific options (as well as write files out with extents). It also doesn't support xattrs.

