summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2012-12-02 21:53:50 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2012-12-09 14:20:48 -0500
commitd17a673ba0a62f6f8755484a574e9ab0186ab705 (patch)
treebf1b1ede83fc9785db6b4f1e072ae3e598518aab
parent9c404ac8da32df78934bb0ce46cdf96af93801e5 (diff)
libremakepkg: implement things using a chroot_exec function
-rwxr-xr-xsrc/chroot-tools/libremakepkg.gpl237
1 files changed, 20 insertions, 17 deletions
diff --git a/src/chroot-tools/libremakepkg.gpl2 b/src/chroot-tools/libremakepkg.gpl2
index 1077b66..fd58d50 100755
--- a/src/chroot-tools/libremakepkg.gpl2
+++ b/src/chroot-tools/libremakepkg.gpl2
@@ -23,6 +23,8 @@ chroot_init() {
mkdir -p "$copydir/pkgdest"
mkdir -p "$copydir/srcdest"
+ mkdir -p "$copydir/build"
+
chroot_makepkg_conf_set PKGDEST /pkgdest
chroot_makepkg_conf_set SRCDEST /srcdest
@@ -66,26 +68,27 @@ chroot_extract() {
chown -R nobody "$copydir"/{build,pkgdest,srcdest}
cp -a "$(which chcleanup)" "${copydir}/clean"
- local file="$copydir/chrootextract"
- echo '#!/bin/bash' > "$file"
- echo '. /etc/profile' >> "$file"
- echo 'export HOME=/build' >> "$file"
- echo 'cd /build' >> "$file"
- echo '/clean' >> "$file"
- echo "sudo -u nobody ${MAKEPKG} $makepkg_args -o" >> "$file"
- chmod 755 "$file"
- archroot "$copydir" -r /chrootextract
+ chroot_exec "/clean && sudo -u nobody ${MAKEPKG} ${makepkg_args} -o"
}
chroot_build() {
- local file="$copydir/chrootbuild"
- echo '#!/bin/bash' > "$file"
- echo '. /etc/profile' >> "$file"
- echo 'export HOME=/build' >> "$file"
- echo 'cd /build' >> "$file"
- echo "sudo -u nobody ${MAKEPKG} $makepkg_args -e" >> "$file"
- chmod 755 "$file"
- archroot -N "$copydir" -r /chrootbuild
+ chroot_exec -N "sudo -u nobody ${MAKEPKG} ${makepkg_args} -e"
+}
+
+chroot_exec() {
+ local flags=''
+ [[ $1 == -N ]] && { flags=$1; shift; }
+ local cmd="$*"
+ cat >"$copydir/chrootexec" <<EOF
+#!/bin/bash
+. /etc/profile
+export HOME=/build
+cd /build
+
+${cmd}
+EOF
+ chmod 755 "$copydir/chrootexec"
+ archroot $flags "$copydir" -r /chrootexec
}
copy_pkgs() {