code-marketplace: auto updated to 1.95.0-1

This commit is contained in:
Lilac 2024-12-21 07:04:24 +00:00
parent eedc25f10e
commit 91226bbb39
3 changed files with 49 additions and 18 deletions

View file

@ -1,11 +1,14 @@
#!/usr/bin/env python3
# This script can update the content of ./patch.json to the latest version
# Usage: ./update.py /path/to/extracted/produce.json
# Where /path/to/extracted/produce.json is extracted from the latest version of official vscode release
# This script will update the ./patch.json to match the official release
# Usage: ./update.py <version-number>
# Where <version-number> is the version of the official release
import sys
import json
import os
import shutil
import subprocess
import sys
key_list = [
"extensionsGallery",
@ -19,19 +22,38 @@ key_list = [
"extensionAllowedBadgeProviders",
"extensionAllowedBadgeProvidersRegex",
"msftInternalDomains",
"linkProtectionTrustedDomains"
"linkProtectionTrustedDomains",
]
product_path = sys.argv[1]
patch_path = "patch.json"
with open(product_path, "r") as product_file:
product_data = json.load(product_file)
def fetch_product_json(version: str):
"""Download official release and extract it, then copy product.json to project root"""
url = f"https://update.code.visualstudio.com/{version}/linux-x64/stable"
download_cmd = ["curl", "-fSL", "-o", "code.tgz", url]
subprocess.run(download_cmd)
extract_cmd = ["tar", "xvf", "code.tgz"]
subprocess.run(extract_cmd)
shutil.copy(src="./VSCode-linux-x64/resources/app/product.json", dst=".")
shutil.rmtree("./VSCode-linux-x64")
os.remove("code.tgz")
patch_data = {}
for key in key_list:
patch_data[key] = product_data[key]
def update_package():
"""Update the package"""
with open("./product.json", "r") as product_file:
product_data = json.load(product_file)
with open(patch_path, "w") as patch_file:
json.dump(patch_data, patch_file, indent='\t')
patch_data = {}
for key in key_list:
patch_data[key] = product_data[key]
with open("./patch.json", "w") as patch_file:
json.dump(patch_data, patch_file, indent="\t")
subprocess.run(["updpkgsums", "./PKGBUILD"])
version = sys.argv[1]
fetch_product_json(version)
update_package()