From 5de167e0ff134fa682ccac55f511ce04877c1707 Mon Sep 17 00:00:00 2001 From: Silvie Chlupova Date: Fri, 21 May 2021 13:14:40 +0200 Subject: [PATCH] Adding option to fetch sources --- share/tito_completion.sh | 1 + src/tito/builder/main.py | 5 +++++ src/tito/cli.py | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/share/tito_completion.sh b/share/tito_completion.sh index 2d64199..3e4533a 100644 --- a/share/tito_completion.sh +++ b/share/tito_completion.sh @@ -32,6 +32,7 @@ __tito_build_opts=' --test --tgz --verbose + --fetch-sources ' __tito_release_opts=' diff --git a/src/tito/builder/main.py b/src/tito/builder/main.py index 3e4ec7d..0cf3c2b 100644 --- a/src/tito/builder/main.py +++ b/src/tito/builder/main.py @@ -21,6 +21,7 @@ import sys import re import shutil import rpm +import urllib.request from pkg_resources import require from distutils.version import LooseVersion as loose_version from tempfile import mkdtemp @@ -79,6 +80,7 @@ class BuilderBase(object): self.quiet = self._get_optional_arg(kwargs, 'quiet', False) self.verbose = self._get_optional_arg(kwargs, 'verbose', False) + self.fetch_sources = self._get_optional_arg(kwargs, 'fetch_sources', False) rpmbuildopts = self._get_optional_arg(args, 'rpmbuild_options', None) if rpmbuildopts: @@ -86,6 +88,9 @@ class BuilderBase(object): else: self.rpmbuild_options = self._get_optional_arg(kwargs, 'rpmbuild_options', '') + if self.fetch_sources: + self.rpmbuild_options += "--define '%_disable_source_fetch 0'" + self.test = self._get_optional_arg(kwargs, 'test', False) # Allow a builder arg to override the test setting passed in, used by # releasers in their config sections. diff --git a/src/tito/cli.py b/src/tito/cli.py index a5c604e..8b3368e 100644 --- a/src/tito/cli.py +++ b/src/tito/cli.py @@ -274,6 +274,9 @@ class BaseCliModule(object): "offline"): self.options.offline = True + if self.config.has_option(BUILDCONFIG_SECTION, "fetch-sources"): + self.options.fetch_sources = self.config.get(BUILDCONFIG_SECTION, "fetch-sources") + # TODO: Not ideal: if self.options.debug: os.environ['DEBUG'] = "true" @@ -355,6 +358,10 @@ class BuildModule(BaseCliModule): default='', metavar="COLLECTION", help="Build package for software collection.") + self.parser.add_option("--fetch-sources", dest='fetch_sources', + action="store_true", + help="Download sources from predefined Source addresses to the SOURCE folder") + def main(self, argv): BaseCliModule.main(self, argv) @@ -375,6 +382,7 @@ class BuildModule(BaseCliModule): 'scl': self.options.scl, 'quiet': self.options.quiet, 'verbose': self.options.verbose, + 'fetch_sources': self.options.fetch_sources, } builder = create_builder(package_name, build_tag,