Fix copy_extra_sources for alternative builders

Fix #367

We accidentally introduced `copy_extra_sources` method as a part of
`BuilderBase` class. Which wouldn't be a problem, except for the fact
that its implementation uses properties, that are not a part of
that class but are rather defined in **some** of its descendats.

Let's define this method only abstractly and let more specific
builder classes to provide their own implementation if it makes
sense for them.
This commit is contained in:
Jakub Kadlcik 2020-04-26 22:51:49 +02:00
parent 6e1ebf4a3f
commit c3c1de77cc

View file

@ -197,21 +197,11 @@ class BuilderBase(object):
mkdir_p(d)
self._check_build_dirs_access(build_dirs)
def _copy_extra_sources(self):
def copy_extra_sources(self):
"""
Copy extra %{SOURCEX} files to the SOURCE folder.
"""
cmd = "spectool -S '%s' --define '_sourcedir %s' | awk '{print $2}'"\
% (self.spec_file, self.start_dir)
sources = getoutput(cmd).split("\n")
for source in sources[1:]:
src = os.path.join(self.rpmbuild_sourcedir, self.tgz_dir, source)
if os.path.islink(src) and os.path.isabs(src):
src = os.path.join(self.start_dir, os.readlink(src))
debug("Copying %s -> %s" % (src, self.rpmbuild_sourcedir))
shutil.copy(src, self.rpmbuild_sourcedir)
return NotImplemented
def srpm(self, dist=None):
"""
@ -224,7 +214,7 @@ class BuilderBase(object):
if self.test:
self._setup_test_specfile()
self._copy_extra_sources()
self.copy_extra_sources()
debug("Creating srpm from spec file: %s" % self.spec_file)
define_dist = ""
@ -270,7 +260,7 @@ class BuilderBase(object):
self._create_build_dirs()
if not self.ran_tgz:
self.tgz()
self._copy_extra_sources()
self.copy_extra_sources()
cmd = 'rpmbuild {0}'.format(
" ".join([
@ -505,6 +495,22 @@ class Builder(ConfigObject, BuilderBase):
# Strip extra dashes if one of the params is empty
return tag_format.format(**kwargs).strip('-')
def copy_extra_sources(self):
"""
Copy extra %{SOURCEX} files to the SOURCE folder.
"""
cmd = "spectool -S '%s' --define '_sourcedir %s' | awk '{print $2}'"\
% (self.spec_file, self.start_dir)
sources = getoutput(cmd).split("\n")
for source in sources[1:]:
src = os.path.join(self.rpmbuild_sourcedir, self.tgz_dir, source)
if os.path.islink(src) and os.path.isabs(src):
src = os.path.join(self.start_dir, os.readlink(src))
debug("Copying %s -> %s" % (src, self.rpmbuild_sourcedir))
shutil.copy(src, self.rpmbuild_sourcedir)
def tgz(self):
"""
Create the .tar.gz required to build this package.