This commit is contained in:
@@ -199,6 +199,29 @@ initramfs_build_failed() {
|
||||
(( succeeded == 0 || succeeded < built ))
|
||||
}
|
||||
|
||||
# pacman downloads from the first mirror in this list (system/mirrors.sh keeps
|
||||
# it fresh). Overridable for the tests.
|
||||
MIRRORLIST="${MIRRORLIST:-/etc/pacman.d/mirrorlist}"
|
||||
# A mirror further behind Arch than this is stale; most sync every few hours
|
||||
MIRROR_STALE_HOURS=24
|
||||
|
||||
# The first mirror in MIRRORLIST, without its /$repo/os/$arch
|
||||
first_mirror() {
|
||||
sed -nE 's/^[[:space:]]*Server[[:space:]]*=[[:space:]]*//p' "$MIRRORLIST" 2> /dev/null \
|
||||
| head -n 1 | sed -E 's#/\$repo.*##'
|
||||
}
|
||||
|
||||
# Print how many hours ago the first mirror last synced with Arch, from the
|
||||
# timestamp mirrors publish in lastsync. Fails if it couldn't tell.
|
||||
mirror_age_hours() {
|
||||
local mirror lastsync
|
||||
mirror="$(first_mirror)"
|
||||
[ -n "$mirror" ] || return 1
|
||||
lastsync="$(curl -sf --max-time 10 "$mirror/lastsync" 2> /dev/null)" || return 1
|
||||
[[ "$lastsync" =~ ^[0-9]+$ ]] || return 1
|
||||
echo $(( ($(date +%s) - lastsync) / 3600 ))
|
||||
}
|
||||
|
||||
# Install a script atomically (copy to a temp file, then rename over the target)
|
||||
# so a copy of it that is running right now keeps reading the old file
|
||||
install_script() {
|
||||
|
||||
Reference in New Issue
Block a user