Merge branch 'verify-SRCDEST' into 'master'

makepkg: Make verify() easier to write correctly

See merge request pacman/pacman!264
This commit is contained in:
Jan Alexander Steffens (heftig) 2025-06-23 09:37:32 +00:00
commit a5537a3202
3 changed files with 12 additions and 27 deletions

View file

@ -102,12 +102,12 @@ systems (see below).
*source (array)*:: *source (array)*::
An array of source files required to build the package. Source files An array of source files required to build the package. Source files
must either reside in the same directory as the PKGBUILD, or be a must either reside in `$SRCDEST` (if set, otherwise the same directory
fully-qualified URL that makepkg can use to download the file. as the PKGBUILD) or be a fully-qualified URL that makepkg can use to
To simplify the maintenance of PKGBUILDs, use the `$pkgname` and `$pkgver` download the file. To simplify the maintenance of PKGBUILDs, use the
variables when specifying the download location, if possible. `$pkgname` and `$pkgver` variables when specifying the download
Compressed files will be extracted automatically unless found in the location, if possible. Compressed files will be extracted automatically
noextract array described below. unless found in the noextract array described below.
+ +
Additional architecture-specific sources can be added by appending an Additional architecture-specific sources can be added by appending an
underscore and the architecture name e.g., 'source_x86_64=()'. There must be a underscore and the architecture name e.g., 'source_x86_64=()'. There must be a
@ -351,7 +351,8 @@ function.
An optional `verify()` function can be specified to implement arbitrary An optional `verify()` function can be specified to implement arbitrary
source authentication. The function should return a non-zero exit code when source authentication. The function should return a non-zero exit code when
verification fails. This function is run before sources are extracted. verification fails. This function is run before sources are extracted.
This function is run inside `$startdir`. This function is run inside `$SRCDEST`, if set, otherwise the same
directory as the PKGBUILD.
*prepare() Function*:: *prepare() Function*::
An optional `prepare()` function can be specified in which operations to An optional `prepare()` function can be specified in which operations to

View file

@ -90,28 +90,12 @@ get_filename() {
# Return the absolute filename of a source entry # Return the absolute filename of a source entry
get_filepath() { get_filepath() {
local file="$(get_filename "$1")" local file="$SRCDEST/$(get_filename "$1")"
local proto="$(get_protocol "$1")" local proto="$(get_protocol "$1")"
case $proto in case $proto in
bzr|git|hg|svn) bzr|git|hg|svn) [[ -d $file ]] || return 1 ;;
if [[ -d "$startdir/$file" ]]; then *) [[ -f $file ]] || return 1 ;;
file="$startdir/$file"
elif [[ -d "$SRCDEST/$file" ]]; then
file="$SRCDEST/$file"
else
return 1
fi
;;
*)
if [[ -f "$startdir/$file" ]]; then
file="$startdir/$file"
elif [[ -f "$SRCDEST/$file" ]]; then
file="$SRCDEST/$file"
else
return 1
fi
;;
esac esac
printf "%s\n" "$file" printf "%s\n" "$file"

View file

@ -450,7 +450,7 @@ run_function() {
} }
run_verify() { run_verify() {
run_function_safe "verify" "$startdir" run_function_safe "verify" "$SRCDEST"
} }
run_prepare() { run_prepare() {