diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-12-08 14:41:44 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-12-09 14:20:48 -0500 |
commit | db3d3af8719706c80a791b0d875d308b021ee81b (patch) | |
tree | 21485099f71fa09d6178d0cefdbb0ea1437bc745 /src/chroot-tools/libremakepkg.gpl2 | |
parent | 1ba64c22602bdf5c53565083c13c67a4583e32ff (diff) |
rethink libremakepkg's chroot logic to make it play well from in a chroot
Diffstat (limited to 'src/chroot-tools/libremakepkg.gpl2')
-rwxr-xr-x | src/chroot-tools/libremakepkg.gpl2 | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/src/chroot-tools/libremakepkg.gpl2 b/src/chroot-tools/libremakepkg.gpl2 index 50bb48e..8770bee 100755 --- a/src/chroot-tools/libremakepkg.gpl2 +++ b/src/chroot-tools/libremakepkg.gpl2 @@ -20,10 +20,10 @@ chroot_init() { if [[ -r "$LIBREHOME/.gnupg/pubring.gpg" ]]; then install -D "$HOME/.gnupg/pubring.gpg" "$copydir/build/.gnupg/pubring.gpg" fi + rm -f "$copydir/build/.makepkg.conf" mkdir -p "$copydir/pkgdest" mkdir -p "$copydir/srcdest" - mkdir -p "$copydir/build" MAKEPKG_CONF=$copydir/etc/makepkg.conf set_conf_makepkg PKGDEST /pkgdest MAKEPKG_CONF=$copydir/etc/makepkg.conf set_conf_makepkg SRCDEST /srcdest @@ -35,12 +35,8 @@ EOF chmod 440 "$copydir/etc/sudoers.d/nobody-pacman" } -chroot_extract() { - if $NOCHROOT; then - chcleanup - sudo -u ${LIBREUSER} ${MAKEPKG} ${makepkg_args} -o - return - fi + +chroot_copy_in() { rm -rf "$copydir"/build/* cp PKGBUILD "$copydir/build/" ( @@ -71,49 +67,49 @@ chroot_extract() { ) chown -R nobody "$copydir"/{build,pkgdest,srcdest} - - cp -a "$(which chcleanup)" "${copydir}/clean" - chroot_exec "/clean && sudo -u nobody ${MAKEPKG} ${makepkg_args} -o" -} - -chroot_build() { - local user=$LIBREUSER - $NOCHROOT || user=nobody - chroot_exec -N "sudo -u ${user} ${MAKEPKG} ${makepkg_args} -e" } chroot_exec() { - local flags='' - [[ $1 == -N ]] && { flags=$1; shift; } + local HASNET=true + [[ $1 == -N ]] && { HASNET=false; shift; } + local cmd="$*" - if $NOCHROOT; then - ${cmd} - else - cat >"$copydir/chrootexec" <<EOF + cat >"$copydir/chrootexec" <<EOF #!/bin/bash . /etc/profile -export HOME=/build -cd /build +${INCHROOT} || export HOME=/build +${INCHROOT} || cd /build ${cmd} EOF - chmod 755 "$copydir/chrootexec" + chmod 755 "$copydir/chrootexec" + + local flags='' + if $INCHROOT; then + $HASNET || flags='-n' + unshare $flags -- /chrootexec + else + $HASNET || flags='-N' librechroot $flags -n "$CHROOT" -l "$CHROOTCOPY" -r /chrootexec fi } -copy_pkgs() { +add_to_local_repo() { for pkgfile in "$copydir"/pkgdest/*.pkg.tar*; do mkdir -p "$copydir/repo" pushd "$copydir/repo" >/dev/null cp "$pkgfile" . repo-add repo.db.tar.gz "${pkgfile##*/}" popd >/dev/null - + done +} +chroot_copy_out() { + for pkgfile in "$copydir"/pkgdest/*.pkg.tar*; do chown "$LIBREUSER" "$pkgfile" mv "$pkgfile" "$PKGDEST" if [[ $PKGDEST != . ]]; then ln -s "$PKGDEST/${pkgfile##*/}" . fi done + copy_logs } |