Skip to content

Commit 46cf6bb

Browse files
authored
Merge pull request #59 from juergenhoetzel/use-correct-cache-name
[buildinfo] Don't hardcode PKGEXT for downloaded files
2 parents 26c774f + 022f168 commit 46cf6bb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

buildinfo

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ declare -i format=1 builddate
2525
declare -a buildenv options installed
2626
declare -A data
2727

28+
shopt -s extglob
29+
2830
# Desc: Parses line into current global state
2931
# 1: line
3032
function parse_line () {
@@ -91,18 +93,19 @@ function verify_archive_link () {
9193
# 1: Package archive link
9294
# 2: Target directory
9395
function download_archive_package () {
94-
local filename="${1}.pkg.tar.xz"
96+
local cachename
9597
local cachedir=$(readlink -e "${2}")
96-
if [[ -f "${cachedir}/${filename}" ]]; then
97-
echo "Hit cache for ${filename}" >&2
98-
echo "${2}/${filename}"
98+
if cachename=$(compgen -G "${2}/${1}.pkg.tar.@(xz|zst)" ); then
99+
echo "Hit cache for $(basename ${cachename})" >&2
100+
echo "${cachename}"
99101
else
100102
local pwd="$(pwd)"
101103
local workdir="$(mktemp -d)"
102104
cd "${workdir}" || exit 1
103105
for ext in zst xz; do
104106
local target="$(get_archive_link "${1}" "$ext")"
105107
if verify_archive_link "${target}"; then
108+
local filename="$(basename ${target})"
106109
echo "Downloading ${filename}" >&2
107110
curl -L --remote-name-all "${target}" "${target}.sig" 2>/dev/null
108111
if gpg --keyring /etc/pacman.d/gnupg/pubring.gpg --verify "${filename}.sig" "${filename}" 2>/dev/null; then

0 commit comments

Comments
 (0)