Update SeaweedFS and add outdated checks
Build Alpine Packages / build-and-publish (v3.24, 3.24) (push) Has been cancelled

This commit is contained in:
Joachim Schlöffel
2026-07-12 07:49:15 +02:00
parent 95834e55d5
commit b19a3288fd
17 changed files with 320 additions and 91 deletions
+144
View File
@@ -0,0 +1,144 @@
#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
# shellcheck source=scripts/apk/package-lib.sh
source "${repo_root}/scripts/apk/package-lib.sh"
mode="${APK_UPDATE_CHECK_MODE:-warn}"
if [[ "${mode}" != "warn" && "${mode}" != "fail" ]]; then
printf 'APK_UPDATE_CHECK_MODE must be warn or fail\n' >&2
exit 2
fi
github_latest_release() {
local repo="$1"
local api_url="https://api.github.com/repos/${repo}/releases/latest"
local response
response="$(curl -fsSL \
-H 'Accept: application/vnd.github+json' \
-H 'X-GitHub-Api-Version: 2022-11-28' \
"${api_url}" 2>/dev/null)" || return 1
printf '%s\n' "${response}" \
| sed -n 's/^[[:space:]]*"tag_name":[[:space:]]*"\([^"]*\)".*/\1/p' \
| head -n 1
}
apkbuild_value() {
local package_dir="$1"
local key="$2"
awk -F= -v key="${key}" '
$1 == key {
value = $2
gsub(/["'\'']/, "", value)
gsub(/^[ \t]+|[ \t]+$/, "", value)
print value
exit
}
' "${package_dir}/APKBUILD"
}
load_update_metadata() {
local package_dir="$1"
local metadata="${package_dir}/update-check.conf"
provider=""
repo=""
version_prefix="v"
if [[ ! -f "${metadata}" ]]; then
return 1
fi
# shellcheck source=/dev/null
source "${metadata}"
if [[ "${provider}" != "github" || -z "${repo}" ]]; then
return 1
fi
}
normalize_version() {
local version="$1"
local prefix="$2"
case "${prefix}" in
none|"")
printf '%s\n' "${version}"
;;
*)
printf '%s\n' "${version#"${prefix}"}"
;;
esac
}
version_is_newer() {
local latest="$1"
local current="$2"
local apk_result
local sorted
if [[ "${latest}" == "${current}" ]]; then
return 1
fi
if command -v apk >/dev/null 2>&1; then
apk_result="$(apk version -t "${latest}-r0" "${current}-r0" 2>/dev/null || true)"
[[ "${apk_result}" == ">" ]]
return
fi
if sort -V </dev/null >/dev/null 2>&1; then
sorted="$(printf '%s\n%s\n' "${current}" "${latest}" | sort -V | tail -n 1)"
[[ "${sorted}" == "${latest}" && "${latest}" != "${current}" ]]
return
fi
return 0
}
printf '%-14s %-14s %-14s %-18s %s\n' "PACKAGE" "CURRENT" "LATEST" "STATUS" "UPSTREAM"
has_update=0
has_unknown=0
while IFS= read -r package_dir; do
apk_validate_package_dir "${package_dir}"
package_name="$(apk_package_name "${package_dir}")"
current_version="$(apkbuild_value "${package_dir}" "pkgver")"
status="unknown"
latest_version="-"
upstream_url="-"
if load_update_metadata "${package_dir}"; then
upstream_url="https://github.com/${repo}/releases"
if latest_tag="$(github_latest_release "${repo}")" && [[ -n "${latest_tag}" ]]; then
latest_version="$(normalize_version "${latest_tag}" "${version_prefix}")"
if version_is_newer "${latest_version}" "${current_version}"; then
status="update-available"
has_update=1
else
status="current"
fi
else
has_unknown=1
fi
else
has_unknown=1
fi
printf '%-14s %-14s %-14s %-18s %s\n' \
"${package_name}" \
"${current_version:-"-"}" \
"${latest_version}" \
"${status}" \
"${upstream_url}"
done < <(apk_package_dirs "${repo_root}")
if [[ "${mode}" == "fail" && ( "${has_update}" -ne 0 || "${has_unknown}" -ne 0 ) ]]; then
exit 1
fi
+1
View File
@@ -4,6 +4,7 @@ set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
cd "${repo_root}"
mise run apk:outdated
mise run apk:lint
mise run apk:build-all
mise run apk:packages
+37 -29
View File
@@ -5,8 +5,8 @@ repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
alpine_version="${ALPINE_VERSION:-3.24}"
platform="${ALPINE_BUILD_PLATFORM:-linux/amd64}"
arch="${ALPINE_ARCH:-x86_64}"
packages="${TEST_SHELL_PACKAGES:-seaweedfs seaweedfs-doc bash-completion seaweedfs-master-openrc seaweedfs-filer-openrc seaweedfs-worker-openrc greptimedb lavinmq lavinmq-doc lavinmq-openrc gitea gitea-doc gitea-openrc}"
shell="${TEST_SHELL:-/bin/bash}"
packages="${TEST_SHELL_PACKAGES:-}"
shell="${TEST_SHELL:-/bin/sh}"
timeout_seconds="${TEST_SHELL_TIMEOUT:-120}"
case "${arch}" in
@@ -24,9 +24,23 @@ if [[ ! -d "${repo_root}/packages/local/${arch}" ]]; then
exit 1
fi
docker_args=(--rm --platform "${platform}")
shopt -s nullglob
repo_keys=("${repo_root}/packages/local/${arch}"/*.rsa.pub)
repo_indexes=("${repo_root}/packages/local/${arch}"/APKINDEX.tar.gz)
shopt -u nullglob
if [[ "${#repo_keys[@]}" -eq 0 ]]; then
printf 'missing repository key: packages/local/%s/*.rsa.pub\n' "${arch}" >&2
exit 1
fi
if [[ "${#repo_indexes[@]}" -eq 0 ]]; then
printf 'missing repository index: packages/local/%s/APKINDEX.tar.gz\n' "${arch}" >&2
exit 1
fi
docker_args=(--rm -i --platform "${platform}")
if [[ -t 0 && -t 1 ]]; then
docker_args+=(-it)
docker_args+=(-t)
fi
docker run "${docker_args[@]}" \
@@ -46,31 +60,25 @@ docker run "${docker_args[@]}" \
printf "Refreshing apk indexes...\n"
timeout "${TEST_SHELL_TIMEOUT}" apk update
printf "Installing test packages: %s\n" "${PACKAGE_LIST}"
timeout "${TEST_SHELL_TIMEOUT}" apk add ${PACKAGE_LIST}
if [ -n "${PACKAGE_LIST}" ]; then
printf "Installing requested test packages: %s\n" "${PACKAGE_LIST}"
timeout "${TEST_SHELL_TIMEOUT}" apk add ${PACKAGE_LIST}
fi
printf "\nInstalled default test packages:\n"
apk info -e seaweedfs seaweedfs-doc seaweedfs-bash-completion \
seaweedfs-master-openrc seaweedfs-filer-openrc seaweedfs-worker-openrc \
greptimedb lavinmq lavinmq-doc lavinmq-openrc \
gitea gitea-doc gitea-openrc \
| sort
if command -v weed >/dev/null 2>&1; then
printf "\nSeaweedFS version:\n"
weed version
fi
if command -v greptime >/dev/null 2>&1; then
printf "\nGreptimeDB version:\n"
greptime --version
fi
if command -v lavinmq >/dev/null 2>&1; then
printf "\nLavinMQ version:\n"
lavinmq -v
fi
if command -v gitea >/dev/null 2>&1; then
printf "\nGitea version:\n"
gitea --version
fi
printf "\nEntering %s. Repository mounted read-only at /work.\n\n" "${TEST_SHELL}"
cat <<EOF
Local APK repository is ready.
Repository: /repo
Workspace: /work
Examples:
apk add seaweedfs seaweedfs-master-openrc
apk add greptimedb greptimedb-docs greptimedb-standalone-openrc
apk add lavinmq lavinmq-openrc
apk add gitea gitea-openrc
Entering ${TEST_SHELL}.
EOF
exec "${TEST_SHELL}"
'