Filter stale APKs from CI package cache
Build Alpine Packages / build-and-publish (v3.24, 3.24) (push) Has been cancelled
Build Alpine Packages / build-and-publish (v3.24, 3.24) (push) Has been cancelled
This commit is contained in:
@@ -2,7 +2,25 @@
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
# shellcheck source=scripts/apk/package-lib.sh
|
||||
. "${repo_root}/scripts/apk/package-lib.sh"
|
||||
|
||||
repo_dir="${repo_root}/packages/local"
|
||||
arches="${ALPINE_ARCHES:-x86_64 aarch64}"
|
||||
declare -A expected_apks=()
|
||||
|
||||
while IFS= read -r package_source_dir; do
|
||||
apk_validate_package_dir "${package_source_dir}"
|
||||
for arch in ${arches}; do
|
||||
if ! apk_package_supports_arch "${package_source_dir}" "${arch}"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
while IFS= read -r apk_name; do
|
||||
expected_apks["${repo_dir}/${arch}/${apk_name}"]=1
|
||||
done < <(apk_package_apk_names "${package_source_dir}" "${arch}")
|
||||
done
|
||||
done < <(apk_all_package_dirs "${repo_root}")
|
||||
|
||||
if [[ -n "${ALPINE_ARCH:-}" ]]; then
|
||||
package_dirs=("${repo_dir}/${ALPINE_ARCH}")
|
||||
@@ -29,6 +47,10 @@ for package_dir in "${package_dirs[@]}"; do
|
||||
|
||||
printf '## %s\n' "$(basename "${package_dir}")"
|
||||
for apk in "${apks[@]}"; do
|
||||
if [[ -z "${expected_apks[${apk}]:-}" ]]; then
|
||||
printf 'Skipping stale local APK: %s\n' "${apk#"${repo_root}/"}"
|
||||
continue
|
||||
fi
|
||||
printf '### %s\n' "$(basename "${apk}")"
|
||||
tar -xOf "${apk}" .PKGINFO 2>/dev/null \
|
||||
| sed -n '/^pkgname =/p;/^pkgver =/p;/^arch =/p;/^depend =/p;/^provides =/p;/^install_if =/p'
|
||||
|
||||
Reference in New Issue
Block a user