summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmgagnome69
1 files changed, 33 insertions, 36 deletions
diff --git a/mgagnome b/mgagnome
index d03928b..f8499fe 100755
--- a/mgagnome
+++ b/mgagnome
@@ -541,48 +541,45 @@ class Downstream(object):
self.tarballs = TARBALLS
self.files = FILES
-def get_downstream_from_upstream(upstream, version):
- # Determine the package name
- downstream = Downstream()
+ def get_downstream_from_upstream(self, upstream, version):
+ if upstream not in self.tarballs:
+ raise ValueError("No packages for upstream name: %s" % upstream)
- if upstream not in downstream.tarballs:
- raise ValueError("No packages for upstream name: %s" % upstream)
+ if len(self.tarballs[upstream]) == 1:
+ return self.tarballs[upstream].keys()
- if len(downstream.tarballs[upstream]) == 1:
- return downstream.tarballs[upstream].keys()
+ # Directories packages are located in
+ root = os.path.expanduser(PKGROOT)
- # Directories packages are located in
- root = os.path.expanduser(PKGROOT)
+ packages = {}
+ for package in self.tarballs[upstream].keys():
+ cwd = os.path.join(root, package)
- packages = {}
- for package in downstream.tarballs[upstream].keys():
- cwd = os.path.join(root, package)
-
- # Checkout package to ensure the checkout reflects the latest changes
- try:
- subprocess.check_call(['mgarepo', 'co', package], cwd=root)
- except subprocess.CalledProcessError:
- raise ValueError("Multiple packages found and cannot checkout %s" % package)
+ # Checkout package to ensure the checkout reflects the latest changes
+ try:
+ subprocess.check_call(['mgarepo', 'co', package], cwd=root)
+ except subprocess.CalledProcessError:
+ raise ValueError("Multiple packages found and cannot checkout %s" % package)
- # Determine version from spec file
- try:
- packages[package] = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)).version
- except subprocess.CalledProcessError:
- raise ValueError("Multiple packages found and cannot determine version of %s" % package)
+ # Determine version from spec file
+ try:
+ packages[package] = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package)).version
+ except subprocess.CalledProcessError:
+ raise ValueError("Multiple packages found and cannot determine version of %s" % package)
- # Return all packages reflecting the current version
- matches = [package for package in packages if packages[package] == version]
- if len(matches):
- return matches
+ # Return all packages reflecting the current version
+ matches = [package for package in packages if packages[package] == version]
+ if len(matches):
+ return matches
- # Return all packages reflecting the version before the current version
- latest_version = get_latest_version(packages.values(), max_version=version)
- matches = [package for package in packages if packages[package] == latest_version]
- if len(matches):
- return matches
+ # Return all packages reflecting the version before the current version
+ latest_version = get_latest_version(packages.values(), max_version=version)
+ matches = [package for package in packages if packages[package] == latest_version]
+ if len(matches):
+ return matches
- # Give up
- raise ValueError("Multiple packages found and cannot determine package for version %s" % version)
+ # Give up
+ raise ValueError("Multiple packages found and cannot determine package for version %s" % version)
def write_file(path, data):
with tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as fdst:
@@ -651,7 +648,7 @@ def cmd_package_new_version(options, parser):
# Determine the package name
if options.upstream:
try:
- package = get_downstream_from_upstream(options.package, options.version)[0]
+ package = Downstream().get_downstream_from_upstream(options.package, options.version)[0]
except ValueError, e:
print >>sys.stderr, "ERROR: %s" % e
sys.exit(1)
@@ -758,7 +755,7 @@ def cmd_parse_ftp_release_list(options, parser):
sys.exit(1)
try:
- packages = get_downstream_from_upstream(module, version)
+ packages = Downstream().get_downstream_from_upstream(module, version)
except ValueError, e:
print >>stderr, "ERROR: %s" % e
if options.mail: _send_reply_mail(stdout, msg, options.mail, error=True)