summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/chroot-tools/librechroot22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
index a688b85..cb74f98 100755
--- a/src/chroot-tools/librechroot
+++ b/src/chroot-tools/librechroot
@@ -190,10 +190,13 @@ usage() {
by the by `CARCH` variable in the `/etc/makepkg.conf`
file inside of the chroot.'
echo
- prose 'In line with this, The `-A CARCH` flag is simply an alias for'
+ prose 'The `-A CARCH` flag is *almost* simply an alias for'
printf ' %s\n' \
'-C "/usr/share/pacman/defaults/pacman.conf.$CARCH" \' \
'-M "/usr/share/pacman/defaults/makepkg.conf.$CARCH"'
+ prose 'However, before doing that, it actually makes a temporary copy of
+ `pacman.conf`, and sets the `Architecture` line to match the
+ `CARCH` line in `makepkg.conf`.'
echo
prose 'Creating a copy, deleting a copy, or syncing a copy can be fairly
slow; but are very fast if $CHROOTDIR is on a btrfs partition.'
@@ -247,10 +250,14 @@ main() {
l) COPY=$OPTARG;;
N) sysd_nspawn_flags+=(--private-network);;
C|M) arch_nspawn_flags+=(-$opt "$OPTARG");;
- A) arch_nspawn_flags+=(
- -C "/usr/share/pacman/defaults/pacman.conf.$OPTARG"
- -M "/usr/share/pacman/defaults/makepkg.conf.$OPTARG"
- );;
+ A)
+ trap 'rm -f -- "$tmppacmanconf"' EXIT
+ tmppacmanconf="$(mktemp --tmpdir librechroot-pacman.conf.XXXXXXXXXX)"
+ < "/usr/share/pacman/defaults/pacman.conf.$OPTARG" sed -r "s|^#?\\s*Architecture.+|Architecture = ${OPTARG}|g" > "$tmppacmanconf"
+ arch_nspawn_flags+=(
+ -C "$tmppacmanconf"
+ -M "/usr/share/pacman/defaults/makepkg.conf.$OPTARG"
+ );;
w) sysd_nspawn_flags+=("--bind=$OPTARG");;
r) sysd_nspawn_flags+=("--bind-ro=$OPTARG");;
*) usage >&2; return 1;;
@@ -382,10 +389,11 @@ main() {
if [[ $mode != delete ]]; then
# "touch" the chroot first
# this will
- # - overwrite \`/etc/pacman.d/mirrorlist'"
- # - set \`CacheDir' in \`/etc/pacman.conf'"
+ # - overwrite '/etc/pacman.d/mirrorlist'"
+ # - set 'CacheDir' in \`/etc/pacman.conf'"
# - apply -C or -M flags
arch-nspawn "$copydir" true
+ 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
fi