public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Matt Jolly" <kangie@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/chromium-tools:master commit in: /
Date: Thu, 28 Mar 2024 02:39:24 +0000 (UTC)	[thread overview]
Message-ID: <1711362422.27d24e85030b0653630c93f123ccc68e310d7dc4.kangie@gentoo> (raw)

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()


             reply	other threads:[~2024-03-28  2:39 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28  2:39 Matt Jolly [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-10-10 21:52 [gentoo-commits] proj/chromium-tools:master commit in: / Matt Jolly
2024-10-10 10:03 Matt Jolly
2024-09-27  0:52 Matt Jolly
2024-09-27  0:52 Matt Jolly
2024-09-27  0:52 Matt Jolly
2024-09-26  7:25 Matt Jolly
2024-09-26  5:29 Matt Jolly
2024-09-26  5:21 Matt Jolly
2024-09-26  3:03 Matt Jolly
2024-09-26  2:39 Matt Jolly
2024-09-26  2:36 Matt Jolly
2024-08-30  3:39 Matt Jolly
2024-06-01  7:22 Matt Jolly
2024-05-31 23:02 Matt Jolly
2024-03-20 21:45 Matt Jolly
2024-03-20 21:45 Matt Jolly
2024-03-20 21:45 Matt Jolly
2024-03-20 21:45 Matt Jolly
2023-02-05 15:09 Stephan Hartmann
2022-09-01 19:33 Mike Gilbert
2022-09-01 19:24 Mike Gilbert
2022-05-06  9:55 Stephan Hartmann
2022-05-03 16:54 Mike Gilbert
2022-05-03 16:54 Mike Gilbert
2022-02-11 17:16 Stephan Hartmann
2022-02-05 16:29 Stephan Hartmann
2022-01-31 20:20 Stephan Hartmann
2020-11-21 19:34 Stephan Hartmann
2020-10-26 17:48 Mike Gilbert
2016-09-15 16:15 Mike Gilbert
2016-09-15 16:11 Mike Gilbert
2015-08-13 20:53 Mike Gilbert
2012-07-31 23:27 Mike Gilbert
2012-07-31 20:39 Mike Gilbert
2012-06-18  7:38 Paweł Hajdan
2011-10-25 16:36 Paweł Hajdan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1711362422.27d24e85030b0653630c93f123ccc68e310d7dc4.kangie@gentoo \
    --to=kangie@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox