/[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 3122 by ovitters, Tue Feb 28 15:06:43 2012 UTC revision 3502 by ovitters, Thu Mar 15 14:08:26 2012 UTC
# Line 43  from email.mime.text import MIMEText Line 43  from email.mime.text import MIMEText
43  # to be able to sleep for a while  # to be able to sleep for a while
44  import time  import time
45    
46    # version freeze
47    import datetime
48    
49  MEDIA="Core Release Source"  MEDIA="Core Release Source"
50  URL="http://download.gnome.org/sources/"  URL="http://download.gnome.org/sources/"
51  PKGROOT='~/pkgs'  PKGROOT='~/pkgs'
# Line 89  def judge_version_increase(version_old, Line 92  def judge_version_increase(version_old,
92          compare = version_cmp(version_new, version_old)          compare = version_cmp(version_new, version_old)
93    
94          if compare == 0:          if compare == 0:
95                # 1.0.0 -> 1.0.1
96              return (-2, "Already at version %s!" % (version_old))              return (-2, "Already at version %s!" % (version_old))
97    
98          if compare != 1:          if compare != 1:
99                # 1.0.1 -> 1.0.0
100              return (-3, "Version %s is older than current version %s!" % (version_new, version_old))              return (-3, "Version %s is older than current version %s!" % (version_new, version_old))
101    
102          # Version is newer, but we don't want to see if it follows the GNOME versioning scheme          # Version is newer, but we don't want to see if it follows the GNOME versioning scheme
# Line 112  def judge_version_increase(version_old, Line 117  def judge_version_increase(version_old,
117          # Major+minor the same? Then go ahead and upgrade!          # Major+minor the same? Then go ahead and upgrade!
118          if majmins[0] == majmins[1]:          if majmins[0] == majmins[1]:
119              # Majmin of both versions are the same, looks good!              # Majmin of both versions are the same, looks good!
120                # 1.1.x -> 1.1.x or 1.0.x -> 1.0.x
121              return (10, None)              return (10, None)
122    
123          # More detailed analysis needed, so figure out the numbers          # More detailed analysis needed, so figure out the numbers
# Line 119  def judge_version_increase(version_old, Line 125  def judge_version_increase(version_old,
125    
126          # Check/ensure major version number is the same          # Check/ensure major version number is the same
127          if majmin_nrs[0][0] != majmin_nrs[1][0]:          if majmin_nrs[0][0] != majmin_nrs[1][0]:
128                # 1.0.x -> 2.0.x
129              return (1, "Major version number increase")              return (1, "Major version number increase")
130    
131          # Minor indicates stable/unstable          # Minor indicates stable/unstable
# Line 127  def judge_version_increase(version_old, Line 134  def judge_version_increase(version_old,
134          # Upgrading to unstable is weird          # Upgrading to unstable is weird
135          if not devstate[1]:          if not devstate[1]:
136              if devstate[0]:              if devstate[0]:
137                    # 1.2.x -> 1.3.x
138                  return (1, "Stable to unstable increase")                  return (1, "Stable to unstable increase")
139    
140                # 1.3.x -> 1.5.x
141              return (4, "Unstable to unstable version increase")              return (4, "Unstable to unstable version increase")
142    
143          # Unstable => stable is always ok          # Unstable => stable is always ok
144          if not devstate[0]:          if not devstate[0]:
145                # 1.1.x -> 1.2.x
146              return (5, "Unstable to stable")              return (5, "Unstable to stable")
147    
148          # Can only be increase of minors from one stable to the next          # Can only be increase of minors from one stable to the next
149            # 1.0.x -> 1.2.x
150          return (6, "Stable version increase")          return (6, "Stable version increase")
151    
152  def line_input (file):  def line_input (file):
# Line 461  def get_upstream_names(): Line 472  def get_upstream_names():
472  def get_downstream_names():  def get_downstream_names():
473      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]*)$')
474    
475      contents = subprocess.check_output(['urpmf', '--files', '.', "--media", MEDIA], close_fds=True).strip("\n").splitlines()      contents = subprocess.check_output(['urpmf', '--qf', '%name|%version|%files', '.', "--media", MEDIA], close_fds=True).strip("\n").splitlines()
476    
477      FILES = {}      FILES = {}
478      TARBALLS = {}      TARBALLS = {}
479    
480      for line in  contents:      for line in  contents:
481          try:          try:
482              srpm, filename = line.split(":")              srpm, version, filename = line.split("|")
483          except ValueError:          except ValueError:
484              print >>sys.stderr, line              print >>sys.stderr, line
485              continue              continue
# Line 480  def get_downstream_names(): Line 491  def get_downstream_names():
491                  module = fileinfo['module']                  module = fileinfo['module']
492    
493                  if module not in TARBALLS:                  if module not in TARBALLS:
494                      TARBALLS[module] = set()                      TARBALLS[module] = {}
495                  TARBALLS[module].add(srpm)                  TARBALLS[module][srpm] = version
496    
497          if srpm not in FILES:          if srpm not in FILES:
498              FILES[srpm] = set()              FILES[srpm] = set()
# Line 498  def get_downstream_from_upstream(upstrea Line 509  def get_downstream_from_upstream(upstrea
509    
510      if len(downstream[upstream]) != 1:      if len(downstream[upstream]) != 1:
511          # XXX - Make it more intelligent          # XXX - Make it more intelligent
512          raise ValueError("Multiple packages found for %s: %s" % (upstream, ", ".join(downstream[upstream])))          raise ValueError("Multiple packages found for %s: %s" % (upstream, ", ".join(downstream[upstream].keys())))
513    
514      return list(downstream[upstream])      return downstream[upstream].keys()
515    
516  def write_file(path, data):  def write_file(path, data):
517      with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst:      with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst:
# Line 509  def write_file(path, data): Line 520  def write_file(path, data):
520          os.rename(fdst.name, path)          os.rename(fdst.name, path)
521    
522  def cmd_co(options, parser):  def cmd_co(options, parser):
523      upstream = get_upstream_names()      root = os.path.expanduser(PKGROOT)
     downstream, downstream_files = get_downstream_names()  
524    
525      cwd = os.path.expanduser(PKGROOT)      for package, module, package_version, spec_version, downstream_files in sorted(join_streams()):
526            print "%s => %s" % (module, package)
527            subprocess.call(['mgarepo', 'co', package], cwd=root)
528    
529      matches = upstream & set(downstream.keys())  def join_streams(show_version=False, only_diff_version=False):
530      for module in matches:      root = os.path.expanduser(PKGROOT)
         print module, "\t".join(downstream[module])  
         for package in downstream[module]:  
             subprocess.call(['mgarepo', 'co', package], cwd=cwd)  
531    
 def join_streams():  
532      upstream = get_upstream_names()      upstream = get_upstream_names()
533      downstream, downstream_files = get_downstream_names()      downstream, downstream_files = get_downstream_names()
534    
535      matches = upstream & set(downstream.keys())      matches = upstream & set(downstream.keys())
536      for module in matches:      for module in matches:
537          for package in downstream[module]:          for package in downstream[module].keys():
538              yield (package, module)              package_version = downstream[module][package]
539                spec_version = None
540                if show_version or only_diff_version:
541                    cwd = os.path.join(root, package)
542                    try:
543                        spec_version = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)).version
544                    except subprocess.CalledProcessError:
545                        spec_version = 'N/A'
546    
547  def cmd_ls(options, parser):              if only_diff_version and package_version == spec_version:
548      for package, module in sorted(join_streams()):                  continue
         print "\t".join((package, module)) if options.upstream else package  
549    
550  def cmd_patches(options, parser):              yield (package, module, package_version, spec_version, downstream_files[package])
     upstream = get_upstream_names()  
     downstream, downstream_files = get_downstream_names()  
551    
552      path = os.path.expanduser(PKGROOT)  def cmd_ls(options, parser):
553        for package, module, package_version, spec_version, downstream_files in sorted(join_streams(show_version=options.show_version, only_diff_version=options.diff)):
554            print package,"\t",
555            if options.upstream: print module, "\t",
556            if options.show_version: print spec_version, "\t", package_version, "\t",
557            print
558    
559      import pprint  def cmd_patches(options, parser):
560        root = os.path.expanduser(PKGROOT)
561    
562      matches = upstream & set(downstream.keys())      for package, module, package_version, spec_version, downstream_files in sorted(join_streams()):
563      for module in sorted(matches):          for filename in downstream_files:
564          for srpm in downstream[module]:              if '.patch' in filename or '.diff' in filename:
565              for filename in downstream_files[srpm]:  
566                  if '.patch' in filename or '.diff' in filename:                  p = Patch(os.path.join(root, package, "SOURCES", filename), show_path=options.path)
567                    valid = ""
568                      p = Patch(os.path.join(path, srpm, "SOURCES", filename), show_path=options.path)                  forwarded = ""
569                      valid = ""                  if p.dep3['headers']:
570                      forwarded = ""                      forwarded = p.dep3['headers'].get('Forwarded', "no")
571                      if p.dep3['headers']:                      if p.dep3['valid']:
572                          forwarded = p.dep3['headers'].get('Forwarded', "no")                          valid="VALID"
573                          if p.dep3['valid']:                  print "\t".join((module, package, str(p), forwarded, valid))
                             valid="VALID"  
                     print "\t".join((module, srpm, str(p), forwarded, valid))  
574    
575  def cmd_dep3(options, parser):  def cmd_dep3(options, parser):
576      p = Patch(options.patch)      p = Patch(options.patch)
# Line 613  def cmd_package_new_version(options, par Line 629  def cmd_package_new_version(options, par
629    
630  def cmd_parse_ftp_release_list(options, parser):  def cmd_parse_ftp_release_list(options, parser):
631      # XXX - not working yet      # XXX - not working yet
632      def _send_reply_mail(contents, orig_msg, to):      def _send_reply_mail(contents, orig_msg, to, error=False):
633          """Send an reply email"""          """Send an reply email"""
634          contents.seek(0)          contents.seek(0)
635          msg = MIMEText(contents.read(), _charset='utf-8')          msg = MIMEText(contents.read(), _charset='utf-8')
636          msg['Subject'] = "Re: %s" % orig_msg['Subject']          if error:
637                # XXX - ugly
638                contents.seek(0)
639                lastline = contents.read().splitlines()[-1]
640                # Remove things like "ERROR: " and so on from the last line
641                lastline = re.sub(r'^(?:[^ :]+:\s+)+', '', lastline)
642                subjecterror = " (ERROR: %s)" % lastline if lastline else " (ERROR)"
643            else:
644                subjecterror = ""
645            msg['Subject'] = "Re: %s%s" % (orig_msg['Subject'], subjecterror)
646          msg['To'] = to          msg['To'] = to
647          msg["In-Reply-To"] = orig_msg["Message-ID"]          msg["In-Reply-To"] = orig_msg["Message-ID"]
648          msg["References"] = orig_msg["Message-ID"]          msg["References"] = orig_msg["Message-ID"]
# Line 635  def cmd_parse_ftp_release_list(options, Line 660  def cmd_parse_ftp_release_list(options,
660      msg = email.email.message_from_file(sys.stdin)      msg = email.email.message_from_file(sys.stdin)
661    
662      if options.mail:      if options.mail:
663          stdout = tempfile.NamedTemporaryFile()          stdout = tempfile.TemporaryFile()
664          stderr = stdout          stderr = stdout
665      else:      else:
666          stdout = sys.stdout          stdout = sys.stdout
# Line 647  def cmd_parse_ftp_release_list(options, Line 672  def cmd_parse_ftp_release_list(options,
672          hexdigest = msg['X-Module-SHA256-tar.xz']          hexdigest = msg['X-Module-SHA256-tar.xz']
673      except KeyError, e:      except KeyError, e:
674          print >>stderr, "ERROR: %s" % e          print >>stderr, "ERROR: %s" % e
675          if options.mail: _send_reply_mail(stdout, msg, options.mail)          if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True)
676          sys.exit(1)          sys.exit(1)
677    
678      try:      try:
679          packages = get_downstream_from_upstream(module, version)          packages = get_downstream_from_upstream(module, version)
680      except ValueError, e:      except ValueError, e:
681          print >>stderr, "ERROR: %s" % e          print >>stderr, "ERROR: %s" % e
682          if options.mail: _send_reply_mail(stdout, msg, options.mail)          if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True)
683          sys.exit(1)          sys.exit(1)
684    
685      if options.wait:      if options.wait:
# Line 663  def cmd_parse_ftp_release_list(options, Line 688  def cmd_parse_ftp_release_list(options,
688          if os.fork() != 0: sys.exit(0)          if os.fork() != 0: sys.exit(0)
689          time.sleep(SLEEP_INITIAL)          time.sleep(SLEEP_INITIAL)
690    
691        error = False
692      for package in packages:      for package in packages:
693          subprocess.call(['mga-gnome', 'increase', '--submit', '--hash', hexdigest, package, version], stdout=stdout, stderr=stderr)          if subprocess.call(['mga-gnome', 'increase', '--submit', '--hash', hexdigest, package, version], stdout=stdout, stderr=stderr):
694                error = True
695    
696      if options.mail: _send_reply_mail(stdout, msg, options.mail)      if options.mail: _send_reply_mail(stdout, msg, options.mail, error=error)
697    
698  def main():  def main():
699      description = """Mageia GNOME commands."""      description = """Mageia GNOME commands."""
# Line 684  def main(): Line 711  def main():
711      subparser = subparsers.add_parser('packages', help='list all GNOME packages')      subparser = subparsers.add_parser('packages', help='list all GNOME packages')
712      subparser.add_argument("-m", "--m", action="store_true", dest="upstream",      subparser.add_argument("-m", "--m", action="store_true", dest="upstream",
713                                         help="Show upstream module")                                         help="Show upstream module")
714        subparser.add_argument(      "--version", action="store_true", dest="show_version",
715                                           help="Show version numbers")
716        subparser.add_argument(      "--diff", action="store_true", dest="diff",
717                                           help="Only show packages with different version")
718      subparser.set_defaults(      subparser.set_defaults(
719          func=cmd_ls, upstream=False          func=cmd_ls, upstream=False, show_version=False, diff=False
720      )      )
721    
722      subparser = subparsers.add_parser('patches', help='list all GNOME patches')      subparser = subparsers.add_parser('patches', help='list all GNOME patches')

Legend:
Removed from v.3122  
changed lines
  Added in v.3502

  ViewVC Help
Powered by ViewVC 1.1.30