1 |
commit: 681e72c7924ed57d7b73183fb07e28f4fb524919 |
2 |
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue May 3 16:53:01 2022 +0000 |
4 |
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue May 3 16:53:32 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/chromium-tools.git/commit/?id=681e72c7 |
7 |
|
8 |
Remove old chrome-bump script |
9 |
|
10 |
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org> |
11 |
|
12 |
chrome-bump | 148 ------------------------------------------------------------ |
13 |
1 file changed, 148 deletions(-) |
14 |
|
15 |
diff --git a/chrome-bump b/chrome-bump |
16 |
deleted file mode 100755 |
17 |
index 1b138e5..0000000 |
18 |
--- a/chrome-bump |
19 |
+++ /dev/null |
20 |
@@ -1,148 +0,0 @@ |
21 |
-#!/usr/bin/env python |
22 |
- |
23 |
-from __future__ import print_function |
24 |
- |
25 |
-import argparse |
26 |
-from contextlib import closing |
27 |
-from debian import deb822 |
28 |
-from glob import glob |
29 |
-import os |
30 |
-import os.path |
31 |
-import portage |
32 |
-import shutil |
33 |
-import subprocess |
34 |
-import sys |
35 |
-try: |
36 |
- from urllib.request import urlopen |
37 |
-except ImportError: |
38 |
- from urllib2 import urlopen |
39 |
- |
40 |
-ARCHIVE = 'https://dl.google.com/linux/chrome/deb' |
41 |
-DIST = 'stable' |
42 |
-COMP = 'main' |
43 |
-ARCH = 'amd64' |
44 |
- |
45 |
-PORTDIR = portage.settings.repositories['gentoo'].location |
46 |
- |
47 |
-PKGMAP = { |
48 |
- 'www-client/google-chrome': { |
49 |
- '*.ebuild': ('', 'google-chrome-stable'), |
50 |
- }, |
51 |
- 'www-client/google-chrome-beta': { |
52 |
- '*.ebuild': ('', 'google-chrome-beta'), |
53 |
- }, |
54 |
- 'www-client/google-chrome-unstable': { |
55 |
- '*.ebuild': ('', 'google-chrome-unstable'), |
56 |
- }, |
57 |
- 'www-plugins/chrome-binary-plugins': { |
58 |
- '*[0123456789].ebuild': ('', 'google-chrome-stable'), |
59 |
- '*_beta*.ebuild': ('_beta', 'google-chrome-beta'), |
60 |
- '*_alpha*.ebuild': ('_alpha', 'google-chrome-unstable'), |
61 |
- }, |
62 |
-} |
63 |
- |
64 |
-ARGS = None |
65 |
- |
66 |
-def get_deb_release(archive, dist): |
67 |
- url = '%s/dists/%s/Release' % (archive, dist) |
68 |
- with closing(urlopen(url)) as fp: |
69 |
- return deb822.Release(fp) |
70 |
- |
71 |
-def get_deb_packages(archive, dist, comp, arch): |
72 |
- url = '%s/dists/%s/%s/binary-%s/Packages' % (archive, dist, comp, arch) |
73 |
- with closing(urlopen(url)) as fp: |
74 |
- return list(deb822.Packages.iter_paragraphs(fp, use_apt_pkg=False)) |
75 |
- |
76 |
-def ebuild_pvr(pn, ebuild): |
77 |
- return ebuild[len(pn) + 1 : -7] |
78 |
- |
79 |
-def ebuild_pv(pn, ebuild): |
80 |
- return ebuild_pvr(pn, ebuild).split('-r')[0] |
81 |
- |
82 |
-def ebuild_version(pn, ebuild): |
83 |
- return ebuild_pv(pn, ebuild).split('_')[0] |
84 |
- |
85 |
-def new_ebuild(pn, version, sep, revision): |
86 |
- return pn + '-' + version + sep + revision + '.ebuild' |
87 |
- |
88 |
-def copy_ebuild(src, dest): |
89 |
- print('cp ' + src + ' ' + dest) |
90 |
- if not ARGS.dry_run: |
91 |
- shutil.copyfile(src, dest) |
92 |
- print('git add ' + dest) |
93 |
- if not ARGS.dry_run: |
94 |
- subprocess.check_call(['git', 'add', dest]) |
95 |
- |
96 |
-def remove_ebuild(ebuild): |
97 |
- print('git rm ' + ebuild) |
98 |
- if not ARGS.dry_run: |
99 |
- subprocess.check_call(['git', 'rm', ebuild]) |
100 |
- |
101 |
-def sync_ebuilds(pkg, debs): |
102 |
- os.chdir(os.path.join(PORTDIR, pkg)) |
103 |
- pn = pkg.split('/')[1] |
104 |
- changed = False |
105 |
- new_versions = [] |
106 |
- |
107 |
- for pattern in PKGMAP[pkg]: |
108 |
- (sep, name) = PKGMAP[pkg][pattern] |
109 |
- ebuilds = sorted(glob(pattern), reverse=True) |
110 |
- |
111 |
- if not ebuilds: |
112 |
- continue |
113 |
- |
114 |
- for deb in debs: |
115 |
- if deb['Package'] != name: |
116 |
- continue |
117 |
- |
118 |
- (version, revision) = deb['Version'].split('-') |
119 |
- found = False |
120 |
- for ebuild in ebuilds: |
121 |
- if version == ebuild_version(pn, ebuild): |
122 |
- found = True |
123 |
- break |
124 |
- if not found: |
125 |
- copy_ebuild(ebuilds[0], new_ebuild(pn, version, sep, '')) |
126 |
- new_versions.append(version) |
127 |
- changed = True |
128 |
- |
129 |
- for ebuild in ebuilds: |
130 |
- found = False |
131 |
- for deb in debs: |
132 |
- if deb['Package'] != name: |
133 |
- continue |
134 |
- |
135 |
- (version, revision) = deb['Version'].split('-') |
136 |
- if version == ebuild_version(pn, ebuild): |
137 |
- found = True |
138 |
- break |
139 |
- if not found: |
140 |
- remove_ebuild(ebuild) |
141 |
- changed = True |
142 |
- |
143 |
- if changed: |
144 |
- if ARGS.commit: |
145 |
- print('repoman commit') |
146 |
- if not ARGS.dry_run: |
147 |
- message = '%s: automated update (%s)' % (pkg, ', '.join(new_versions)) |
148 |
- if len(message) > 69: |
149 |
- message = '%s: automated update' % pkg |
150 |
- subprocess.check_call(['repoman', 'commit', '-S', '-m', message]) |
151 |
- else: |
152 |
- print('repoman manifest') |
153 |
- if not ARGS.dry_run: |
154 |
- subprocess.check_call(['repoman', 'manifest']) |
155 |
- |
156 |
-def main(): |
157 |
- parser = argparse.ArgumentParser() |
158 |
- parser.add_argument('--commit', '-c', action='store_true') |
159 |
- parser.add_argument('--dry-run', '-n', action='store_true') |
160 |
- global ARGS |
161 |
- ARGS = parser.parse_args() |
162 |
- |
163 |
- debs = get_deb_packages(ARCHIVE, DIST, COMP, ARCH) |
164 |
- for pkg in PKGMAP: |
165 |
- sync_ebuilds(pkg, debs) |
166 |
- |
167 |
-if __name__ == '__main__': |
168 |
- main() |