summaryrefslogtreecommitdiff
path: root/src/chroot-tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/chroot-tools')
-rw-r--r--src/chroot-tools/hooks-chcleanup.sh3
-rwxr-xr-xsrc/chroot-tools/libremakepkg32
-rw-r--r--src/chroot-tools/makechrootpkg.sh.patch68
3 files changed, 76 insertions, 27 deletions
diff --git a/src/chroot-tools/hooks-chcleanup.sh b/src/chroot-tools/hooks-chcleanup.sh
index 6a95dfb..cd6179b 100644
--- a/src/chroot-tools/hooks-chcleanup.sh
+++ b/src/chroot-tools/hooks-chcleanup.sh
@@ -9,7 +9,6 @@ clean_chroot() (
cd /build
sudo -u nobody "$(librelib chroot/chcleanup)"
else
- librechroot -l "$copydir" clean-pkgs
+ librechroot "${librechroot_flags[@]}" clean-pkgs
fi
- r=$?; echo clean_chroot returning $r; return $r
)
diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg
index 45f57ea..5494202 100755
--- a/src/chroot-tools/libremakepkg
+++ b/src/chroot-tools/libremakepkg
@@ -33,6 +33,7 @@ NONET=true # can be changed with the -N flag
# {SRC,LOG,PKG}DEST set at runtime by makepkg.conf
# MAKEFLAGS, PACKAGER set at runtime by makepkg.conf
# LIBREUSER, LIBREHOME are set by conf.sh
+librechroot_flags=()
# Hooks ########################################################################
@@ -89,23 +90,21 @@ add_to_local_repo() {
build() (
local copydir=$1; shift
- local cmd=(/chrootbuild "$@")
-
- run_hook pre_build "$copydir"
- trap "run_hook post_build '$copydir'" EXIT
local netflag=''
+ local run=()
if $INCHROOT; then
- ! $NONET || netflag='-n'
- unshare $netflag -- "${cmd[@]}"
- else
! $NONET || netflag='-N'
- librechroot $netflag \
- -r "$PWD:/startdir_host" \
- -r "$SRCDEST:/srcdest_host" \
- -l "$copydir" \
- run "${cmd[@]}"
+ run=(unshare)
+ else
+ ! $NONET || netflag='-n'
+ run=(librechroot "${librechroot_flags[@]}" run)
fi
+
+ "${run[@]}" /chrootprepare "$@"
+ run_hook pre_build "$copydir"
+ trap "run_hook post_build '$copydir'" EXIT
+ "${run[@]}" /chrootbuild "$@"
)
# The main program #############################################################
@@ -211,6 +210,13 @@ main() {
MAKEFLAGS="$(get_conf_makepkg MAKEFLAGS '')"
PACKAGER="$(get_conf_makepkg PACKAGER '')"
+ librechroot_flags=(
+ -r "$PWD:/startdir_host"
+ -r "$SRCDEST:/srcdest_host"
+ -n "$CHROOT"
+ -l "$copy"
+ )
+
# OK, we are starting now ##############################################
if $INCHROOT; then
@@ -221,7 +227,7 @@ main() {
lock 9 "$copydir.lock" \
"Waiting for existing lock on chroot copy to be released: [%s]" "$copy"
# Create the chroot if it does not exist
- librechroot -n "$CHROOT" -l "$copy" make
+ librechroot "${librechroot_flags[@]}" make
fi
# Set target CARCH
diff --git a/src/chroot-tools/makechrootpkg.sh.patch b/src/chroot-tools/makechrootpkg.sh.patch
index f5b8ed7..275b88a 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 2013-09-12 10:02:36.000000000 -0400
++++ makechrootpkg.sh.ugly 2013-09-14 13:51:51.000000000 -0400
@@ -12,6 +12,7 @@
shopt -s nullglob
@@ -162,7 +162,7 @@
sed -i '/^PACKAGER=/d' "$copydir/etc/makepkg.conf"
echo "PACKAGER='${PACKAGER}'" >> "$copydir/etc/makepkg.conf"
fi
-@@ -235,6 +270,14 @@
+@@ -235,20 +270,37 @@
chmod 440 "$copydir/etc/sudoers.d/nobody-pacman"
fi
@@ -176,8 +176,12 @@
+
# 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)" \
-@@ -242,13 +285,19 @@
+- printf $'#!/bin/bash\n%s\n_chrootbuild %q "$@"' "$(declare -f _chrootbuild)" \
++ 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)" \
+ "$run_namcap" >"$copydir/chrootbuild"
chmod +x "$copydir/chrootbuild"
}
@@ -199,7 +203,7 @@
makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o
else
( export SRCDEST BUILDDIR="$builddir"
-@@ -258,7 +307,7 @@
+@@ -258,20 +310,15 @@
(( $? != 0 )) && die "Could not download sources."
# Clean up garbage from verifysource
@@ -207,8 +211,48 @@
+ 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
+- local makepkg_args=("$@")
+-
+- . /etc/profile
+- export HOME=/build
+- shopt -s nullglob
+
+ # XXX: Workaround makepkg disliking read-only dirs
++ rm -rf -- /srcdest/* /startdir/*
+ ln -sft /srcdest /srcdest_host/*
+ ln -sft /startdir /startdir_host/*
+
+@@ -286,15 +333,27 @@
+ done
+ done
+
+- 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*
++}
++
++_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
# Safety check
if [[ ! -w PKGBUILD ]]; then
@@ -216,7 +260,7 @@
echo "Can't write to PKGBUILD!"
exit 1
fi
-@@ -312,12 +362,24 @@
+@@ -312,12 +371,24 @@
exit 0
}
@@ -241,7 +285,7 @@
for l in "$copydir"/logdest/*; do
chown "$src_owner" "$l"
mv "$l" "$LOGDEST"
-@@ -325,6 +387,10 @@
+@@ -325,6 +396,10 @@
}
# }}}
@@ -252,7 +296,7 @@
umask 0022
load_vars /etc/makepkg.conf
-@@ -335,27 +401,37 @@
+@@ -335,27 +410,37 @@
[[ -d $SRCDEST ]] || SRCDEST=$PWD
[[ -d $LOGDEST ]] || LOGDEST=$PWD
@@ -296,7 +340,7 @@
if (( ret != 0 )); then
if $temp_chroot; then
-@@ -366,3 +442,4 @@
+@@ -366,3 +451,4 @@
else
true
fi