508 |
|
|
509 |
self.names = tarballs |
self.names = tarballs |
510 |
|
|
511 |
def get_downstream_names(): |
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 |
602 |
root = os.path.expanduser(PKGROOT) |
root = os.path.expanduser(PKGROOT) |
603 |
|
|
604 |
upstream = 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)): |