diff options
Diffstat (limited to 'src/chroot-tools/makechrootpkg.sh.patch')
-rw-r--r-- | src/chroot-tools/makechrootpkg.sh.patch | 120 |
1 files changed, 85 insertions, 35 deletions
diff --git a/src/chroot-tools/makechrootpkg.sh.patch b/src/chroot-tools/makechrootpkg.sh.patch index f5b8ed7..540e6ba 100644 --- a/src/chroot-tools/makechrootpkg.sh.patch +++ b/src/chroot-tools/makechrootpkg.sh.patch @@ -1,5 +1,5 @@ ---- makechrootpkg.sh.in 2013-09-08 23:01:20.000000000 -0400 -+++ makechrootpkg.sh.ugly 2013-09-09 15:43:06.000000000 -0400 +--- makechrootpkg.sh.in 2014-01-05 18:51:41.463720929 -0500 ++++ makechrootpkg.sh.ugly 2014-02-09 20:20:25.021630727 -0500 @@ -12,6 +12,7 @@ shopt -s nullglob @@ -8,8 +8,8 @@ _makepkg_args=(-s --noconfirm -L --holdver) makepkg_args=("${_makepkg_args[@]}") repack=false -@@ -26,9 +27,10 @@ - declare -i ret=0 +@@ -29,9 +30,10 @@ + bindmounts_rw=() copy=$USER -[[ -n $SUDO_USER ]] && copy=$SUDO_USER @@ -20,15 +20,15 @@ usage() { echo "Usage: ${0##*/} [options] -r <chrootdir> [--] [makepkg args]" -@@ -62,6 +64,7 @@ +@@ -67,6 +69,7 @@ exit 1 } +parse_options_init() { - while getopts 'hcur:I:l:nT' arg; do + while getopts 'hcur:I:l:nTD:d:' arg; do case "$arg" in h) usage ;; -@@ -86,9 +89,6 @@ +@@ -93,9 +96,6 @@ [[ ! -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" @@ -38,9 +38,9 @@ if [[ ${copy:0:1} = / ]]; then copydir=$copy else -@@ -103,30 +103,47 @@ - repack=true - fi +@@ -115,30 +115,48 @@ + esac + done -if [[ -n $SUDO_USER ]]; then +if [[ -n ${SUDO_USER:-} ]]; then @@ -54,8 +54,9 @@ +# Usage: load_vars $makepkg_conf +# Globals: +# - SRCDEST -+# - LOGDEST ++# - SRCPKGDEST +# - PKGDEST ++# - LOGDEST +# - MAKEFLAGS +# - PACKAGER load_vars() { @@ -63,7 +64,7 @@ [[ -f $makepkg_conf ]] || return 1 - for var in {SRC,PKG,LOG}DEST MAKEFLAGS PACKAGER; do + for var in {SRC,SRCPKG,PKG,LOG}DEST MAKEFLAGS PACKAGER; do - [[ -z ${!var} ]] && eval $(grep "^${var}=" "$makepkg_conf") + [[ -z ${!var:-} ]] && eval $(grep "^${var}=" "$makepkg_conf") done @@ -92,7 +93,7 @@ # 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" -@@ -147,10 +164,15 @@ +@@ -159,11 +177,16 @@ # Drop the read lock again lock_close 8 @@ -100,6 +101,7 @@ } -clean_temporary() { +- stat_busy "Removing temporary copy [%s]" "$copy" +# Usage: delete_chroot $copydir [$copy] +delete_chroot() { + local copydir=$1 @@ -107,10 +109,11 @@ + # Detect chrootdir filesystem type + local chroottype=$(stat -f -c %T "$copydir") + - stat_busy "Removing temporary copy [%s]" "$copy" - if [[ "$chroottype" == btrfs ]]; then ++ stat_busy "Removing chroot copy [%s]" "$copy" + if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then btrfs subvolume delete "$copydir" >/dev/null || -@@ -166,9 +188,14 @@ + die "Unable to delete subvolume %s" "$copydir" +@@ -178,9 +201,14 @@ stat_done } @@ -125,7 +128,7 @@ for install_pkg in "${install_pkgs[@]}"; do pkgname="${install_pkg##*/}" cp "$install_pkg" "$copydir/$pkgname" -@@ -179,11 +206,19 @@ +@@ -193,11 +221,19 @@ rm "$copydir/$pkgname" done @@ -147,9 +150,9 @@ $repack || rm -rf "$copydir/build" mkdir -p "$copydir/build" -@@ -217,12 +252,12 @@ +@@ -236,12 +272,12 @@ - chown -R nobody "$copydir"/{build,pkgdest,logdest,srcdest,startdir} + chown -R nobody "$copydir"/{build,pkgdest,srcpkgdest,logdest,srcdest,startdir} - if [[ -n $MAKEFLAGS ]]; then + if [[ -n ${MAKEFLAGS:-} ]]; then @@ -162,22 +165,26 @@ sed -i '/^PACKAGER=/d' "$copydir/etc/makepkg.conf" echo "PACKAGER='${PACKAGER}'" >> "$copydir/etc/makepkg.conf" fi -@@ -235,6 +270,14 @@ +@@ -254,20 +290,38 @@ chmod 440 "$copydir/etc/sudoers.d/nobody-pacman" fi + if ! grep -q '^\[repo\]' "$copydir/etc/pacman.conf"; then -+ cat >> "$copydir/etc/pacman.conf" <<EOF -+[repo] ++ local line=$(grep -n '^\[' "$copydir/etc/pacman.conf" |grep -Fv ':[options]'|sed 's/:.*//;1q') ++ local ins='[repo] +SigLevel = Optional TrustAll +Server = file:///repo -+EOF ++' ++ sed -i "${line}i${ins//$'\n'/\n}" "$copydir/etc/pacman.conf" + fi + # This is a little gross, but this way the script is recreated every time in the # working copy ++ printf $'#!/bin/bash\n%s\n_chrootprepare "$@"' "$(declare -f _chrootprepare)" \ ++ > "$copydir/chrootprepare" ++ chmod +x "$copydir/chrootprepare" printf $'#!/bin/bash\n%s\n_chrootbuild %q "$@"' "$(declare -f _chrootbuild)" \ -@@ -242,13 +285,19 @@ + "$run_namcap" >"$copydir/chrootbuild" chmod +x "$copydir/chrootbuild" } @@ -199,7 +206,7 @@ makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o else ( export SRCDEST BUILDDIR="$builddir" -@@ -258,7 +307,7 @@ +@@ -277,10 +331,10 @@ (( $? != 0 )) && die "Could not download sources." # Clean up garbage from verifysource @@ -207,8 +214,20 @@ + rm -rf "$builddir" } - _chrootbuild() { -@@ -295,6 +344,7 @@ +-_chrootbuild() { ++_chrootprepare() { + # This function isn't run in makechrootpkg, + # so no global variables + local run_namcap="$1"; shift +@@ -291,6 +345,7 @@ + shopt -s nullglob + + # XXX: Workaround makepkg disliking read-only dirs ++ rm -rf -- /srcdest/* /startdir/* + ln -sft /srcdest /srcdest_host/* + ln -sft /startdir /startdir_host/* + +@@ -316,11 +371,29 @@ # Safety check if [[ ! -w PKGBUILD ]]; then @@ -216,7 +235,30 @@ echo "Can't write to PKGBUILD!" exit 1 fi -@@ -312,12 +362,24 @@ + +- sudo -u nobody makepkg "${makepkg_args[@]}" || exit 1 ++ # Sync deps now, as networking may be disabled during _chrootbuild ++ cp /repo/repo.db /var/lib/pacman/sync/repo.db ++ sudo -u nobody makepkg "${makepkg_args[@]}" -o ++} ++ ++_chrootbuild() { ++ # This function isn't run in makechrootpkg, ++ # so no global variables ++ local run_namcap="$1"; shift ++ local makepkg_args=("$@") ++ ++ . /etc/profile ++ export HOME=/build ++ shopt -s nullglob ++ ++ cd /startdir ++ ++ sudo -u nobody makepkg "${makepkg_args[@]}" -e || exit 1 + + if $run_namcap; then + pacman -S --needed --noconfirm namcap +@@ -333,12 +406,24 @@ exit 0 } @@ -239,9 +281,9 @@ + local l for l in "$copydir"/logdest/*; do + [[ $l == */logpipe.* ]] && continue chown "$src_owner" "$l" - mv "$l" "$LOGDEST" -@@ -325,6 +387,10 @@ +@@ -352,6 +437,10 @@ } # }}} @@ -252,9 +294,9 @@ umask 0022 load_vars /etc/makepkg.conf -@@ -335,27 +401,37 @@ - [[ -d $SRCDEST ]] || SRCDEST=$PWD - [[ -d $LOGDEST ]] || LOGDEST=$PWD +@@ -363,30 +452,45 @@ + [[ -d $SRCPKGDEST ]] || SRCPKGDEST=$PWD + [[ -d $LOGDEST ]] || LOGDEST=$PWD -create_chroot +# Lock the chroot we want to use. We'll keep this lock until we exit. @@ -264,7 +306,9 @@ + sync_chroot "$chrootdir" "$copy" +fi - $update_first && arch-nspawn "$copydir" pacman -Syu --noconfirm + $update_first && arch-nspawn "$copydir" \ + "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ + pacman -Syu --noconfirm -[[ -n ${install_pkgs[*]} ]] && install_packages +if [[ -n ${install_pkgs[*]:-} ]]; then @@ -283,6 +327,12 @@ if arch-nspawn "$copydir" \ --bind-ro="$PWD:/startdir_host" \ --bind-ro="$SRCDEST:/srcdest_host" \ + "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ ++ /chrootprepare && ++ arch-nspawn "$copydir" \ ++ --bind-ro="$PWD:/startdir_host" \ ++ --bind-ro="$SRCDEST:/srcdest_host" \ ++ "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ /chrootbuild "${makepkg_args[@]}" then - move_products @@ -296,7 +346,7 @@ if (( ret != 0 )); then if $temp_chroot; then -@@ -366,3 +442,4 @@ +@@ -397,3 +501,4 @@ else true fi |