summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Jolly <kangie@gentoo.org>2024-08-30 13:32:47 +1000
committerMatt Jolly <kangie@gentoo.org>2024-08-30 13:39:38 +1000
commit9775b00690b10139b4e1055585b543d17d91d6bf (patch)
treec475e3e13e182aea9185c24034f6c557e0dab4fc
parentadd script to generate libvpx test tarball (diff)
downloadchromium-tools-9775b00690b10139b4e1055585b543d17d91d6bf.tar.gz
chromium-tools-9775b00690b10139b4e1055585b543d17d91d6bf.tar.bz2
chromium-tools-9775b00690b10139b4e1055585b543d17d91d6bf.zip
Replace chromium toolchain script with a faster one using web requests
Signed-off-by: Matt Jolly <kangie@gentoo.org>
-rwxr-xr-xget-chromium-toolchain-strings.py63
-rwxr-xr-xget-opera-version-mapping.py2
-rwxr-xr-xget_chromium_toolchain_strings.sh70
3 files changed, 64 insertions, 71 deletions
diff --git a/get-chromium-toolchain-strings.py b/get-chromium-toolchain-strings.py
new file mode 100755
index 0000000..0582912
--- /dev/null
+++ b/get-chromium-toolchain-strings.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0-or-later
+# This script extracts the revision and sub-revision from the update.py and update_rust.py files in the Chromium source code.
+# The revision and sub-revision are used to identify the version of Clang and Rust used in the Chromium toolchain.
+
+
+import requests
+import sys
+
+
+def get_revision_info(url):
+ """
+ Extracts revision and sub-revision from a Chromium source file URL.
+
+ Args:
+ url (str): The URL of the source file on GitHub's raw endpoint.
+
+ Returns:
+ tuple: A tuple containing the revision (str) and sub-revision (int),
+ or (None, None) if not found.
+ """
+ response = requests.get(url)
+ if response.status_code == 200:
+ text = response.content.decode('utf-8') # Decode to UTF-8
+ lines = text.splitlines()
+ revision = None
+ sub_revision = None
+ for line in lines:
+ if line.startswith("CLANG_REVISION") and not line.startswith("PACKAGE_VERSION"):
+ revision = line.split("=")[1].strip().strip("'")
+ elif line.startswith("CLANG_SUB_REVISION") and not line.startswith("PACKAGE_VERSION"):
+ sub_revision = int(line.split("=")[1].strip())
+ elif line.startswith("RUST_REVISION") and not line.startswith("specieid") and not line.startswith(" return"):
+ # I know that's spelt wrong, but apparently google cant't spell
+ revision = line.split("=")[1].strip().strip("'")
+ elif line.startswith("RUST_SUB_REVISION") and not line.startswith("specieid") and not line.startswith(" return"):
+ sub_revision = int(line.split("=")[1].strip()[-1])
+ if revision is None or sub_revision is None:
+ raise ValueError("Failed to extract revision and sub-revision")
+ return revision, sub_revision
+ else:
+ raise ValueError(f"Failed to get revision info. Status code: {response.status_code}")
+
+
+def main():
+ version = sys.argv[1] if len(sys.argv) > 1 else "128.0.6613.113"
+ # It's a lot easier to use GH raw URLs for this
+ base_url = "https://raw.githubusercontent.com/chromium/chromium/"
+ clang_url = f"{base_url}{version}/tools/clang/scripts/update.py"
+ rust_url = f"{base_url}{version}/tools/rust/update_rust.py"
+ clang_revision, clang_sub_revision = get_revision_info(clang_url)
+ rust_revision, rust_sub_revision = get_revision_info(rust_url)
+ if clang_revision and clang_sub_revision:
+ print(f"clang revision: {clang_revision}-{clang_sub_revision}")
+ else:
+ print("clang revision not found")
+ if rust_revision and rust_sub_revision:
+ print(f"rust revision: {rust_revision}-{rust_sub_revision}")
+ else:
+ print("rust revision not found")
+
+if __name__ == "__main__":
+ main()
diff --git a/get-opera-version-mapping.py b/get-opera-version-mapping.py
index 2b515b4..3e68ec9 100755
--- a/get-opera-version-mapping.py
+++ b/get-opera-version-mapping.py
@@ -103,7 +103,7 @@ def remediate_unknown_versions(versions):
# Example usage
# Base URL with version placeholder
base_url = "https://blogs.opera.com/desktop/changelog-for-{}/"
-opera_chromium_versions = get_opera_chromium_versions(base_url, 100, 110)
+opera_chromium_versions = get_opera_chromium_versions(base_url, 110, 115)
opera_chromium_versions = remediate_unknown_versions(opera_chromium_versions)
diff --git a/get_chromium_toolchain_strings.sh b/get_chromium_toolchain_strings.sh
deleted file mode 100755
index 483d66f..0000000
--- a/get_chromium_toolchain_strings.sh
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/bash
-
-# This script extracts version information from Chromium sources by way of a Gentoo ebuild
-# then plugs the version information into the ebuild file. This is useful for updating the
-# toolchain versions in the ebuild file when a new (major) version of Chromium is released.
-
-# Usage: get_chromium_toolchain_strings.sh <ebuild_file>
-# <ebuild_file>: The path to the Chromium ebuild file
-
-# Extract the version string from an ebuild
-get_version() {
- local filename="$1"
- [[ -z "$filename" ]] && return 1 # Check for empty filename
- local version_match="${filename##*-}"; # Extract everything after the last hyphen
- version_match="${version_match%.*}" # Remove extension (.ebuild)
- echo "$version_match"
-}
-
-# Display script usage
-usage() {
- echo "Usage: get_chromium_toolchain_strings.sh <ebuild_file>"
- echo " <ebuild_file>: The path to the Chromium ebuild file"
-}
-
-# Get the ebuild filename as the first argument
-ebuild_file="$1"
-
-# Check for missing argument
-if [[ -z "$ebuild_file" ]]; then
- echo "Error: Please provide an ebuild filename as an argument."
- usage
- exit 1
-fi
-
-# Extract version from filename
-version="$(get_version "$ebuild_file")"
-
-# Check if version extraction failed (function return code)
-if [[ $? -ne 0 ]]; then
- echo "Error: Could not extract version from filename."
- exit 1
-fi
-
-# Construct S string based on version
-# Bad luck if you don't use /var/tmp/portage, I guess.
-S="/var/tmp/portage/www-client/chromium-${version}/work/chromium-${version}/"
-
-# Run ebuild with clean and unpack options
-ebuild "$ebuild_file" clean unpack
-
-# No secret sauce here - it's just simpler to set the field separator to a single quote
-# and then extract the final character from the sub-revision field.
-# This is a bit of a hack, but it works for now - I haven't see upstream go past the
-# 9th sub-revision yet!
-
-llvm_version=$(awk -F"'" '
-/CLANG_REVISION =/ { revision = $2 }
-/CLANG_SUB_REVISION =/ { printf("%s-%d\n", revision, substr($1, length($1), 1)) }
-' "${S}/tools/clang/scripts/update.py")
-
-rust_version=$(awk -F"'" '
-/RUST_REVISION =/ { revision = $2 }
-/RUST_SUB_REVISION =/ { printf("%s-%d\n", revision, substr($1, length($1), 1)) }
-' "${S}/tools/rust/update_rust.py")
-
-# Substitute versions into ebuild (assuming specific locations)
-sed -i "s/GOOGLE_CLANG_VER=.*/GOOGLE_CLANG_VER=${llvm_version}/" "$ebuild_file"
-sed -i "s/GOOGLE_RUST_VER=.*/GOOGLE_RUST_VER=${rust_version}/" "$ebuild_file"
-
-echo "Successfully substituted versions into $ebuild_file"