From d94badcd0be4f1f0bdc85a9e17f622373fcc42b2 Mon Sep 17 00:00:00 2001 From: Levente Polyak Date: Wed, 18 May 2022 02:31:26 +0200 Subject: make: split out source files into src folder --- src/archbuild.in | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/archbuild.in (limited to 'src/archbuild.in') diff --git a/src/archbuild.in b/src/archbuild.in new file mode 100644 index 0000000..e6cf19a --- /dev/null +++ b/src/archbuild.in @@ -0,0 +1,98 @@ +#!/bin/bash +# +# SPDX-License-Identifier: GPL-3.0-or-later + +m4_include(lib/common.sh) +m4_include(lib/archroot.sh) + +base_packages=(base-devel) +makechrootpkg_args=(-c -n -C) + +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 +if [[ -f "@pkgdatadir@/setarch-aliases.d/${arch}" ]]; then + read -r set_arch < "@pkgdatadir@/setarch-aliases.d/${arch}" +else + set_arch="${arch}" +fi +chroots='/var/lib/archbuild' +clean_first=false + +pacman_config="@pkgdatadir@/pacman-${repo}.conf" +if [[ -f @pkgdatadir@/pacman-${repo}-${arch}.conf ]]; then + pacman_config="@pkgdatadir@/pacman-${repo}-${arch}.conf" +fi +makepkg_config="@pkgdatadir@/makepkg-${arch}.conf" +if [[ -f @pkgdatadir@/makepkg-${repo}-${arch}.conf ]]; then + makepkg_config="@pkgdatadir@/makepkg-${repo}-${arch}.conf" +fi + +usage() { + echo "Usage: $cmd [options] -- [makechrootpkg args]" + echo ' -h This help' + echo ' -c Recreate the chroot before building' + echo ' -r Create chroots in this directory' + echo '' + echo "Default makechrootpkg args: ${makechrootpkg_args[*]}" + echo '' + exit 1 +} + +while getopts 'hcr:' arg; do + case "${arg}" in + c) clean_first=true ;; + r) chroots="$OPTARG" ;; + *) usage ;; + esac +done + +check_root SOURCE_DATE_EPOCH,SRCDEST,SRCPKGDEST,PKGDEST,LOGDEST,MAKEFLAGS,PACKAGER,GNUPGHOME + +# Pass all arguments after -- right to makepkg +makechrootpkg_args+=("${@:$OPTIND}") + +if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then + msg "Creating chroot for [%s] (%s)..." "${repo}" "${arch}" + + for copy in "${chroots}/${repo}-${arch}"/*; do + [[ -d $copy ]] || continue + msg2 "Deleting chroot copy '%s'..." "$(basename "${copy}")" + + lock 9 "$copy.lock" "Locking chroot copy '%s'" "$copy" + + subvolume_delete_recursive "${copy}" + rm -rf --one-file-system "${copy}" + done + lock_close 9 + + rm -rf --one-file-system "${chroots}/${repo}-${arch}" + (umask 0022; mkdir -p "${chroots}/${repo}-${arch}") + setarch "${set_arch}" mkarchroot \ + -C "${pacman_config}" \ + -M "${makepkg_config}" \ + "${chroots}/${repo}-${arch}/root" \ + "${base_packages[@]}" || abort +else + lock 9 "${chroots}/${repo}-${arch}/root.lock" "Locking clean chroot" + arch-nspawn \ + -C "${pacman_config}" \ + -M "${makepkg_config}" \ + "${chroots}/${repo}-${arch}/root" \ + pacman -Syuu --noconfirm || abort +fi + +# Always build official packages reproducibly +if [[ ! -v SOURCE_DATE_EPOCH ]]; then + export SOURCE_DATE_EPOCH=$(date +%s) +fi + +msg "Building in chroot for [%s] (%s)..." "${repo}" "${arch}" +exec makechrootpkg -r "${chroots}/${repo}-${arch}" "${makechrootpkg_args[@]}" -- cgit v1.2.3-70-g09d2