49 |
# packages --sort |
# packages --sort |
50 |
import itertools |
import itertools |
51 |
|
|
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 |
|
|
510 |
|
|
511 |
URL="http://download.gnome.org/sources/" |
URL="http://download.gnome.org/sources/" |
512 |
limit = None |
limit = None |
513 |
|
_cache_versions = {} |
514 |
|
|
515 |
def __init__(self): |
def __init__(self): |
516 |
urlopen = urllib2.build_opener() |
urlopen = urllib2.build_opener() |
531 |
|
|
532 |
self.names = tarballs |
self.names = tarballs |
533 |
|
|
534 |
|
@classmethod |
535 |
|
def versions(cls, module): |
536 |
|
# XXX - ugly |
537 |
|
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 |
|
cls._cache_versions[module] = versions |
547 |
|
|
548 |
|
return cls._cache_versions[module] |
549 |
|
|
550 |
class Downstream(object): |
class Downstream(object): |
551 |
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]*)$') |
552 |
|
|
575 |
|
|
576 |
if module not in TARBALLS: |
if module not in TARBALLS: |
577 |
TARBALLS[module] = {} |
TARBALLS[module] = {} |
578 |
TARBALLS[module][srpm] = version |
|
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: |
if srpm not in FILES: |
587 |
FILES[srpm] = set() |
FILES[srpm] = set() |
693 |
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)) |
694 |
print |
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 |
730 |
|
|
731 |
def cmd_patches(options, parser): |
def cmd_patches(options, parser): |
732 |
root = os.path.expanduser(Downstream.PKGROOT) |
root = os.path.expanduser(Downstream.PKGROOT) |
733 |
|
|
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 |
path = os.path.join(cwd, "SOURCES", filename) |
path = os.path.join(cwd, "SOURCES", filename) |
794 |
if not is_valid_hash(path, options.algo, options.hexdigest): |
if not is_valid_hash(path, options.algo, options.hexdigest): |
803 |
|
|
804 |
# Submit is optional |
# Submit is optional |
805 |
if options.submit: |
if options.submit: |
806 |
subprocess.check_call(['mgarepo', 'submit'], cwd=cwd) |
cmd = ['mgarepo', 'submit'] |
807 |
|
if Downstream.DISTRO: |
808 |
|
cmd.extend(('--define', 'section=core/updates_testing', '-t', Downstream.DISTRO)) |
809 |
|
subprocess.check_call(cmd, cwd=cwd) |
810 |
except subprocess.CalledProcessError: |
except subprocess.CalledProcessError: |
811 |
sys.exit(1) |
sys.exit(1) |
812 |
|
|
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=True, 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 |
|
|
990 |
if options.limit_upstream: |
if options.limit_upstream: |
991 |
Upstream.limit = set(options.limit_upstream.read().strip("\n").splitlines()) |
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: |
if options.distro: |
997 |
Downstream.PKGROOT = os.path.join('~/pkgs', options.distro) |
Downstream.PKGROOT = os.path.join('~/pkgs', options.distro) |
998 |
Downstream.MEDIA = "Core Release %s Source" % options.distro |
Downstream.MEDIA = "Core Release {0} Source,Core {0} Updates Source,Core {0} Updates Testing Source".format(options.distro) |
999 |
Downstream.DISTRO = options.distro |
Downstream.DISTRO = options.distro |
1000 |
|
|
1001 |
try: |
try: |