46 |
# version freeze |
# version freeze |
47 |
import datetime |
import datetime |
48 |
|
|
49 |
MEDIA="Core Release Source" |
# packages --sort |
50 |
URL="http://download.gnome.org/sources/" |
import itertools |
51 |
PKGROOT='~/pkgs' |
|
52 |
SLEEP_INITIAL=300 |
SLEEP_INITIAL=180 |
53 |
|
SLEEP_REPEAT=30 |
54 |
|
SLEEP_TIMES=20 |
55 |
|
|
56 |
re_majmin = re.compile(r'^([0-9]+\.[0-9]+).*') |
re_majmin = re.compile(r'^([0-9]+\.[0-9]+).*') |
57 |
re_version = re.compile(r'([-.]|\d+|[^-.\d]+)') |
re_version = re.compile(r'([-.]|\d+|[^-.\d]+)') |
259 |
else spec.sources() |
else spec.sources() |
260 |
return dict((os.path.basename(name), name) for name, no, flags in srclist) |
return dict((os.path.basename(name), name) for name, no, flags in srclist) |
261 |
|
|
262 |
def update(self, version): |
def update(self, version, force=False): |
263 |
"""Update specfile (increase version)""" |
"""Update specfile (increase version)""" |
264 |
cur_version = self.version |
cur_version = self.version |
265 |
|
|
271 |
|
|
272 |
if judgement < 5: |
if judgement < 5: |
273 |
print "WARNING: %s!" % (msg) |
print "WARNING: %s!" % (msg) |
274 |
return False |
if not force: return False |
275 |
|
|
276 |
# XXX - os.path.join is hackish |
# XXX - os.path.join is hackish |
277 |
if subprocess.check_output(["svn", "diff", os.path.join(self.path, '..')]) != '': |
svn_diff_output = subprocess.check_output(["svn", "diff", os.path.join(self.path, '..')]) |
278 |
|
if svn_diff_output != '': |
279 |
|
print svn_diff_output |
280 |
print >>sys.stderr, "ERROR: Package has uncommitted changes!" |
print >>sys.stderr, "ERROR: Package has uncommitted changes!" |
281 |
return False |
if not force: |
282 |
|
return False |
283 |
|
|
284 |
|
# Forcing package submission: revert changes |
285 |
|
try: |
286 |
|
print >>sys.stderr, "WARNING: Force used; reverting svn changes" |
287 |
|
subprocess.check_call(["svn", "revert", "-R", os.path.join(self.path, '..')]) |
288 |
|
except subprocess.CalledProcessError: |
289 |
|
return False |
290 |
|
|
291 |
with open(self.path, "rw") as f: |
with open(self.path, "rw") as f: |
292 |
data = f.read() |
data = f.read() |
314 |
print "ERROR: Increased version to %s, but RPM doesn't agree!?!" % version |
print "ERROR: Increased version to %s, but RPM doesn't agree!?!" % version |
315 |
return False |
return False |
316 |
|
|
317 |
|
|
318 |
|
# Try to download the new tarball various times and wait between attempts |
319 |
|
tries = 0 |
320 |
|
while tries < SLEEP_TIMES: |
321 |
|
tries += 1 |
322 |
|
if tries > 1: time.sleep(SLEEP_REPEAT) |
323 |
|
try: |
324 |
|
# Download new tarball |
325 |
|
subprocess.check_call(['mgarepo', 'sync', '-d'], cwd=self.cwd) |
326 |
|
# success, so exit loop |
327 |
|
break |
328 |
|
except subprocess.CalledProcessError, e: |
329 |
|
# mgarepo sync returns 1 if the tarball cannot be downloaded |
330 |
|
if e.returncode != 1: |
331 |
|
return False |
332 |
|
else: |
333 |
|
return False |
334 |
|
|
335 |
|
|
336 |
try: |
try: |
|
# Download new tarball |
|
|
subprocess.check_call(['mgarepo', 'sync', '-d'], cwd=self.cwd) |
|
337 |
# Check patches still apply |
# Check patches still apply |
338 |
subprocess.check_call(['bm', '-p', '--nodeps'], cwd=self.cwd) |
subprocess.check_call(['bm', '-p', '--nodeps'], cwd=self.cwd) |
339 |
except subprocess.CalledProcessError: |
except subprocess.CalledProcessError: |
340 |
|
logfile = os.path.join(os.path.dirname(self.path), 'log.%s' % os.path.splitext(os.path.basename(self.path))[0]) |
341 |
|
if os.path.exists(logfile): |
342 |
|
subprocess.call(['tail', '-n', '15', logfile]) |
343 |
return False |
return False |
344 |
|
|
345 |
return True |
return True |
484 |
|
|
485 |
return self._svn_author |
return self._svn_author |
486 |
|
|
|
def get_upstream_names(): |
|
|
urlopen = urllib2.build_opener() |
|
487 |
|
|
488 |
good_dir = re.compile('^[-A-Za-z0-9_+.]+/$') |
class Upstream(object): |
489 |
|
|
490 |
|
URL="http://download.gnome.org/sources/" |
491 |
|
limit = None |
492 |
|
|
493 |
# Get the files |
def __init__(self): |
494 |
usock = urlopen.open(URL) |
urlopen = urllib2.build_opener() |
|
parser = urllister() |
|
|
parser.feed(usock.read()) |
|
|
usock.close() |
|
|
parser.close() |
|
|
files = parser.urls |
|
495 |
|
|
496 |
tarballs = set([filename.replace('/', '') for filename in files if good_dir.search(filename)]) |
good_dir = re.compile('^[-A-Za-z0-9_+.]+/$') |
497 |
|
|
498 |
return tarballs |
# Get the files |
499 |
|
usock = urlopen.open(self.URL) |
500 |
|
parser = urllister() |
501 |
|
parser.feed(usock.read()) |
502 |
|
usock.close() |
503 |
|
parser.close() |
504 |
|
files = parser.urls |
505 |
|
|
506 |
def get_downstream_names(): |
tarballs = set([filename.replace('/', '') for filename in files if good_dir.search(filename)]) |
507 |
|
if self.limit is not None: |
508 |
|
tarballs.intersection_update(self.limit) |
509 |
|
|
510 |
|
self.names = tarballs |
511 |
|
|
512 |
|
class Downstream(object): |
513 |
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]*)$') |
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]*)$') |
514 |
|
|
515 |
contents = subprocess.check_output(['urpmf', '--files', '.', "--media", MEDIA], close_fds=True).strip("\n").splitlines() |
MEDIA="Core Release Source" |
516 |
|
PKGROOT='~/pkgs' |
517 |
|
DISTRO=None |
518 |
|
|
519 |
FILES = {} |
def __init__(self): |
520 |
TARBALLS = {} |
contents = subprocess.check_output(['urpmf', '--qf', '%name|%version|%files', '.', "--media", self.MEDIA], close_fds=True).strip("\n").splitlines() |
521 |
|
|
522 |
for line in contents: |
FILES = {} |
523 |
try: |
TARBALLS = {} |
|
srpm, filename = line.split(":") |
|
|
except ValueError: |
|
|
print >>sys.stderr, line |
|
|
continue |
|
524 |
|
|
525 |
if '.tar' in filename: |
for line in contents: |
526 |
r = re_file.match(filename) |
try: |
527 |
if r: |
srpm, version, filename = line.split("|") |
528 |
fileinfo = r.groupdict() |
except ValueError: |
529 |
module = fileinfo['module'] |
print >>sys.stderr, line |
530 |
|
continue |
|
if module not in TARBALLS: |
|
|
TARBALLS[module] = set() |
|
|
TARBALLS[module].add(srpm) |
|
|
|
|
|
if srpm not in FILES: |
|
|
FILES[srpm] = set() |
|
|
FILES[srpm].add(filename) |
|
531 |
|
|
532 |
return TARBALLS, FILES |
if '.tar' in filename: |
533 |
|
r = self.re_file.match(filename) |
534 |
|
if r: |
535 |
|
fileinfo = r.groupdict() |
536 |
|
module = fileinfo['module'] |
537 |
|
|
538 |
|
if module not in TARBALLS: |
539 |
|
TARBALLS[module] = {} |
540 |
|
TARBALLS[module][srpm] = version |
541 |
|
|
542 |
|
if srpm not in FILES: |
543 |
|
FILES[srpm] = set() |
544 |
|
FILES[srpm].add(filename) |
545 |
|
|
546 |
def get_downstream_from_upstream(upstream, version): |
self.tarballs = TARBALLS |
547 |
# Determine the package name |
self.files = FILES |
|
downstream, downstream_files = get_downstream_names() |
|
548 |
|
|
549 |
if upstream not in downstream: |
@classmethod |
550 |
raise ValueError("No packages for upstream name: %s" % upstream) |
def co(cls, package, cwd=None): |
551 |
|
if cwd is None: |
552 |
|
cwd = os.path.expanduser(cls.PKGROOT) |
553 |
|
|
554 |
|
cmd = ['mgarepo', 'co'] |
555 |
|
if cls.DISTRO: |
556 |
|
cmd.extend(('-d', cls.DISTRO)) |
557 |
|
cmd.append(package) |
558 |
|
return subprocess.check_call(cmd, cwd=cwd) |
559 |
|
|
560 |
|
def get_downstream_from_upstream(self, upstream, version): |
561 |
|
if upstream not in self.tarballs: |
562 |
|
raise ValueError("No packages for upstream name: %s" % upstream) |
563 |
|
|
564 |
|
if len(self.tarballs[upstream]) == 1: |
565 |
|
return self.tarballs[upstream].keys() |
566 |
|
|
567 |
|
# Directories packages are located in |
568 |
|
root = os.path.expanduser(self.PKGROOT) |
569 |
|
|
570 |
|
packages = {} |
571 |
|
for package in self.tarballs[upstream].keys(): |
572 |
|
cwd = os.path.join(root, package) |
573 |
|
|
574 |
|
# Checkout package to ensure the checkout reflects the latest changes |
575 |
|
try: |
576 |
|
self.co(package, cwd=root) |
577 |
|
except subprocess.CalledProcessError: |
578 |
|
raise ValueError("Multiple packages found and cannot checkout %s" % package) |
579 |
|
|
580 |
|
# Determine version from spec file |
581 |
|
try: |
582 |
|
packages[package] = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)).version |
583 |
|
except subprocess.CalledProcessError: |
584 |
|
raise ValueError("Multiple packages found and cannot determine version of %s" % package) |
585 |
|
|
586 |
if len(downstream[upstream]) != 1: |
# Return all packages reflecting the current version |
587 |
# XXX - Make it more intelligent |
matches = [package for package in packages if packages[package] == version] |
588 |
raise ValueError("Multiple packages found for %s: %s" % (upstream, ", ".join(downstream[upstream]))) |
if len(matches): |
589 |
|
return matches |
590 |
|
|
591 |
|
# Return all packages reflecting the version before the current version |
592 |
|
latest_version = get_latest_version(packages.values(), max_version=version) |
593 |
|
matches = [package for package in packages if packages[package] == latest_version] |
594 |
|
if len(matches): |
595 |
|
return matches |
596 |
|
|
597 |
return list(downstream[upstream]) |
# Give up |
598 |
|
raise ValueError("Multiple packages found and cannot determine package for version %s" % version) |
599 |
|
|
600 |
def write_file(path, data): |
def write_file(path, data): |
601 |
with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst: |
with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst: |
604 |
os.rename(fdst.name, path) |
os.rename(fdst.name, path) |
605 |
|
|
606 |
def cmd_co(options, parser): |
def cmd_co(options, parser): |
607 |
upstream = get_upstream_names() |
for package, module, package_version, spec_version, downstream_files in sorted(join_streams()): |
608 |
downstream, downstream_files = get_downstream_names() |
print "%s => %s" % (module, package) |
609 |
|
try: |
610 |
|
Downstream.co(package) |
611 |
|
except subprocess.CalledProcessError: |
612 |
|
pass |
613 |
|
|
614 |
cwd = os.path.expanduser(PKGROOT) |
def join_streams(show_version=False, only_diff_version=False): |
615 |
|
root = os.path.expanduser(Downstream.PKGROOT) |
616 |
|
|
617 |
matches = upstream & set(downstream.keys()) |
upstream = Upstream().names |
618 |
for module in matches: |
downstream = Downstream() |
|
print module, "\t".join(downstream[module]) |
|
|
for package in downstream[module]: |
|
|
subprocess.call(['mgarepo', 'co', package], cwd=cwd) |
|
|
|
|
|
def join_streams(): |
|
|
upstream = get_upstream_names() |
|
|
downstream, downstream_files = get_downstream_names() |
|
619 |
|
|
620 |
matches = upstream & set(downstream.keys()) |
matches = upstream & set(downstream.tarballs.keys()) |
621 |
for module in matches: |
for module in matches: |
622 |
for package in downstream[module]: |
for package in downstream.tarballs[module].keys(): |
623 |
yield (package, module) |
package_version = downstream.tarballs[module][package] |
624 |
|
spec_version = None |
625 |
|
if show_version or only_diff_version: |
626 |
|
cwd = os.path.join(root, package) |
627 |
|
try: |
628 |
|
spec_version = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)).version |
629 |
|
except subprocess.CalledProcessError: |
630 |
|
spec_version = 'N/A' |
631 |
|
|
632 |
|
if only_diff_version and package_version == spec_version: |
633 |
|
continue |
634 |
|
|
635 |
|
yield (package, module, package_version, spec_version, downstream.files[package]) |
636 |
|
|
637 |
def cmd_ls(options, parser): |
def cmd_ls(options, parser): |
638 |
for package, module in sorted(join_streams()): |
streams = join_streams(show_version=options.show_version, only_diff_version=options.diff) |
639 |
print "\t".join((package, module)) if options.upstream else package |
if options.sort: |
640 |
|
SORT=dict(zip(options.sort.read().splitlines(), itertools.count())) |
641 |
|
|
642 |
def cmd_patches(options, parser): |
streams = sorted(streams, key=lambda a: (SORT.get(a[1], 9999), a[0])) |
643 |
upstream = get_upstream_names() |
else: |
644 |
downstream, downstream_files = get_downstream_names() |
streams = sorted(streams) |
645 |
|
|
646 |
path = os.path.expanduser(PKGROOT) |
for package, module, package_version, spec_version, downstream_files in streams: |
647 |
|
sys.stdout.write(package) |
648 |
|
if options.upstream: sys.stdout.write("\t%s" % module) |
649 |
|
if options.show_version: sys.stdout.write("\t%s\t%s" % (spec_version, package_version)) |
650 |
|
print |
651 |
|
|
652 |
import pprint |
def cmd_patches(options, parser): |
653 |
|
root = os.path.expanduser(Downstream.PKGROOT) |
654 |
|
|
655 |
matches = upstream & set(downstream.keys()) |
for package, module, package_version, spec_version, downstream_files in sorted(join_streams()): |
656 |
for module in sorted(matches): |
for filename in downstream_files: |
657 |
for srpm in downstream[module]: |
if '.patch' in filename or '.diff' in filename: |
658 |
for filename in downstream_files[srpm]: |
|
659 |
if '.patch' in filename or '.diff' in filename: |
p = Patch(os.path.join(root, package, "SOURCES", filename), show_path=options.path) |
660 |
|
valid = "" |
661 |
p = Patch(os.path.join(path, srpm, "SOURCES", filename), show_path=options.path) |
forwarded = "" |
662 |
valid = "" |
if p.dep3['headers']: |
663 |
forwarded = "" |
forwarded = p.dep3['headers'].get('Forwarded', "no") |
664 |
if p.dep3['headers']: |
if p.dep3['valid']: |
665 |
forwarded = p.dep3['headers'].get('Forwarded', "no") |
valid="VALID" |
666 |
if p.dep3['valid']: |
print "\t".join((module, package, str(p), forwarded, valid)) |
|
valid="VALID" |
|
|
print "\t".join((module, srpm, str(p), forwarded, valid)) |
|
667 |
|
|
668 |
def cmd_dep3(options, parser): |
def cmd_dep3(options, parser): |
669 |
p = Patch(options.patch) |
p = Patch(options.patch) |
673 |
# Determine the package name |
# Determine the package name |
674 |
if options.upstream: |
if options.upstream: |
675 |
try: |
try: |
676 |
package = get_downstream_from_upstream(options.package, options.version)[0] |
package = Downstream().get_downstream_from_upstream(options.package, options.version)[0] |
677 |
except ValueError, e: |
except ValueError, e: |
678 |
print >>sys.stderr, "ERROR: %s" % e |
print >>sys.stderr, "ERROR: %s" % e |
679 |
sys.exit(1) |
sys.exit(1) |
681 |
package = options.package |
package = options.package |
682 |
|
|
683 |
# Directories packages are located in |
# Directories packages are located in |
684 |
root = os.path.expanduser(PKGROOT) |
root = os.path.expanduser(Downstream.PKGROOT) |
685 |
cwd = os.path.join(root, package) |
cwd = os.path.join(root, package) |
686 |
|
|
687 |
# Checkout package to ensure the checkout reflects the latest changes |
# Checkout package to ensure the checkout reflects the latest changes |
688 |
try: |
try: |
689 |
subprocess.check_call(['mgarepo', 'co', package], cwd=root) |
Downstream.co(package, cwd=root) |
690 |
except subprocess.CalledProcessError: |
except subprocess.CalledProcessError: |
691 |
sys.exit(1) |
sys.exit(1) |
692 |
|
|
693 |
# SpecFile class handles the actual version+release change |
# SpecFile class handles the actual version+release change |
694 |
s = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)) |
s = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)) |
695 |
print "%s => %s" % (s.version, options.version) |
print "%s => %s" % (s.version, options.version) |
696 |
if not s.update(options.version): |
if not s.update(options.version, force=options.force): |
697 |
sys.exit(1) |
sys.exit(1) |
698 |
|
|
699 |
# Check hash, if given |
# Check hash, if given |
704 |
sys.stderr(1) |
sys.stderr(1) |
705 |
|
|
706 |
for filename in sources: |
for filename in sources: |
707 |
if not is_valid_hash(os.path.join(cwd, "SOURCES", filename), options.algo, options.hexdigest): |
path = os.path.join(cwd, "SOURCES", filename) |
708 |
|
if not is_valid_hash(path, options.algo, options.hexdigest): |
709 |
print >>sys.stderr, "ERROR: Hash file failed check for %s!" % path |
print >>sys.stderr, "ERROR: Hash file failed check for %s!" % path |
710 |
print >>sys.stderr, "ERROR: Reverting changes!" |
print >>sys.stderr, "ERROR: Reverting changes!" |
711 |
subprocess.call(['svn', 'revert', '-R', cwd], cwd=cwd) |
subprocess.call(['svn', 'revert', '-R', cwd], cwd=cwd) |
712 |
sys.exit(1) |
sys.exit(1) |
713 |
|
|
714 |
# We can even checkin and submit :-) |
try: |
715 |
if options.submit: |
# If we made it this far, checkin the changes |
716 |
try: |
subprocess.check_call(['mgarepo', 'ci', '-m', 'new version %s' % options.version], cwd=cwd) |
717 |
# checkin changes |
|
718 |
subprocess.check_call(['mgarepo', 'ci', '-m', 'new version %s' % options.version], cwd=cwd) |
# Submit is optional |
719 |
# and submit |
if options.submit: |
720 |
subprocess.check_call(['mgarepo', 'submit'], cwd=cwd) |
subprocess.check_call(['mgarepo', 'submit'], cwd=cwd) |
721 |
except subprocess.CalledProcessError: |
except subprocess.CalledProcessError: |
722 |
sys.exit(1) |
sys.exit(1) |
723 |
|
|
724 |
def cmd_parse_ftp_release_list(options, parser): |
def cmd_parse_ftp_release_list(options, parser): |
725 |
# XXX - not working yet |
def _send_reply_mail(contents, orig_msg, to, packages=[], error=False): |
|
def _send_reply_mail(contents, orig_msg, to, error=False): |
|
726 |
"""Send an reply email""" |
"""Send an reply email""" |
727 |
contents.seek(0) |
contents.seek(0) |
728 |
msg = MIMEText(contents.read(), _charset='utf-8') |
msg = MIMEText(contents.read(), _charset='utf-8') |
729 |
|
|
730 |
if error: |
if error: |
731 |
# XXX - ugly |
# XXX - ugly |
732 |
contents.seek(0) |
contents.seek(0) |
733 |
lastline = contents.read().splitlines()[-1] |
lastline = contents.read().rstrip().splitlines()[-1] |
734 |
# Remove things like "ERROR: " and so on from the last line |
# Remove things like "ERROR: " and so on from the last line |
735 |
lastline = re.sub(r'^(?:[^ :]+:\s+)+', '', lastline) |
lastline = re.sub(r'^(?:[^ :]+:\s+)+', '', lastline) |
736 |
subjecterrror = " (ERROR: %s)" % lastline if lastline else " (ERROR)" |
# Remove things like " - " (youri output from mgarepo submit) |
737 |
|
lastline = re.sub(r'^\s+-\s+', '', lastline) |
738 |
|
subjecterror = " (ERROR: %s)" % lastline if lastline else " (ERROR)" |
739 |
else: |
else: |
740 |
subjecterror = "" |
subjecterror = "" |
741 |
msg['Subject'] = "Re: %s%s" (orig_msg['Subject'], subjecterror) |
|
742 |
|
if packages: |
743 |
|
subject = "%s %s%s" % (", ".join(packages), orig_msg['X-Module-Version'], subjecterror) |
744 |
|
else: |
745 |
|
subject = "Re: %s%s" % (orig_msg['Subject'], subjecterror) |
746 |
|
|
747 |
|
msg['Subject'] = subject |
748 |
msg['To'] = to |
msg['To'] = to |
749 |
msg["In-Reply-To"] = orig_msg["Message-ID"] |
msg["In-Reply-To"] = orig_msg["Message-ID"] |
750 |
msg["References"] = orig_msg["Message-ID"] |
msg["References"] = orig_msg["Message-ID"] |
768 |
stdout = sys.stdout |
stdout = sys.stdout |
769 |
stderr = sys.stderr |
stderr = sys.stderr |
770 |
|
|
|
version_freeze = datetime.datetime(2012,3,7,23,59,0) |
|
|
now = datetime.datetime.utcnow() |
|
|
if now > version_freeze: |
|
|
print >>stderr, "ERROR: Past version freeze" |
|
|
if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True) |
|
|
sys.exit(1) |
|
|
|
|
771 |
try: |
try: |
772 |
module = msg['X-Module-Name'] |
module = msg['X-Module-Name'] |
773 |
version = msg['X-Module-Version'] |
version = msg['X-Module-Version'] |
778 |
sys.exit(1) |
sys.exit(1) |
779 |
|
|
780 |
try: |
try: |
781 |
packages = get_downstream_from_upstream(module, version) |
packages = Downstream().get_downstream_from_upstream(module, version) |
782 |
except ValueError, e: |
except ValueError, e: |
783 |
print >>stderr, "ERROR: %s" % e |
print >>stderr, "ERROR: %s" % e |
784 |
if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True) |
if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True) |
788 |
# maildrop aborts and will try to deliver after 5min |
# maildrop aborts and will try to deliver after 5min |
789 |
# fork to avoid this |
# fork to avoid this |
790 |
if os.fork() != 0: sys.exit(0) |
if os.fork() != 0: sys.exit(0) |
791 |
time.sleep(SLEEP_INITIAL) |
# wait SLEEP_INITIAL after the message was sent |
792 |
|
secs = SLEEP_INITIAL |
793 |
|
t = email.utils.parsedate_tz(msg['Date']) |
794 |
|
if t is not None: |
795 |
|
msg_time = email.utils.mktime_tz(t) |
796 |
|
secs = SLEEP_INITIAL - (time.time() - msg_time) |
797 |
|
|
798 |
|
if secs > 0: time.sleep(secs) |
799 |
|
|
800 |
error = False |
error = False |
801 |
for package in packages: |
for package in packages: |
802 |
if subprocess.call(['mga-gnome', 'increase', '--submit', '--hash', hexdigest, package, version], stdout=stdout, stderr=stderr): |
cmd = ['mga-gnome', 'increase', '--hash', hexdigest] |
803 |
|
if options.submit: |
804 |
|
cmd.append('--submit') |
805 |
|
if options.force: |
806 |
|
cmd.append('--force') |
807 |
|
cmd.extend((package, version)) |
808 |
|
if subprocess.call(cmd, stdout=stdout, stderr=stderr): |
809 |
error = True |
error = True |
810 |
|
|
811 |
if options.mail: _send_reply_mail(stdout, msg, options.mail, error=error) |
if options.mail: _send_reply_mail(stdout, msg, options.mail, packages=packages, error=error) |
812 |
|
|
813 |
def main(): |
def main(): |
814 |
description = """Mageia GNOME commands.""" |
description = """Mageia GNOME commands.""" |
815 |
epilog="""Report bugs to Olav Vitters""" |
epilog="""Report bugs to Olav Vitters""" |
816 |
parser = argparse.ArgumentParser(description=description,epilog=epilog) |
parser = argparse.ArgumentParser(description=description,epilog=epilog) |
817 |
|
parser.add_argument("-l", "--limit", type=argparse.FileType('r', 0), |
818 |
|
dest="limit_upstream", metavar="FILE", |
819 |
|
help="File containing upstream names") |
820 |
|
parser.add_argument("-d", "--distro", action="store", dest="distro", |
821 |
|
help="Distribution release") |
822 |
|
|
823 |
# SUBPARSERS |
# SUBPARSERS |
824 |
subparsers = parser.add_subparsers(title='subcommands') |
subparsers = parser.add_subparsers(title='subcommands') |
831 |
subparser = subparsers.add_parser('packages', help='list all GNOME packages') |
subparser = subparsers.add_parser('packages', help='list all GNOME packages') |
832 |
subparser.add_argument("-m", "--m", action="store_true", dest="upstream", |
subparser.add_argument("-m", "--m", action="store_true", dest="upstream", |
833 |
help="Show upstream module") |
help="Show upstream module") |
834 |
|
subparser.add_argument( "--version", action="store_true", dest="show_version", |
835 |
|
help="Show version numbers") |
836 |
|
subparser.add_argument( "--diff", action="store_true", dest="diff", |
837 |
|
help="Only show packages with different version") |
838 |
|
subparser.add_argument( "--sort", type=argparse.FileType('r', 0), |
839 |
|
dest="sort", metavar="FILE", |
840 |
|
help="Sort packages according to order in given FILE") |
841 |
|
|
842 |
subparser.set_defaults( |
subparser.set_defaults( |
843 |
func=cmd_ls, upstream=False |
func=cmd_ls, upstream=False, show_version=False, diff=False |
844 |
) |
) |
845 |
|
|
846 |
subparser = subparsers.add_parser('patches', help='list all GNOME patches') |
subparser = subparsers.add_parser('patches', help='list all GNOME patches') |
859 |
subparser = subparsers.add_parser('increase', help='Increase version number') |
subparser = subparsers.add_parser('increase', help='Increase version number') |
860 |
subparser.add_argument("package", help="Package name") |
subparser.add_argument("package", help="Package name") |
861 |
subparser.add_argument("version", help="Version number") |
subparser.add_argument("version", help="Version number") |
862 |
|
subparser.add_argument("-f", "--force", action="store_true", dest="force", |
863 |
|
help="Override warnings, just do it") |
864 |
subparser.add_argument("-u", "--upstream", action="store_true", dest="upstream", |
subparser.add_argument("-u", "--upstream", action="store_true", dest="upstream", |
865 |
help="Package name reflects the upstream name") |
help="Package name reflects the upstream name") |
866 |
subparser.add_argument("-s", "--submit", action="store_true", dest="submit", |
subparser.add_argument("-s", "--submit", action="store_true", dest="submit", |
870 |
subparser.add_argument("--hash", dest="hexdigest", |
subparser.add_argument("--hash", dest="hexdigest", |
871 |
help="Hexdigest of the hash") |
help="Hexdigest of the hash") |
872 |
subparser.set_defaults( |
subparser.set_defaults( |
873 |
func=cmd_package_new_version, submit=False, upstream=False, hexdigest=None, algo="sha256" |
func=cmd_package_new_version, submit=True, upstream=False, hexdigest=None, algo="sha256", |
874 |
|
force=False |
875 |
) |
) |
876 |
|
|
877 |
subparser = subparsers.add_parser('gnome-release-email', help='Submit packages based on GNOME ftp-release-list email') |
subparser = subparsers.add_parser('gnome-release-email', help='Submit packages based on GNOME ftp-release-list email') |
878 |
subparser.add_argument("-m", "--mail", help="Email address to send the progress to") |
subparser.add_argument("-m", "--mail", help="Email address to send the progress to") |
879 |
subparser.add_argument("-w", "--wait", action="store_true", |
subparser.add_argument("-w", "--wait", action="store_true", |
880 |
help="Wait before trying to retrieve the new version") |
help="Wait before trying to retrieve the new version") |
881 |
|
subparser.add_argument("-s", "--submit", action="store_true", dest="submit", |
882 |
|
help="Commit changes and submit") |
883 |
|
subparser.add_argument("-f", "--force", action="store_true", |
884 |
|
help="Force submission") |
885 |
subparser.set_defaults( |
subparser.set_defaults( |
886 |
func=cmd_parse_ftp_release_list |
func=cmd_parse_ftp_release_list, force=False, wait=False |
887 |
) |
) |
888 |
|
|
889 |
if len(sys.argv) == 1: |
if len(sys.argv) == 1: |
891 |
sys.exit(2) |
sys.exit(2) |
892 |
|
|
893 |
options = parser.parse_args() |
options = parser.parse_args() |
894 |
|
if options.limit_upstream: |
895 |
|
Upstream.limit = set(options.limit_upstream.read().strip("\n").splitlines()) |
896 |
|
|
897 |
|
if options.distro: |
898 |
|
Downstream.PKGROOT = os.path.join('~/pkgs', options.distro) |
899 |
|
Downstream.MEDIA = "Core Release %s Source" % options.distro |
900 |
|
Downstream.DISTRO = options.distro |
901 |
|
|
902 |
try: |
try: |
903 |
options.func(options, parser) |
options.func(options, parser) |
913 |
sys.exit(0) |
sys.exit(0) |
914 |
|
|
915 |
if __name__ == "__main__": |
if __name__ == "__main__": |
916 |
|
os.environ['PYTHONUNBUFFERED'] = '1' |
917 |
main() |
main() |