summaryrefslogtreecommitdiff
path: root/src/chroot-tools/makechrootpkg.sh.patch
diff options
context:
space:
mode:
Diffstat (limited to 'src/chroot-tools/makechrootpkg.sh.patch')
-rw-r--r--src/chroot-tools/makechrootpkg.sh.patch143
1 files changed, 76 insertions, 67 deletions
diff --git a/src/chroot-tools/makechrootpkg.sh.patch b/src/chroot-tools/makechrootpkg.sh.patch
index 4dd1146..8180d89 100644
--- a/src/chroot-tools/makechrootpkg.sh.patch
+++ b/src/chroot-tools/makechrootpkg.sh.patch
@@ -1,14 +1,21 @@
---- makechrootpkg.sh.in 2013-10-26 14:53:57.000000000 -0400
-+++ makechrootpkg.sh.ugly 2013-11-16 15:14:04.000000000 -0500
-@@ -12,6 +12,7 @@
+--- makechrootpkg.sh.in 2014-05-10 22:03:27.956692573 -0400
++++ makechrootpkg.sh.ugly 2014-05-10 22:09:15.376594518 -0400
+@@ -1,4 +1,6 @@
+ #!/bin/bash
++# License: GNU GPLv2
++#
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; version 2 of the License.
+@@ -12,6 +14,7 @@
shopt -s nullglob
+init_variables() {
- _makepkg_args=(-s --noconfirm -L --holdver)
- makepkg_args=("${_makepkg_args[@]}")
+ default_makepkg_args=(-s --noconfirm -L --holdver)
+ makepkg_args=("${default_makepkg_args[@]}")
repack=false
-@@ -29,9 +30,10 @@
+@@ -29,9 +32,10 @@
bindmounts_rw=()
copy=$USER
@@ -20,7 +27,7 @@
usage() {
echo "Usage: ${0##*/} [options] -r <chrootdir> [--] [makepkg args]"
-@@ -67,6 +69,7 @@
+@@ -67,6 +71,7 @@
exit 1
}
@@ -28,7 +35,7 @@
while getopts 'hcur:I:l:nTD:d:' arg; do
case "$arg" in
h) usage ;;
-@@ -93,9 +96,6 @@
+@@ -91,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 +45,9 @@
if [[ ${copy:0:1} = / ]]; then
copydir=$copy
else
-@@ -110,30 +110,47 @@
- repack=true
- fi
+@@ -113,30 +115,48 @@
+ esac
+ done
-if [[ -n $SUDO_USER ]]; then
+if [[ -n ${SUDO_USER:-} ]]; then
@@ -54,8 +61,9 @@
+# Usage: load_vars $makepkg_conf
+# Globals:
+# - SRCDEST
-+# - LOGDEST
++# - SRCPKGDEST
+# - PKGDEST
++# - LOGDEST
+# - MAKEFLAGS
+# - PACKAGER
load_vars() {
@@ -63,7 +71,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,11 +100,14 @@
# 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"
-@@ -154,11 +171,16 @@
+@@ -157,14 +177,19 @@
# Drop the read lock again
lock_close 8
- fi
+
+ # Update mtime
+ touch "$copydir"
}
-clean_temporary() {
@@ -109,10 +120,10 @@
+ local chroottype=$(stat -f -c %T "$copydir")
+
+ stat_busy "Removing chroot copy [%s]" "$copy"
- if [[ "$chroottype" == btrfs ]]; then
+ if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then
btrfs subvolume delete "$copydir" >/dev/null ||
die "Unable to delete subvolume %s" "$copydir"
-@@ -173,9 +195,14 @@
+@@ -179,9 +204,14 @@
stat_done
}
@@ -127,7 +138,7 @@
for install_pkg in "${install_pkgs[@]}"; do
pkgname="${install_pkg##*/}"
cp "$install_pkg" "$copydir/$pkgname"
-@@ -188,11 +215,19 @@
+@@ -194,11 +224,19 @@
rm "$copydir/$pkgname"
done
@@ -149,9 +160,9 @@
$repack || rm -rf "$copydir/build"
mkdir -p "$copydir/build"
-@@ -226,12 +261,12 @@
+@@ -237,12 +275,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
@@ -164,7 +175,7 @@
sed -i '/^PACKAGER=/d' "$copydir/etc/makepkg.conf"
echo "PACKAGER='${PACKAGER}'" >> "$copydir/etc/makepkg.conf"
fi
-@@ -244,20 +279,38 @@
+@@ -255,20 +293,38 @@
chmod 440 "$copydir/etc/sudoers.d/nobody-pacman"
fi
@@ -174,16 +185,15 @@
+SigLevel = Optional TrustAll
+Server = file:///repo
+'
-+ sed -i "${line}i${ins//$'\n'/\n}" "$copydir/etc/pacman.conf"
++ 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_chrootbuild %q "$@"' "$(declare -f _chrootbuild)" \
-+ printf '#!/bin/bash\n%s\n_chrootprepare "$@"' "$(declare -f _chrootprepare)" \
++ 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)" \
+ printf $'#!/bin/bash\n%s\n_chrootbuild %q "$@"' "$(declare -f _chrootbuild)" \
"$run_namcap" >"$copydir/chrootbuild"
chmod +x "$copydir/chrootbuild"
}
@@ -206,7 +216,7 @@
makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o
else
( export SRCDEST BUILDDIR="$builddir"
-@@ -267,20 +320,15 @@
+@@ -278,10 +334,10 @@
(( $? != 0 )) && die "Could not download sources."
# Clean up garbage from verifysource
@@ -218,31 +228,28 @@
+_chrootprepare() {
# 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
+ local run_namcap="$1"; shift
+@@ -292,6 +348,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/*
-@@ -295,15 +343,27 @@
- done
- done
+@@ -317,11 +374,29 @@
-- cd /startdir
--
- # XXX: Keep PKGBUILD writable for pkgver()
-- rm PKGBUILD*
-- cp /startdir_host/PKGBUILD* .
-- chown nobody PKGBUILD*
-+ rm /startdir/PKGBUILD*
-+ cp /startdir_host/PKGBUILD* /startdir
-+ chown nobody /startdir/PKGBUILD*
+ # Safety check
+ if [[ ! -w PKGBUILD ]]; then
++ # XXX: internationalize this message
+ echo "Can't write to PKGBUILD!"
+ exit 1
+ fi
+
+- 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() {
@@ -256,14 +263,12 @@
+ shopt -s nullglob
+
+ cd /startdir
++
++ sudo -u nobody makepkg "${makepkg_args[@]}" -e || exit 1
- # Safety check
- if [[ ! -w PKGBUILD ]]; then
-+ # XXX: internationalize this message
- echo "Can't write to PKGBUILD!"
- exit 1
- fi
-@@ -321,12 +381,24 @@
+ if $run_namcap; then
+ pacman -S --needed --noconfirm namcap
+@@ -334,12 +409,24 @@
exit 0
}
@@ -286,9 +291,9 @@
+ local l
for l in "$copydir"/logdest/*; do
+ [[ $l == */logpipe.* ]] && continue
chown "$src_owner" "$l"
- mv "$l" "$LOGDEST"
-@@ -334,6 +406,10 @@
+@@ -353,6 +440,10 @@
}
# }}}
@@ -298,26 +303,24 @@
+
umask 0022
- load_vars /etc/makepkg.conf
-@@ -344,17 +420,25 @@
- [[ -d $SRCDEST ]] || SRCDEST=$PWD
- [[ -d $LOGDEST ]] || LOGDEST=$PWD
+ load_vars "$USER_HOME/.makepkg.conf"
+@@ -364,30 +455,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.
+lock 9 "$copydir.lock" "Locking chroot copy [%s]" "$copy"
-
--$update_first && arch-nspawn "$copydir" \
-- "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
-- pacman -Syu --noconfirm
++
+if [[ ! -d $copydir ]] || $clean_first; then
+ sync_chroot "$chrootdir" "$copy"
+fi
--[[ -n ${install_pkgs[*]} ]] && install_packages
-+$update_first && arch-nspawn "$copydir" pacman -Syu --noconfirm
+ $update_first && arch-nspawn "$copydir" \
+ "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
+ pacman -Syu --noconfirm
--prepare_chroot
+-[[ -n ${install_pkgs[*]} ]] && install_packages
+if [[ -n ${install_pkgs[*]:-} ]]; then
+ install_packages "$copydir" "${install_pkgs[@]}"
+ ret=$?
@@ -325,15 +328,21 @@
+ [[ -f PKGBUILD ]] || exit $ret
+fi
--download_sources
+-prepare_chroot
+prepare_chroot "$copydir" "$USER_HOME" "$repack"
-+
+
+-download_sources
+download_sources "$copydir" "$src_owner"
if arch-nspawn "$copydir" \
--bind-ro="$PWD:/startdir_host" \
-@@ -362,12 +446,12 @@
+ --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
@@ -347,7 +356,7 @@
if (( ret != 0 )); then
if $temp_chroot; then
-@@ -378,3 +462,4 @@
+@@ -398,3 +504,4 @@
else
true
fi