From 1c9765185d9e38608b9eb7f8e2d79837ead074d2 Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Nov 01 2016 05:17:54 +0000 Subject: Enusre to download sources in cliClient cliClient is the better place to call cliClient.sources to download sources files. This makes it easier for downstream client tool to extend cliClient.sources and no need to overwrite related methods to use the extension, where the related methods are compile, install, prep, local and srpm. Signed-off-by: Chenxiong Qi --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index 411df0c..79419e6 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -1968,8 +1968,6 @@ class Commands(object): Logs the output and returns nothing """ - # Get the sources - self.sources() # setup the rpm command cmd = ['rpmbuild'] if builddir: @@ -2026,8 +2024,6 @@ class Commands(object): Logs the output and returns nothing """ - # Get the sources - self.sources() # setup the rpm command cmd = ['rpmbuild'] if builddir: @@ -2100,7 +2096,6 @@ class Commands(object): # This could really use a list of arches to build for and loop over # Get the sources - self.sources() # build up the rpm command cmd = ['rpmbuild'] if builddir: @@ -2330,8 +2325,6 @@ class Commands(object): Logs the output and returns nothing """ - # Get the sources - self.sources() # setup the rpm command cmd = ['rpmbuild'] if builddir: diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index d0ba73a..2633b24 100755 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -1080,6 +1080,8 @@ see API KEY section of copr-cli(1) man page. self.push() def compile(self): + self.sources() + arch = None short = False nocheck = False @@ -1184,6 +1186,7 @@ see API KEY section of copr-cli(1) man page. self.log.info("Commit if happy or revert with: git reset --hard HEAD") def install(self): + self.sources() self.cmd.install(arch=self.args.arch, short=self.args.short_circuit, builddir=self.args.builddir, @@ -1193,6 +1196,7 @@ see API KEY section of copr-cli(1) man page. self.cmd.lint(self.args.info, self.args.rpmlintconf) def local(self): + self.sources() self.cmd.local(arch=self.args.arch, hashtype=self.args.hash, builddir=self.args.builddir) @@ -1251,6 +1255,7 @@ see API KEY section of copr-cli(1) man page. self.cmd.patch(self.args.suffix, rediff=self.args.rediff) def prep(self): + self.sources() self.cmd.prep(arch=self.args.arch, builddir=self.args.builddir) def pull(self): @@ -1267,10 +1272,20 @@ see API KEY section of copr-cli(1) man page. return self.build() def sources(self): - self.cmd.sources(self.args.outdir) + """Download files listed in sources + + For command compile, prep, install, local and srpm, files are needed to + be downloaded before doing what the command does. Hence, for these + cases, sources is not called from command line. Instead, from rpkg + inside. + """ + # When sources is not called from command line, option outdir is not + # available. + outdir = getattr(self.args, 'outdir', None) + self.cmd.sources(outdir) def srpm(self): - self.cmd.sources() + self.sources() self.cmd.srpm(hashtype=self.args.hash) def switch_branch(self):