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 |
|
# check-latest |
53 |
|
import requests |
54 |
|
|
55 |
SLEEP_INITIAL=180 |
SLEEP_INITIAL=180 |
56 |
SLEEP_REPEAT=30 |
SLEEP_REPEAT=30 |
57 |
SLEEP_TIMES=20 |
SLEEP_TIMES=30 |
58 |
|
|
59 |
re_majmin = re.compile(r'^([0-9]+\.[0-9]+).*') |
re_majmin = re.compile(r'^([0-9]+\.[0-9]+).*') |
60 |
re_version = re.compile(r'([-.]|\d+|[^-.\d]+)') |
re_version = re.compile(r'([-.]|\d+|[^-.\d]+)') |
82 |
latest = version |
latest = version |
83 |
return latest |
return latest |
84 |
|
|
85 |
|
def get_safe_max_version(version): |
86 |
|
if not re_majmin.match(version): |
87 |
|
return None |
88 |
|
|
89 |
|
majmin_nr = map(long, re_majmin.sub(r'\1', version).split('.')) |
90 |
|
|
91 |
|
if majmin_nr[1] % 2 == 0: |
92 |
|
return "%d.%d" % (majmin_nr[0], majmin_nr[1] + 1) |
93 |
|
else: |
94 |
|
return "%d.%d" % (majmin_nr[0], majmin_nr[1] + 2) |
95 |
|
|
96 |
def judge_version_increase(version_old, version_new): |
def judge_version_increase(version_old, version_new): |
97 |
"""Judge quality of version increase: |
"""Judge quality of version increase: |
98 |
|
|
305 |
with open(self.path, "rw") as f: |
with open(self.path, "rw") as f: |
306 |
data = f.read() |
data = f.read() |
307 |
|
|
308 |
|
if data.count("%subrel") != 0: |
309 |
|
print >>sys.stderr, "ERROR: %subrel found; don't know what to do!" |
310 |
|
return False |
311 |
|
|
312 |
if data.count("%mkrel") != 1: |
if data.count("%mkrel") != 1: |
313 |
print >>sys.stderr, "ERROR: Multiple %mkrel found; don't know what to do!" |
print >>sys.stderr, "ERROR: Multiple %mkrel found; don't know what to do!" |
314 |
return False |
return False |
337 |
tries = 0 |
tries = 0 |
338 |
while tries < SLEEP_TIMES: |
while tries < SLEEP_TIMES: |
339 |
tries += 1 |
tries += 1 |
340 |
if tries > 1: time.sleep(SLEEP_REPEAT) |
if tries > 1: time.sleep(SLEEP_REPEAT * 2 ** (tries // 10)) |
341 |
try: |
try: |
342 |
# Download new tarball |
# Download new tarball |
343 |
subprocess.check_call(['mgarepo', 'sync', '-d'], cwd=self.cwd) |
subprocess.check_call(['mgarepo', 'sync', '-d'], cwd=self.cwd) |
346 |
except subprocess.CalledProcessError, e: |
except subprocess.CalledProcessError, e: |
347 |
# mgarepo sync returns 1 if the tarball cannot be downloaded |
# mgarepo sync returns 1 if the tarball cannot be downloaded |
348 |
if e.returncode != 1: |
if e.returncode != 1: |
349 |
|
subprocess.check_call(["svn", "revert", "-R", os.path.join(self.path, '..')]) |
350 |
return False |
return False |
351 |
else: |
else: |
352 |
|
# failed to download tarball |
353 |
|
subprocess.check_call(["svn", "revert", "-R", os.path.join(self.path, '..')]) |
354 |
return False |
return False |
355 |
|
|
356 |
|
|
505 |
|
|
506 |
return self._svn_author |
return self._svn_author |
507 |
|
|
|
def get_upstream_names(): |
|
|
urlopen = urllib2.build_opener() |
|
508 |
|
|
509 |
good_dir = re.compile('^[-A-Za-z0-9_+.]+/$') |
class Upstream(object): |
510 |
|
|
511 |
# Get the files |
URL="http://download.gnome.org/sources/" |
512 |
usock = urlopen.open(URL) |
limit = None |
513 |
parser = urllister() |
_cache_versions = {} |
514 |
parser.feed(usock.read()) |
|
515 |
usock.close() |
def __init__(self): |
516 |
parser.close() |
urlopen = urllib2.build_opener() |
517 |
files = parser.urls |
|
518 |
|
good_dir = re.compile('^[-A-Za-z0-9_+.]+/$') |
519 |
|
|
520 |
|
# Get the files |
521 |
|
usock = urlopen.open(self.URL) |
522 |
|
parser = urllister() |
523 |
|
parser.feed(usock.read()) |
524 |
|
usock.close() |
525 |
|
parser.close() |
526 |
|
files = parser.urls |
527 |
|
|
528 |
|
tarballs = set([filename.replace('/', '') for filename in files if good_dir.search(filename)]) |
529 |
|
if self.limit is not None: |
530 |
|
tarballs.intersection_update(self.limit) |
531 |
|
|
532 |
tarballs = set([filename.replace('/', '') for filename in files if good_dir.search(filename)]) |
self.names = tarballs |
533 |
|
|
534 |
return tarballs |
@classmethod |
535 |
|
def versions(cls, module): |
536 |
def get_downstream_names(): |
# XXX - ugly |
537 |
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]*)$') |
if module not in cls._cache_versions: |
538 |
|
versions = None |
539 |
|
|
540 |
|
url = '%s%s/cache.json' % (cls.URL, module) |
541 |
|
r = requests.get(url) |
542 |
|
j = r.json |
543 |
|
if j is not None and len(j) > 2 and module in j[2]: |
544 |
|
versions = j[2][module] |
545 |
|
|
546 |
contents = subprocess.check_output(['urpmf', '--qf', '%name|%version|%files', '.', "--media", MEDIA], close_fds=True).strip("\n").splitlines() |
cls._cache_versions[module] = versions |
547 |
|
|
548 |
FILES = {} |
return cls._cache_versions[module] |
|
TARBALLS = {} |
|
549 |
|
|
550 |
for line in contents: |
class Downstream(object): |
551 |
try: |
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]*)$') |
|
srpm, version, filename = line.split("|") |
|
|
except ValueError: |
|
|
print >>sys.stderr, line |
|
|
continue |
|
552 |
|
|
553 |
if '.tar' in filename: |
MEDIA="Core Release Source" |
554 |
r = re_file.match(filename) |
PKGROOT='~/pkgs' |
555 |
if r: |
DISTRO=None |
|
fileinfo = r.groupdict() |
|
|
module = fileinfo['module'] |
|
|
|
|
|
if module not in TARBALLS: |
|
|
TARBALLS[module] = {} |
|
|
TARBALLS[module][srpm] = version |
|
|
|
|
|
if srpm not in FILES: |
|
|
FILES[srpm] = set() |
|
|
FILES[srpm].add(filename) |
|
556 |
|
|
557 |
return TARBALLS, FILES |
def __init__(self): |
558 |
|
contents = subprocess.check_output(['urpmf', '--qf', '%name|%version|%files', '.', "--media", self.MEDIA], close_fds=True).strip("\n").splitlines() |
559 |
|
|
560 |
def get_downstream_from_upstream(upstream, version): |
FILES = {} |
561 |
# Determine the package name |
TARBALLS = {} |
|
downstream, downstream_files = get_downstream_names() |
|
562 |
|
|
563 |
if upstream not in downstream: |
for line in contents: |
564 |
raise ValueError("No packages for upstream name: %s" % upstream) |
try: |
565 |
|
srpm, version, filename = line.split("|") |
566 |
|
except ValueError: |
567 |
|
print >>sys.stderr, line |
568 |
|
continue |
569 |
|
|
570 |
if len(downstream[upstream]) == 1: |
if '.tar' in filename: |
571 |
return downstream[upstream].keys() |
r = self.re_file.match(filename) |
572 |
|
if r: |
573 |
|
fileinfo = r.groupdict() |
574 |
|
module = fileinfo['module'] |
575 |
|
|
576 |
|
if module not in TARBALLS: |
577 |
|
TARBALLS[module] = {} |
578 |
|
|
579 |
|
if srpm in TARBALLS[module]: |
580 |
|
# srpm seen before, check if version is newer |
581 |
|
if version_cmp(TARBALLS[module][srpm], version) == 1: |
582 |
|
TARBALLS[module][srpm] = version |
583 |
|
else: |
584 |
|
TARBALLS[module][srpm] = version |
585 |
|
|
586 |
|
if srpm not in FILES: |
587 |
|
FILES[srpm] = set() |
588 |
|
FILES[srpm].add(filename) |
589 |
|
|
590 |
# Directories packages are located in |
self.tarballs = TARBALLS |
591 |
root = os.path.expanduser(PKGROOT) |
self.files = FILES |
592 |
|
|
593 |
packages = {} |
@classmethod |
594 |
for package in downstream[upstream].keys(): |
def co(cls, package, cwd=None): |
595 |
cwd = os.path.join(root, package) |
if cwd is None: |
596 |
|
cwd = os.path.expanduser(cls.PKGROOT) |
597 |
|
|
598 |
|
cmd = ['mgarepo', 'co'] |
599 |
|
if cls.DISTRO: |
600 |
|
cmd.extend(('-d', cls.DISTRO)) |
601 |
|
cmd.append(package) |
602 |
|
return subprocess.check_call(cmd, cwd=cwd) |
603 |
|
|
604 |
|
def get_downstream_from_upstream(self, upstream, version): |
605 |
|
if upstream not in self.tarballs: |
606 |
|
raise ValueError("No packages for upstream name: %s" % upstream) |
607 |
|
|
608 |
|
if len(self.tarballs[upstream]) == 1: |
609 |
|
return self.tarballs[upstream].keys() |
610 |
|
|
611 |
|
# Directories packages are located in |
612 |
|
root = os.path.expanduser(self.PKGROOT) |
613 |
|
|
614 |
|
packages = {} |
615 |
|
for package in self.tarballs[upstream].keys(): |
616 |
|
cwd = os.path.join(root, package) |
617 |
|
|
618 |
# Checkout package to ensure the checkout reflects the latest changes |
# Checkout package to ensure the checkout reflects the latest changes |
619 |
try: |
try: |
620 |
subprocess.check_call(['mgarepo', 'co', package], cwd=root) |
self.co(package, cwd=root) |
621 |
except subprocess.CalledProcessError: |
except subprocess.CalledProcessError: |
622 |
raise ValueError("Multiple packages found and cannot checkout %s" % package) |
raise ValueError("Multiple packages found and cannot checkout %s" % package) |
623 |
|
|
624 |
# Determine version from spec file |
# Determine version from spec file |
625 |
try: |
try: |
626 |
packages[package] = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)).version |
packages[package] = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)).version |
627 |
except subprocess.CalledProcessError: |
except subprocess.CalledProcessError: |
628 |
raise ValueError("Multiple packages found and cannot determine version of %s" % package) |
raise ValueError("Multiple packages found and cannot determine version of %s" % package) |
629 |
|
|
630 |
# Return all packages reflecting the current version |
# Return all packages reflecting the current version |
631 |
matches = [package for package in packages if packages[package] == version] |
matches = [package for package in packages if packages[package] == version] |
632 |
if len(matches): |
if len(matches): |
633 |
return matches |
return matches |
634 |
|
|
635 |
# Return all packages reflecting the version before the current version |
# Return all packages reflecting the version before the current version |
636 |
latest_version = get_latest_version(packages.values(), max_version=version) |
latest_version = get_latest_version(packages.values(), max_version=version) |
637 |
matches = [package for package in packages if packages[package] == latest_version] |
matches = [package for package in packages if packages[package] == latest_version] |
638 |
if len(matches): |
if len(matches): |
639 |
return matches |
return matches |
640 |
|
|
641 |
# Give up |
# Give up |
642 |
raise ValueError("Multiple packages found and cannot determine package for version %s" % version) |
raise ValueError("Multiple packages found and cannot determine package for version %s" % version) |
643 |
|
|
644 |
def write_file(path, data): |
def write_file(path, data): |
645 |
with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst: |
with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst: |
648 |
os.rename(fdst.name, path) |
os.rename(fdst.name, path) |
649 |
|
|
650 |
def cmd_co(options, parser): |
def cmd_co(options, parser): |
|
root = os.path.expanduser(PKGROOT) |
|
|
|
|
651 |
for package, module, package_version, spec_version, downstream_files in sorted(join_streams()): |
for package, module, package_version, spec_version, downstream_files in sorted(join_streams()): |
652 |
print "%s => %s" % (module, package) |
print "%s => %s" % (module, package) |
653 |
subprocess.call(['mgarepo', 'co', package], cwd=root) |
try: |
654 |
|
Downstream.co(package) |
655 |
|
except subprocess.CalledProcessError: |
656 |
|
pass |
657 |
|
|
658 |
def join_streams(show_version=False, only_diff_version=False): |
def join_streams(show_version=False, only_diff_version=False): |
659 |
root = os.path.expanduser(PKGROOT) |
root = os.path.expanduser(Downstream.PKGROOT) |
660 |
|
|
661 |
upstream = get_upstream_names() |
upstream = Upstream().names |
662 |
downstream, downstream_files = get_downstream_names() |
downstream = Downstream() |
663 |
|
|
664 |
matches = upstream & set(downstream.keys()) |
matches = upstream & set(downstream.tarballs.keys()) |
665 |
for module in matches: |
for module in matches: |
666 |
for package in downstream[module].keys(): |
for package in downstream.tarballs[module].keys(): |
667 |
package_version = downstream[module][package] |
package_version = downstream.tarballs[module][package] |
668 |
spec_version = None |
spec_version = None |
669 |
if show_version or only_diff_version: |
if show_version or only_diff_version: |
670 |
cwd = os.path.join(root, package) |
cwd = os.path.join(root, package) |
676 |
if only_diff_version and package_version == spec_version: |
if only_diff_version and package_version == spec_version: |
677 |
continue |
continue |
678 |
|
|
679 |
yield (package, module, package_version, spec_version, downstream_files[package]) |
yield (package, module, package_version, spec_version, downstream.files[package]) |
680 |
|
|
681 |
def cmd_ls(options, parser): |
def cmd_ls(options, parser): |
682 |
for package, module, package_version, spec_version, downstream_files in sorted(join_streams(show_version=options.show_version, only_diff_version=options.diff)): |
streams = join_streams(show_version=options.show_version, only_diff_version=options.diff) |
683 |
print package,"\t", |
if options.sort: |
684 |
if options.upstream: print module, "\t", |
SORT=dict(zip(options.sort.read().splitlines(), itertools.count())) |
685 |
if options.show_version: print spec_version, "\t", package_version, "\t", |
|
686 |
|
streams = sorted(streams, key=lambda a: (SORT.get(a[1], 9999), a[0])) |
687 |
|
else: |
688 |
|
streams = sorted(streams) |
689 |
|
|
690 |
|
for package, module, package_version, spec_version, downstream_files in streams: |
691 |
|
sys.stdout.write(package) |
692 |
|
if options.upstream: sys.stdout.write("\t%s" % module) |
693 |
|
if options.show_version: sys.stdout.write("\t%s\t%s" % (spec_version, package_version)) |
694 |
|
print |
695 |
|
|
696 |
|
def cmd_check_latest(options, parser): |
697 |
|
streams = join_streams(show_version=True) |
698 |
|
|
699 |
|
for package, module, package_version, spec_version, downstream_files in streams: |
700 |
|
upgrade=set() |
701 |
|
sys.stdout.write(package) |
702 |
|
sys.stdout.write("\t%s\t%s" % (spec_version, package_version)) |
703 |
|
|
704 |
|
safe_max_version = get_safe_max_version(spec_version) |
705 |
|
|
706 |
|
versions = Upstream.versions(module) |
707 |
|
if versions: |
708 |
|
latest_version = get_latest_version(versions) |
709 |
|
safe_version = get_latest_version(versions, safe_max_version) |
710 |
|
|
711 |
|
cmp_latest = version_cmp(latest_version, spec_version) |
712 |
|
if cmp_latest < 0: |
713 |
|
latest_version = 'N/A' |
714 |
|
upgrade.add('l') |
715 |
|
elif cmp_latest > 0: |
716 |
|
upgrade.add('L') |
717 |
|
|
718 |
|
cmp_safe = version_cmp(safe_version, spec_version) |
719 |
|
if cmp_safe < 0: |
720 |
|
safe_version = 'N/A' |
721 |
|
upgrade.add('s') |
722 |
|
elif cmp_safe > 0: |
723 |
|
upgrade.add('S') |
724 |
|
|
725 |
|
sys.stdout.write("\t%s" % latest_version) |
726 |
|
sys.stdout.write("\t%s" % safe_version) |
727 |
|
sys.stdout.write("\t%s" % "".join(sorted(upgrade))) |
728 |
|
|
729 |
print |
print |
730 |
|
|
731 |
def cmd_patches(options, parser): |
def cmd_patches(options, parser): |
732 |
root = os.path.expanduser(PKGROOT) |
root = os.path.expanduser(Downstream.PKGROOT) |
733 |
|
|
734 |
for package, module, package_version, spec_version, downstream_files in sorted(join_streams()): |
for package, module, package_version, spec_version, downstream_files in sorted(join_streams()): |
735 |
for filename in downstream_files: |
for filename in downstream_files: |
752 |
# Determine the package name |
# Determine the package name |
753 |
if options.upstream: |
if options.upstream: |
754 |
try: |
try: |
755 |
package = get_downstream_from_upstream(options.package, options.version)[0] |
package = Downstream().get_downstream_from_upstream(options.package, options.version)[0] |
756 |
except ValueError, e: |
except ValueError, e: |
757 |
print >>sys.stderr, "ERROR: %s" % e |
print >>sys.stderr, "ERROR: %s" % e |
758 |
sys.exit(1) |
sys.exit(1) |
760 |
package = options.package |
package = options.package |
761 |
|
|
762 |
# Directories packages are located in |
# Directories packages are located in |
763 |
root = os.path.expanduser(PKGROOT) |
root = os.path.expanduser(Downstream.PKGROOT) |
764 |
cwd = os.path.join(root, package) |
cwd = os.path.join(root, package) |
765 |
|
|
766 |
# Checkout package to ensure the checkout reflects the latest changes |
# Checkout package to ensure the checkout reflects the latest changes |
767 |
try: |
try: |
768 |
subprocess.check_call(['mgarepo', 'co', package], cwd=root) |
Downstream.co(package, cwd=root) |
769 |
except subprocess.CalledProcessError: |
except subprocess.CalledProcessError: |
770 |
sys.exit(1) |
sys.exit(1) |
771 |
|
|
782 |
print >>sys.stderr, "ERROR: Cannot determine source file (for hash check)!" |
print >>sys.stderr, "ERROR: Cannot determine source file (for hash check)!" |
783 |
sys.stderr(1) |
sys.stderr(1) |
784 |
|
|
785 |
|
# If there are multiple sources, try to see if there is a preferred name |
786 |
|
# --> needed for metacity hash check (multiple tarball sources) |
787 |
|
if len(sources) > 1: |
788 |
|
preferred_name = '%s-%s.tar.xz' % (package, options.version) |
789 |
|
if preferred_name in sources: |
790 |
|
sources = [preferred_name] |
791 |
|
|
792 |
for filename in sources: |
for filename in sources: |
793 |
if not is_valid_hash(os.path.join(cwd, "SOURCES", filename), options.algo, options.hexdigest): |
path = os.path.join(cwd, "SOURCES", filename) |
794 |
|
if not is_valid_hash(path, options.algo, options.hexdigest): |
795 |
print >>sys.stderr, "ERROR: Hash file failed check for %s!" % path |
print >>sys.stderr, "ERROR: Hash file failed check for %s!" % path |
796 |
print >>sys.stderr, "ERROR: Reverting changes!" |
print >>sys.stderr, "ERROR: Reverting changes!" |
797 |
subprocess.call(['svn', 'revert', '-R', cwd], cwd=cwd) |
subprocess.call(['svn', 'revert', '-R', cwd], cwd=cwd) |
798 |
sys.exit(1) |
sys.exit(1) |
799 |
|
|
800 |
# We can even checkin and submit :-) |
try: |
801 |
if options.submit: |
# If we made it this far, checkin the changes |
802 |
try: |
subprocess.check_call(['mgarepo', 'ci', '-m', 'new version %s' % options.version], cwd=cwd) |
803 |
# checkin changes |
|
804 |
subprocess.check_call(['mgarepo', 'ci', '-m', 'new version %s' % options.version], cwd=cwd) |
# Submit is optional |
805 |
# and submit |
if options.submit: |
806 |
subprocess.check_call(['mgarepo', 'submit'], cwd=cwd) |
cmd = ['mgarepo', 'submit'] |
807 |
except subprocess.CalledProcessError: |
if Downstream.DISTRO: |
808 |
sys.exit(1) |
cmd.extend(('--define', 'section=core/updates_testing', '-t', Downstream.DISTRO)) |
809 |
|
subprocess.check_call(cmd, cwd=cwd) |
810 |
|
except subprocess.CalledProcessError: |
811 |
|
sys.exit(1) |
812 |
|
|
813 |
def cmd_parse_ftp_release_list(options, parser): |
def cmd_parse_ftp_release_list(options, parser): |
814 |
def _send_reply_mail(contents, orig_msg, to, error=False): |
def _send_reply_mail(contents, orig_msg, to, packages=[], error=False): |
815 |
"""Send an reply email""" |
"""Send an reply email""" |
816 |
contents.seek(0) |
contents.seek(0) |
817 |
msg = MIMEText(contents.read(), _charset='utf-8') |
msg = MIMEText(contents.read(), _charset='utf-8') |
818 |
|
|
819 |
if error: |
if error: |
820 |
# XXX - ugly |
# XXX - ugly |
821 |
contents.seek(0) |
contents.seek(0) |
827 |
subjecterror = " (ERROR: %s)" % lastline if lastline else " (ERROR)" |
subjecterror = " (ERROR: %s)" % lastline if lastline else " (ERROR)" |
828 |
else: |
else: |
829 |
subjecterror = "" |
subjecterror = "" |
830 |
msg['Subject'] = "Re: %s%s" % (orig_msg['Subject'], subjecterror) |
|
831 |
|
if packages: |
832 |
|
subject = "%s %s%s" % (", ".join(packages), orig_msg['X-Module-Version'], subjecterror) |
833 |
|
else: |
834 |
|
subject = "Re: %s%s" % (orig_msg['Subject'], subjecterror) |
835 |
|
|
836 |
|
msg['Subject'] = subject |
837 |
msg['To'] = to |
msg['To'] = to |
838 |
msg["In-Reply-To"] = orig_msg["Message-ID"] |
msg["In-Reply-To"] = orig_msg["Message-ID"] |
839 |
msg["References"] = orig_msg["Message-ID"] |
msg["References"] = orig_msg["Message-ID"] |
867 |
sys.exit(1) |
sys.exit(1) |
868 |
|
|
869 |
try: |
try: |
870 |
packages = get_downstream_from_upstream(module, version) |
packages = Downstream().get_downstream_from_upstream(module, version) |
871 |
except ValueError, e: |
except ValueError, e: |
872 |
print >>stderr, "ERROR: %s" % e |
print >>stderr, "ERROR: %s" % e |
873 |
if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True) |
if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True) |
888 |
|
|
889 |
error = False |
error = False |
890 |
for package in packages: |
for package in packages: |
891 |
cmd = ['mga-gnome', 'increase', '--submit', '--hash', hexdigest] |
cmd = ['mga-gnome', 'increase', '--hash', hexdigest] |
892 |
|
if options.submit: |
893 |
|
cmd.append('--submit') |
894 |
if options.force: |
if options.force: |
895 |
cmd.append('--force') |
cmd.append('--force') |
896 |
cmd.extend((package, version)) |
cmd.extend((package, version)) |
897 |
if subprocess.call(cmd, stdout=stdout, stderr=stderr): |
if subprocess.call(cmd, stdout=stdout, stderr=stderr): |
898 |
error = True |
error = True |
899 |
|
|
900 |
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) |
901 |
|
|
902 |
def main(): |
def main(): |
903 |
description = """Mageia GNOME commands.""" |
description = """Mageia GNOME commands.""" |
904 |
epilog="""Report bugs to Olav Vitters""" |
epilog="""Report bugs to Olav Vitters""" |
905 |
parser = argparse.ArgumentParser(description=description,epilog=epilog) |
parser = argparse.ArgumentParser(description=description,epilog=epilog) |
906 |
|
parser.add_argument("-l", "--limit", type=argparse.FileType('r', 0), |
907 |
|
dest="limit_upstream", metavar="FILE", |
908 |
|
help="File containing upstream names") |
909 |
|
parser.add_argument("-d", "--distro", action="store", dest="distro", |
910 |
|
help="Distribution release") |
911 |
|
|
912 |
# SUBPARSERS |
# SUBPARSERS |
913 |
subparsers = parser.add_subparsers(title='subcommands') |
subparsers = parser.add_subparsers(title='subcommands') |
924 |
help="Show version numbers") |
help="Show version numbers") |
925 |
subparser.add_argument( "--diff", action="store_true", dest="diff", |
subparser.add_argument( "--diff", action="store_true", dest="diff", |
926 |
help="Only show packages with different version") |
help="Only show packages with different version") |
927 |
|
subparser.add_argument( "--sort", type=argparse.FileType('r', 0), |
928 |
|
dest="sort", metavar="FILE", |
929 |
|
help="Sort packages according to order in given FILE") |
930 |
|
|
931 |
subparser.set_defaults( |
subparser.set_defaults( |
932 |
func=cmd_ls, upstream=False, show_version=False, diff=False |
func=cmd_ls, upstream=False, show_version=False, diff=False |
933 |
) |
) |
934 |
|
|
935 |
|
subparser = subparsers.add_parser('check-latest', help='check for latest version of packages') |
936 |
|
subparser.set_defaults( |
937 |
|
func=cmd_check_latest |
938 |
|
) |
939 |
|
|
940 |
subparser = subparsers.add_parser('patches', help='list all GNOME patches') |
subparser = subparsers.add_parser('patches', help='list all GNOME patches') |
941 |
subparser.add_argument("-p", "--path", action="store_true", dest="path", |
subparser.add_argument("-p", "--path", action="store_true", dest="path", |
942 |
help="Show full path to patch") |
help="Show full path to patch") |
959 |
help="Package name reflects the upstream name") |
help="Package name reflects the upstream name") |
960 |
subparser.add_argument("-s", "--submit", action="store_true", dest="submit", |
subparser.add_argument("-s", "--submit", action="store_true", dest="submit", |
961 |
help="Commit changes and submit") |
help="Commit changes and submit") |
962 |
|
subparser.add_argument( "--no-submit", action="store_false", dest="submit", |
963 |
|
help="Do not commit changes and submit") |
964 |
subparser.add_argument("-a", "--algorithm", choices=hashlib.algorithms, dest="algo", |
subparser.add_argument("-a", "--algorithm", choices=hashlib.algorithms, dest="algo", |
965 |
help="Hash algorithm") |
help="Hash algorithm") |
966 |
subparser.add_argument("--hash", dest="hexdigest", |
subparser.add_argument("--hash", dest="hexdigest", |
967 |
help="Hexdigest of the hash") |
help="Hexdigest of the hash") |
968 |
subparser.set_defaults( |
subparser.set_defaults( |
969 |
func=cmd_package_new_version, submit=False, upstream=False, hexdigest=None, algo="sha256", |
func=cmd_package_new_version, submit=argparse.SUPPRESS, upstream=False, hexdigest=None, algo="sha256", |
970 |
force=False |
force=False |
971 |
) |
) |
972 |
|
|
974 |
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") |
975 |
subparser.add_argument("-w", "--wait", action="store_true", |
subparser.add_argument("-w", "--wait", action="store_true", |
976 |
help="Wait before trying to retrieve the new version") |
help="Wait before trying to retrieve the new version") |
977 |
|
subparser.add_argument("-s", "--submit", action="store_true", dest="submit", |
978 |
|
help="Commit changes and submit") |
979 |
subparser.add_argument("-f", "--force", action="store_true", |
subparser.add_argument("-f", "--force", action="store_true", |
980 |
help="Force submission") |
help="Force submission") |
981 |
subparser.set_defaults( |
subparser.set_defaults( |
987 |
sys.exit(2) |
sys.exit(2) |
988 |
|
|
989 |
options = parser.parse_args() |
options = parser.parse_args() |
990 |
|
if options.limit_upstream: |
991 |
|
Upstream.limit = set(options.limit_upstream.read().strip("\n").splitlines()) |
992 |
|
|
993 |
|
if not hasattr(options, 'submit'): |
994 |
|
options.submit = not options.distro |
995 |
|
|
996 |
|
if options.distro: |
997 |
|
Downstream.PKGROOT = os.path.join('~/pkgs', options.distro) |
998 |
|
Downstream.MEDIA = "Core Release {0} Source,Core {0} Updates Source,Core {0} Updates Testing Source".format(options.distro) |
999 |
|
Downstream.DISTRO = options.distro |
1000 |
|
|
1001 |
try: |
try: |
1002 |
options.func(options, parser) |
options.func(options, parser) |