/[soft]/mga-gnome/trunk/mga-gnome
ViewVC logotype

Annotation of /mga-gnome/trunk/mga-gnome

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3122 - (hide annotations) (download)
Tue Feb 28 15:06:43 2012 UTC (8 years, 1 month ago) by ovitters
File size: 24479 byte(s)
workaround maildrop 5min timeout
1 ovitters 3121 #!/usr/bin/python -u
2 ovitters 2932
3 ovitters 3057 # A lot of the code comes from ftpadmin, see
4     # http://git.gnome.org/browse/sysadmin-bin/tree/ftpadmin
5     # Written by Olav Vitters
6    
7     # basic modules:
8 ovitters 2932 import os
9     import os.path
10     import sys
11     import re
12     import subprocess
13 ovitters 3057
14     # command line parsing, error handling:
15 ovitters 2932 import argparse
16 ovitters 2936 import errno
17 ovitters 3057
18     # overwriting files by moving them (safer):
19 ovitters 2944 import tempfile
20     import shutil
21 ovitters 3057
22     # version comparison:
23 ovitters 3045 import rpm
24 ovitters 3057
25     # opening tarballs:
26     import tarfile
27     import gzip
28     import bz2
29     import lzma # pyliblzma
30    
31     # getting links from HTML document:
32 ovitters 2932 from sgmllib import SGMLParser
33 ovitters 3057 import urllib2
34     import urlparse
35 ovitters 2932
36 ovitters 3115 # for checking hashes
37     import hashlib
38    
39 ovitters 3119 # for parsing ftp-release-list emails
40     import email
41     from email.mime.text import MIMEText
42    
43 ovitters 3120 # to be able to sleep for a while
44     import time
45 ovitters 3119
46 ovitters 2932 MEDIA="Core Release Source"
47     URL="http://download.gnome.org/sources/"
48     PKGROOT='~/pkgs'
49 ovitters 3120 SLEEP_INITIAL=300
50 ovitters 2932
51 ovitters 3090 re_majmin = re.compile(r'^([0-9]+\.[0-9]+).*')
52 ovitters 3012 re_version = re.compile(r'([-.]|\d+|[^-.\d]+)')
53    
54     def version_cmp(a, b):
55     """Compares two versions
56    
57     Returns
58     -1 if a < b
59     0 if a == b
60     1 if a > b
61 ovitters 3045 """
62 ovitters 3012
63 ovitters 3045 return rpm.labelCompare(('1', a, '1'), ('1', b, '1'))
64 ovitters 3012
65     def get_latest_version(versions, max_version=None):
66     """Gets the latest version number
67    
68     if max_version is specified, gets the latest version number before
69     max_version"""
70     latest = None
71     for version in versions:
72     if ( latest is None or version_cmp(version, latest) > 0 ) \
73     and ( max_version is None or version_cmp(version, max_version) < 0 ):
74     latest = version
75     return latest
76    
77 ovitters 3088 def judge_version_increase(version_old, version_new):
78     """Judge quality of version increase:
79    
80     Returns a tuple containing judgement and message
81    
82     Judgement:
83     Less than 0: Error
84     0 to 4: Better not
85     5+: Ok"""
86     versions = (version_old, version_new)
87    
88     # First do a basic version comparison to ensure version_new is actually newer
89     compare = version_cmp(version_new, version_old)
90    
91     if compare == 0:
92     return (-2, "Already at version %s!" % (version_old))
93    
94     if compare != 1:
95     return (-3, "Version %s is older than current version %s!" % (version_new, version_old))
96    
97     # Version is newer, but we don't want to see if it follows the GNOME versioning scheme
98     majmins = [re_majmin.sub(r'\1', ver) for ver in versions if re_majmin.match(ver) is not None]
99    
100     if len(majmins) == 1:
101     return (-1, "Version number scheme changes: %s" % (", ".join(versions)))
102    
103     if len(majmins) == 0:
104     return (0, "Unsupported version numbers: %s" % (", ".join(versions)))
105    
106     # Follows GNOME versioning scheme
107     # Meaning: x.y.z
108     # x = major
109     # y = minor : even if stable
110     # z = micro
111    
112     # Major+minor the same? Then go ahead and upgrade!
113     if majmins[0] == majmins[1]:
114     # Majmin of both versions are the same, looks good!
115     return (10, None)
116    
117     # More detailed analysis needed, so figure out the numbers
118     majmin_nrs = [map(long, ver.split('.')) for ver in majmins]
119    
120     # Check/ensure major version number is the same
121     if majmin_nrs[0][0] != majmin_nrs[1][0]:
122     return (1, "Major version number increase")
123    
124     # Minor indicates stable/unstable
125     devstate = (majmin_nrs[0][1] % 2 == 0, majmin_nrs[1][1] % 2 == 0)
126    
127     # Upgrading to unstable is weird
128     if not devstate[1]:
129     if devstate[0]:
130     return (1, "Stable to unstable increase")
131    
132     return (4, "Unstable to unstable version increase")
133    
134     # Unstable => stable is always ok
135     if not devstate[0]:
136     return (5, "Unstable to stable")
137    
138     # Can only be increase of minors from one stable to the next
139     return (6, "Stable version increase")
140    
141 ovitters 2936 def line_input (file):
142     for line in file:
143     if line[-1] == '\n':
144     yield line[:-1]
145     else:
146     yield line
147    
148 ovitters 2955 def call_editor(filename):
149     """Return a sequence of possible editor binaries for the current platform"""
150    
151     editors = []
152    
153     for varname in 'VISUAL', 'EDITOR':
154     if varname in os.environ:
155     editors.append(os.environ[varname])
156    
157     editors.extend(('/usr/bin/editor', 'vi', 'pico', 'nano', 'joe'))
158    
159     for editor in editors:
160     try:
161     ret = subprocess.call([editor, filename])
162     except OSError, e:
163     if e.errno == 2:
164     continue
165     raise
166    
167     if ret == 127:
168     continue
169    
170     return True
171    
172 ovitters 2932 class urllister(SGMLParser):
173     def reset(self):
174     SGMLParser.reset(self)
175     self.urls = []
176    
177     def start_a(self, attrs):
178     href = [v for k, v in attrs if k=='href']
179     if href:
180     self.urls.extend(href)
181    
182 ovitters 3057 class XzTarFile(tarfile.TarFile):
183    
184     OPEN_METH = tarfile.TarFile.OPEN_METH.copy()
185     OPEN_METH["xz"] = "xzopen"
186    
187     @classmethod
188     def xzopen(cls, name, mode="r", fileobj=None, **kwargs):
189     """Open gzip compressed tar archive name for reading or writing.
190     Appending is not allowed.
191     """
192     if len(mode) > 1 or mode not in "rw":
193     raise ValueError("mode must be 'r' or 'w'")
194    
195     if fileobj is not None:
196     fileobj = _LMZAProxy(fileobj, mode)
197     else:
198     fileobj = lzma.LZMAFile(name, mode)
199    
200     try:
201     # lzma doesn't immediately return an error
202     # try and read a bit of data to determine if it is a valid xz file
203     fileobj.read(_LZMAProxy.blocksize)
204     fileobj.seek(0)
205     t = cls.taropen(name, mode, fileobj, **kwargs)
206     except IOError:
207     raise tarfile.ReadError("not a xz file")
208     except lzma.error:
209     raise tarfile.ReadError("not a xz file")
210     t._extfileobj = False
211     return t
212    
213 ovitters 3082 if not hasattr(tarfile.TarFile, 'xzopen'):
214 ovitters 3057 tarfile.open = XzTarFile.open
215    
216 ovitters 3115 def is_valid_hash(path, algo, hexdigest):
217     if algo not in hashlib.algorithms:
218     raise ValueError("Unknown hash algorithm: %s" % algo)
219    
220     local_hash = getattr(hashlib, algo)()
221    
222     with open(path, 'rb') as fp:
223     data = fp.read(32768)
224     while data:
225     local_hash.update(data)
226     data = fp.read(32768)
227    
228     return local_hash.hexdigest() == hexdigest
229    
230 ovitters 3012 class SpecFile(object):
231     re_update_version = re.compile(r'^(?P<pre>Version:\s*)(?P<version>.+)(?P<post>\s*)$', re.MULTILINE + re.IGNORECASE)
232     re_update_release = re.compile(r'^(?P<pre>Release:\s*)(?P<release>%mkrel \d+)(?P<post>\s*)$', re.MULTILINE + re.IGNORECASE)
233    
234     def __init__(self, path):
235     self.path = path
236     self.cwd = os.path.dirname(path)
237    
238     @property
239     def version(self):
240     return subprocess.check_output(["rpm", "--specfile", self.path, "--queryformat", "%{VERSION}\n"]).splitlines()[0]
241 ovitters 3115 @property
242     def sources(self):
243     ts = rpm.ts()
244     spec = ts.parseSpec(self.path)
245     srclist = spec.sources if isinstance(spec.sources, (list, tuple)) \
246     else spec.sources()
247     return dict((os.path.basename(name), name) for name, no, flags in srclist)
248 ovitters 3037
249 ovitters 3012 def update(self, version):
250     """Update specfile (increase version)"""
251     cur_version = self.version
252    
253 ovitters 3088 (judgement, msg) = judge_version_increase(cur_version, version)
254 ovitters 3037
255 ovitters 3088 if judgement < 0:
256     print >>sys.stderr, "ERROR: %s!" % (msg)
257 ovitters 3037 return False
258    
259 ovitters 3088 if judgement < 5:
260 ovitters 3089 print "WARNING: %s!" % (msg)
261 ovitters 3012 return False
262    
263 ovitters 3039 # XXX - os.path.join is hackish
264     if subprocess.check_output(["svn", "diff", os.path.join(self.path, '..')]) != '':
265     print >>sys.stderr, "ERROR: Package has uncommitted changes!"
266     return False
267    
268 ovitters 3012 with open(self.path, "rw") as f:
269     data = f.read()
270    
271     if data.count("%mkrel") != 1:
272 ovitters 3037 print >>sys.stderr, "ERROR: Multiple %mkrel found; don't know what to do!"
273 ovitters 3012 return False
274    
275     data, nr = self.re_update_version.subn(r'\g<pre>%s\g<post>' % version, data, 1)
276     if nr != 1:
277 ovitters 3037 print >>sys.stderr, "ERROR: Could not increase version!"
278 ovitters 3012 return False
279    
280     data, nr = self.re_update_release.subn(r'\g<pre>%mkrel 1\g<post>', data, 1)
281     if nr != 1:
282 ovitters 3037 print >>sys.stderr, "ERROR: Could not reset release!"
283 ovitters 3012 return False
284    
285     # Overwrite file with new version number
286     write_file(self.path, data)
287    
288    
289 ovitters 3045 # Verify that RPM also agrees that version number has changed
290 ovitters 3012 if self.version != version:
291     print "ERROR: Increased version to %s, but RPM doesn't agree!?!" % version
292     return False
293    
294 ovitters 3034 try:
295     # Download new tarball
296     subprocess.check_call(['mgarepo', 'sync', '-d'], cwd=self.cwd)
297     # Check patches still apply
298     subprocess.check_call(['bm', '-p', '--nodeps'], cwd=self.cwd)
299     except subprocess.CalledProcessError:
300     return False
301 ovitters 3012
302     return True
303    
304 ovitters 2936 class Patch(object):
305     """Do things with patches"""
306    
307     re_dep3 = re.compile(r'^(?:#\s*)?(?P<header>[-A-Za-z0-9]+?):\s*(?P<data>.*)$')
308     re_dep3_cont = re.compile(r'^#?\s+(?P<data>.*)$')
309    
310     def __init__(self, path, show_path=False):
311     """Path: path to patch (might not exist)"""
312     self.path = path
313     self.show_path = show_path
314    
315     def __str__(self):
316     return self.path if self.show_path else os.path.basename(self.path)
317    
318     def add_dep3(self):
319 ovitters 2955 """Add DEP-3 headers to a patch file"""
320 ovitters 2944 if self.dep3['valid']:
321     return False
322    
323     new_headers = (
324     ('Author', self.svn_author),
325     ('Subject', ''),
326     ('Applied-Upstream', ''),
327     ('Forwarded', ''),
328     ('Bug', ''),
329     )
330    
331     with tempfile.NamedTemporaryFile(dir=os.path.dirname(self.path), delete=False) as fdst:
332     with open(self.path, "r") as fsrc:
333     # Start with any existing DEP3 headers
334     for i in range(self.dep3['last_nr']):
335     fdst.write(fsrc.read())
336    
337     # After that add the DEP3 headers
338     add_line = False
339     for header, data in new_headers:
340     if header in self.dep3['headers']:
341     continue
342    
343     # XXX - wrap this at 80 chars
344     add_line = True
345 ovitters 2955 print >>fdst, "%s: %s" % (header, "" if data is None else data)
346 ovitters 2944
347     if add_line: print >>fdst, ""
348     # Now copy any other data and the patch
349     shutil.copyfileobj(fsrc, fdst)
350    
351     fdst.flush()
352     os.rename(fdst.name, self.path)
353    
354 ovitters 2955 call_editor(self.path)
355    
356 ovitters 2936 #Author: fwang
357     #Subject: Build fix: Fix glib header inclusion
358     #Applied-Upstream: commit:30602
359     #Forwarded: yes
360     #Bug: http://bugzilla.abisource.com/show_bug.cgi?id=13247
361    
362     def _read_dep3(self):
363 ovitters 2955 """Read DEP-3 headers from an existing patch file
364    
365     This will also parse git headers"""
366 ovitters 2936 dep3 = {}
367 ovitters 2944 headers = {}
368 ovitters 2936
369     last_header = None
370 ovitters 2944 last_nr = 0
371     nr = 0
372 ovitters 2936 try:
373     with open(self.path, "r") as f:
374     for line in line_input(f):
375 ovitters 2944 nr += 1
376     # stop trying to parse when real patch begins
377 ovitters 2936 if line == '---':
378     break
379    
380     r = self.re_dep3.match(line)
381     if r:
382     info = r.groupdict()
383 ovitters 3012
384     # Avoid matching URLS
385     if info['data'].startswith('//') and info['header'].lower () == info['header']:
386     continue
387    
388 ovitters 2944 headers[info['header']] = info['data']
389 ovitters 2936 last_header = info['header']
390 ovitters 2944 last_nr = nr
391 ovitters 2936 continue
392    
393     r = self.re_dep3_cont.match(line)
394     if r:
395     info = r.groupdict()
396     if last_header:
397 ovitters 2944 headers[last_header] = " ".join((headers[last_header], info['data']))
398     last_nr = nr
399 ovitters 2936 continue
400    
401     last_header = None
402     except IOError:
403     pass
404 ovitters 2944
405     dep3['valid'] = \
406     (('Description' in headers and headers['Description'].strip() != '')
407     or ('Subject' in headers and headers['Subject'].strip() != '')) \
408     and (('Origin' in headers and headers['Origin'].strip() != '') \
409     or ('Author' in headers and headers['Author'].strip() != '') \
410     or ('From' in headers and headers['From'].strip() != ''))
411     dep3['last_nr'] = last_nr
412     dep3['headers'] = headers
413    
414 ovitters 2936 self._dep3 = dep3
415    
416     @property
417     def dep3(self):
418     if not hasattr(self, '_dep3'):
419     self._read_dep3()
420    
421     return self._dep3
422    
423 ovitters 2944 @property
424     def svn_author(self):
425     if not hasattr(self, '_svn_author'):
426 ovitters 3083 try:
427     contents = subprocess.check_output(['svn', 'log', '-q', "--", self.path], close_fds=True).strip("\n").splitlines()
428    
429 ovitters 2944 for line in contents:
430     if ' | ' not in line:
431     continue
432 ovitters 2936
433 ovitters 2944 fields = line.split(' | ')
434     if len(fields) >= 3:
435     self._svn_author = fields[1]
436 ovitters 3083 except subprocess.CalledProcessError:
437     pass
438 ovitters 2944
439 ovitters 2955 if not hasattr(self, '_svn_author'):
440     return None
441    
442 ovitters 2944 return self._svn_author
443    
444 ovitters 2932 def get_upstream_names():
445     urlopen = urllib2.build_opener()
446    
447     good_dir = re.compile('^[-A-Za-z0-9_+.]+/$')
448    
449     # Get the files
450     usock = urlopen.open(URL)
451     parser = urllister()
452     parser.feed(usock.read())
453     usock.close()
454     parser.close()
455     files = parser.urls
456    
457     tarballs = set([filename.replace('/', '') for filename in files if good_dir.search(filename)])
458    
459     return tarballs
460    
461     def get_downstream_names():
462     re_file = re.compile(r'^(?P<module>.*?)[_-](?:(?P<oldversion>([0-9]+[\.])*[0-9]+)-)?(?P<version>([0-9]+[\.\-])*[0-9]+)\.(?P<format>(?:tar\.|diff\.)?[a-z][a-z0-9]*)$')
463    
464 ovitters 3083 contents = subprocess.check_output(['urpmf', '--files', '.', "--media", MEDIA], close_fds=True).strip("\n").splitlines()
465 ovitters 2932
466     FILES = {}
467     TARBALLS = {}
468    
469     for line in contents:
470     try:
471     srpm, filename = line.split(":")
472     except ValueError:
473     print >>sys.stderr, line
474     continue
475    
476     if '.tar' in filename:
477     r = re_file.match(filename)
478     if r:
479     fileinfo = r.groupdict()
480     module = fileinfo['module']
481    
482     if module not in TARBALLS:
483     TARBALLS[module] = set()
484     TARBALLS[module].add(srpm)
485    
486     if srpm not in FILES:
487     FILES[srpm] = set()
488     FILES[srpm].add(filename)
489    
490     return TARBALLS, FILES
491    
492 ovitters 3119 def get_downstream_from_upstream(upstream, version):
493     # Determine the package name
494     downstream, downstream_files = get_downstream_names()
495 ovitters 3012
496 ovitters 3119 if upstream not in downstream:
497     raise ValueError("No packages for upstream name: %s" % upstream)
498    
499     if len(downstream[upstream]) != 1:
500     # XXX - Make it more intelligent
501 ovitters 3120 raise ValueError("Multiple packages found for %s: %s" % (upstream, ", ".join(downstream[upstream])))
502 ovitters 3119
503     return list(downstream[upstream])
504    
505 ovitters 3012 def write_file(path, data):
506     with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst:
507     fdst.write(data)
508     fdst.flush()
509     os.rename(fdst.name, path)
510    
511 ovitters 2932 def cmd_co(options, parser):
512     upstream = get_upstream_names()
513     downstream, downstream_files = get_downstream_names()
514    
515     cwd = os.path.expanduser(PKGROOT)
516    
517     matches = upstream & set(downstream.keys())
518     for module in matches:
519     print module, "\t".join(downstream[module])
520     for package in downstream[module]:
521     subprocess.call(['mgarepo', 'co', package], cwd=cwd)
522    
523 ovitters 3114 def join_streams():
524 ovitters 2932 upstream = get_upstream_names()
525     downstream, downstream_files = get_downstream_names()
526    
527     matches = upstream & set(downstream.keys())
528     for module in matches:
529 ovitters 3114 for package in downstream[module]:
530     yield (package, module)
531 ovitters 2932
532 ovitters 3114 def cmd_ls(options, parser):
533     for package, module in sorted(join_streams()):
534     print "\t".join((package, module)) if options.upstream else package
535    
536 ovitters 2932 def cmd_patches(options, parser):
537     upstream = get_upstream_names()
538     downstream, downstream_files = get_downstream_names()
539    
540     path = os.path.expanduser(PKGROOT)
541    
542 ovitters 2936 import pprint
543    
544 ovitters 2932 matches = upstream & set(downstream.keys())
545     for module in sorted(matches):
546     for srpm in downstream[module]:
547     for filename in downstream_files[srpm]:
548     if '.patch' in filename or '.diff' in filename:
549 ovitters 3012
550 ovitters 2936 p = Patch(os.path.join(path, srpm, "SOURCES", filename), show_path=options.path)
551 ovitters 3012 valid = ""
552     forwarded = ""
553 ovitters 2944 if p.dep3['headers']:
554 ovitters 3012 forwarded = p.dep3['headers'].get('Forwarded', "no")
555 ovitters 2944 if p.dep3['valid']:
556 ovitters 3012 valid="VALID"
557     print "\t".join((module, srpm, str(p), forwarded, valid))
558 ovitters 2932
559 ovitters 2944 def cmd_dep3(options, parser):
560     p = Patch(options.patch)
561     p.add_dep3()
562    
563 ovitters 3012 def cmd_package_new_version(options, parser):
564 ovitters 3087 # Determine the package name
565 ovitters 3086 if options.upstream:
566 ovitters 3119 try:
567     package = get_downstream_from_upstream(options.package, options.version)[0]
568     except ValueError, e:
569     print >>sys.stderr, "ERROR: %s" % e
570 ovitters 3086 sys.exit(1)
571     else:
572     package = options.package
573    
574 ovitters 3087 # Directories packages are located in
575 ovitters 3044 root = os.path.expanduser(PKGROOT)
576     cwd = os.path.join(root, package)
577 ovitters 3038
578 ovitters 3087 # Checkout package to ensure the checkout reflects the latest changes
579 ovitters 3044 try:
580     subprocess.check_call(['mgarepo', 'co', package], cwd=root)
581     except subprocess.CalledProcessError:
582     sys.exit(1)
583 ovitters 3087
584     # SpecFile class handles the actual version+release change
585 ovitters 3038 s = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package))
586 ovitters 3037 print "%s => %s" % (s.version, options.version)
587 ovitters 3012 if not s.update(options.version):
588     sys.exit(1)
589    
590 ovitters 3115 # Check hash, if given
591     if options.hexdigest is not None:
592     sources = [name for name, origname in s.sources.iteritems() if '://' in origname]
593     if not len(sources):
594     print >>sys.stderr, "ERROR: Cannot determine source file (for hash check)!"
595     sys.stderr(1)
596    
597     for filename in sources:
598     if not is_valid_hash(os.path.join(cwd, "SOURCES", filename), options.algo, options.hexdigest):
599     print >>sys.stderr, "ERROR: Hash file failed check for %s!" % path
600     print >>sys.stderr, "ERROR: Reverting changes!"
601     subprocess.call(['svn', 'revert', '-R', cwd], cwd=cwd)
602     sys.exit(1)
603    
604 ovitters 3087 # We can even checkin and submit :-)
605 ovitters 3038 if options.submit:
606     try:
607     # checkin changes
608 ovitters 3087 subprocess.check_call(['mgarepo', 'ci', '-m', 'new version %s' % options.version], cwd=cwd)
609 ovitters 3038 # and submit
610     subprocess.check_call(['mgarepo', 'submit'], cwd=cwd)
611     except subprocess.CalledProcessError:
612     sys.exit(1)
613 ovitters 3012
614 ovitters 3119 def cmd_parse_ftp_release_list(options, parser):
615     # XXX - not working yet
616     def _send_reply_mail(contents, orig_msg, to):
617     """Send an reply email"""
618     contents.seek(0)
619     msg = MIMEText(contents.read(), _charset='utf-8')
620     msg['Subject'] = "Re: %s" % orig_msg['Subject']
621     msg['To'] = to
622     msg["In-Reply-To"] = orig_msg["Message-ID"]
623     msg["References"] = orig_msg["Message-ID"]
624 ovitters 3038
625 ovitters 3119 # Call sendmail program directly so it doesn't matter if the service is running
626     cmd = ['/usr/sbin/sendmail', '-oi', '--']
627     cmd.extend([to])
628     p = subprocess.Popen(cmd, stdin=subprocess.PIPE)
629     p.stdin.write(msg.as_string())
630     p.stdin.flush()
631     p.stdin.close()
632     p.wait()
633    
634    
635     msg = email.email.message_from_file(sys.stdin)
636    
637     if options.mail:
638     stdout = tempfile.NamedTemporaryFile()
639     stderr = stdout
640     else:
641     stdout = sys.stdout
642     stderr = sys.stderr
643    
644     try:
645     module = msg['X-Module-Name']
646     version = msg['X-Module-Version']
647     hexdigest = msg['X-Module-SHA256-tar.xz']
648     except KeyError, e:
649     print >>stderr, "ERROR: %s" % e
650     if options.mail: _send_reply_mail(stdout, msg, options.mail)
651     sys.exit(1)
652    
653     try:
654     packages = get_downstream_from_upstream(module, version)
655     except ValueError, e:
656     print >>stderr, "ERROR: %s" % e
657     if options.mail: _send_reply_mail(stdout, msg, options.mail)
658     sys.exit(1)
659    
660 ovitters 3120 if options.wait:
661 ovitters 3122 # maildrop aborts and will try to deliver after 5min
662     # fork to avoid this
663     if os.fork() != 0: sys.exit(0)
664 ovitters 3120 time.sleep(SLEEP_INITIAL)
665    
666 ovitters 3119 for package in packages:
667 ovitters 3120 subprocess.call(['mga-gnome', 'increase', '--submit', '--hash', hexdigest, package, version], stdout=stdout, stderr=stderr)
668 ovitters 3119
669     if options.mail: _send_reply_mail(stdout, msg, options.mail)
670    
671 ovitters 2932 def main():
672     description = """Mageia GNOME commands."""
673     epilog="""Report bugs to Olav Vitters"""
674     parser = argparse.ArgumentParser(description=description,epilog=epilog)
675    
676     # SUBPARSERS
677     subparsers = parser.add_subparsers(title='subcommands')
678     # install
679     subparser = subparsers.add_parser('co', help='checkout all GNOME modules')
680     subparser.set_defaults(
681     func=cmd_co
682     )
683    
684     subparser = subparsers.add_parser('packages', help='list all GNOME packages')
685 ovitters 3114 subparser.add_argument("-m", "--m", action="store_true", dest="upstream",
686     help="Show upstream module")
687 ovitters 2932 subparser.set_defaults(
688 ovitters 3114 func=cmd_ls, upstream=False
689 ovitters 2932 )
690    
691     subparser = subparsers.add_parser('patches', help='list all GNOME patches')
692     subparser.add_argument("-p", "--path", action="store_true", dest="path",
693 ovitters 2944 help="Show full path to patch")
694 ovitters 2932 subparser.set_defaults(
695     func=cmd_patches, path=False
696     )
697    
698 ovitters 2944 subparser = subparsers.add_parser('dep3', help='Add dep3 headers')
699     subparser.add_argument("patch", help="Patch")
700     subparser.set_defaults(
701     func=cmd_dep3, path=False
702     )
703 ovitters 2932
704 ovitters 3012 subparser = subparsers.add_parser('increase', help='Increase version number')
705     subparser.add_argument("package", help="Package name")
706     subparser.add_argument("version", help="Version number")
707 ovitters 3086 subparser.add_argument("-u", "--upstream", action="store_true", dest="upstream",
708     help="Package name reflects the upstream name")
709 ovitters 3038 subparser.add_argument("-s", "--submit", action="store_true", dest="submit",
710     help="Commit changes and submit")
711 ovitters 3115 subparser.add_argument("-a", "--algorithm", choices=hashlib.algorithms, dest="algo",
712     help="Hash algorithm")
713     subparser.add_argument("--hash", dest="hexdigest",
714     help="Hexdigest of the hash")
715 ovitters 3012 subparser.set_defaults(
716 ovitters 3115 func=cmd_package_new_version, submit=False, upstream=False, hexdigest=None, algo="sha256"
717 ovitters 3012 )
718    
719 ovitters 3119 subparser = subparsers.add_parser('gnome-release-email', help='Submit packages based on GNOME ftp-release-list email')
720     subparser.add_argument("-m", "--mail", help="Email address to send the progress to")
721 ovitters 3120 subparser.add_argument("-w", "--wait", action="store_true",
722     help="Wait before trying to retrieve the new version")
723 ovitters 3119 subparser.set_defaults(
724     func=cmd_parse_ftp_release_list
725     )
726    
727 ovitters 2932 if len(sys.argv) == 1:
728     parser.print_help()
729     sys.exit(2)
730    
731     options = parser.parse_args()
732    
733     try:
734     options.func(options, parser)
735     except KeyboardInterrupt:
736     print('Interrupted')
737     sys.exit(1)
738     except EOFError:
739     print('EOF')
740     sys.exit(1)
741     except IOError, e:
742     if e.errno != errno.EPIPE:
743     raise
744     sys.exit(0)
745    
746     if __name__ == "__main__":
747     main()

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26