Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/makechrootpkg.in
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2019-02-13 02:45:36 -0500
committerLevente Polyak <anthraxx@archlinux.org>2019-08-09 19:41:52 +0200
commit8dbf95cdd4858cccf43f7f176b44a0c1121df07b (patch)
treecf628e82185c525d381be8caceea20b593f7d087 /makechrootpkg.in
parent46d614d91a90a60839280060f736dc3be8445502 (diff)
makechrootpkg: check truthiness using shell arithmetic
Using the literal strings "true" and "false" is inaccurate and may result in uncertainty of whether it is set when doing string comparison, or simply rely on the shell implementation of treating the string as a command builtin, then executing the value as a shell command. Emulate makepkg, which makes heavy use of shell arithmetic for this purpose. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
Diffstat (limited to 'makechrootpkg.in')
-rw-r--r--makechrootpkg.in37
1 files changed, 19 insertions, 18 deletions
diff --git a/makechrootpkg.in b/makechrootpkg.in
index 0d24ac2..d9369d4 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -17,17 +17,18 @@ shopt -s nullglob
default_makepkg_args=(--syncdeps --noconfirm --log --holdver --skipinteg)
makepkg_args=("${default_makepkg_args[@]}")
-keepbuilddir=false
-update_first=false
-clean_first=false
-run_namcap=false
-temp_chroot=false
chrootdir=
passeddir=
makepkg_user=
declare -a install_pkgs
declare -i ret=0
+keepbuilddir=0
+update_first=0
+clean_first=0
+run_namcap=0
+temp_chroot=0
+
bindmounts_ro=()
bindmounts_rw=()
@@ -167,7 +168,7 @@ install_packages() {
}
prepare_chroot() {
- [[ $keepbuilddir = true ]] || rm -rf "$copydir/build"
+ (( keepbuilddir )) || rm -rf "$copydir/build"
local builduser_uid builduser_gid
builduser_uid="${SUDO_UID:-$UID}"
@@ -206,7 +207,7 @@ EOF
declare -p SOURCE_DATE_EPOCH 2>/dev/null || true
printf '_chrootbuild "$@" || exit\n'
- if [[ $run_namcap = true ]]; then
+ if (( run_namcap )); then
declare -f _chrootnamcap
printf '_chrootnamcap || exit\n'
fi
@@ -289,15 +290,15 @@ move_products() {
while getopts 'hcur:I:l:nTD:d:U:' arg; do
case "$arg" in
- c) clean_first=true ;;
+ c) clean_first=1 ;;
D) bindmounts_ro+=("--bind-ro=$OPTARG") ;;
d) bindmounts_rw+=("--bind=$OPTARG") ;;
- u) update_first=true ;;
+ u) update_first=1 ;;
r) passeddir="$OPTARG" ;;
I) install_pkgs+=("$OPTARG") ;;
l) copy="$OPTARG" ;;
- n) run_namcap=true; makepkg_args+=(--install) ;;
- T) temp_chroot=true; copy+="-$$" ;;
+ n) run_namcap=1; makepkg_args+=(--install) ;;
+ T) temp_chroot=1; copy+="-$$" ;;
U) makepkg_user="$OPTARG" ;;
h|*) usage ;;
esac
@@ -326,10 +327,10 @@ makepkg_args+=("${@:$OPTIND}")
# See if -R or -e was passed to makepkg
for arg in "${makepkg_args[@]}"; do
case ${arg%%=*} in
- --repackage|--noextract) keepbuilddir=true; break ;;
- --repackage|--noextract) keepbuilddir=true; break ;;
+ --repackage|--noextract) keepbuilddir=1; break ;;
+ --repackage|--noextract) keepbuilddir=1; break ;;
--*) ;;
- -*R*|-*e*) keepbuilddir=true; break ;;
+ -*R*|-*e*) keepbuilddir=1; break ;;
esac
done
@@ -353,11 +354,11 @@ load_vars /etc/makepkg.conf
# Lock the chroot we want to use. We'll keep this lock until we exit.
lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy"
-if [[ ! -d $copydir ]] || $clean_first; then
+if [[ ! -d $copydir ]] || (( clean_first )); then
sync_chroot "$chrootdir" "$copydir" "$copy"
fi
-$update_first && arch-nspawn "$copydir" \
+(( update_first )) && arch-nspawn "$copydir" \
"${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
pacman -Syu --noconfirm
@@ -388,10 +389,10 @@ else
(( ret += 1 ))
fi
-$temp_chroot && delete_chroot "$copydir" "$copy"
+(( temp_chroot )) && delete_chroot "$copydir" "$copy"
if (( ret != 0 )); then
- if $temp_chroot; then
+ if (( temp_chroot )); then
die "Build failed"
else
die "Build failed, check %s/build" "$copydir"