BlueGit

golden-age paperdoll-renderer

Files

paperdoll-renderer / scripts / package / arch.sh

arch.sh

arch.sh 1.4 KiB Download Raw
1#!/usr/bin/env bash
2# Build an Arch .pkg.tar.zst with makepkg. The package is not installed and
3# it is not published.
4set -euo pipefail
5
6root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
7if ! command -v makepkg >/dev/null 2>&1; then
8 echo "makepkg is not installed. The Arch package job runs on archlinux/archlinux:base-devel." >&2
9 exit 1
10fi
11
12version="$(bash "$root/scripts/ci/package-version.sh")"
13export REPO_ROOT="$root"
14export PAPERDOLL_PKGVER="$version"
15export CARGO_HOME="${CARGO_HOME:-$root/cargo-home}"
16
17work="$(mktemp -d)"
18trap 'rm -rf "$work"' EXIT
19cp "$root/packaging/arch/PKGBUILD" "$work/PKGBUILD"
20
21run_makepkg() {
22 (cd "$work" && makepkg -f --noconfirm --nodeps)
23}
24
25if [[ "$(id -u)" -eq 0 ]]; then
26 if ! id builduser >/dev/null 2>&1; then
27 useradd -m builduser
28 fi
29 chown -R builduser:builduser "$root" "$work"
30 su builduser -c "export REPO_ROOT='$root' PAPERDOLL_PKGVER='$version' CARGO_HOME='$CARGO_HOME' PATH='$PATH'; cd '$work' && makepkg -f --noconfirm --nodeps"
31else
32 run_makepkg
33fi
34
35mapfile -t packages < <(find "$work" -maxdepth 1 -type f -name "paperdoll-renderer-${version}-*-x86_64.pkg.tar.zst" ! -name '*.sig')
36if [[ "${#packages[@]}" -ne 1 ]]; then
37 echo "expected one Arch package, found ${#packages[@]}" >&2
38 exit 1
39fi
40mkdir -p "$root/dist"
41cp -f "${packages[0]}" "$root/dist/paperdoll-renderer-x86_64.pkg.tar.zst"
42echo "wrote dist/paperdoll-renderer-x86_64.pkg.tar.zst"