46 |
# version freeze |
# version freeze |
47 |
import datetime |
import datetime |
48 |
|
|
49 |
|
# packages --sort |
50 |
|
import itertools |
51 |
|
|
52 |
MEDIA="Core Release Source" |
MEDIA="Core Release Source" |
53 |
URL="http://download.gnome.org/sources/" |
URL="http://download.gnome.org/sources/" |
54 |
PKGROOT='~/pkgs' |
PKGROOT='~/pkgs' |
544 |
self.tarballs = TARBALLS |
self.tarballs = TARBALLS |
545 |
self.files = FILES |
self.files = FILES |
546 |
|
|
547 |
def get_downstream_from_upstream(upstream, version): |
def get_downstream_from_upstream(self, upstream, version): |
548 |
# Determine the package name |
if upstream not in self.tarballs: |
549 |
downstream = Downstream() |
raise ValueError("No packages for upstream name: %s" % upstream) |
|
# downstream, downstream_files = get_downstream_names() |
|
550 |
|
|
551 |
if upstream not in downstream: |
if len(self.tarballs[upstream]) == 1: |
552 |
raise ValueError("No packages for upstream name: %s" % upstream) |
return self.tarballs[upstream].keys() |
553 |
|
|
554 |
if len(downstream.tarballs[upstream]) == 1: |
# Directories packages are located in |
555 |
return downstream.tarballs[upstream].keys() |
root = os.path.expanduser(PKGROOT) |
556 |
|
|
557 |
# Directories packages are located in |
packages = {} |
558 |
root = os.path.expanduser(PKGROOT) |
for package in self.tarballs[upstream].keys(): |
559 |
|
cwd = os.path.join(root, package) |
|
packages = {} |
|
|
for package in downstream.tarballs[upstream].keys(): |
|
|
cwd = os.path.join(root, package) |
|
560 |
|
|
561 |
# Checkout package to ensure the checkout reflects the latest changes |
# Checkout package to ensure the checkout reflects the latest changes |
562 |
try: |
try: |
563 |
subprocess.check_call(['mgarepo', 'co', package], cwd=root) |
subprocess.check_call(['mgarepo', 'co', package], cwd=root) |
564 |
except subprocess.CalledProcessError: |
except subprocess.CalledProcessError: |
565 |
raise ValueError("Multiple packages found and cannot checkout %s" % package) |
raise ValueError("Multiple packages found and cannot checkout %s" % package) |
566 |
|
|
567 |
# Determine version from spec file |
# Determine version from spec file |
568 |
try: |
try: |
569 |
packages[package] = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)).version |
packages[package] = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)).version |
570 |
except subprocess.CalledProcessError: |
except subprocess.CalledProcessError: |
571 |
raise ValueError("Multiple packages found and cannot determine version of %s" % package) |
raise ValueError("Multiple packages found and cannot determine version of %s" % package) |
572 |
|
|
573 |
# Return all packages reflecting the current version |
# Return all packages reflecting the current version |
574 |
matches = [package for package in packages if packages[package] == version] |
matches = [package for package in packages if packages[package] == version] |
575 |
if len(matches): |
if len(matches): |
576 |
return matches |
return matches |
577 |
|
|
578 |
# Return all packages reflecting the version before the current version |
# Return all packages reflecting the version before the current version |
579 |
latest_version = get_latest_version(packages.values(), max_version=version) |
latest_version = get_latest_version(packages.values(), max_version=version) |
580 |
matches = [package for package in packages if packages[package] == latest_version] |
matches = [package for package in packages if packages[package] == latest_version] |
581 |
if len(matches): |
if len(matches): |
582 |
return matches |
return matches |
583 |
|
|
584 |
# Give up |
# Give up |
585 |
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) |
586 |
|
|
587 |
def write_file(path, data): |
def write_file(path, data): |
588 |
with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst: |
with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst: |
621 |
yield (package, module, package_version, spec_version, downstream.files[package]) |
yield (package, module, package_version, spec_version, downstream.files[package]) |
622 |
|
|
623 |
def cmd_ls(options, parser): |
def cmd_ls(options, parser): |
624 |
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) |
625 |
|
if options.sort: |
626 |
|
SORT=dict(zip(options.sort.read().splitlines(), itertools.count())) |
627 |
|
|
628 |
|
streams = sorted(streams, key=lambda a: (SORT.get(a[1], 9999), a[0])) |
629 |
|
else: |
630 |
|
streams = sorted(streams) |
631 |
|
|
632 |
|
for package, module, package_version, spec_version, downstream_files in streams: |
633 |
sys.stdout.write(package) |
sys.stdout.write(package) |
634 |
if options.upstream: sys.stdout.write("\t%s" % module) |
if options.upstream: sys.stdout.write("\t%s" % module) |
635 |
if options.show_version: sys.stdout.write("\t%s\t%s" % (spec_version, package_version)) |
if options.show_version: sys.stdout.write("\t%s\t%s" % (spec_version, package_version)) |
659 |
# Determine the package name |
# Determine the package name |
660 |
if options.upstream: |
if options.upstream: |
661 |
try: |
try: |
662 |
package = get_downstream_from_upstream(options.package, options.version)[0] |
package = Downstream().get_downstream_from_upstream(options.package, options.version)[0] |
663 |
except ValueError, e: |
except ValueError, e: |
664 |
print >>sys.stderr, "ERROR: %s" % e |
print >>sys.stderr, "ERROR: %s" % e |
665 |
sys.exit(1) |
sys.exit(1) |
697 |
subprocess.call(['svn', 'revert', '-R', cwd], cwd=cwd) |
subprocess.call(['svn', 'revert', '-R', cwd], cwd=cwd) |
698 |
sys.exit(1) |
sys.exit(1) |
699 |
|
|
700 |
# We can even checkin and submit :-) |
try: |
701 |
if options.submit: |
# If we made it this far, checkin the changes |
702 |
try: |
subprocess.check_call(['mgarepo', 'ci', '-m', 'new version %s' % options.version], cwd=cwd) |
703 |
# checkin changes |
|
704 |
subprocess.check_call(['mgarepo', 'ci', '-m', 'new version %s' % options.version], cwd=cwd) |
# Submit is optional |
705 |
# and submit |
if options.submit: |
706 |
# XXX HACK NOT TO AUTO SUBMIT ATM |
subprocess.check_call(['mgarepo', 'submit'], cwd=cwd) |
707 |
if options.hexdigest is None: |
except subprocess.CalledProcessError: |
708 |
subprocess.check_call(['mgarepo', 'submit'], cwd=cwd) |
sys.exit(1) |
|
except subprocess.CalledProcessError: |
|
|
sys.exit(1) |
|
709 |
|
|
710 |
def cmd_parse_ftp_release_list(options, parser): |
def cmd_parse_ftp_release_list(options, parser): |
711 |
def _send_reply_mail(contents, orig_msg, to, packages=[], error=False): |
def _send_reply_mail(contents, orig_msg, to, packages=[], error=False): |
764 |
sys.exit(1) |
sys.exit(1) |
765 |
|
|
766 |
try: |
try: |
767 |
packages = get_downstream_from_upstream(module, version) |
packages = Downstream().get_downstream_from_upstream(module, version) |
768 |
except ValueError, e: |
except ValueError, e: |
769 |
print >>stderr, "ERROR: %s" % e |
print >>stderr, "ERROR: %s" % e |
770 |
if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True) |
if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True) |
785 |
|
|
786 |
error = False |
error = False |
787 |
for package in packages: |
for package in packages: |
788 |
cmd = ['mga-gnome', 'increase', '--submit', '--hash', hexdigest] |
cmd = ['mga-gnome', 'increase', '--hash', hexdigest] |
789 |
|
if options.submit: |
790 |
|
cmd.append('--submit') |
791 |
if options.force: |
if options.force: |
792 |
cmd.append('--force') |
cmd.append('--force') |
793 |
cmd.extend((package, version)) |
cmd.extend((package, version)) |
819 |
help="Show version numbers") |
help="Show version numbers") |
820 |
subparser.add_argument( "--diff", action="store_true", dest="diff", |
subparser.add_argument( "--diff", action="store_true", dest="diff", |
821 |
help="Only show packages with different version") |
help="Only show packages with different version") |
822 |
|
subparser.add_argument( "--sort", type=argparse.FileType('r', 0), |
823 |
|
dest="sort", metavar="FILE", |
824 |
|
help="Sort packages according to order in given FILE") |
825 |
|
|
826 |
subparser.set_defaults( |
subparser.set_defaults( |
827 |
func=cmd_ls, upstream=False, show_version=False, diff=False |
func=cmd_ls, upstream=False, show_version=False, diff=False |
828 |
) |
) |
862 |
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") |
863 |
subparser.add_argument("-w", "--wait", action="store_true", |
subparser.add_argument("-w", "--wait", action="store_true", |
864 |
help="Wait before trying to retrieve the new version") |
help="Wait before trying to retrieve the new version") |
865 |
|
subparser.add_argument("-s", "--submit", action="store_true", dest="submit", |
866 |
|
help="Commit changes and submit") |
867 |
subparser.add_argument("-f", "--force", action="store_true", |
subparser.add_argument("-f", "--force", action="store_true", |
868 |
help="Force submission") |
help="Force submission") |
869 |
subparser.set_defaults( |
subparser.set_defaults( |