summaryrefslogtreecommitdiff
path: root/src/chroot-tools/libremakepkg.gpl2
diff options
context:
space:
mode:
authorNicolás Reynolds <apoyosis@correo.inta.gob.ar>2012-11-30 01:00:18 -0300
committerNicolás Reynolds <apoyosis@correo.inta.gob.ar>2012-11-30 01:00:18 -0300
commitb021874d73c9dded2e05f2095efa5c3a6d23b496 (patch)
treeb2b9a7bd88f0476accd17d23c1ef53c7cc920be7 /src/chroot-tools/libremakepkg.gpl2
parent73b813613aa08646515f4e06c71503b18125cec3 (diff)
parentba312fb72ec0843297978796a20c6ffc1fe3ef6e (diff)
Merge branch 'master' of http://projects.parabolagnulinux.org/libretools
Conflicts: src/aur src/chroot-tools/librechroot src/librerepkg
Diffstat (limited to 'src/chroot-tools/libremakepkg.gpl2')
-rwxr-xr-xsrc/chroot-tools/libremakepkg.gpl2102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/chroot-tools/libremakepkg.gpl2 b/src/chroot-tools/libremakepkg.gpl2
new file mode 100755
index 0000000..1f2d185
--- /dev/null
+++ b/src/chroot-tools/libremakepkg.gpl2
@@ -0,0 +1,102 @@
+#!/bin/bash
+# Contains code derived from devtools' "makechrootpkg"
+
+# Copyright 2011-2012 The Arch Linux Development Team
+# Copyright 2012 Luke Shumaker
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+chroot_init() {
+ # no-op; make sure the chroot exists
+ librechroot -n -l "$CHROOTCOPY" "$CHROOT"
+
+ if [[ -r "$LIBREHOME/.gnupg/pubring.gpg" ]]; then
+ install -D "$HOME/.gnupg/pubring.gpg" "$copydir/build/.gnupg/pubring.gpg"
+ fi
+
+ mkdir -p "$copydir/pkgdest"
+ mkdir -p "$copydir/srcdest"
+ chroot_makepkg_conf_set PKGDEST /pkgdest
+ chroot_makepkg_conf_set SRCDEST /srcdest
+
+ cat > "$copydir/etc/sudoers.d/nobody-pacman" <<EOF
+Defaults env_keep += "HOME"
+nobody ALL = NOPASSWD: /usr/bin/pacman
+EOF
+ chmod 440 "$copydir/etc/sudoers.d/nobody-pacman"
+}
+
+chroot_extract() {
+ rm -rf "$copydir"/build/*
+ cp PKGBUILD "$copydir/build/"
+ (
+ source PKGBUILD
+
+ # Copy source files
+ for file in "${source[@]}"; do
+ file="${file%%::*}"
+ file="${file##*://*/}"
+ if [[ -f $file ]]; then
+ cp "$file" "$copydir/srcdest/"
+ elif [[ -f $SRCDEST/$file ]]; then
+ cp "$SRCDEST/$file" "$copydir/srcdest/"
+ fi
+ done
+
+ # Find all changelog and install files, even inside functions
+ for i in 'changelog' 'install'; do
+ while read -r file; do
+ # evaluate any bash variables used
+ eval file=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$file")\"
+ if [[ -f $file ]]; then
+ cp "$file" "$copydir/build/"
+ fi
+ done < <(sed -n "s/^[[:space:]]*$i=//p" PKGBUILD)
+ done
+ )
+
+ chown -R nobody "$copydir"/{build,pkgdest,srcdest}
+
+ local file="$copydir/chrootextract"
+ echo '#!/bin/bash' > "$file"
+ echo '. /etc/profile' >> "$file"
+ echo 'export HOME=/build' >> "$file"
+ echo 'cd /build' >> "$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
+}
+
+copy_pkgs() {
+ 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
+
+ chown "$LIBREUSER" "$pkgfile"
+ mv "$pkgfile" "$PKGDEST"
+ if [[ $PKGDEST != . ]]; then
+ ln -s "$PKGDEST/${pkgfile##*/}" .
+ fi
+ done
+}