49 |
# packages --sort |
# packages --sort |
50 |
import itertools |
import itertools |
51 |
|
|
|
MEDIA="Core Release Source" |
|
|
URL="http://download.gnome.org/sources/" |
|
|
PKGROOT='~/pkgs' |
|
52 |
SLEEP_INITIAL=180 |
SLEEP_INITIAL=180 |
53 |
SLEEP_REPEAT=30 |
SLEEP_REPEAT=30 |
54 |
SLEEP_TIMES=20 |
SLEEP_TIMES=20 |
487 |
|
|
488 |
class Upstream(object): |
class Upstream(object): |
489 |
|
|
490 |
|
URL="http://download.gnome.org/sources/" |
491 |
limit = None |
limit = None |
492 |
|
|
493 |
def __init__(self): |
def __init__(self): |
496 |
good_dir = re.compile('^[-A-Za-z0-9_+.]+/$') |
good_dir = re.compile('^[-A-Za-z0-9_+.]+/$') |
497 |
|
|
498 |
# Get the files |
# Get the files |
499 |
usock = urlopen.open(URL) |
usock = urlopen.open(self.URL) |
500 |
parser = urllister() |
parser = urllister() |
501 |
parser.feed(usock.read()) |
parser.feed(usock.read()) |
502 |
usock.close() |
usock.close() |
512 |
class Downstream(object): |
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 |
|
MEDIA="Core Release Source" |
516 |
|
PKGROOT='~/pkgs' |
517 |
|
DISTRO=None |
518 |
|
|
519 |
def __init__(self): |
def __init__(self): |
520 |
contents = subprocess.check_output(['urpmf', '--qf', '%name|%version|%files', '.', "--media", MEDIA], close_fds=True).strip("\n").splitlines() |
contents = subprocess.check_output(['urpmf', '--qf', '%name|%version|%files', '.', "--media", self.MEDIA], close_fds=True).strip("\n").splitlines() |
521 |
|
|
522 |
FILES = {} |
FILES = {} |
523 |
TARBALLS = {} |
TARBALLS = {} |
546 |
self.tarballs = TARBALLS |
self.tarballs = TARBALLS |
547 |
self.files = FILES |
self.files = FILES |
548 |
|
|
549 |
|
@classmethod |
550 |
|
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): |
def get_downstream_from_upstream(self, upstream, version): |
561 |
if upstream not in self.tarballs: |
if upstream not in self.tarballs: |
562 |
raise ValueError("No packages for upstream name: %s" % upstream) |
raise ValueError("No packages for upstream name: %s" % upstream) |
565 |
return self.tarballs[upstream].keys() |
return self.tarballs[upstream].keys() |
566 |
|
|
567 |
# Directories packages are located in |
# Directories packages are located in |
568 |
root = os.path.expanduser(PKGROOT) |
root = os.path.expanduser(self.PKGROOT) |
569 |
|
|
570 |
packages = {} |
packages = {} |
571 |
for package in self.tarballs[upstream].keys(): |
for package in self.tarballs[upstream].keys(): |
573 |
|
|
574 |
# Checkout package to ensure the checkout reflects the latest changes |
# Checkout package to ensure the checkout reflects the latest changes |
575 |
try: |
try: |
576 |
subprocess.check_call(['mgarepo', 'co', package], cwd=root) |
self.co(package, cwd=root) |
577 |
except subprocess.CalledProcessError: |
except subprocess.CalledProcessError: |
578 |
raise ValueError("Multiple packages found and cannot checkout %s" % package) |
raise ValueError("Multiple packages found and cannot checkout %s" % package) |
579 |
|
|
604 |
os.rename(fdst.name, path) |
os.rename(fdst.name, path) |
605 |
|
|
606 |
def cmd_co(options, parser): |
def cmd_co(options, parser): |
|
root = os.path.expanduser(PKGROOT) |
|
|
|
|
607 |
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()): |
608 |
print "%s => %s" % (module, package) |
print "%s => %s" % (module, package) |
609 |
subprocess.call(['mgarepo', 'co', package], cwd=root) |
try: |
610 |
|
Downstream.co(package) |
611 |
|
except subprocess.CalledProcessError: |
612 |
|
pass |
613 |
|
|
614 |
def join_streams(show_version=False, only_diff_version=False): |
def join_streams(show_version=False, only_diff_version=False): |
615 |
root = os.path.expanduser(PKGROOT) |
root = os.path.expanduser(Downstream.PKGROOT) |
616 |
|
|
617 |
upstream = Upstream().names |
upstream = Upstream().names |
618 |
downstream = Downstream() |
downstream = Downstream() |
650 |
print |
print |
651 |
|
|
652 |
def cmd_patches(options, parser): |
def cmd_patches(options, parser): |
653 |
root = os.path.expanduser(PKGROOT) |
root = os.path.expanduser(Downstream.PKGROOT) |
654 |
|
|
655 |
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()): |
656 |
for filename in downstream_files: |
for filename in downstream_files: |
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 |
|
|
817 |
parser.add_argument("-l", "--limit", type=argparse.FileType('r', 0), |
parser.add_argument("-l", "--limit", type=argparse.FileType('r', 0), |
818 |
dest="limit_upstream", metavar="FILE", |
dest="limit_upstream", metavar="FILE", |
819 |
help="File containing upstream names") |
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') |
894 |
if options.limit_upstream: |
if options.limit_upstream: |
895 |
Upstream.limit = set(options.limit_upstream.read().strip("\n").splitlines()) |
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) |
904 |
except KeyboardInterrupt: |
except KeyboardInterrupt: |