🏡 index : quine-global/app-build.git

# shellcheck shell=bash
# Shared by build-*.sh: runs in a Fedora container with the app's repo at
# /src, a cache that outlives the job at /cache, and RPMs going to /out.
set -euo pipefail

# The checkout and caches belong to other users than the container's root.
git_safe() { git config --global --add safe.directory '*'; }

# Packages the app with packaging/$NAME.spec. The spec gets version_,
# release_ and srcdir (/src), plus any extra --define pairs passed here.
package_rpm() {
  local version=$1; shift
  local release
  release=$(date -u +%Y%m%d%H%M).git$(git -C /src rev-parse --short=7 HEAD)
  rpmbuild -bb "/src/packaging/$NAME.spec" \
    --define "_topdir /tmp/rpmbuild" \
    --define "version_ $version" --define "release_ $release" --define "srcdir /src" \
    "$@"
  cp -v /tmp/rpmbuild/RPMS/*/*.rpm /out/
}