Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src/lib/build/build.sh
diff options
context:
space:
mode:
authorLevente Polyak <anthraxx@archlinux.org>2024-02-06 21:59:11 +0100
committerLevente Polyak <anthraxx@archlinux.org>2024-02-08 00:52:20 +0100
commit3ecba314fc3a7508d80c5450aaae4b5fc507d62b (patch)
treeb49d8fb9233d9f821b1769a7c8520d22d51b38a8 /src/lib/build/build.sh
parent5042dcaeb4916e199b30ecf21048a4234da43499 (diff)
feat(build): consolidate repo flags in build and release subcommand
Previously the behavior was inconsistent and not fully fulfilling its purpose of only using --repo once when initially pushing a new and unknown package to the official repositories. Consolidate the behavior by only allowing to use --repo during the initial packaging and disallow any subsequent usage. The expected user experience is to subsequently use --testing or --staging to influence the auto-detection of the build target. This avoids any kind of human error which leads to releasing core packages to extra-testing by accident. Furthermore, allow the build subcommand to automatically fallback to extra as the default stable repository target which greatly improves the usability for AUR or local override builds. Fixes #193 Fixes #191 Component: pkgctl build Component: pkgctl release Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
Diffstat (limited to 'src/lib/build/build.sh')
-rw-r--r--src/lib/build/build.sh35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/lib/build/build.sh b/src/lib/build/build.sh
index 64a6ce3..8e9a3bb 100644
--- a/src/lib/build/build.sh
+++ b/src/lib/build/build.sh
@@ -49,7 +49,7 @@ pkgctl_build_usage() {
BUILD OPTIONS
--arch ARCH Specify architectures to build for (disables auto-detection)
- --repo REPO Specify a target repository (disables auto-detection)
+ --repo REPO Specify target repository for new packages not in any official repo
-s, --staging Build against the staging counterpart of the auto-detected repo
-t, --testing Build against the testing counterpart of the auto-detected repo
-o, --offload Build on a remote server and transfer artifacts afterwards
@@ -89,8 +89,7 @@ pkgctl_build_check_option_group_repo() {
local repo=$2
local testing=$3
local staging=$4
- if ( (( testing )) && (( staging )) ) ||
- ( [[ $repo =~ ^.*-(staging|testing)$ ]] && ( (( testing )) || (( staging )) )); then
+ if [[ -n "${repo}" ]] || (( testing )) || (( staging )); then
die "The argument '%s' cannot be used with one or more of the other specified arguments" "${option}"
exit 1
fi
@@ -153,8 +152,8 @@ pkgctl_build() {
;;
--repo)
(( $# <= 1 )) && die "missing argument for %s" "$1"
- REPO="${2}"
pkgctl_build_check_option_group_repo '--repo' "${REPO}" "${TESTING}" "${STAGING}"
+ REPO="${2}"
shift 2
;;
--arch)
@@ -203,13 +202,13 @@ pkgctl_build() {
shift
;;
-s|--staging)
- STAGING=1
pkgctl_build_check_option_group_repo '--staging' "${REPO}" "${TESTING}" "${STAGING}"
+ STAGING=1
shift
;;
-t|--testing)
- TESTING=1
pkgctl_build_check_option_group_repo '--testing' "${REPO}" "${TESTING}" "${STAGING}"
+ TESTING=1
shift
;;
-c|--clean)
@@ -331,14 +330,22 @@ pkgctl_build() {
pkgbuild_checksum=$(b2sum PKGBUILD | awk '{print $1}')
msg "Building ${pkgbase}"
- # auto-detection of build target
- if [[ -z ${pkgrepo} ]]; then
- if ! pkgrepo=$(get_pacman_repo_from_pkgbuild PKGBUILD); then
- die 'failed to get pacman repo'
- fi
- if [[ -z "${pkgrepo}" ]]; then
- die 'unknown repo, specify --repo for packages not currently in any official repo'
- fi
+ # auto-detect target repository
+ if ! repo=$(get_pacman_repo_from_pkgbuild PKGBUILD); then
+ die 'Failed to query pacman repo'
+ fi
+
+ # fail if an existing package specifies --repo
+ if [[ -n "${repo}" ]] && [[ -n ${pkgrepo} ]]; then
+ die 'Using --repo for packages that exist in official repositories is disallowed'
+ fi
+
+ # assign auto-detected target repository
+ if [[ -n ${repo} ]]; then
+ pkgrepo=${repo}
+ # fallback to extra for unreleased packages
+ elif [[ -z ${pkgrepo} ]]; then
+ pkgrepo=extra
fi
# special cases to resolve final build target