summaryrefslogtreecommitdiff
path: root/archbuild.in
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2011-08-29 10:53:50 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2011-10-07 21:53:02 +0200
commit46c4def0733a78ce08702d188e3e1a141fb07316 (patch)
tree69fb80eff39981680faeeba01f88be48026fc05f /archbuild.in
parent142b032212fd94c0fde75a3dd223444c212c2eaa (diff)
downloaddevtools-46c4def0733a78ce08702d188e3e1a141fb07316.tar.xz
Support non-standard install locations
This build system overhaul allows for adding (define-style) macros to our scripts. All source files are now suffixed with ".in" to clarify that they might contain unprocessed defines. The Makefile provides a new rule to preprocess source files and generate proper output scripts. Also, add a "@pkgdatadir@" define (as used in GNU Autotools) and use it instead of hardcoded paths to "/usr/share/devtools" everywhere. We missed this when adding PREFIX support to the build system in commit 35fc83ce7d8dc26cd424321f2e8638d05da0a6d4. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'archbuild.in')
-rw-r--r--archbuild.in68
1 files changed, 68 insertions, 0 deletions
diff --git a/archbuild.in b/archbuild.in
new file mode 100644
index 0000000..92d2554
--- /dev/null
+++ b/archbuild.in
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+base_packages=(base base-devel sudo)
+
+cmd="${0##*/}"
+if [[ "${cmd%%-*}" == 'multilib' ]]; then
+ repo="${cmd%-build}"
+ arch='x86_64'
+ base_packages+=(multilib-devel)
+else
+ tag="${cmd%-build}"
+ repo=${tag%-*}
+ arch=${tag##*-}
+fi
+chroots='/var/tmp/archbuild'
+clean_first=false
+
+usage() {
+ echo "usage $cmd"
+ echo ' -c Recreate the chroot before building'
+ echo ' -r <dir> Create chroots in this directory'
+ exit 1
+}
+
+while getopts 'cr:' arg; do
+ case "${arg}" in
+ c) clean_first=true ;;
+ r) chroots="$OPTARG" ;;
+ *) usage ;;
+ esac
+done
+
+if [[ "$EUID" != '0' ]]; then
+ echo 'This script must be run as root.'
+ exit 1
+fi
+
+if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then
+ echo "Creating chroot for [${repo}] (${arch})..."
+
+ for copy in "${chroots}/${repo}-${arch}"/*; do
+ [[ -d $copy ]] || continue
+ echo "Deleting chroot copy '$(basename "${copy}")'..."
+
+ # Lock the copy
+ exec 9>"${copy}.lock"
+ flock 9
+
+ { type -P btrfs && btrfs subvolume delete "${copy}"; } &>/dev/null
+ rm -rf "${copy}"
+ done
+ exec 9>&-
+
+ rm -rf "${chroots}/${repo}-${arch}"
+ mkdir -p "${chroots}/${repo}-${arch}"
+ setarch "${arch}" mkarchroot \
+ -C "@pkgdatadir@/pacman-${repo}.conf" \
+ -M "@pkgdatadir@/makepkg-${arch}.conf" \
+ "${chroots}/${repo}-${arch}/root" \
+ "${base_packages[@]}"
+else
+ setarch ${arch} mkarchroot \
+ -u \
+ "${chroots}/${repo}-${arch}/root"
+fi
+
+echo "Building in chroot for [${repo}] (${arch})..."
+setarch "${arch}" makechrootpkg -c -r "${chroots}/${repo}-${arch}"