index : devtools32 | |
Archlinux32 fork of devtools | gitolite user |
summaryrefslogtreecommitdiff |
author | Levente Polyak <anthraxx@archlinux.org> | 2024-02-06 21:59:11 +0100 |
---|---|---|
committer | Levente Polyak <anthraxx@archlinux.org> | 2024-02-08 00:52:20 +0100 |
commit | 3ecba314fc3a7508d80c5450aaae4b5fc507d62b (patch) | |
tree | b49d8fb9233d9f821b1769a7c8520d22d51b38a8 /src/lib | |
parent | 5042dcaeb4916e199b30ecf21048a4234da43499 (diff) |
-rw-r--r-- | src/lib/build/build.sh | 35 | ||||
-rw-r--r-- | src/lib/release.sh | 29 | ||||
-rw-r--r-- | src/lib/util/pacman.sh | 7 |
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 diff --git a/src/lib/release.sh b/src/lib/release.sh index 028d92e..700b2b0 100644 --- a/src/lib/release.sh +++ b/src/lib/release.sh @@ -35,7 +35,7 @@ pkgctl_release_usage() { OPTIONS -m, --message MSG Use the given <msg> as the commit message - -r, --repo REPO Specify a target repository (disables auto-detection) + -r, --repo REPO Specify target repository for new packages not in any official repo -s, --staging Release to the staging counterpart of the auto-detected repo -t, --testing Release to the testing counterpart of the auto-detected repo -u, --db-update Automatically update the pacman database after uploading @@ -43,8 +43,8 @@ pkgctl_release_usage() { EXAMPLES $ ${COMMAND} - $ ${COMMAND} --repo core-testing --message 'libyay 0.42 rebuild' libfoo libbar - $ ${COMMAND} --staging --db-update libfoo + $ ${COMMAND} --staging --message 'libyay 0.42 rebuild' libfoo libbar + $ ${COMMAND} --repo extra --db-update new-package _EOF_ } @@ -134,15 +134,22 @@ pkgctl_release() { pushd "${path}" >/dev/null pkgbase=$(basename "${path}") - if [[ -n ${REPO} ]]; then - repo=${REPO} - else - if ! repo=$(get_pacman_repo_from_pkgbuild PKGBUILD); then - die 'Failed to get pacman repo' - fi - if [[ -z "${repo}" ]]; then - die 'Unknown repo, please specify --repo for new packages' + # 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 ${REPO} ]]; then + die 'Using --repo for packages that exist in official repositories is disallowed' + fi + + # fail if a new package does not specify --repo + if [[ -z "${repo}" ]]; then + if [[ -z ${REPO} ]]; then + die 'Specify --repo for packages that do not yet exist in official repositories' fi + repo=${REPO} fi if (( TESTING )); then diff --git a/src/lib/util/pacman.sh b/src/lib/util/pacman.sh index 82a227b..620e1a8 100644 --- a/src/lib/util/pacman.sh +++ b/src/lib/util/pacman.sh @@ -38,6 +38,11 @@ get_pacman_repo_from_pkgbuild() { return fi + # update the pacman repo cache if it doesn't exist yet + if [[ ! -d "${_DEVTOOLS_PACMAN_CACHE_DIR}" ]]; then + update_pacman_repo_cache + fi + slock 10 "${_DEVTOOLS_PACMAN_CACHE_DIR}.lock" "Locking pacman database cache" # query repo of passed pkgname, specify --nodeps twice to skip all dependency checks mapfile -t repos < <(pacman --config "${_DEVTOOLS_PACMAN_CONF_DIR}/multilib.conf" \ @@ -47,7 +52,7 @@ get_pacman_repo_from_pkgbuild() { --nodeps \ --print \ --print-format '%n %r' \ - "${pkgnames[0]}" | awk '$1=="'"${pkgnames[0]}"'"{print $2}' + "${pkgnames[0]}" 2>/dev/null | awk '$1=="'"${pkgnames[0]}"'"{print $2}' ) lock_close 10 |