/[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 3557 by ovitters, Sun Mar 18 14:59:46 2012 UTC revision 3559 by ovitters, Mon Mar 19 08:33:32 2012 UTC
# Line 309  class SpecFile(object): Line 309  class SpecFile(object):
309          tries = 0          tries = 0
310          while tries < SLEEP_TIMES:          while tries < SLEEP_TIMES:
311              tries += 1              tries += 1
312                if tries > 1: time.sleep(SLEEP_REPEAT)
313              try:              try:
314                  # Download new tarball                  # Download new tarball
315                  subprocess.check_call(['mgarepo', 'sync', '-d'], cwd=self.cwd)                  subprocess.check_call(['mgarepo', 'sync', '-d'], cwd=self.cwd)
316                    # success, so exit loop
317                  break                  break
318              except subprocess.CalledProcessError, e:              except subprocess.CalledProcessError, e:
319                  # mgarepo sync returns 1 if the tarball cannot be downloaded                  # mgarepo sync returns 1 if the tarball cannot be downloaded
320                  if e.returncode != 1:                  if e.returncode != 1:
321                      return False                      return False
322            else:
323                return False
324    
                 if tries == SLEEP_TIMES:  
                     return False  
   
                 time.sleep(SLEEP_REPEAT)  
325    
326          try:          try:
327              # Check patches still apply              # Check patches still apply
# 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()
531          raise ValueError("Multiple packages found for %s: %s" % (upstream, ", ".join(downstream[upstream].keys())))  
532        # 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      return downstream[upstream].keys()      # 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.3557  
changed lines
  Added in v.3559

  ViewVC Help
Powered by ViewVC 1.1.30