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 |
# Get the files |
limit = None |
|
usock = urlopen.open(URL) |
|
|
parser = urllister() |
|
|
parser.feed(usock.read()) |
|
|
usock.close() |
|
|
parser.close() |
|
|
files = parser.urls |
|
491 |
|
|
492 |
tarballs = set([filename.replace('/', '') for filename in files if good_dir.search(filename)]) |
def __init__(self): |
493 |
|
urlopen = urllib2.build_opener() |
494 |
|
|
495 |
return tarballs |
good_dir = re.compile('^[-A-Za-z0-9_+.]+/$') |
496 |
|
|
497 |
def get_downstream_names(): |
# Get the files |
498 |
|
usock = urlopen.open(URL) |
499 |
|
parser = urllister() |
500 |
|
parser.feed(usock.read()) |
501 |
|
usock.close() |
502 |
|
parser.close() |
503 |
|
files = parser.urls |
504 |
|
|
505 |
|
tarballs = set([filename.replace('/', '') for filename in files if good_dir.search(filename)]) |
506 |
|
if self.limit is not None: |
507 |
|
tarballs.intersection_update(self.limit) |
508 |
|
|
509 |
|
self.names = tarballs |
510 |
|
|
511 |
|
class Downstream(object): |
512 |
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]*)$') |
513 |
|
|
514 |
contents = subprocess.check_output(['urpmf', '--qf', '%name|%version|%files', '.', "--media", MEDIA], close_fds=True).strip("\n").splitlines() |
def __init__(self): |
515 |
|
contents = subprocess.check_output(['urpmf', '--qf', '%name|%version|%files', '.', "--media", MEDIA], close_fds=True).strip("\n").splitlines() |
516 |
|
|
517 |
FILES = {} |
FILES = {} |
518 |
TARBALLS = {} |
TARBALLS = {} |
519 |
|
|
520 |
for line in contents: |
for line in contents: |
521 |
try: |
try: |
522 |
srpm, version, filename = line.split("|") |
srpm, version, filename = line.split("|") |
523 |
except ValueError: |
except ValueError: |
524 |
print >>sys.stderr, line |
print >>sys.stderr, line |
525 |
continue |
continue |
526 |
|
|
527 |
if '.tar' in filename: |
if '.tar' in filename: |
528 |
r = re_file.match(filename) |
r = self.re_file.match(filename) |
529 |
if r: |
if r: |
530 |
fileinfo = r.groupdict() |
fileinfo = r.groupdict() |
531 |
module = fileinfo['module'] |
module = fileinfo['module'] |
532 |
|
|
533 |
if module not in TARBALLS: |
if module not in TARBALLS: |
534 |
TARBALLS[module] = {} |
TARBALLS[module] = {} |
535 |
TARBALLS[module][srpm] = version |
TARBALLS[module][srpm] = version |
536 |
|
|
537 |
if srpm not in FILES: |
if srpm not in FILES: |
538 |
FILES[srpm] = set() |
FILES[srpm] = set() |
539 |
FILES[srpm].add(filename) |
FILES[srpm].add(filename) |
540 |
|
|
541 |
return TARBALLS, FILES |
self.tarballs = TARBALLS |
542 |
|
self.files = FILES |
543 |
|
|
544 |
def get_downstream_from_upstream(upstream, version): |
def get_downstream_from_upstream(upstream, version): |
545 |
# Determine the package name |
# Determine the package name |
546 |
downstream, downstream_files = get_downstream_names() |
downstream = Downstream() |
547 |
|
# downstream, downstream_files = get_downstream_names() |
548 |
|
|
549 |
if upstream not in downstream: |
if upstream not in downstream: |
550 |
raise ValueError("No packages for upstream name: %s" % upstream) |
raise ValueError("No packages for upstream name: %s" % upstream) |
551 |
|
|
552 |
if len(downstream[upstream]) == 1: |
if len(downstream.tarballs[upstream]) == 1: |
553 |
return downstream[upstream].keys() |
return downstream.tarballs[upstream].keys() |
554 |
|
|
555 |
# Directories packages are located in |
# Directories packages are located in |
556 |
root = os.path.expanduser(PKGROOT) |
root = os.path.expanduser(PKGROOT) |
557 |
|
|
558 |
packages = {} |
packages = {} |
559 |
for package in downstream[upstream].keys(): |
for package in downstream.tarballs[upstream].keys(): |
560 |
cwd = os.path.join(root, package) |
cwd = os.path.join(root, package) |
561 |
|
|
562 |
# Checkout package to ensure the checkout reflects the latest changes |
# Checkout package to ensure the checkout reflects the latest changes |
601 |
def join_streams(show_version=False, only_diff_version=False): |
def join_streams(show_version=False, only_diff_version=False): |
602 |
root = os.path.expanduser(PKGROOT) |
root = os.path.expanduser(PKGROOT) |
603 |
|
|
604 |
upstream = get_upstream_names() |
upstream = Upstream().names |
605 |
downstream, downstream_files = get_downstream_names() |
downstream = Downstream() |
606 |
|
|
607 |
matches = upstream & set(downstream.keys()) |
matches = upstream & set(downstream.tarballs.keys()) |
608 |
for module in matches: |
for module in matches: |
609 |
for package in downstream[module].keys(): |
for package in downstream.tarballs[module].keys(): |
610 |
package_version = downstream[module][package] |
package_version = downstream.tarballs[module][package] |
611 |
spec_version = None |
spec_version = None |
612 |
if show_version or only_diff_version: |
if show_version or only_diff_version: |
613 |
cwd = os.path.join(root, package) |
cwd = os.path.join(root, package) |
619 |
if only_diff_version and package_version == spec_version: |
if only_diff_version and package_version == spec_version: |
620 |
continue |
continue |
621 |
|
|
622 |
yield (package, module, package_version, spec_version, downstream_files[package]) |
yield (package, module, package_version, spec_version, downstream.files[package]) |
623 |
|
|
624 |
def cmd_ls(options, parser): |
def cmd_ls(options, parser): |
625 |
for package, module, package_version, spec_version, downstream_files in sorted(join_streams(show_version=options.show_version, only_diff_version=options.diff)): |
for package, module, package_version, spec_version, downstream_files in sorted(join_streams(show_version=options.show_version, only_diff_version=options.diff)): |
626 |
print package,"\t", |
sys.stdout.write(package) |
627 |
if options.upstream: print module, "\t", |
if options.upstream: sys.stdout.write("\t%s" % module) |
628 |
if options.show_version: print spec_version, "\t", package_version, "\t", |
if options.show_version: sys.stdout.write("\t%s\t%s" % (spec_version, package_version)) |
629 |
print |
print |
630 |
|
|
631 |
def cmd_patches(options, parser): |
def cmd_patches(options, parser): |
696 |
# checkin changes |
# checkin changes |
697 |
subprocess.check_call(['mgarepo', 'ci', '-m', 'new version %s' % options.version], cwd=cwd) |
subprocess.check_call(['mgarepo', 'ci', '-m', 'new version %s' % options.version], cwd=cwd) |
698 |
# and submit |
# and submit |
699 |
subprocess.check_call(['mgarepo', 'submit'], cwd=cwd) |
# XXX HACK NOT TO AUTO SUBMIT ATM |
700 |
|
if options.hexdigest is None: |
701 |
|
subprocess.check_call(['mgarepo', 'submit'], cwd=cwd) |
702 |
except subprocess.CalledProcessError: |
except subprocess.CalledProcessError: |
703 |
sys.exit(1) |
sys.exit(1) |
704 |
|
|
793 |
description = """Mageia GNOME commands.""" |
description = """Mageia GNOME commands.""" |
794 |
epilog="""Report bugs to Olav Vitters""" |
epilog="""Report bugs to Olav Vitters""" |
795 |
parser = argparse.ArgumentParser(description=description,epilog=epilog) |
parser = argparse.ArgumentParser(description=description,epilog=epilog) |
796 |
|
parser.add_argument("-l", "--limit", type=argparse.FileType('r', 0), |
797 |
|
dest="limit_upstream", metavar="FILE", |
798 |
|
help="File containing upstream names") |
799 |
|
|
800 |
# SUBPARSERS |
# SUBPARSERS |
801 |
subparsers = parser.add_subparsers(title='subcommands') |
subparsers = parser.add_subparsers(title='subcommands') |
862 |
sys.exit(2) |
sys.exit(2) |
863 |
|
|
864 |
options = parser.parse_args() |
options = parser.parse_args() |
865 |
|
if options.limit_upstream: |
866 |
|
Upstream.limit = set(options.limit_upstream.read().strip("\n").splitlines()) |
867 |
|
|
868 |
try: |
try: |
869 |
options.func(options, parser) |
options.func(options, parser) |