update to V2
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
# Pure VirtIO filename helpers shared by TA-ProxMenu and its tests.
|
||||
|
||||
TAPM_VIRTIO_FILENAME_FROM_URL() {
|
||||
local url="${1%%\?*}"
|
||||
local filename="${url##*/}"
|
||||
|
||||
[[ "$filename" =~ ^virtio-win(-0\.1\.[0-9]+)?\.iso$ ]] || return 1
|
||||
printf '%s\n' "$filename"
|
||||
}
|
||||
|
||||
TAPM_VIRTIO_LABELED_FILENAME() {
|
||||
local source_filename="$1"
|
||||
local label="$2"
|
||||
local version=''
|
||||
|
||||
[[ "$label" =~ ^[a-z0-9-]+$ ]] || return 1
|
||||
if [[ "$source_filename" =~ ^virtio-win-(0\.1\.[0-9]+)\.iso$ ]]; then
|
||||
version="${BASH_REMATCH[1]}"
|
||||
elif [[ "$source_filename" != 'virtio-win.iso' ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
printf 'virtio-win-%s%s.iso\n' "$label" "${version:+-${version}}"
|
||||
}
|
||||
|
||||
TAPM_VIRTIO_CACHE_VALID() {
|
||||
local checked_at="${1:-}"
|
||||
local now="${2:-}"
|
||||
local max_age="${3:-}"
|
||||
local filename="${4:-}"
|
||||
|
||||
[[ "$checked_at" =~ ^[0-9]+$ &&
|
||||
"$now" =~ ^[0-9]+$ &&
|
||||
"$max_age" =~ ^[1-9][0-9]*$ &&
|
||||
"$filename" =~ ^virtio-win(-[0-9]+\.[0-9]+\.[0-9]+)?\.iso$ ]] ||
|
||||
return 1
|
||||
(( now >= checked_at && now - checked_at < max_age ))
|
||||
}
|
||||
Reference in New Issue
Block a user