There is specdir to get the (absolute) directory path.
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
def __init__(self, specfile):
# Load spec file into our special data structure
- 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._content = LinkedList()
try:
with open(specfile) as spec_file:
"""
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))
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'])
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:
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,
# 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:
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):
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):
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
repo.set_branch(branch)
- return os.path.basename(spec.specfile)
+ return spec.specfile
def rebase_pq(repo, branch, options):
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'