Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@parabola.nu>2017-02-19 16:27:55 -0500
committerLuke Shumaker <lukeshu@parabola.nu>2017-02-19 16:27:55 -0500
commit687b00c814ce84321f7972504d1da574bf4e6e2c (patch)
tree8b3c5627ea957c5c31f03d5312f6737bb63731eb
parent070092d2492c6d21f42d2bb8d47bfd5e4a4ecfa5 (diff)
makechrootpkg: re-indent
-rw-r--r--makechrootpkg.in276
1 files changed, 138 insertions, 138 deletions
diff --git a/makechrootpkg.in b/makechrootpkg.in
index 35a1286..5c2086e 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -15,26 +15,26 @@ m4_include(lib/common.sh)
shopt -s nullglob
init_variables() {
-default_makepkg_args=(-s --noconfirm -L --holdver)
-makepkg_args=("${default_makepkg_args[@]}")
-repack=false
-update_first=false
-clean_first=false
-install_pkg=
-run_namcap=false
-temp_chroot=false
-chrootdir=
-passeddir=
-declare -a install_pkgs
-declare -i ret=0
-
-bindmounts_ro=()
-bindmounts_rw=()
-
-copy=$USER
-[[ -n ${SUDO_USER:-} ]] && copy=$SUDO_USER
-[[ -z "$copy" || $copy = root ]] && copy=copy
-src_owner=${SUDO_USER:-$USER}
+ default_makepkg_args=(-s --noconfirm -L --holdver)
+ makepkg_args=("${default_makepkg_args[@]}")
+ repack=false
+ update_first=false
+ clean_first=false
+ install_pkg=
+ run_namcap=false
+ temp_chroot=false
+ chrootdir=
+ passeddir=
+ declare -a install_pkgs
+ declare -i ret=0
+
+ bindmounts_ro=()
+ bindmounts_rw=()
+
+ copy=$USER
+ [[ -n ${SUDO_USER:-} ]] && copy=$SUDO_USER
+ [[ -z "$copy" || $copy = root ]] && copy=copy
+ src_owner=${SUDO_USER:-$USER}
}
usage() {
@@ -166,27 +166,27 @@ sync_chroot() {
# Detect chrootdir filesystem type
local chroottype=$(stat -f -c %T "$chrootdir")
- # 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 [%s]" "$chrootdir/root"
-
- stat_busy "Synchronizing chroot copy [%s] -> [%s]" "$chrootdir/root" "$copydir"
- if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then
- if [[ -d $copydir ]]; then
- btrfs_subvolume_delete "$copydir" >/dev/null ||
- die "Unable to delete subvolume %s" "$copydir"
- fi
- btrfs subvolume snapshot "$chrootdir/root" "$copydir" >/dev/null ||
- die "Unable to create subvolume %s" "$copydir"
- else
- mkdir -p "$copydir"
- rsync -a --delete -q -W -x "$chrootdir/root/" "$copydir"
+ # 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 [%s]" "$chrootdir/root"
+
+ stat_busy "Synchronizing chroot copy [%s] -> [%s]" "$chrootdir/root" "$copydir"
+ if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then
+ if [[ -d $copydir ]]; then
+ btrfs_subvolume_delete "$copydir" >/dev/null ||
+ die "Unable to delete subvolume %s" "$copydir"
fi
- stat_done
+ btrfs subvolume snapshot "$chrootdir/root" "$copydir" >/dev/null ||
+ die "Unable to create subvolume %s" "$copydir"
+ else
+ mkdir -p "$copydir"
+ rsync -a --delete -q -W -x "$chrootdir/root/" "$copydir"
+ fi
+ stat_done
- # Drop the read lock again
- lock_close 8
+ # Drop the read lock again
+ lock_close 8
# Update mtime
touch "$copydir"
@@ -459,120 +459,120 @@ move_products() {
# }}}
main() {
-init_variables
-
-orig_argv=("$@")
-
-while getopts 'hcur:I:l:nTD:d:' arg; do
- case "$arg" in
- c) clean_first=true ;;
- D) bindmounts_ro+=(--bind-ro="$OPTARG") ;;
- d) bindmounts_rw+=(--bind="$OPTARG") ;;
- u) update_first=true ;;
- r) passeddir="$OPTARG" ;;
- I) install_pkgs+=("$OPTARG") ;;
- l) copy="$OPTARG" ;;
- n) run_namcap=true; makepkg_args+=(-i) ;;
- T) temp_chroot=true; copy+="-$$" ;;
- h|*) usage ;;
- esac
-done
+ init_variables
+
+ orig_argv=("$@")
+
+ while getopts 'hcur:I:l:nTD:d:' arg; do
+ case "$arg" in
+ c) clean_first=true ;;
+ D) bindmounts_ro+=(--bind-ro="$OPTARG") ;;
+ d) bindmounts_rw+=(--bind="$OPTARG") ;;
+ u) update_first=true ;;
+ r) passeddir="$OPTARG" ;;
+ I) install_pkgs+=("$OPTARG") ;;
+ l) copy="$OPTARG" ;;
+ n) run_namcap=true; makepkg_args+=(-i) ;;
+ T) temp_chroot=true; copy+="-$$" ;;
+ h|*) usage ;;
+ esac
+ done
+
+ [[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.'
+
+ check_root "$0" "${orig_argv[@]}"
-[[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.'
+ # Canonicalize chrootdir, getting rid of trailing /
+ chrootdir=$(readlink -e "$passeddir")
+ [[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir"
+ [[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkarchroot %s/root base-devel" "$chrootdir"
-check_root "$0" "${orig_argv[@]}"
+ # Detect chrootdir filesystem type
+ chroottype=$(stat -f -c %T "$chrootdir")
+
+ if [[ ${copy:0:1} = / ]]; then
+ copydir=$copy
+ else
+ copydir="$chrootdir/$copy"
+ fi
-# Canonicalize chrootdir, getting rid of trailing /
-chrootdir=$(readlink -e "$passeddir")
-[[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir"
-[[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkarchroot %s/root base-devel" "$chrootdir"
+ # Pass all arguments after -- right to makepkg
+ makepkg_args+=("${@:$OPTIND}")
+
+ # See if -R was passed to makepkg
+ for arg in "${@:OPTIND}"; do
+ case ${arg%%=*} in
+ -*R*|--repackage)
+ repack=true
+ break 2
+ ;;
+ esac
+ done
-# Detect chrootdir filesystem type
-chroottype=$(stat -f -c %T "$chrootdir")
+ if [[ -n $SUDO_USER ]]; then
+ eval "USER_HOME=~$SUDO_USER"
+ else
+ USER_HOME=$HOME
+ fi
-if [[ ${copy:0:1} = / ]]; then
- copydir=$copy
-else
- copydir="$chrootdir/$copy"
-fi
+ umask 0022
-# Pass all arguments after -- right to makepkg
-makepkg_args+=("${@:$OPTIND}")
+ load_vars "$USER_HOME/.makepkg.conf"
+ load_vars /etc/makepkg.conf
-# See if -R was passed to makepkg
-for arg in "${@:OPTIND}"; do
- case ${arg%%=*} in
- -*R*|--repackage)
- repack=true
- break 2
- ;;
- esac
-done
+ # Use PKGBUILD directory if these don't exist
+ [[ -d $PKGDEST ]] || PKGDEST=$PWD
+ [[ -d $SRCDEST ]] || SRCDEST=$PWD
+ [[ -d $SRCPKGDEST ]] || SRCPKGDEST=$PWD
+ [[ -d $LOGDEST ]] || LOGDEST=$PWD
-if [[ -n $SUDO_USER ]]; then
- eval "USER_HOME=~$SUDO_USER"
-else
- USER_HOME=$HOME
-fi
+ # Lock the chroot we want to use. We'll keep this lock until we exit.
+ lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy"
-umask 0022
+ if [[ ! -d $copydir ]] || $clean_first; then
+ sync_chroot "$chrootdir" "$copy"
+ fi
-load_vars "$USER_HOME/.makepkg.conf"
-load_vars /etc/makepkg.conf
+ $update_first && arch-nspawn "$copydir" \
+ "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
+ pacman -Syu --noconfirm
-# Use PKGBUILD directory if these don't exist
-[[ -d $PKGDEST ]] || PKGDEST=$PWD
-[[ -d $SRCDEST ]] || SRCDEST=$PWD
-[[ -d $SRCPKGDEST ]] || SRCPKGDEST=$PWD
-[[ -d $LOGDEST ]] || LOGDEST=$PWD
+ if [[ -n ${install_pkgs[*]:-} ]]; then
+ install_packages "$copydir" "${install_pkgs[@]}"
+ ret=$?
+ # If there is no PKGBUILD we have done
+ [[ -f PKGBUILD ]] || exit $ret
+ fi
-# Lock the chroot we want to use. We'll keep this lock until we exit.
-lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy"
+ download_sources "$copydir" "$src_owner"
-if [[ ! -d $copydir ]] || $clean_first; then
- sync_chroot "$chrootdir" "$copy"
-fi
+ prepare_chroot "$copydir" "$USER_HOME" "$repack"
-$update_first && arch-nspawn "$copydir" \
+ if arch-nspawn "$copydir" \
+ --bind-ro="$PWD:/startdir_host" \
+ --bind-ro="$SRCDEST:/srcdest_host" \
+ "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
+ /chrootprepare "${makepkg_args[@]}" &&
+ arch-nspawn "$copydir" \
+ --bind-ro="$PWD:/startdir_host" \
+ --bind-ro="$SRCDEST:/srcdest_host" \
"${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
- pacman -Syu --noconfirm
-
-if [[ -n ${install_pkgs[*]:-} ]]; then
- install_packages "$copydir" "${install_pkgs[@]}"
- ret=$?
- # If there is no PKGBUILD we have done
- [[ -f PKGBUILD ]] || exit $ret
-fi
-
-download_sources "$copydir" "$src_owner"
-
-prepare_chroot "$copydir" "$USER_HOME" "$repack"
-
-if arch-nspawn "$copydir" \
- --bind-ro="$PWD:/startdir_host" \
- --bind-ro="$SRCDEST:/srcdest_host" \
- "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
- /chrootprepare "${makepkg_args[@]}" &&
- arch-nspawn "$copydir" \
- --bind-ro="$PWD:/startdir_host" \
- --bind-ro="$SRCDEST:/srcdest_host" \
- "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
- /chrootbuild "${makepkg_args[@]}"
-then
- move_products "$copydir" "$src_owner"
-else
- (( ret += 1 ))
-fi
-
-$temp_chroot && delete_chroot "$copydir"
-
-if (( ret != 0 )); then
- if $temp_chroot; then
- die "Build failed"
+ /chrootbuild "${makepkg_args[@]}"
+ then
+ move_products "$copydir" "$src_owner"
+ else
+ (( ret += 1 ))
+ fi
+
+ $temp_chroot && delete_chroot "$copydir"
+
+ if (( ret != 0 )); then
+ if $temp_chroot; then
+ die "Build failed"
+ else
+ die "Build failed, check %s/build" "$copydir"
+ fi
else
- die "Build failed, check %s/build" "$copydir"
+ true
fi
-else
- true
-fi
}