/[soft]/mga-gnome/trunk/mga-gnome
ViewVC logotype

Diff of /mga-gnome/trunk/mga-gnome

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5287 by ovitters, Fri Aug 3 05:18:24 2012 UTC revision 6243 by ovitters, Tue Oct 16 07:57:27 2012 UTC
# Line 49  import datetime Line 49  import datetime
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
# Line 79  def get_latest_version(versions, max_ver Line 82  def get_latest_version(versions, max_ver
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    
# Line 291  class SpecFile(object): Line 305  class SpecFile(object):
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
# Line 328  class SpecFile(object): Line 346  class SpecFile(object):
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    
# Line 489  class Upstream(object): Line 510  class Upstream(object):
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()
# Line 509  class Upstream(object): Line 531  class Upstream(object):
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    
# Line 537  class Downstream(object): Line 575  class Downstream(object):
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()
# Line 649  def cmd_ls(options, parser): Line 693  def cmd_ls(options, parser):
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    
# Line 717  def cmd_package_new_version(options, par Line 796  def cmd_package_new_version(options, par
796    
797          # Submit is optional          # Submit is optional
798          if options.submit:          if options.submit:
799              subprocess.check_call(['mgarepo', 'submit'], cwd=cwd)              cmd = ['mgarepo', 'submit']
800                if Downstream.DISTRO:
801                    cmd.extend(('--define', 'section=core/updates_testing', '-t', Downstream.DISTRO))
802                subprocess.check_call(cmd, cwd=cwd)
803      except subprocess.CalledProcessError:      except subprocess.CalledProcessError:
804          sys.exit(1)          sys.exit(1)
805    
# Line 843  def main(): Line 925  def main():
925          func=cmd_ls, upstream=False, show_version=False, diff=False          func=cmd_ls, upstream=False, show_version=False, diff=False
926      )      )
927    
928        subparser = subparsers.add_parser('check-latest', help='check for latest version of packages')
929        subparser.set_defaults(
930            func=cmd_check_latest
931        )
932    
933      subparser = subparsers.add_parser('patches', help='list all GNOME patches')      subparser = subparsers.add_parser('patches', help='list all GNOME patches')
934      subparser.add_argument("-p", "--path", action="store_true", dest="path",      subparser.add_argument("-p", "--path", action="store_true", dest="path",
935                                         help="Show full path to patch")                                         help="Show full path to patch")
# Line 865  def main(): Line 952  def main():
952                                         help="Package name reflects the upstream name")                                         help="Package name reflects the upstream name")
953      subparser.add_argument("-s", "--submit", action="store_true", dest="submit",      subparser.add_argument("-s", "--submit", action="store_true", dest="submit",
954                                         help="Commit changes and submit")                                         help="Commit changes and submit")
955        subparser.add_argument(      "--no-submit", action="store_false", dest="submit",
956                                           help="Do not commit changes and submit")
957      subparser.add_argument("-a", "--algorithm", choices=hashlib.algorithms, dest="algo",      subparser.add_argument("-a", "--algorithm", choices=hashlib.algorithms, dest="algo",
958                                         help="Hash algorithm")                                         help="Hash algorithm")
959      subparser.add_argument("--hash", dest="hexdigest",      subparser.add_argument("--hash", dest="hexdigest",
960                                         help="Hexdigest of the hash")                                         help="Hexdigest of the hash")
961      subparser.set_defaults(      subparser.set_defaults(
962          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",
963          force=False          force=False
964      )      )
965    
# Line 894  def main(): Line 983  def main():
983      if options.limit_upstream:      if options.limit_upstream:
984          Upstream.limit = set(options.limit_upstream.read().strip("\n").splitlines())          Upstream.limit = set(options.limit_upstream.read().strip("\n").splitlines())
985    
986        if not hasattr(options, 'submit'):
987            options.submit = not options.distro
988    
989      if options.distro:      if options.distro:
990          Downstream.PKGROOT = os.path.join('~/pkgs', options.distro)          Downstream.PKGROOT = os.path.join('~/pkgs', options.distro)
991          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)
992          Downstream.DISTRO = options.distro          Downstream.DISTRO = options.distro
993    
994      try:      try:

Legend:
Removed from v.5287  
changed lines
  Added in v.6243

  ViewVC Help
Powered by ViewVC 1.1.30