linuxPackages_latest.prl-tools: use libxml2 to parse html in update script
This commit is contained in:
parent
478d963e3c
commit
888a7effec
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env nix-shell
|
||||||
#!nix-shell -i bash -p curl jq
|
#!nix-shell -i bash -p curl jq libxml2
|
||||||
|
|
||||||
set -eu -o pipefail
|
set -eu -o pipefail
|
||||||
|
|
||||||
@ -11,13 +11,15 @@ path="$nixpkgs/pkgs/os-specific/linux/prl-tools/default.nix"
|
|||||||
kb_url="https://kb.parallels.com/en/130212"
|
kb_url="https://kb.parallels.com/en/130212"
|
||||||
content="$(curl -s "$kb_url")"
|
content="$(curl -s "$kb_url")"
|
||||||
|
|
||||||
# Match latest version from Parallels knowledge base
|
# Parse HTML content and retrieve og:description for header metadata
|
||||||
regex='<meta property="og:description" content="[^"]*Parallels Desktop[\ 0-9]*for Mac ([0-9]+\.[0-9]+\.[0-9+]) \(([0-9]+)\)[^"]*" />'
|
description=$(echo "$content" | xmllint --recover --html --xpath 'string(//meta[@property="og:description"]/@content)' - 2>/dev/null)
|
||||||
if [[ $content =~ $regex ]]; then
|
regex='[^0-9]+([0-9]+\.[0-9]+\.[0-9]+)[^\(]+\(([0-9]+)\)'
|
||||||
|
if [[ $description =~ $regex ]]; then
|
||||||
version="${BASH_REMATCH[1]}-${BASH_REMATCH[2]}"
|
version="${BASH_REMATCH[1]}-${BASH_REMATCH[2]}"
|
||||||
echo "Found latest version: $version"
|
echo "Found latest version: $version"
|
||||||
else
|
else
|
||||||
echo "Failed to extract version from $kb_url" >&2
|
echo "Failed to extract version from $kb_url" >&2
|
||||||
|
echo "Retrived description: $description" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user