From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-1615291-garchives=archives.gentoo.org@lists.gentoo.org> Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 062C5158041 for <garchives@archives.gentoo.org>; Thu, 28 Mar 2024 02:39:28 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0C8FBE29C2; Thu, 28 Mar 2024 02:39:27 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id DB3C6E29C2 for <gentoo-commits@lists.gentoo.org>; Thu, 28 Mar 2024 02:39:26 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 09A2B34305C for <gentoo-commits@lists.gentoo.org>; Thu, 28 Mar 2024 02:39:26 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 6192D15F4 for <gentoo-commits@lists.gentoo.org>; Thu, 28 Mar 2024 02:39:24 +0000 (UTC) From: "Matt Jolly" <kangie@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Jolly" <kangie@gentoo.org> Message-ID: <1711362422.27d24e85030b0653630c93f123ccc68e310d7dc4.kangie@gentoo> Subject: [gentoo-commits] proj/chromium-tools:master commit in: / X-VCS-Repository: proj/chromium-tools X-VCS-Files: get-opera-version-mapping.py package-chromium-ffmpeg.py X-VCS-Directories: / X-VCS-Committer: kangie X-VCS-Committer-Name: Matt Jolly X-VCS-Revision: 27d24e85030b0653630c93f123ccc68e310d7dc4 X-VCS-Branch: master Date: Thu, 28 Mar 2024 02:39:24 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 780ea182-94de-41a5-9070-a594df9078a3 X-Archives-Hash: 6a6497d7da4628010f98b0e701149033 commit: 27d24e85030b0653630c93f123ccc68e310d7dc4 Author: Matt Jolly <kangie <AT> gentoo <DOT> org> AuthorDate: Mon Mar 25 07:46:52 2024 +0000 Commit: Matt Jolly <kangie <AT> gentoo <DOT> org> CommitDate: Mon Mar 25 10:27:02 2024 +0000 URL: https://gitweb.gentoo.org/proj/chromium-tools.git/commit/?id=27d24e85 automate chromium-ffmpeg packaging Signed-off-by: Matt Jolly <kangie <AT> gentoo.org> get-opera-version-mapping.py | 2 +- package-chromium-ffmpeg.py | 175 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+), 1 deletion(-) diff --git a/get-opera-version-mapping.py b/get-opera-version-mapping.py index 43f8f32..2b515b4 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, 108) +opera_chromium_versions = get_opera_chromium_versions(base_url, 100, 110) opera_chromium_versions = remediate_unknown_versions(opera_chromium_versions) diff --git a/package-chromium-ffmpeg.py b/package-chromium-ffmpeg.py new file mode 100755 index 0000000..5db694e --- /dev/null +++ b/package-chromium-ffmpeg.py @@ -0,0 +1,175 @@ +#!/usr/bin/env python3 + +import re +import os +import logging +import subprocess +import requests + +# Configure logging +logging.basicConfig( + format='%(asctime)s - %(levelname)s - %(message)s', level=logging.INFO, + datefmt='%Y-%m-%d %H:%M:%S') + + +def get_commit(version_url): + """Fetches the git hash from the Chromium ffmpeg submodule URL using requests. + + Args: + version_url: The URL of the Chromium ffmpeg submodule for a specific version. + + Returns: + The git commit hash found in the submodule URL, or None if not found. + """ + try: + # Use requests.get to fetch the URL content + response = requests.get(version_url) + response.raise_for_status() # Raise exception for non-200 status codes + + # Search for commit hash within the 'gitlink-detail' class (adapt if needed) + match = re.search( + r'<div class="gitlink-detail">Submodule link to (.*?) of', response.text) + if match: + return match.group(1) + else: + return None + except requests.exceptions.RequestException as e: + logging.error(f"Error: Failed to fetch URL {version_url} - {e}") + return None + + +def archive_ffmpeg(version, commit_hash): + """Archives the Chromium ffmpeg repository at the specified commit hash. + + Args: + version: The Chromium major version (e.g. 123). + commit_hash: The git commit hash of the desired ffmpeg revision. + """ + # Base directory for ffmpeg checkout (configurable) + ffmpeg_dir = os.getenv("FFMPEG_TEMP_DIR", "/tmp/ffmpeg") + # Archive filename with version substitution + archive_name = f"/tmp/ffmpeg-chromium-{version}.tar.xz" + + repo_uri = "https://chromium.googlesource.com/chromium/third_party/ffmpeg" + + # Check if ffmpeg directory already exists + if os.path.exists(ffmpeg_dir): + # Verify remote URL matches expected repository + try: + output = subprocess.run( + ["git", "remote", "-v"], cwd=ffmpeg_dir, capture_output=True, check=True).stdout.decode() + if not re.search(repo_uri, output, re.MULTILINE): + logging.error( + f"Existing ffmpeg directory {ffmpeg_dir} points to a different remote. Please remove and re-clone.") + exit(1) + except subprocess.CalledProcessError as e: + logging.error(f"Error verifying remote URL: {e}") + exit(1) + + # Update existing repository + try: + subprocess.run(["git", "pull"], cwd=ffmpeg_dir, check=True) + except subprocess.CalledProcessError as e: + logging.error(f"Error updating ffmpeg repository: {e}") + exit(1) + else: + # Clone the Chromium ffmpeg repository + try: + subprocess.run( + ["git", "clone", repo_uri, ffmpeg_dir], check=True) + except subprocess.CalledProcessError as e: + logging.error(f"Error cloning ffmpeg repository: {e}") + exit(1) + + # Archive the ffmpeg directory with prefix and specific commit hash + try: + logging.info( + f"Archiving ffmpeg-chromium@{commit_hash}, this may take a moment...") + subprocess.run(["git", "archive", "--format=tar.xz", "-o", archive_name, + f"--prefix=ffmpeg-chromium-{version}/", commit_hash], cwd=ffmpeg_dir, check=True) + logging.info( + f"ffmpeg-chromium@{commit_hash} archived to {archive_name}") + except subprocess.CalledProcessError as e: + logging.error(f"Error archiving ffmpeg: {e}") + + +def copy_and_update_ebuild(version, commit_hash): + """Copies the latest ffmpeg-chromium.ebuild and updates the COMMIT variable. + + Args: + version: The Chromium version (e.g., 124). + commit_hash: The git commit hash of the desired ffmpeg revision. + """ + # Target directory for ffmpeg-chromium ebuilds (configurable) + ebuild_dir = os.getenv("FFMPEG_EBUILD_DIR", + "/var/db/repos/gentoo/media-video/ffmpeg-chromium") + # Destination ebuild filename with version substitution + dest_ebuild = f"ffmpeg-chromium-{version}.ebuild" + + # Find the highest version ebuild file + highest_version = None + for filename in os.listdir(ebuild_dir): + match = re.match(r"ffmpeg-chromium-(\d+)\.ebuild", filename) + if match: + current_version = int(match.group(1)) + if highest_version is None or current_version > highest_version: + highest_version = current_version + highest_ebuild = os.path.join(ebuild_dir, filename) + # Check if a higher version ebuild exists + if highest_version: + # Copy the highest version ebuild + try: + subprocess.run(["cp", highest_ebuild, + os.path.join(ebuild_dir, dest_ebuild)], + check=True,) + except subprocess.CalledProcessError as e: + logging.error(f"Error copying ebuild file: {e}") + exit(1) + + logging.info( + f"Copied ffmpeg-chromium-{highest_version}.ebuild to {dest_ebuild}" + ) + + # Update the COMMIT variable in the copied ebuild + with open(os.path.join(ebuild_dir, dest_ebuild), "r+") as f: + lines = f.readlines() + for i, line in enumerate(lines): + if line.startswith("COMMIT="): + lines[i] = f"COMMIT={commit_hash}\n" + f.seek(0) + f.writelines(lines) + logging.info( + f"Updated COMMIT variable in {dest_ebuild} to {commit_hash}") + break + else: + logging.info( + f"No existing ffmpeg-chromium ebuilds found in {ebuild_dir}") + + +def main(): + """Main function to handle user input and script execution.""" + version_regex = r"^\d+\.\d+(?:\.\d+(?:\.\d+)?)?$" # Validate version format + + while True: + version = input("Enter Chromium version (e.g., 123.0.4567.890): ") + if re.match(version_regex, version): + break + else: + print( + "Invalid version format. Please enter a version like X.Y.Z.W (e.g., 123.0.4567.890)") + + version_url = f"https://chromium.googlesource.com/chromium/src.git/+/refs/tags/{version}/third_party/ffmpeg" + commit_hash = get_commit(version_url) + if commit_hash: + logging.info( + f"Chromium version {version} uses ffmpeg commit {commit_hash}") + major_version = version.split(".")[0] + archive_ffmpeg(major_version, commit_hash) + copy_and_update_ebuild(major_version, commit_hash) + else: + logging.error( + f"Failed to retrieve commit hash for Chromium version {version}") + + +if __name__ == "__main__": + main()