Skip to content

Commit

Permalink
Fixes issues with upgrade_v8.
Browse files Browse the repository at this point in the history
* The omahaproxy.appspot.com server is gone.
* The new dashboard only provides commit hashes.
  • Loading branch information
tommie committed Dec 24, 2023
1 parent 889acfd commit b95fac9
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions deps/upgrade_v8.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
package include
import (
%s
\t%s
)
"""

CHROME_VERSIONS_URL = "https://omahaproxy.appspot.com/all.json?os=linux&channel=stable"
CHROME_VERSIONS_URL = "https://chromiumdash.appspot.com/fetch_releases?channel=Stable&platform=Linux&num=1&offset=0"
V8_VERSION_FILE = "v8_version"

deps_path = os.path.dirname(os.path.realpath(__file__))
Expand Down Expand Up @@ -55,7 +55,7 @@ def create_include_vendor_file(src_path, directories):
package_names.append(package_name(directory_name, index, total_directories))

with open(os.path.join(src_path, 'vendor.go'), 'w') as temp_file:
temp_file.write(include_vendor_file_template % (' '.join(package_names)))
temp_file.write(include_vendor_file_template % ('\t'.join(package_names)))

def create_vendor_files(src_path):
directories = get_directories_names(src_path)
Expand All @@ -75,36 +75,37 @@ def create_vendor_files(src_path):

def update_v8_version_file(src_path, version):
with open(os.path.join(src_path, V8_VERSION_FILE), "w") as v8_file:
v8_file.write(version)
print(version, file=v8_file)

def read_v8_version_file(src_path):
v8_version_file = open(os.path.join(src_path, V8_VERSION_FILE), "r")
return v8_version_file.read().strip()

def get_latest_v8_info():
def get_latest_v8_hash():
with urllib.request.urlopen(CHROME_VERSIONS_URL) as response:
json_response = response.read()
return json.loads(json_response)[0]["hashes"]["v8"]

return json.loads(json_response)
def get_v8_version_tag():
tags = subprocess.check_output(["git", "tag", "--points-at", latest_stable_v8_hash], cwd=v8_path, env=env).decode('utf-8')
return tags.split(os.linesep)[0]

# Current version
current_v8_version_installed = read_v8_version_file(deps_path)
current_v8_hash_installed = read_v8_version_file(deps_path)

# Get latest version
latest_v8_info = get_latest_v8_info()
latest_stable_v8_hash = get_latest_v8_hash()

latest_stable_v8_version = latest_v8_info[0]["versions"][0]["v8_version"]

if current_v8_version_installed != latest_stable_v8_version:
subprocess.check_call(["git", "fetch", "origin", latest_stable_v8_version],
if current_v8_hash_installed != latest_stable_v8_hash:
subprocess.check_call(["git", "fetch", "origin", latest_stable_v8_hash],
cwd=v8_path,
env=env)
# checkout latest stable commit
subprocess.check_call(["git", "checkout", latest_stable_v8_version],
latest_stable_v8_version = get_v8_version_tag()
subprocess.check_call(["git", "-c", "advice.detachedHead=false", "checkout", latest_stable_v8_version],
cwd=v8_path,
env=env)

shutil.rmtree(deps_include_path)
shutil.copytree(v8_include_path, deps_include_path, dirs_exist_ok=True)
create_vendor_files(deps_include_path)
update_v8_version_file(deps_path, latest_stable_v8_version)
update_v8_version_file(deps_path, latest_stable_v8_hash)

0 comments on commit b95fac9

Please sign in to comment.