mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-24 12:42:47 +00:00
Define _sourcedir for get_project_name RPM query
Follow-up for be89941 Fix: #311 Supersedes: #313 The `get_project_name` function is called in an early phase when the temporary `SOURCES` directory for a current build doesn't exist yet. Therefore as a little workaround, we set `_sourcedir` to an upstream directory containing the package spec file. Defining a custom `_sourcedir` (and therefore not using `~/rpmbuild/SOURCES`) shouldn't be a problem because tito builds should not depend on anything outside of the upstream git repository. The use-case described in PR#313 works as expected. SOURCE1: somecool.macros %include %{SOURCE1} For multi-spec projects, where you have e.g . ├── foo │ ├── foo.spec ├── bar │ ├── bar.spec It is possible to include the common macros from a parent (or some other) directory by having a symlink. cd foo ln -s ../somecool.macros ./ Or possibly some other way which I am currently not aware of because I wasn't able to e.g. persuade `%include` to include from the parent directory.
This commit is contained in:
parent
d9cbc94840
commit
387757e0be
2 changed files with 7 additions and 4 deletions
|
@ -211,7 +211,6 @@ class BuilderBase(object):
|
||||||
debug("Copying %s -> %s" % (src, self.rpmbuild_sourcedir))
|
debug("Copying %s -> %s" % (src, self.rpmbuild_sourcedir))
|
||||||
shutil.copy(src, self.rpmbuild_sourcedir)
|
shutil.copy(src, self.rpmbuild_sourcedir)
|
||||||
|
|
||||||
|
|
||||||
def srpm(self, dist=None):
|
def srpm(self, dist=None):
|
||||||
"""
|
"""
|
||||||
Build a source RPM.
|
Build a source RPM.
|
||||||
|
@ -269,6 +268,7 @@ class BuilderBase(object):
|
||||||
self._create_build_dirs()
|
self._create_build_dirs()
|
||||||
if not self.ran_tgz:
|
if not self.ran_tgz:
|
||||||
self.tgz()
|
self.tgz()
|
||||||
|
self._copy_extra_sources()
|
||||||
|
|
||||||
cmd = 'rpmbuild {0}'.format(
|
cmd = 'rpmbuild {0}'.format(
|
||||||
" ".join([
|
" ".join([
|
||||||
|
|
|
@ -827,9 +827,12 @@ def get_project_name(tag=None, scl=None):
|
||||||
name = search_for(file_path, r"\s*Name:\s*(.*?)\s*$")[0][0]
|
name = search_for(file_path, r"\s*Name:\s*(.*?)\s*$")[0][0]
|
||||||
return name
|
return name
|
||||||
else:
|
else:
|
||||||
|
sourcedir = os.path.dirname(file_path)
|
||||||
output = run_command(
|
output = run_command(
|
||||||
"rpm -q --qf '%%{name}\n' %s --specfile %s 2> /dev/null | grep -e '^$' -v | head -1" %
|
"rpm -q --qf '%%{name}\n' %s --specfile %s --define '_sourcedir %s' "
|
||||||
(scl_to_rpm_option(scl, silent=True), file_path))
|
"2> /dev/null | grep -e '^$' -v | head -1" %
|
||||||
|
(scl_to_rpm_option(scl, silent=True), file_path, sourcedir))
|
||||||
|
|
||||||
if not output:
|
if not output:
|
||||||
error_out(["Unable to determine project name from spec file: %s" % file_path,
|
error_out(["Unable to determine project name from spec file: %s" % file_path,
|
||||||
"Try rpm -q --specfile %s" % file_path,
|
"Try rpm -q --specfile %s" % file_path,
|
||||||
|
|
Loading…
Add table
Reference in a new issue