makerepropkg: do fast cache lookups
Teach get_pkgfile to call itself in local-only mode and find a cached file no matter what its extension is. Avoids repetitively trying to curl random files, fail with 404 errors, and proceed to discover a cache hit under a different file extension. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
This commit is contained in:
parent
00f7a6a415
commit
99c2020d47
|
@ -57,9 +57,15 @@ parse_buildinfo() {
|
||||||
get_pkgfile() {
|
get_pkgfile() {
|
||||||
local cdir=${cache_dirs[0]}
|
local cdir=${cache_dirs[0]}
|
||||||
local pkgfilebase=${1}
|
local pkgfilebase=${1}
|
||||||
|
local mode=${2}
|
||||||
local pkgname=${pkgfilebase%-*-*-*}
|
local pkgname=${pkgfilebase%-*-*-*}
|
||||||
local pkgfile ext
|
local pkgfile ext
|
||||||
|
|
||||||
|
# try without downloading
|
||||||
|
if [[ ${mode} != localonly ]] && get_pkgfile "${pkgfilebase}" localonly; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
for ext in .zst .xz ''; do
|
for ext in .zst .xz ''; do
|
||||||
pkgfile=${pkgfilebase}.pkg.tar${ext}
|
pkgfile=${pkgfilebase}.pkg.tar${ext}
|
||||||
|
|
||||||
|
@ -72,6 +78,9 @@ get_pkgfile() {
|
||||||
|
|
||||||
for f in "${pkgfile}" "${pkgfile}.sig"; do
|
for f in "${pkgfile}" "${pkgfile}.sig"; do
|
||||||
if [[ ! -f "${cdir}/${f}" ]]; then
|
if [[ ! -f "${cdir}/${f}" ]]; then
|
||||||
|
if [[ ${mode} = localonly ]]; then
|
||||||
|
continue 2
|
||||||
|
fi
|
||||||
msg2 "retrieving '%s'..." "${f}" >&2
|
msg2 "retrieving '%s'..." "${f}" >&2
|
||||||
curl -Llf -# -o "${cdir}/${f}" "${archiveurl}/${pkgname:0:1}/${pkgname}/${f}" || continue 2
|
curl -Llf -# -o "${cdir}/${f}" "${archiveurl}/${pkgname:0:1}/${pkgname}/${f}" || continue 2
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue