Skip to content

Commit fa5afbc

Browse files
felixonmarsanthraxx
andcommitted
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 <[email protected]> Signed-off-by: Levente Polyak <[email protected]>
1 parent 412d032 commit fa5afbc

File tree

4 files changed

+57
-45
lines changed

4 files changed

+57
-45
lines changed

checkpkg.in

+52-44
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,6 @@ shopt -s extglob
66

77
m4_include(lib/common.sh)
88

9-
# Source makepkg.conf; fail if it is not found
10-
if [[ -r '/etc/makepkg.conf' ]]; then
11-
# shellcheck source=makepkg-x86_64.conf
12-
source '/etc/makepkg.conf'
13-
else
14-
die '/etc/makepkg.conf not found!'
15-
fi
16-
17-
# Source user-specific makepkg.conf overrides
18-
if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf" ]]; then
19-
# shellcheck source=/dev/null
20-
source "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf"
21-
elif [[ -r "$HOME/.makepkg.conf" ]]; then
22-
# shellcheck source=/dev/null
23-
source "$HOME/.makepkg.conf"
24-
fi
25-
269
usage() {
2710
cat <<- _EOF_
2811
Usage: ${BASH_SOURCE[0]##*/} [OPTIONS]
@@ -35,40 +18,65 @@ usage() {
3518
list for both packages and a library list for both packages.
3619
3720
OPTIONS
38-
-r, --rmdir Remove the temporary directory
39-
-w, --warn Print a warning in case of differences
40-
-h, --help Show this help text
21+
-r, --rmdir Remove the temporary directory
22+
-w, --warn Print a warning in case of differences
23+
-M, --makepkg-config Set an alternate makepkg configuration file
24+
-h, --help Show this help text
4125
_EOF_
4226
}
4327

4428
RMDIR=0
4529
WARN=0
30+
MAKEPKG_CONF=/etc/makepkg.conf
31+
32+
# option checking
33+
while (( $# )); do
34+
case $1 in
35+
-h|--help)
36+
usage
37+
exit 0
38+
;;
39+
-r|--rmdir)
40+
RMDIR=1
41+
shift
42+
;;
43+
-w|--warn)
44+
WARN=1
45+
shift
46+
;;
47+
-M|--makepkg-config)
48+
MAKEPKG_CONF="$2"
49+
shift 2
50+
;;
51+
--)
52+
shift
53+
break
54+
;;
55+
-*,--*)
56+
die "invalid argument: %s" "$1"
57+
;;
58+
*)
59+
break
60+
;;
61+
esac
62+
done
4663

47-
OPT_SHORT='rwh'
48-
OPT_LONG=('rmdir' 'warn' 'help')
49-
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
50-
exit 1
64+
# Source makepkg.conf; fail if it is not found
65+
if [[ -r "${MAKEPKG_CONF}" ]]; then
66+
# shellcheck source=makepkg-x86_64.conf
67+
source "${MAKEPKG_CONF}"
68+
else
69+
die "${MAKEPKG_CONF} not found!"
70+
fi
71+
72+
# Source user-specific makepkg.conf overrides
73+
if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf" ]]; then
74+
# shellcheck source=/dev/null
75+
source "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf"
76+
elif [[ -r "$HOME/.makepkg.conf" ]]; then
77+
# shellcheck source=/dev/null
78+
source "$HOME/.makepkg.conf"
5179
fi
52-
set -- "${OPTRET[@]}"
53-
54-
while :; do
55-
case $1 in
56-
-r|--rmdir)
57-
RMDIR=1
58-
;;
59-
-w|--warn)
60-
WARN=1
61-
;;
62-
-h|--help)
63-
usage
64-
exit 0
65-
;;
66-
--)
67-
shift; break
68-
;;
69-
esac
70-
shift
71-
done
7280

7381
if [[ ! -f PKGBUILD ]]; then
7482
die 'This must be run in the directory of a built package.'

doc/checkpkg.1.asciidoc

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ Options
2929
*-w, --warn*::
3030
Print a warning instead of a regular message in case of soname differences.
3131

32+
*-M, --makepkg-config*::
33+
Set an alternate makepkg configuration file.
34+
3235
*-h, --help*::
3336
Show a help text
3437

makechrootpkg.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ else
408408
done
409409

410410
msg2 "Checking packages"
411-
sudo -u "$makepkg_user" checkpkg --rmdir --warn "${remotepkgs[@]/#file:\/\//}"
411+
sudo -u "$makepkg_user" checkpkg --rmdir --warn --makepkg-config "$copydir/etc/makepkg.conf" "${remotepkgs[@]/#file:\/\//}"
412412
fi
413413
true
414414
fi

zsh_completion.in

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

0 commit comments

Comments
 (0)