nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 53 lines 2.2 kB view raw
1#!/usr/bin/env nix-shell 2#!nix-shell -i bash -p curl jq libxml2 3 4set -eu -o pipefail 5 6nixpkgs="$(git rev-parse --show-toplevel)" 7path="$nixpkgs/pkgs/by-name/pr/prl-tools/package.nix" 8 9# Currently this script only supports Parallels 26 10# Please change the knowledge base url after each major release 11kb_url="https://kb.parallels.com/en/131014" 12content="$(curl -s "$kb_url")" 13 14# Extract all version/build pairs and select the latest (by semver, then build) 15# Prefer the article content; fallback to whole body text 16article_text="$(echo "$content" | xmllint --recover --html --xpath 'string(//div[@id="article-content"])' - 2>/dev/null || true)" 17if [[ -z "${article_text:-}" ]]; then 18 article_text="$(echo "$content" | xmllint --recover --html --xpath 'string(//body)' - 2>/dev/null || echo "$content")" 19fi 20 21# Find all "X.Y.Z (BUILD)" occurrences like "20.4.1 (55996)" 22mapfile -t candidates < <(echo "$article_text" \ 23 | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+[[:space:]]*\(([0-9]+)\)' \ 24 | sed -E 's/([0-9]+\.[0-9]+\.[0-9]+)[[:space:]]*\(([0-9]+)\)/\1 \2/' \ 25 | sort -u) 26 27if [[ ${#candidates[@]} -eq 0 ]]; then 28 echo "Failed to extract any version from $kb_url" >&2 29 exit 1 30fi 31 32# Sort by version then build and pick the highest 33latest_pair="$(printf '%s\n' "${candidates[@]}" | sort -V -k1,1 -k2,2n | tail -n1)" 34latest_ver="$(awk '{print $1}' <<< "$latest_pair")" 35latest_build="$(awk '{print $2}' <<< "$latest_pair")" 36version="${latest_ver}-${latest_build}" 37echo "Found latest version: $version" 38 39# Extract and compare current version 40old_version="$(grep -o 'version = ".*"' "$path" | awk -F'"' '{print $2}')" 41if [[ "$old_version" > "$version" || "$old_version" == "$version" ]]; then 42 echo "Current version $old_version is up-to-date" 43 exit 0 44fi 45 46# Update version and hash 47major_version="$(echo "$version" | cut -d. -f1)" 48dmg_url="https://download.parallels.com/desktop/v${major_version}/${version}/ParallelsDesktop-${version}.dmg" 49sha256="$(nix store prefetch-file "$dmg_url" --json | jq -r '.hash')" 50sed -i -e "s,version = \"$old_version\",version = \"$version\"," \ 51 -e "s,hash = \"sha256-.*\",hash = \"$sha256\"," "$path" 52 53echo "Updated linuxPackages_latest.prl-tools $old_version -> $version"