diff --git a/README.rst b/README.rst index 4add699..f31ff89 100644 --- a/README.rst +++ b/README.rst @@ -219,6 +219,16 @@ requires_ban Controlling the build process ------------------------------ +extra_sources + This file contains a list of extra files to be added to the ``.spec`` and + optionally installed as well. Each non-blank and non-comment line should start + with the file name as found in the Git directory, followed by arguments to be + passed to the /usr/bin/install(3) command, with at least one argument starting + with a slash, denoting the destination directory (there's no need for + ``%{buildroot}``). If the install arguments are missing, Autospec will not + generate an installation command and the package should specify how to install + in the install_append file (see below). + configure This file contains configuration flags to pass to the ``%configure`` macro for autotools based tarballs. As an example, adding ``--disable-static`` to diff --git a/autospec/config.py b/autospec/config.py index 34b20be..476076b 100644 --- a/autospec/config.py +++ b/autospec/config.py @@ -61,6 +61,7 @@ install_append = [] service_restart = [] patches = [] verpatches = OrderedDict() +extra_sources = [] autoreconf = False custom_desc = "" custom_summ = "" @@ -630,6 +631,7 @@ def parse_config_files(path, bump, filemanager, version): global extra_configure_avx2 global extra_configure_avx512 global config_files + global extra_sources global parallel_build global license_fetch global license_show @@ -758,6 +760,13 @@ def parse_config_files(path, bump, filemanager, version): tarball.release = str(r) print("Release :", tarball.release) + content = read_conf_file(os.path.join(path, "extra_sources")) + for source in content: + fields = source.split(maxsplit=1) + print("Adding additional source file: %s" % fields[0]) + config_files.add(os.path.basename(fields[0])) + extra_sources.append(fields) + content = read_conf_file(os.path.join(path, "buildreq_ban")) for banned in content: print("Banning build requirement: %s." % banned) @@ -991,6 +1000,7 @@ def load_specfile(specfile): specfile.install_prepend = install_prepend specfile.install_append = install_append specfile.service_restart = service_restart + specfile.extra_sources = extra_sources specfile.patches = patches specfile.verpatches = verpatches specfile.autoreconf = autoreconf diff --git a/autospec/specfiles.py b/autospec/specfiles.py index 00a0f2e..9c7cde2 100644 --- a/autospec/specfiles.py +++ b/autospec/specfiles.py @@ -54,6 +54,7 @@ class Specfile(object): self.packages = OrderedDict() self.requires = set() self.buildreqs = [] + self.extra_sources = [] self.patches = [] self.verpatches = OrderedDict() self.default_desc = "" @@ -177,7 +178,12 @@ class Specfile(object): # if package is verified, include the signature in the source tarball if self.keyid and config.signature: - self._write_strip(f"Source{count+1} : {config.signature}") + count += 1 + self._write_strip(f"Source{count} : {config.signature}") + + for source in self.extra_sources: + count += 1 + self._write("Source{0} : {1}\n".format(count, source[0])) def write_summary(self): """Write package summary to spec file.""" @@ -937,6 +943,22 @@ class Specfile(object): self._write_strip("install -m 0644 %{{SOURCE{0}}} %{{buildroot}}/usr/lib/tmpfiles.d/{1}.conf" .format(self.source_index[self.sources["tmpfile"][0]], self.name)) + for source in self.extra_sources: + if len(source) == 1: + # Don't automatically install if we don't have install arguments + continue + actual_source = "%{_sourcedir}/" + source[0] + dest = None + install_args = [] + for arg in source[1].split(): + if dest is None and arg.startswith('/'): + dest = arg + else: + install_args.append(arg) + self._write_strip("mkdir -p %{{buildroot}}{0}".format(os.path.dirname(dest))) + self._write_strip("install {0} {1} %{{buildroot}}{2}" + .format(" ".join(install_args), actual_source, dest)) + def write_cmake_install(self): """Write install section to spec file for cmake builds.""" self.write_build_append()