From 888a7effec00a3252b0bbaed0a4b8e56efac6499 Mon Sep 17 00:00:00 2001 From: codgician <15964984+codgician@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:17:49 +0800 Subject: [PATCH] linuxPackages_latest.prl-tools: use libxml2 to parse html in update script --- pkgs/os-specific/linux/prl-tools/update.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkgs/os-specific/linux/prl-tools/update.sh b/pkgs/os-specific/linux/prl-tools/update.sh index fad989127aed..b1000fbd966c 100755 --- a/pkgs/os-specific/linux/prl-tools/update.sh +++ b/pkgs/os-specific/linux/prl-tools/update.sh @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash -p curl jq +#!nix-shell -i bash -p curl jq libxml2 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" content="$(curl -s "$kb_url")" -# Match latest version from Parallels knowledge base -regex='' -if [[ $content =~ $regex ]]; then +# Parse HTML content and retrieve og:description for header metadata +description=$(echo "$content" | xmllint --recover --html --xpath 'string(//meta[@property="og:description"]/@content)' - 2>/dev/null) +regex='[^0-9]+([0-9]+\.[0-9]+\.[0-9]+)[^\(]+\(([0-9]+)\)' +if [[ $description =~ $regex ]]; then version="${BASH_REMATCH[1]}-${BASH_REMATCH[2]}" echo "Found latest version: $version" else echo "Failed to extract version from $kb_url" >&2 + echo "Retrived description: $description" >&2 exit 1 fi