From 1676629ba3b7b7fa0b48d455e9a4d6d09823004b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 2 Dec 2012 21:53:50 -0500 Subject: libremakepkg: implement things using a chroot_exec function --- src/chroot-tools/libremakepkg.gpl2 | 37 ++++++++++++++++++++----------------- 1 file 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" <