diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2013-01-04 15:10:02 +0200 |
---|---|---|
committer | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2013-04-03 10:11:41 +0300 |
commit | bc95e033eceaf8e5c388854b132c063588dc61c7 (patch) | |
tree | 5a8aa8010f1ecbf575b40e10b6238346a8b5cd69 | |
parent | 47b92482997f6d8f784443ff2eeef4c7d6738dc8 (diff) | |
download | git-buildpackage-bc95e033eceaf8e5c388854b132c063588dc61c7.tar.gz git-buildpackage-bc95e033eceaf8e5c388854b132c063588dc61c7.tar.bz2 git-buildpackage-bc95e033eceaf8e5c388854b132c063588dc61c7.zip |
rpm.SpecFile: change specfile attribute to represent filename
There is specdir to get the (absolute) directory path.
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r-- | gbp/rpm/__init__.py | 8 | ||||
-rwxr-xr-x | gbp/scripts/buildpackage_rpm.py | 10 | ||||
-rwxr-xr-x | gbp/scripts/import_srpm.py | 7 | ||||
-rwxr-xr-x | gbp/scripts/pq_rpm.py | 2 | ||||
-rw-r--r-- | tests/test_rpm.py | 2 |
5 files changed, 14 insertions, 15 deletions
diff --git a/gbp/rpm/__init__.py b/gbp/rpm/__init__.py index 059a8169..d5d306fa 100644 --- a/gbp/rpm/__init__.py +++ b/gbp/rpm/__init__.py @@ -147,8 +147,8 @@ class SpecFile(object): self.epoch = str(source_header[rpm.RPMTAG_EPOCH]) \ if source_header[rpm.RPMTAG_EPOCH] != None else None self.packager = source_header[rpm.RPMTAG_PACKAGER] - self.specfile = os.path.abspath(specfile) - self.specdir = os.path.dirname(self.specfile) + self.specfile = os.path.basename(specfile) + self.specdir = os.path.dirname(os.path.abspath(specfile)) self.patches = {} self.sources = {} self._tags = {} @@ -239,7 +239,7 @@ class SpecFile(object): """ Write, possibly updated, spec to disk """ - with open(self.specfile, 'w') as spec_file: + with open(os.path.join(self.specdir, self.specfile), 'w') as spec_file: for line in self._content: spec_file.write(str(line)) @@ -656,7 +656,7 @@ class SpecFile(object): Return patches of the RPM as a gbp patchseries """ series = PatchSeries() - patchdir = os.path.dirname(self.specfile) + patchdir = self.specdir for n, p in sorted(self.patches.iteritems()): if p['autoupdate'] and p['apply']: fname = os.path.basename(p['filename']) diff --git a/gbp/scripts/buildpackage_rpm.py b/gbp/scripts/buildpackage_rpm.py index 0c17e867..70a73d1b 100755 --- a/gbp/scripts/buildpackage_rpm.py +++ b/gbp/scripts/buildpackage_rpm.py @@ -507,9 +507,8 @@ def main(argv): pkgfiles = os.listdir(spec.specdir) for f in pkgfiles: src = os.path.join(spec.specdir, f) - if f == os.path.basename(spec.specfile): + if f == spec.specfile: dst = os.path.join(spec_dir, f) - spec.specfile = os.path.abspath(dst) else: dst = os.path.join(source_dir, f) try: @@ -520,7 +519,7 @@ def main(argv): shutil.copy2(src, dst) except IOError, err: raise GbpError, "Error exporting files: %s" % err - spec.specdir = spec_dir + spec.specdir = os.path.abspath(spec_dir) if options.orig_prefix != 'auto': options.orig_prefix = options.orig_prefix % dict(spec.version, @@ -560,9 +559,10 @@ def main(argv): # Finally build the package: if options.builder.startswith("rpmbuild"): - builder_args.extend([spec.specfile]) + builder_args.append(os.path.join(spec.specdir, + spec.specfile)) else: - builder_args.extend([os.path.basename(spec.specfile)]) + builder_args.append(spec.specfile) RunAtCommand(options.builder, builder_args, shell=True, extra_env={'GBP_BUILD_DIR': export_dir})(dir=export_dir) if options.postbuild: diff --git a/gbp/scripts/import_srpm.py b/gbp/scripts/import_srpm.py index bf9a61a0..0db870e0 100755 --- a/gbp/scripts/import_srpm.py +++ b/gbp/scripts/import_srpm.py @@ -150,8 +150,7 @@ def import_spec_patches(repo, spec, dirs): repo.force_head('HEAD', hard=True) raise PatchImportError("Unable to update spec file, you need to edit" "and commit it manually") - repo.commit_all(msg=PATCH_AUTODELETE_COMMIT_MSG % - os.path.basename(spec.specfile)) + repo.commit_all(msg=PATCH_AUTODELETE_COMMIT_MSG % spec.specfile) def force_to_branch_head(repo, branch): @@ -324,7 +323,7 @@ def main(argv): for num, src in spec.sources.iteritems(): if num != spec.orig_src_num: files.append(src['filename']) - files.append(spec.specfile) + files.append(os.path.join(spec.specdir, spec.specfile)) for fname in files: fpath = os.path.join(dirs['src'], fname) if os.path.exists(fpath): @@ -462,7 +461,7 @@ def main(argv): if options.patch_import: spec = parse_spec(os.path.join(repo.path, options.packaging_dir, - os.path.basename(spec.specfile))) + spec.specfile)) import_spec_patches(repo, spec, dirs) commit = options.packaging_branch diff --git a/gbp/scripts/pq_rpm.py b/gbp/scripts/pq_rpm.py index 0e6290eb..64ba4236 100755 --- a/gbp/scripts/pq_rpm.py +++ b/gbp/scripts/pq_rpm.py @@ -435,7 +435,7 @@ def import_spec_patches(repo, branch, tries, options): repo.set_branch(branch) - return os.path.basename(spec.specfile) + return spec.specfile def rebase_pq(repo, branch, options): diff --git a/tests/test_rpm.py b/tests/test_rpm.py index 3e04fcd8..01d8b277 100644 --- a/tests/test_rpm.py +++ b/tests/test_rpm.py @@ -88,7 +88,7 @@ class TestSpecFile(object): spec = SpecFileTester(spec_filepath) # Test basic properties - assert spec.specfile == spec_filepath + assert spec.specfile == os.path.basename(spec_filepath) assert spec.specdir == os.path.dirname(spec_filepath) assert spec.name == 'gbp-test' |