/[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 3558 by ovitters, Sun Mar 18 15:05:26 2012 UTC revision 3559 by ovitters, Mon Mar 19 08:33:32 2012 UTC
# Line 526  def get_downstream_from_upstream(upstrea Line 526  def get_downstream_from_upstream(upstrea
526      if upstream not in downstream:      if upstream not in downstream:
527          raise ValueError("No packages for upstream name: %s" % upstream)          raise ValueError("No packages for upstream name: %s" % upstream)
528    
529      if len(downstream[upstream]) != 1:      if len(downstream[upstream]) == 1:
530          # XXX - Make it more intelligent          return downstream[upstream].keys()
         raise ValueError("Multiple packages found for %s: %s" % (upstream, ", ".join(downstream[upstream].keys())))  
531    
532      return downstream[upstream].keys()      # Directories packages are located in
533        root = os.path.expanduser(PKGROOT)
534    
535        packages = {}
536        for package in downstream[upstream].keys():
537            cwd = os.path.join(root, package)
538    
539            # Checkout package to ensure the checkout reflects the latest changes
540            try:
541                subprocess.check_call(['mgarepo', 'co', package], cwd=root)
542            except subprocess.CalledProcessError:
543                raise ValueError("Multiple packages found and cannot checkout %s" % package)
544    
545            # Determine version from spec file
546            try:
547                packages[package] = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)).version
548            except subprocess.CalledProcessError:
549                raise ValueError("Multiple packages found and cannot determine version of %s" % package)
550    
551        # Return all packages reflecting the current version
552        matches = [package for package in packages if packages[package] == version]
553        if len(matches):
554            return matches
555    
556        # Return all packages reflecting the version before the current version
557        latest_version = get_latest_version(packages.values(), max_version=version)
558        matches = [package for package in packages if packages[package] == latest_version]
559        if len(matches):
560            return matches
561    
562        # Give up
563        raise ValueError("Multiple packages found and cannot determine package for version %s" % version)
564    
565  def write_file(path, data):  def write_file(path, data):
566      with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst:      with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst:

Legend:
Removed from v.3558  
changed lines
  Added in v.3559

  ViewVC Help
Powered by ViewVC 1.1.30