Unverified Commit ed0f0dde authored by codgician's avatar codgician
Browse files

linuxPackages_latest.prl-tools: fix regex used in updater script to comply with latest webpage

parent 7045aa75
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -12,13 +12,12 @@ kb_url="https://kb.parallels.com/en/130212"
content="$(curl -s "$kb_url")"

# Match latest version from Parallels knowledge base
regex='<meta property="og:description" content="[^"]*Parallels Desktop ([0-9]+) for Mac ([0-9]+\.[0-9]+\.[0-9+]) \(([0-9]+)\)[^"]*" />'
regex='<meta property="og:description" content="[^"]*Parallels Desktop[\ 0-9]*for Mac ([0-9]+\.[0-9]+\.[0-9+]) \(([0-9]+)\)[^"]*" />'
if [[ $content =~ $regex ]]; then
    major_version="${BASH_REMATCH[1]}"
    version="${BASH_REMATCH[2]}-${BASH_REMATCH[3]}"
    echo "Found latest version: $version, major version: $major_version"
    version="${BASH_REMATCH[1]}-${BASH_REMATCH[2]}"
    echo "Found latest version: $version"
else
    echo "Failed to extract version from $kb_url"
    echo "Failed to extract version from $kb_url" >&2
    exit 1
fi

@@ -30,10 +29,11 @@ if [[ "$old_version" > "$version" || "$old_version" == "$version" ]]; then
fi

# Update version and hash
major_version=$(echo $version | cut -d. -f1)
dmg_url="https://download.parallels.com/desktop/v${major_version}/${version}/ParallelsDesktop-${version}.dmg"
sha256="$(nix store prefetch-file $dmg_url --json | jq -r '.hash')"
sed -i -e "s/version = \"$old_version\"/version = \"$version\"/" \
    -e "s/hash = \"sha256-.*\"/hash = \"$sha256\"/" "$path"
sed -i -e "s,version = \"$old_version\",version = \"$version\"," \
    -e "s,hash = \"sha256-.*\",hash = \"$sha256\"," "$path"

git commit -qm "linuxPackages_latest.prl-tools: $old_version -> $version" "$path"
echo "Updated linuxPackages_latest.prl-tools $old_version -> $version"