/[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 3651 by ovitters, Wed Mar 21 19:36:29 2012 UTC revision 3652 by ovitters, Wed Mar 21 19:38:52 2012 UTC
# Line 541  class Downstream(object): Line 541  class Downstream(object):
541          self.tarballs = TARBALLS          self.tarballs = TARBALLS
542          self.files = FILES          self.files = FILES
543    
544  def get_downstream_from_upstream(upstream, version):      def get_downstream_from_upstream(self, upstream, version):
545      # Determine the package name          if upstream not in self.tarballs:
546      downstream = Downstream()              raise ValueError("No packages for upstream name: %s" % upstream)
547    
548      if upstream not in downstream.tarballs:          if len(self.tarballs[upstream]) == 1:
549          raise ValueError("No packages for upstream name: %s" % upstream)              return self.tarballs[upstream].keys()
550    
551      if len(downstream.tarballs[upstream]) == 1:          # Directories packages are located in
552          return downstream.tarballs[upstream].keys()          root = os.path.expanduser(PKGROOT)
553    
554      # Directories packages are located in          packages = {}
555      root = os.path.expanduser(PKGROOT)          for package in self.tarballs[upstream].keys():
556                cwd = os.path.join(root, package)
557      packages = {}  
558      for package in downstream.tarballs[upstream].keys():              # Checkout package to ensure the checkout reflects the latest changes
559          cwd = os.path.join(root, package)              try:
560                    subprocess.check_call(['mgarepo', 'co', package], cwd=root)
561          # Checkout package to ensure the checkout reflects the latest changes              except subprocess.CalledProcessError:
562          try:                  raise ValueError("Multiple packages found and cannot checkout %s" % package)
563              subprocess.check_call(['mgarepo', 'co', package], cwd=root)  
564          except subprocess.CalledProcessError:              # Determine version from spec file
565              raise ValueError("Multiple packages found and cannot checkout %s" % package)              try:
566                    packages[package] = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)).version
567          # Determine version from spec file              except subprocess.CalledProcessError:
568          try:                  raise ValueError("Multiple packages found and cannot determine version of %s" % package)
569              packages[package] = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)).version  
570          except subprocess.CalledProcessError:          # Return all packages reflecting the current version
571              raise ValueError("Multiple packages found and cannot determine version of %s" % package)          matches = [package for package in packages if packages[package] == version]
572            if len(matches):
573      # Return all packages reflecting the current version              return matches
574      matches = [package for package in packages if packages[package] == version]  
575      if len(matches):          # Return all packages reflecting the version before the current version
576          return matches          latest_version = get_latest_version(packages.values(), max_version=version)
577            matches = [package for package in packages if packages[package] == latest_version]
578      # Return all packages reflecting the version before the current version          if len(matches):
579      latest_version = get_latest_version(packages.values(), max_version=version)              return matches
     matches = [package for package in packages if packages[package] == latest_version]  
     if len(matches):  
         return matches  
580    
581      # Give up          # Give up
582      raise ValueError("Multiple packages found and cannot determine package for version %s" % version)          raise ValueError("Multiple packages found and cannot determine package for version %s" % version)
583    
584  def write_file(path, data):  def write_file(path, data):
585      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 651  def cmd_package_new_version(options, par Line 648  def cmd_package_new_version(options, par
648      # Determine the package name      # Determine the package name
649      if options.upstream:      if options.upstream:
650          try:          try:
651              package = get_downstream_from_upstream(options.package, options.version)[0]              package = Downstream().get_downstream_from_upstream(options.package, options.version)[0]
652          except ValueError, e:          except ValueError, e:
653              print >>sys.stderr, "ERROR: %s" % e              print >>sys.stderr, "ERROR: %s" % e
654              sys.exit(1)              sys.exit(1)
# Line 758  def cmd_parse_ftp_release_list(options, Line 755  def cmd_parse_ftp_release_list(options,
755          sys.exit(1)          sys.exit(1)
756    
757      try:      try:
758          packages = get_downstream_from_upstream(module, version)          packages = Downstream().get_downstream_from_upstream(module, version)
759      except ValueError, e:      except ValueError, e:
760          print >>stderr, "ERROR: %s" % e          print >>stderr, "ERROR: %s" % e
761          if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True)          if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True)

Legend:
Removed from v.3651  
changed lines
  Added in v.3652

  ViewVC Help
Powered by ViewVC 1.1.28