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=20 |
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 |
|
|
503 |
|
|
504 |
URL="http://download.gnome.org/sources/" |
URL="http://download.gnome.org/sources/" |
505 |
limit = None |
limit = None |
506 |
|
_cache_versions = {} |
507 |
|
|
508 |
def __init__(self): |
def __init__(self): |
509 |
urlopen = urllib2.build_opener() |
urlopen = urllib2.build_opener() |
524 |
|
|
525 |
self.names = tarballs |
self.names = tarballs |
526 |
|
|
527 |
|
@classmethod |
528 |
|
def versions(cls, module): |
529 |
|
# XXX - ugly |
530 |
|
if module not in cls._cache_versions: |
531 |
|
versions = None |
532 |
|
|
533 |
|
url = '%s%s/cache.json' % (cls.URL, module) |
534 |
|
r = requests.get(url) |
535 |
|
j = r.json |
536 |
|
if j is not None and len(j) > 2 and module in j[2]: |
537 |
|
versions = j[2][module] |
538 |
|
|
539 |
|
cls._cache_versions[module] = versions |
540 |
|
|
541 |
|
return cls._cache_versions[module] |
542 |
|
|
543 |
class Downstream(object): |
class Downstream(object): |
544 |
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]*)$') |
545 |
|
|
680 |
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)) |
681 |
print |
print |
682 |
|
|
683 |
|
def cmd_check_latest(options, parser): |
684 |
|
streams = join_streams(show_version=True) |
685 |
|
|
686 |
|
for package, module, package_version, spec_version, downstream_files in streams: |
687 |
|
sys.stdout.write(package) |
688 |
|
sys.stdout.write("\t%s\t%s" % (spec_version, package_version)) |
689 |
|
|
690 |
|
safe_max_version = get_safe_max_version(spec_version) |
691 |
|
|
692 |
|
versions = Upstream.versions(module) |
693 |
|
if versions: |
694 |
|
latest_version = get_latest_version(versions) |
695 |
|
safe_version = get_latest_version(versions, safe_max_version) |
696 |
|
|
697 |
|
if version_cmp(latest_version, spec_version) < 0: latest_version = 'N/A' |
698 |
|
if version_cmp(safe_version, spec_version) < 0: safe_version = 'N/A' |
699 |
|
|
700 |
|
sys.stdout.write("\t%s" % latest_version) |
701 |
|
sys.stdout.write("\t%s" % safe_version) |
702 |
|
print |
703 |
|
|
704 |
def cmd_patches(options, parser): |
def cmd_patches(options, parser): |
705 |
root = os.path.expanduser(Downstream.PKGROOT) |
root = os.path.expanduser(Downstream.PKGROOT) |
706 |
|
|
895 |
func=cmd_ls, upstream=False, show_version=False, diff=False |
func=cmd_ls, upstream=False, show_version=False, diff=False |
896 |
) |
) |
897 |
|
|
898 |
|
subparser = subparsers.add_parser('check-latest', help='check for latest version of packages') |
899 |
|
subparser.set_defaults( |
900 |
|
func=cmd_check_latest |
901 |
|
) |
902 |
|
|
903 |
subparser = subparsers.add_parser('patches', help='list all GNOME patches') |
subparser = subparsers.add_parser('patches', help='list all GNOME patches') |
904 |
subparser.add_argument("-p", "--path", action="store_true", dest="path", |
subparser.add_argument("-p", "--path", action="store_true", dest="path", |
905 |
help="Show full path to patch") |
help="Show full path to patch") |