Files
TA-ProxMenu/inc/virtio-helpers.inc
T
2026-07-25 19:35:17 -05:00

26 lines
660 B
Bash

#!/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}}"
}