Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/makechrootpkg.in
diff options
context:
space:
mode:
Diffstat (limited to 'makechrootpkg.in')
-rw-r--r--makechrootpkg.in34
1 files changed, 18 insertions, 16 deletions
diff --git a/makechrootpkg.in b/makechrootpkg.in
index d03b703..052ab71 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -12,7 +12,8 @@ m4_include(lib/common.sh)
shopt -s nullglob
-makepkg_args='-s --noconfirm -L --holdver'
+_makepkg_args=(-s --noconfirm -L --holdver)
+makepkg_args=("${_makepkg_args[@]}")
repack=false
update_first=false
clean_first=false
@@ -46,7 +47,7 @@ usage() {
echo 'command:'
echo ' mkarchroot <chrootdir>/root base-devel'
echo ''
- echo "Default makepkg args: $makepkg_args"
+ echo "Default makepkg args: ${_makepkg_args[*]}"
echo ''
echo 'Flags:'
echo '-h This help'
@@ -76,11 +77,12 @@ while getopts 'hcur:I:l:nTD:d:' arg; do
r) passeddir="$OPTARG" ;;
I) install_pkgs+=("$OPTARG") ;;
l) copy="$OPTARG" ;;
- n) run_namcap=true; makepkg_args="$makepkg_args -i" ;;
+ n) run_namcap=true; makepkg_args+=('-i') ;;
T) temp_chroot=true; copy+="-$$" ;;
- *) makepkg_args="$makepkg_args -$arg $OPTARG" ;;
+ *) usage >&2 ;;
esac
done
+shift $(($OPTIND - 1))
(( EUID != 0 )) && die 'This script must be run as root.'
@@ -101,7 +103,7 @@ else
fi
# Pass all arguments after -- right to makepkg
-makepkg_args="$makepkg_args ${*:$OPTIND}"
+makepkg_args+=("$@")
# See if -R was passed to makepkg
for arg in "${@:OPTIND}"; do
@@ -134,14 +136,14 @@ load_vars() {
create_chroot() {
# Lock the chroot we want to use. We'll keep this lock until we exit.
- lock 9 "$copydir.lock" "Locking chroot copy [$copy]"
+ lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy"
if [[ ! -d $copydir ]] || $clean_first; then
# Get a read lock on the root chroot to make
# sure we don't clone a half-updated chroot
slock 8 "$chrootdir/root.lock" "Locking clean chroot"
- stat_busy "Creating clean working copy [$copy]"
+ stat_busy "Creating clean working copy [%s]" "$copy"
if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then
if [[ -d $copydir ]]; then
btrfs subvolume delete "$copydir" >/dev/null ||
@@ -156,12 +158,12 @@ create_chroot() {
stat_done
# Drop the read lock again
- exec 8>&-
+ lock_close 8
fi
}
clean_temporary() {
- stat_busy "Removing temporary copy [$copy]"
+ stat_busy "Removing temporary copy [%s]" "$copy"
if [[ "$chroottype" == btrfs ]]; then
btrfs subvolume delete "$copydir" >/dev/null ||
die "Unable to delete subvolume %s" "$copydir"
@@ -254,8 +256,8 @@ EOF
# This is a little gross, but this way the script is recreated every time in the
# working copy
- printf $'#!/bin/bash\n%s\n_chrootbuild %q %q' "$(declare -f _chrootbuild)" \
- "$makepkg_args" "$run_namcap" >"$copydir/chrootbuild"
+ printf $'#!/bin/bash\n%s\n_chrootbuild %q "$@"' "$(declare -f _chrootbuild)" \
+ "$run_namcap" >"$copydir/chrootbuild"
chmod +x "$copydir/chrootbuild"
}
@@ -281,8 +283,8 @@ download_sources() {
_chrootbuild() {
# This function isn't run in makechrootpkg,
# so no global variables
- local makepkg_args="$1"
- local run_namcap="$2"
+ local run_namcap="$1"; shift
+ local makepkg_args=("$@")
. /etc/profile
export HOME=/build
@@ -318,7 +320,7 @@ _chrootbuild() {
exit 1
fi
- sudo -u nobody makepkg $makepkg_args || exit 1
+ sudo -u nobody makepkg "${makepkg_args[@]}" || exit 1
if $run_namcap; then
pacman -S --needed --noconfirm namcap
@@ -352,8 +354,8 @@ move_products() {
umask 0022
-load_vars "$USER_HOME/.makepkg.conf"
load_vars /etc/makepkg.conf
+load_vars "$USER_HOME/.makepkg.conf"
# Use PKGBUILD directory if these don't exist
[[ -d $PKGDEST ]] || PKGDEST=$PWD
@@ -377,7 +379,7 @@ if arch-nspawn "$copydir" \
--bind-ro="$PWD:/startdir_host" \
--bind-ro="$SRCDEST:/srcdest_host" \
"${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
- /chrootbuild
+ /chrootbuild "${makepkg_args[@]}"
then
move_products
else