summaryrefslogtreecommitdiff
path: root/src/chroot-tools/librechroot
diff options
context:
space:
mode:
Diffstat (limited to 'src/chroot-tools/librechroot')
-rwxr-xr-xsrc/chroot-tools/librechroot64
1 files changed, 32 insertions, 32 deletions
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 </dev/null
+ chroot-run "$copydir" true </dev/null
if [[ -n ${tmppacmanconf:-} ]]; then
rm -f -- "$tmppacmanconf"
fi
trap EXIT # clear the trap to remove the tmp pacman.conf from -A
- arch_nspawn_flags=() # XXX dirty hack, don't apply -C or -M again
+ mkarchroot_flags=() # XXX dirty hack, don't apply -C or -M again
fi
########################################################################
@@ -499,10 +499,10 @@ main() {
chroot_add_to_local_repo "$copydir" "$@"
;;
install-name)
- arch-nspawn "$copydir" pacman -Sy --noconfirm -- "$@" </dev/null
+ chroot-run "$copydir" pacman -Sy --noconfirm -- "$@" </dev/null
;;
update)
- arch-nspawn "$copydir" pacman -Syu --noconfirm </dev/null
+ chroot-run "$copydir" pacman -Syu --noconfirm </dev/null
;;
clean-pkgs)
trap "rm -f -- ${copydir@Q}/{chcleanup,chrootexec}" EXIT
@@ -514,15 +514,15 @@ main() {
'/chcleanup' \
> "$copydir/chrootexec"
chmod 755 "$copydir/chrootexec"
- arch-nspawn "$copydir" /chrootexec </dev/null
+ chroot-run "$copydir" /chrootexec </dev/null
;;
# Other
run)
- arch-nspawn "$copydir" "$@"
+ chroot-run "$copydir" "$@"
;;
enter)
- arch-nspawn "$copydir" bash
+ chroot-run "$copydir" bash
;;
clean-repo)
rm -rf "${copydir}"/repo/*