diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-12-02 21:53:50 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-12-02 21:53:50 -0500 |
commit | 1676629ba3b7b7fa0b48d455e9a4d6d09823004b (patch) | |
tree | 3179986fffa10f6b6f525420b6a55aa27422ab91 /src/chroot-tools | |
parent | 69630547758d4aefff8a6cd12336935fa9fdca1c (diff) |
libremakepkg: implement things using a chroot_exec function
Diffstat (limited to 'src/chroot-tools')
-rwxr-xr-x | src/chroot-tools/libremakepkg.gpl2 | 37 |
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() { |