checkpkg: set makepkg vars from build root to support none host archs

When building for an architecture different from the host, the correct
old package was downloaded as "$copydir"'s pacman was configured with
the target CARCH, but checkpkg doesn't know this and tries to search the
cache for host CARCH instead, producing the following error:

`==> ERROR: tarball not found for package: xxx`

This change fixes this by passing the appropriate makepkg config
explicitly, so that checkpkg behaves consistently.

Co-Authored-by: Levente Polyak <anthraxx@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
This commit is contained in:
Felix Yan 2021-07-27 19:22:19 +08:00 committed by Levente Polyak
parent 412d032c26
commit fa5afbc30b
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8
4 changed files with 57 additions and 45 deletions

View File

@ -6,23 +6,6 @@ shopt -s extglob
m4_include(lib/common.sh) m4_include(lib/common.sh)
# Source makepkg.conf; fail if it is not found
if [[ -r '/etc/makepkg.conf' ]]; then
# shellcheck source=makepkg-x86_64.conf
source '/etc/makepkg.conf'
else
die '/etc/makepkg.conf not found!'
fi
# Source user-specific makepkg.conf overrides
if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf" ]]; then
# shellcheck source=/dev/null
source "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf"
elif [[ -r "$HOME/.makepkg.conf" ]]; then
# shellcheck source=/dev/null
source "$HOME/.makepkg.conf"
fi
usage() { usage() {
cat <<- _EOF_ cat <<- _EOF_
Usage: ${BASH_SOURCE[0]##*/} [OPTIONS] Usage: ${BASH_SOURCE[0]##*/} [OPTIONS]
@ -35,41 +18,66 @@ usage() {
list for both packages and a library list for both packages. list for both packages and a library list for both packages.
OPTIONS OPTIONS
-r, --rmdir Remove the temporary directory -r, --rmdir Remove the temporary directory
-w, --warn Print a warning in case of differences -w, --warn Print a warning in case of differences
-h, --help Show this help text -M, --makepkg-config Set an alternate makepkg configuration file
-h, --help Show this help text
_EOF_ _EOF_
} }
RMDIR=0 RMDIR=0
WARN=0 WARN=0
MAKEPKG_CONF=/etc/makepkg.conf
OPT_SHORT='rwh' # option checking
OPT_LONG=('rmdir' 'warn' 'help') while (( $# )); do
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then case $1 in
exit 1 -h|--help)
fi usage
set -- "${OPTRET[@]}" exit 0
;;
while :; do -r|--rmdir)
case $1 in RMDIR=1
-r|--rmdir) shift
RMDIR=1 ;;
;; -w|--warn)
-w|--warn) WARN=1
WARN=1 shift
;; ;;
-h|--help) -M|--makepkg-config)
usage MAKEPKG_CONF="$2"
exit 0 shift 2
;; ;;
--) --)
shift; break shift
;; break
esac ;;
shift -*,--*)
die "invalid argument: %s" "$1"
;;
*)
break
;;
esac
done done
# Source makepkg.conf; fail if it is not found
if [[ -r "${MAKEPKG_CONF}" ]]; then
# shellcheck source=makepkg-x86_64.conf
source "${MAKEPKG_CONF}"
else
die "${MAKEPKG_CONF} not found!"
fi
# Source user-specific makepkg.conf overrides
if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf" ]]; then
# shellcheck source=/dev/null
source "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf"
elif [[ -r "$HOME/.makepkg.conf" ]]; then
# shellcheck source=/dev/null
source "$HOME/.makepkg.conf"
fi
if [[ ! -f PKGBUILD ]]; then if [[ ! -f PKGBUILD ]]; then
die 'This must be run in the directory of a built package.' die 'This must be run in the directory of a built package.'
fi fi

View File

@ -29,6 +29,9 @@ Options
*-w, --warn*:: *-w, --warn*::
Print a warning instead of a regular message in case of soname differences. Print a warning instead of a regular message in case of soname differences.
*-M, --makepkg-config*::
Set an alternate makepkg configuration file.
*-h, --help*:: *-h, --help*::
Show a help text Show a help text

View File

@ -408,7 +408,7 @@ else
done done
msg2 "Checking packages" msg2 "Checking packages"
sudo -u "$makepkg_user" checkpkg --rmdir --warn "${remotepkgs[@]/#file:\/\//}" sudo -u "$makepkg_user" checkpkg --rmdir --warn --makepkg-config "$copydir/etc/makepkg.conf" "${remotepkgs[@]/#file:\/\//}"
fi fi
true true
fi fi

View File

@ -77,6 +77,7 @@ _rebuildpkgs_args=(
_checkpkg_args=( _checkpkg_args=(
'(-r --rmdir)'{-r,--rmdir}'[Remove the temporary directory]' '(-r --rmdir)'{-r,--rmdir}'[Remove the temporary directory]'
'(-w --warn)'{-w,--warn}'[Print a warning in case of differences]' '(-w --warn)'{-w,--warn}'[Print a warning in case of differences]'
'(-M --makepkg-config)'{-M,--makepkg-config}'[Location of a makepkg config file]:makepkg_config:_files -g "*.conf(.)"'
'(-h --help)'{-h,--help}'[Display usage]' '(-h --help)'{-h,--help}'[Display usage]'
) )