Compare commits

..

1 Commits

Author SHA1 Message Date
Levente Polyak
7a64d33b88 chore(license): avoid sourcing PKGBUILD in check subcommand
We don't actually need any data from the package, except the pkgbase
which is exclusively used during logging. Simply grep the pkgbase name
and use the path during early code path issues.

Component: pkgctl license check
2025-08-02 06:30:25 +02:00
2 changed files with 21 additions and 50 deletions

View File

@@ -8,8 +8,6 @@ DEVTOOLS_INCLUDE_DB_MOVE_SH=1
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
# shellcheck source=src/lib/common.sh
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
# shellcheck source=src/lib/valid-repos.sh
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-repos.sh
set -e
@@ -22,7 +20,6 @@ pkgctl_db_move_usage() {
Move packages between binary repositories.
OPTIONS
--noconfirm Bypass any confirmation messages, should only be used with caution
-h, --help Show this help text
EXAMPLES
@@ -32,12 +29,9 @@ _EOF_
}
pkgctl_db_move() {
if (( $# < 3 )); then
pkgctl_db_move_usage
exit 1
fi
local CONFIRM=1
local SOURCE_REPO=""
local TARGET_REPO=""
local PKGBASES=()
# option checking
while (( $# )); do
@@ -46,10 +40,6 @@ pkgctl_db_move() {
pkgctl_db_move_usage
exit 0
;;
--noconfirm)
CONFIRM=0
shift
;;
-*)
die "invalid argument: %s" "$1"
;;
@@ -59,35 +49,16 @@ pkgctl_db_move() {
esac
done
local source_repo=$1
local target_repo=$2
if (( $# < 3 )); then
pkgctl_db_move_usage
exit 1
fi
SOURCE_REPO=$1
TARGET_REPO=$2
shift 2
PKGBASES+=("$@")
if ! in_array "${source_repo}" "${DEVTOOLS_VALID_REPOS[@]}"; then
die "Invalid source repository: %s" "${source_repo}"
fi
if ! in_array "${target_repo}" "${DEVTOOLS_VALID_REPOS[@]}"; then
die "Invalid target repository: %s" "${target_repo}"
fi
if (( CONFIRM )); then
local pkglist
pkglist=$(printf '%s\n' "$@" | paste -sd ' ')
read -r -p "Move packages from [${source_repo}] to [${target_repo}]: ${pkglist}? [Y/n] " response
case ${response} in
[Yy][Ee][Ss]|[Yy]|'')
: # continue
;;
*)
exit 0
;;
esac
fi
local pkgbase
for pkgbase in "$@"; do
msg "Moving [%s] from [%s] to [%s]" "${pkgbase}" "${source_repo}" "${target_repo}"
# shellcheck disable=SC2046
db-move "${source_repo}" "${target_repo}" $(pacman -Sql "${source_repo}" | grep "^${pkgbase}" || echo "${pkgbase}")
done
# shellcheck disable=SC2029
ssh "${PACKAGING_REPO_RELEASE_HOST}" db-move "${SOURCE_REPO}" "${TARGET_REPO}" "${PKGBASES[@]}"
}

View File

@@ -94,19 +94,19 @@ pkgctl_license_check() {
pushd "${path}" >/dev/null
if [[ ! -f PKGBUILD ]]; then
msg_error "${BOLD}${pkgbase}:${ALL_OFF} no PKGBUILD found"
msg_error "${BOLD}${path}:${ALL_OFF} no PKGBUILD found"
return 1
fi
# reset common PKGBUILD variables
unset pkgbase
# shellcheck source=contrib/makepkg/PKGBUILD.proto
if ! . ./PKGBUILD; then
msg_error "${BOLD}${pkgbase}:${ALL_OFF} failed to source PKGBUILD"
if [[ ! -f .SRCINFO ]]; then
msg_error "${BOLD}${path}:${ALL_OFF} no .SRCINFO found"
return 1
fi
if ! pkgbase=$(grep --max-count=1 --extended-regexp "pkgbase = (.+)" .SRCINFO | awk '{print $3}'); then
msg_error "${BOLD}${path}:${ALL_OFF} pkgbase not found in .SRCINFO"
return 1
fi
pkgbase=${pkgbase:-$pkgname}
if [[ ! -e LICENSE ]]; then
msg_error "${BOLD}${pkgbase}:${ALL_OFF} is missing the LICENSE file"