From e51206cf3223baaca3a108f1215b98bcab0afdea Mon Sep 17 00:00:00 2001 From: David P Date: Fri, 9 Jul 2021 00:54:23 -0400 Subject: initial arch-nspawn replacement with chroot-run Signed-off-by: David P --- INSTALL | 2 +- po/es/libretools.po | 18 +++++++++---- src/chroot-tools/.gitignore | 2 +- src/chroot-tools/Makefile | 4 +-- src/chroot-tools/librechroot | 64 ++++++++++++++++++++++---------------------- src/lib/Makefile | 4 +-- 6 files changed, 51 insertions(+), 43 deletions(-) diff --git a/INSTALL b/INSTALL index a74a376..5af9ede 100644 --- a/INSTALL +++ b/INSTALL @@ -71,7 +71,7 @@ main libretools subpackage: - GNU Make (only needed for `librefetch`) - ssh client (OpenSSH, only needed for `librerelease`) - rsync - - systemd-nspawn (for the chroot tools) + - chroot - tokyocabinet Configuration diff --git a/po/es/libretools.po b/po/es/libretools.po index 3d1dc27..f60d0fb 100644 --- a/po/es/libretools.po +++ b/po/es/libretools.po @@ -500,23 +500,31 @@ msgstr "" msgid "Retrieving missing deps: %s" msgstr "Recibiendo dependencias faltantes: %s" -#: src/chroot-tools/arch-nspawn:42 src/chroot-tools/mkarchroot:40 +#: src/chroot-tools/chroot-run:27 +msgid "Killing chroot process: %s (%s)" +msgstr "Matando proceso del chroot: %s (%s)" + +#: src/chroot-tools/chroot-run:72 src/chroot-tools/mkarchroot:40 msgid "invalid argument '%s'" msgstr "argumento inválido '%s'" -#: src/chroot-tools/arch-nspawn:47 +#: src/chroot-tools/chroot-run:77 msgid "You must specify a directory." msgstr "Debe especificar un directorio." -#: src/chroot-tools/arch-nspawn:53 src/chroot-tools/mkarchroot:52 +#: src/chroot-tools/chroot-run:83 src/chroot-tools/mkarchroot:52 msgid "Please specify a working directory." msgstr "Por favor especifique un directorio de trabajo." -#: src/chroot-tools/arch-nspawn:103 +#: src/chroot-tools/chroot-run:143 msgid "'%s' does not appear to be an Arch chroot." msgstr "'%s' no parece ser un chroot de Arch." -#: src/chroot-tools/arch-nspawn:105 +#: src/chroot-tools/chroot-run:149 +msgid "failed to setup API filesystems in chroot %s" +msgstr "falló al configurar los sistemas de archivos API en el chroot" + +#: src/chroot-tools/chroot-run:145 msgid "chroot '%s' is not at version %s. Please rebuild." msgstr "chroot '%s' no está a la versión %s. Por favor reconstruir." diff --git a/src/chroot-tools/.gitignore b/src/chroot-tools/.gitignore index 8054d28..c176bd4 100644 --- a/src/chroot-tools/.gitignore +++ b/src/chroot-tools/.gitignore @@ -1,6 +1,6 @@ makechrootpkg.sh* makechrootpkg.in -arch-nspawn* +chroot-run* mkarchroot* !*.patch diff --git a/src/chroot-tools/Makefile b/src/chroot-tools/Makefile index de79819..a279172 100644 --- a/src/chroot-tools/Makefile +++ b/src/chroot-tools/Makefile @@ -4,9 +4,9 @@ include $(topsrcdir)/build-aux/Makefile.head.mk pkglibexecdir = $(libexecdir)/libretools/chroot pkglibdir = $(libdir)/libretools/chroot -libretools.src.devtools = makechrootpkg.in mkarchroot.in arch-nspawn.in +libretools.src.devtools = makechrootpkg.in mkarchroot.in chroot-run.in libretools.out.bins = librechroot libremakepkg -libretools.out.libexecs = arch-nspawn chcleanup distcc-tool indent mkarchroot +libretools.out.libexecs = chroot-run chcleanup distcc-tool indent mkarchroot libretools.out.libs = $(libretools.src.sh) makechrootpkg.sh files.out.int += chcleanup.lib files.sys.libretools += $(bindir)/chcleanup # not in libretools.out.bins because explicit rule diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index 1c76661..48e83c2 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -42,19 +42,19 @@ umask 0022 # Wrappers for files in ${pkglibexecdir}/chroot/ # ################################################################################ -readonly _arch_nspawn="$(librelib chroot/arch-nspawn)" +readonly _chroot_run="$(librelib chroot/chroot-run)" readonly _mkarchroot="$(librelib chroot/mkarchroot)" -arch_nspawn_flags=() -sysd_nspawn_flags=() +chroot_run_flags=() +mkarchroot_flags=() -hack_arch_nspawn_flags() { +hack_mkarchroot_flags() { local copydir="$1" local makepkg_conf="$copydir/etc/makepkg.conf" OPTIND=1 - set -- "${arch_nspawn_flags[@]}" + set -- "${mkarchroot_flags[@]}" while getopts 'hC:M:c:f:s' arg; do case "$arg" in M) makepkg_conf="$OPTARG" ;; @@ -89,27 +89,27 @@ hack_arch_nspawn_flags() { prose 'Such a binfmt_misc entry is provided by the %s package. If you have it installed, but still see this message, you may need to restart %s.' \ - qemu-user-static-binfmt systemd-binfmt.service + qemu-user-static-binfmt binfmt return $EXIT_NOTINSTALLED fi # Let qemu/binfmt_misc do its thing - arch_nspawn_flags+=(-f "$interpreter" -s) + mkarchroot_flags+=(-f "$interpreter" -s) fi } -# Usage: arch-nspawn $copydir $cmd... -arch-nspawn() { +# Usage: chroot-run $copydir $cmd... +chroot-run() { local copydir=$1; shift local cmd=("$@") - local arch_nspawn_flags=("${arch_nspawn_flags[@]}") - hack_arch_nspawn_flags "$copydir" + local mkarchroot_flags=("${mkarchroot_flags[@]}") + hack_mkarchroot_flags "$copydir" - "$_arch_nspawn" \ - "${arch_nspawn_flags[@]}" \ + "$_chroot_run" \ + "${mkarchroot_flags[@]}" \ + "${chroot_run_flags[@]}" "$copydir" \ - "${sysd_nspawn_flags[@]}" \ -- \ "${cmd[@]}" } @@ -119,13 +119,13 @@ mkarchroot() { local copydir=$1; shift local pkgs=("$@") - local arch_nspawn_flags=("${arch_nspawn_flags[@]}") - hack_arch_nspawn_flags "$copydir" + local mkarchroot_flags=("${mkarchroot_flags[@]}") + hack_mkarchroot_flags "$copydir" local cmd=( unshare -m "$_mkarchroot" - # mkarchroot flags: (flags are very similar to arch-nspawn) - "${arch_nspawn_flags[@]}" + # mkarchroot flags: + "${mkarchroot_flags[@]}" # chroot directory: -- "$copydir" # pacman flags: @@ -240,8 +240,8 @@ usage() { prose 'This command will make the following configuration changes in the chroot:' bullet 'overwrite `/etc/libretools.d/chroot.conf`' # libretools/librechroot - bullet 'overwrite `/etc/pacman.d/mirrorlist`' # devtools/arch-nspawn - bullet 'set `CacheDir` in `/etc/pacman.conf`' # devtools/arch-nspawn + bullet 'overwrite `/etc/pacman.d/mirrorlist`' # devtools/chroot-run + bullet 'set `CacheDir` in `/etc/pacman.conf`' # devtools/chroot-run prose 'If a new `pacman.conf` is inserted with the `-C` flag, the change is made after the file is copied in; the `-C` flag doesn'"'"'t stop the change from being effective.' @@ -314,8 +314,8 @@ main() { case $opt in n) CHROOT=$OPTARG;; l) COPY=$OPTARG;; - N) sysd_nspawn_flags+=(--private-network);; - C|M) arch_nspawn_flags+=(-$opt "$OPTARG");; + N) chroot_run_flags+=(-$opt);; + C|M) mkarchroot_flags+=(-$opt "$OPTARG");; A) if ! [[ -f "/usr/share/pacman/defaults/pacman.conf.$OPTARG" && -f "/usr/share/pacman/defaults/makepkg.conf.$OPTARG" ]]; then error 'Unsupported architecture: %s' "$OPTARG" @@ -334,12 +334,12 @@ main() { '\n\n# Enable the volatile arm [aur] repo only as needed.' \ '\n#[aur]\n#Server = https://mirror.archlinuxarm.org/$arch/$repo/' \ >> "$tmppacmanconf" - arch_nspawn_flags+=( + mkarchroot_flags+=( -C "$tmppacmanconf" -M "/usr/share/pacman/defaults/makepkg.conf.$OPTARG" );; - w) sysd_nspawn_flags+=("--bind=$OPTARG");; - r) sysd_nspawn_flags+=("--bind-ro=$OPTARG");; + w) chroot_run_flags+=(-b "-B:$OPTARG:$OPTARG");; + r) chroot_run_flags+=(-b "-Br:$OPTARG:$OPTARG");; *) usage >&2; return $EXIT_INVALIDARGUMENT;; esac used_opts[$opt]+=1 @@ -474,12 +474,12 @@ main() { # - overwrite '/etc/pacman.d/mirrorlist'" # - set 'CacheDir' in \`/etc/pacman.conf'" # - apply -C or -M flags - arch-nspawn "$copydir" true "$copydir/chrootexec" chmod 755 "$copydir/chrootexec" - arch-nspawn "$copydir" /chrootexec