summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmgagnome22
1 files changed, 14 insertions, 8 deletions
diff --git a/mgagnome b/mgagnome
index cfe79ac..276573a 100755
--- a/mgagnome
+++ b/mgagnome
@@ -368,10 +368,12 @@ class SpecFile():
re.MULTILINE + re.IGNORECASE
)
- def __init__(self, path, module=None):
+ def __init__(self, path, package=None, module=None):
self.path = path
- self.cwd = os.path.dirname(path)
- self.module = module
+ self._package = package
+ self.module = package.name if package else module
+
+ self.cwd = package.path if package else os.path.dirname(path)
self._changes = collections.OrderedDict()
self._should_rebuild = False
self._changed_spec_file = False
@@ -391,7 +393,8 @@ class SpecFile():
@property
def version(self):
"""Provide the version as parsed by rpm"""
- cmd = ["rpm", "--define", "_topdir %s" % os.path.join(self.cwd, ".."), "--specfile", self.path,
+ topdir = self._package.path if self._package else os.path.join(self.cwd, "..")
+ cmd = ["rpm", "--define", "_topdir %s" % topdir, "--specfile", self.path,
"--queryformat", "%{VERSION}\n"]
return subprocess.check_output(cmd).decode("utf-8").splitlines()[0]
@@ -403,14 +406,16 @@ class SpecFile():
@property
def release(self):
"""Provide the release as parsed by rpm"""
- cmd = ["rpm", "--define", "%dist %nil", "--define", "_topdir %s" % os.path.join(self.cwd, ".."),
+ topdir = self._package.path if self._package else os.path.join(self.cwd, "..")
+ cmd = ["rpm", "--define", "%dist %nil", "--define", "_topdir %s" % topdir,
"--specfile", self.path, "--queryformat", "%{RELEASE}\n"]
return subprocess.check_output(cmd).decode("utf-8").splitlines()[0]
def _sources_and_patches(self, flag=None):
os.chdir(self.cwd)
+ topdir = self._package.path if self._package else os.path.join(self.cwd, "..")
rpm.delMacro("_topdir")
- rpm.addMacro("_topdir", os.path.join(self.cwd, '..'))
+ rpm.addMacro("_topdir", topdir)
trans_set = rpm.ts()
spec = trans_set.parseSpec(self.path)
try:
@@ -783,8 +788,9 @@ class SpecFile():
Parses the spec file to do this, so any macros are expanded"""
+ topdir = self._package.path if self._package else os.path.join(self.cwd, "..")
rpm.delMacro("_topdir")
- rpm.addMacro("_topdir", os.path.join(self.cwd, '..'))
+ rpm.addMacro("_topdir", topdir)
trans_set = rpm.ts()
try:
spec = trans_set.parseSpec(self.path)
@@ -1435,7 +1441,7 @@ class Package:
"""Return the SpecFile for a given package"""
path = self.path
- return SpecFile(os.path.join(path, "SPECS", "%s.spec" % self.name), module=self.name)
+ return SpecFile(os.path.join(path, "SPECS", "%s.spec" % self.name), package=self, module=self.name)
@retry(subprocess.CalledProcessError)