public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Stephan Hartmann" <sultan@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/chromium-tools:master commit in: /
Date: Sat, 21 Nov 2020 19:34:48 +0000 (UTC)	[thread overview]
Message-ID: <1605987278.7e33e3e27556dd8c7774b5b2ec94250c4e687f50.sultan@gentoo> (raw)

commit:     7e33e3e27556dd8c7774b5b2ec94250c4e687f50
Author:     Stephan Hartmann <sultan <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 21 19:34:38 2020 +0000
Commit:     Stephan Hartmann <sultan <AT> gentoo <DOT> org>
CommitDate: Sat Nov 21 19:34:38 2020 +0000
URL:        https://gitweb.gentoo.org/proj/chromium-tools.git/commit/?id=7e33e3e2

Add alternative chrome bump script

Signed-off-by: Stephan Hartmann <sultan <AT> gentoo.org>

 bump_chrome.py | 258 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 258 insertions(+)

diff --git a/bump_chrome.py b/bump_chrome.py
new file mode 100755
index 0000000..a046815
--- /dev/null
+++ b/bump_chrome.py
@@ -0,0 +1,258 @@
+#!/bin/env python3
+
+import argparse
+import json
+import os
+import shutil
+import sys
+import urllib.request
+
+from portage.dbapi.porttree import portdbapi
+from portage.versions import *
+from portage.package.ebuild import digestgen, config
+from portage.output import EOutput
+
+from git import Repo
+
+channels = ["stable", "beta", "dev"]
+pkg_data = \
+{
+    "www-client" :
+    {
+        "stable" :
+        {
+            "pkg"     : "google-chrome",
+            "suffix"  : None,
+            "version" : None,
+            "bump"    : False,
+            "stable"  : False
+        },
+        "beta"   :
+        {
+            "pkg"     : "google-chrome-beta",
+            "suffix"  : None,
+            "version" : None,
+            "bump"    : False,
+            "stable"  : False
+        },
+        "dev"    :
+        {
+            "pkg"     : "google-chrome-unstable",
+            "suffix"  : None,
+            "version" : None,
+            "bump"    : False,
+            "stable"  : False
+        }
+    },
+    "www-plugins" :
+    {
+        "stable" :
+        {
+            "pkg"     : "chrome-binary-plugins",
+            "suffix"  : None,
+            "version" : None,
+            "bump"    : False,
+            "stable"  : True
+        },
+        "beta" :
+        {
+            "pkg"     : "chrome-binary-plugins",
+            "suffix"  : "beta",
+            "version" : None,
+            "bump"    : False,
+            "stable"  : False
+        },
+        "dev"  :
+        {
+            "pkg"     : "chrome-binary-plugins",
+            "suffix"  : "alpha",
+            "version" : None,
+            "bump"    : False,
+            "stable"  : False
+        }
+    }
+}
+
+def getChromeVersionData(base_url, os):
+    if not base_url.endswith("/"):
+        url = base_url + "/"
+    url += f"all.json?os={os}"
+
+    response = urllib.request.urlopen(url)
+    data = json.loads(response.read())
+    return data[0]["versions"]
+
+def getChromeChannelVersion(versions, channel):
+    for item in versions:
+        if item["channel"] == channel:
+            return item["current_version"]
+    return None
+
+def isMajorBump(uversion, tversion):
+    uv_list = uversion.split('.')
+    tv_list = tversion.split('.')
+    if int(uv_list[0]) > int(tv_list[0]):
+        return True
+    return False
+
+def getPrevChannel(channel):
+    channel_list = channels + [channels[len(channels) - 1]]
+    for i in range(0, len(channel_list) - 1):
+        if channel_list[i] == channel:
+            return channel_list[i + 1]
+    raise ValueError(f"Unknown channel \"{channel}\".")
+
+def main():
+    parser = argparse.ArgumentParser()
+    parser.add_argument('--commit', '-c', action='store_true')
+    parser.add_argument('--dry-run', '-n', action='store_true')
+    args = parser.parse_args()
+
+    output = EOutput()
+
+    output.einfo("Fetching upstream version information ...")
+
+    versions = getChromeVersionData(base_url="https://omahaproxy.appspot.com",
+                                    os="linux")
+
+    chrome_info = {}
+    for channel in channels:
+        chrome_info[channel] = None
+
+    for channel in channels:
+        chrome_info[channel] = getChromeChannelVersion(versions=versions,
+                                                       channel=channel)
+
+    output.einfo("Looking up Chrome version information in tree ...")
+
+    db = portdbapi()
+    repo_path = db.getRepositoryPath(repository_id="gentoo")
+    for category in pkg_data.keys():
+        for channel in channels:
+            pkg  = pkg_data[category][channel]["pkg"]
+            cpvs = db.cp_list(mycp=f"{category}/{pkg}", mytree=repo_path)
+            pkg_data[category][channel]["version"] = None
+            for cpv in cpvs:
+                (cp, version, rev) = pkgsplit(mypkg=cpv)
+                suffix = pkg_data[category][channel]['suffix']
+                if suffix is not None:
+                    suffix = "_" + suffix
+                    if version.endswith(suffix):
+                        pkg_data[category][channel]["version"] = version[:-len(suffix)]
+                elif not "_" in version:
+                    pkg_data[category][channel]["version"] = version
+            if pkg_data[category][channel]["version"] is None:
+                output.ewarn("Couldn't determine tree version for "+
+                             "{category}/{pkg}")
+
+    output.einfo("Comparing Chrome version informations ...")
+
+    for channel in channels:
+        if chrome_info[channel] is None:
+            output.ewarn(f"Upstream version unknown for channel \"{channel}\".")
+        else:
+            for category in pkg_data.keys():
+                pkg_data[category][channel]["bump"] = False
+                ver_info = vercmp(chrome_info[channel],
+                                  pkg_data[category][channel]["version"])
+                if ver_info is None:
+                    output.ewarn("Cannot determine new version for " +
+                                 f"channel \"{channel}\" of " +
+                                 f"{category}/" +
+                                 f"{pkg_data[category][channel]['pkg']}.")
+                elif ver_info > 0:
+                    pkg_data[category][channel]["bump"] = True
+                elif ver_info < 0:
+                    output.ewarn("Upstream reverted bump for " +
+                                 f"channel \"{channel}\" of " +
+                                 f"{category}/" +
+                                 f"{pkg_data[category][channel]['pkg']}.")
+
+    for category in pkg_data.keys():
+        for channel in channels:
+            pkg = pkg_data[category][channel]["pkg"]
+            output.einfo(f"{category}/{pkg} version information:")
+            need_bump = pkg_data[category][channel]["bump"]
+            uversion  = chrome_info[channel]
+            tversion  = pkg_data[category][channel]["version"]
+            output.einfo(f"\t{channel}\t{tversion}\t{uversion}" +
+                         f"\t==> {'bump' if need_bump else 'no bump'}")
+
+    repo = Repo(repo_path)
+    if repo.is_dirty():
+        output.eerror("Git Repository is dirty, can't continue.")
+        sys.exit(1)
+
+    index = repo.index
+    for channel in channels:
+        for category in pkg_data.keys():
+            if not pkg_data[category][channel]["bump"]:
+                continue
+            uversion   = chrome_info[channel]
+            tversion   = pkg_data[category][channel]["version"]
+            major_bump = isMajorBump(uversion=uversion, tversion=tversion)
+            pkg        = pkg_data[category][channel]["pkg"]
+            suffix     = pkg_data[category][channel]["suffix"]
+            if suffix is not None:
+                suffix = "_" + suffix
+            else:
+                suffix = ""
+            output.einfo(f"Bumping {category}/{pkg} ...")
+            if major_bump:
+                prev_channel = getPrevChannel(channel=channel)
+                prev_pkg     = pkg_data[category][prev_channel]["pkg"]
+                prev_version = pkg_data[category][prev_channel]["version"]
+                prev_suffix  = pkg_data[category][prev_channel]["suffix"]
+                print(prev_pkg)
+                if prev_suffix is not None:
+                    prev_suffix = "_" + prev_suffix
+                else:
+                    prev_suffix = ""
+                from_ebuild = os.path.join(repo_path,
+                                           category,
+                                           prev_pkg,
+                                           prev_pkg + "-" +
+                                           prev_version + prev_suffix +
+                                           ".ebuild")
+            else:
+                from_ebuild = os.path.join(repo_path,
+                                           category,
+                                           pkg,
+                                           pkg + "-" +
+                                           tversion + suffix +
+                                           ".ebuild")
+            to_ebuild = os.path.join(repo_path,
+                                     category,
+                                     pkg,
+                                     pkg + "-" +
+                                     uversion + suffix +
+                                     ".ebuild")
+
+            shutil.copyfile(from_ebuild, to_ebuild)
+
+            index.add(to_ebuild)
+            if major_bump:
+                old_ebuild = os.path.join(repo_path,
+                                          category,
+                                          pkg,
+                                          pkg + "-" +
+                                          tversion + suffix +
+                                          ".ebuild")
+                index.remove(old_ebuild, working_tree=True)
+            else:
+                index.remove(from_ebuild, working_tree=True)
+
+            to_path = os.path.dirname(to_ebuild)
+            cfg = config.config()
+            cfg["O"] = to_path
+
+            digestgen.digestgen(None, cfg, db)
+
+            index.add(os.path.join(to_path, "Manifest"))
+
+            repo.git.commit("-m",
+                            f"{category}/{pkg}: automated update ({uversion})",
+                            "-s", "-S")
+
+if __name__ == "__main__":
+    main()


             reply	other threads:[~2020-11-21 19:34 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-21 19:34 Stephan Hartmann [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-03-10 13:43 [gentoo-commits] proj/chromium-tools:master commit in: / Matt Jolly
2025-03-10 13:43 Matt Jolly
2024-10-23  3:50 Matt Jolly
2024-10-23  3:50 Matt Jolly
2024-10-10 21:52 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-28  2:39 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-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=1605987278.7e33e3e27556dd8c7774b5b2ec94250c4e687f50.sultan@gentoo \
    --to=sultan@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