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,  5 Feb 2022 16:29:17 +0000 (UTC)	[thread overview]
Message-ID: <1644078552.46e5883adc29ea0ae920800a449db4684004dc3a.sultan@gentoo> (raw)

commit:     46e5883adc29ea0ae920800a449db4684004dc3a
Author:     Stephan Hartmann <sultan <AT> gentoo <DOT> org>
AuthorDate: Sat Feb  5 16:28:38 2022 +0000
Commit:     Stephan Hartmann <sultan <AT> gentoo <DOT> org>
CommitDate: Sat Feb  5 16:29:12 2022 +0000
URL:        https://gitweb.gentoo.org/proj/chromium-tools.git/commit/?id=46e5883a

bump_chrome.py: add revision and dry run support

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

 bump_chrome.py | 99 ++++++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 66 insertions(+), 33 deletions(-)

diff --git a/bump_chrome.py b/bump_chrome.py
index a046815..dadc059 100755
--- a/bump_chrome.py
+++ b/bump_chrome.py
@@ -6,6 +6,7 @@ import os
 import shutil
 import sys
 import urllib.request
+import subprocess
 
 from portage.dbapi.porttree import portdbapi
 from portage.versions import *
@@ -25,7 +26,7 @@ pkg_data = \
             "suffix"  : None,
             "version" : None,
             "bump"    : False,
-            "stable"  : False
+            "stable"  : True
         },
         "beta"   :
         {
@@ -102,9 +103,13 @@ def getPrevChannel(channel):
             return channel_list[i + 1]
     raise ValueError(f"Unknown channel \"{channel}\".")
 
+def getEbuildVersion(version):
+    if version[1] == "r0":
+        return version[0]
+    return f"{version[0]}-{version[1]}"
+
 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()
 
@@ -134,13 +139,14 @@ def main():
             pkg_data[category][channel]["version"] = None
             for cpv in cpvs:
                 (cp, version, rev) = pkgsplit(mypkg=cpv)
-                suffix = pkg_data[category][channel]['suffix']
+                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)]
+                        pkg_data[category][channel]["version"] = (version[:-len(suffix)],
+                                                                  rev)
                 elif not "_" in version:
-                    pkg_data[category][channel]["version"] = version
+                    pkg_data[category][channel]["version"] = (version, rev)
             if pkg_data[category][channel]["version"] is None:
                 output.ewarn("Couldn't determine tree version for "+
                              "{category}/{pkg}")
@@ -154,7 +160,7 @@ def main():
             for category in pkg_data.keys():
                 pkg_data[category][channel]["bump"] = False
                 ver_info = vercmp(chrome_info[channel],
-                                  pkg_data[category][channel]["version"])
+                                  pkg_data[category][channel]["version"][0])
                 if ver_info is None:
                     output.ewarn("Cannot determine new version for " +
                                  f"channel \"{channel}\" of " +
@@ -174,23 +180,26 @@ def main():
             output.einfo(f"{category}/{pkg} version information:")
             need_bump = pkg_data[category][channel]["bump"]
             uversion  = chrome_info[channel]
-            tversion  = pkg_data[category][channel]["version"]
+            tversion  = getEbuildVersion(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)
+    if not args.dry_run:
+        repo = Repo(repo_path)
+        if repo.is_dirty():
+            output.eerror("Git Repository is dirty, can't continue.")
+            sys.exit(1)
+
+        index = repo.index
 
-    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)
+            tversion   = getEbuildVersion(pkg_data[category][channel]["version"])
+            major_bump = isMajorBump(uversion=uversion,
+                                     tversion=pkg_data[category][channel]["version"][0])
             pkg        = pkg_data[category][channel]["pkg"]
             suffix     = pkg_data[category][channel]["suffix"]
             if suffix is not None:
@@ -201,58 +210,82 @@ def main():
             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_version = getEbuildVersion(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,
+                from_ebuild = os.path.join(category,
                                            prev_pkg,
                                            prev_pkg + "-" +
                                            prev_version + prev_suffix +
                                            ".ebuild")
             else:
-                from_ebuild = os.path.join(repo_path,
-                                           category,
+                from_ebuild = os.path.join(category,
                                            pkg,
                                            pkg + "-" +
                                            tversion + suffix +
                                            ".ebuild")
-            to_ebuild = os.path.join(repo_path,
-                                     category,
+            to_ebuild = os.path.join(category,
                                      pkg,
                                      pkg + "-" +
                                      uversion + suffix +
                                      ".ebuild")
 
-            shutil.copyfile(from_ebuild, to_ebuild)
+            if args.dry_run:
+                print(f"cp {from_ebuild} {to_ebuild}")
+                if not major_bump:
+                    print(f"git rm {from_ebuild}")
+            else:
+                from_ebuild = os.path.join(repo_path, from_ebuild)
+                shutil.copyfile(from_ebuild,
+                                os.path.join(repo_path, to_ebuild))
+                if not major_bump:
+                    index.remove(from_ebuild, working_tree=True)
 
-            index.add(to_ebuild)
             if major_bump:
-                old_ebuild = os.path.join(repo_path,
-                                          category,
+                old_ebuild = os.path.join(category,
                                           pkg,
                                           pkg + "-" +
                                           tversion + suffix +
                                           ".ebuild")
-                index.remove(old_ebuild, working_tree=True)
+                if args.dry_run:
+                    print(f"git rm {old_ebuild}")
+                else:
+                    index.remove(os.path.join(repo_path, old_ebuild),
+                                 working_tree=True)
+                if pkg_data[category][channel]["stable"]:
+                    if args.dry_run:
+                        print(f"ekeyword amd64 {to_ebuild}")
+                    else:
+                        subprocess.run(["ekeyword", "amd64",
+                                        os.path.join(repo_path, to_ebuild)])
+
+            if args.dry_run:
+                print(f"git add {to_ebuild}")
             else:
-                index.remove(from_ebuild, working_tree=True)
+                to_ebuild = os.path.join(repo_path, to_ebuild)
+                index.add(to_ebuild)
 
             to_path = os.path.dirname(to_ebuild)
             cfg = config.config()
             cfg["O"] = to_path
 
-            digestgen.digestgen(None, cfg, db)
+            if args.dry_run:
+                print(f"git add {os.path.join(to_path, 'Manifest')}")
+                print("git commit -m",
+                      f"\"{category}/{pkg}: automated update",
+                      f"({uversion}{suffix})",
+                      "-s -S\"")
+            else:
+                digestgen.digestgen(None, cfg, db)
 
-            index.add(os.path.join(to_path, "Manifest"))
+                index.add(os.path.join(to_path, "Manifest"))
 
-            repo.git.commit("-m",
-                            f"{category}/{pkg}: automated update ({uversion})",
-                            "-s", "-S")
+                repo.git.commit("-m",
+                                f"{category}/{pkg}: automated update ({uversion}{suffix})",
+                                "-s", "-S")
 
 if __name__ == "__main__":
     main()


             reply	other threads:[~2022-02-05 16:29 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-05 16:29 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-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=1644078552.46e5883adc29ea0ae920800a449db4684004dc3a.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