summaryrefslogtreecommitdiff
path: root/src/chroot-tools/libremakepkg.gpl2
diff options
context:
space:
mode:
Diffstat (limited to 'src/chroot-tools/libremakepkg.gpl2')
-rwxr-xr-xsrc/chroot-tools/libremakepkg.gpl260
1 files changed, 35 insertions, 25 deletions
diff --git a/src/chroot-tools/libremakepkg.gpl2 b/src/chroot-tools/libremakepkg.gpl2
index 1077b66..8770bee 100755
--- a/src/chroot-tools/libremakepkg.gpl2
+++ b/src/chroot-tools/libremakepkg.gpl2
@@ -20,11 +20,13 @@ 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"
- chroot_makepkg_conf_set PKGDEST /pkgdest
- chroot_makepkg_conf_set SRCDEST /srcdest
+
+ MAKEPKG_CONF=$copydir/etc/makepkg.conf set_conf_makepkg PKGDEST /pkgdest
+ MAKEPKG_CONF=$copydir/etc/makepkg.conf set_conf_makepkg SRCDEST /srcdest
cat > "$copydir/etc/sudoers.d/nobody-pacman" <<EOF
Defaults env_keep += "HOME"
@@ -33,7 +35,8 @@ EOF
chmod 440 "$copydir/etc/sudoers.d/nobody-pacman"
}
-chroot_extract() {
+
+chroot_copy_in() {
rm -rf "$copydir"/build/*
cp PKGBUILD "$copydir/build/"
(
@@ -64,42 +67,49 @@ 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_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() {
+ local HASNET=true
+ [[ $1 == -N ]] && { HASNET=false; shift; }
+
+ local cmd="$*"
+ cat >"$copydir/chrootexec" <<EOF
+#!/bin/bash
+. /etc/profile
+${INCHROOT} || export HOME=/build
+${INCHROOT} || cd /build
+
+${cmd}
+EOF
+ 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
}