diff options
author | Ricky Zhou <rzhou@redhat.com> | 2010-07-27 14:25:04 -0500 |
---|---|---|
committer | Clark Williams <williams@redhat.com> | 2010-07-27 14:25:04 -0500 |
commit | 5b6d32a3c920c4b8f494838361f886811af6d785 (patch) | |
tree | 9d2b562dee35d2a24a28cb32d5bdeaf5ab35e9e2 | |
parent | c2fa61517f526c1a08e1844f7107c1a898ad91b5 (diff) | |
download | mock-5b6d32a3c920c4b8f494838361f886811af6d785.tar.gz mock-5b6d32a3c920c4b8f494838361f886811af6d785.tar.xz mock-5b6d32a3c920c4b8f494838361f886811af6d785.zip |
allow --sources to specify either single file or directory (BZ# 510409)
Mock originally takes just a directory for the argument to --sources;
expand this to allow for a single file or a directory.
Signed-off-by: Clark Williams <williams@redhat.com>
-rwxr-xr-x | py/mock.py | 7 | ||||
-rw-r--r-- | py/mock/backend.py | 14 |
2 files changed, 16 insertions, 5 deletions
@@ -171,10 +171,11 @@ def command_parse(config_opts): " before running command when using --chroot") parser.add_option("--spec", action="store", - help="Specifies spec file to use to build an SRPM (used only with --buildsrpm)") + help="Specifies spec file to use to build an SRPM (used only with --buildsrpm)") parser.add_option("--sources", action="store", - help="Specifies sources to use to build an SRPM (used only with --buildsrpm)") - + help="Specifies sources (either a single file or a directory of files)" + "to use to build an SRPM (used only with --buildsrpm)") + # verbosity parser.add_option("-v", "--verbose", action="store_const", const=2, dest="verbose", default=1, help="verbose build") diff --git a/py/mock/backend.py b/py/mock/backend.py index f22ac12..e35c6c7 100644 --- a/py/mock/backend.py +++ b/py/mock/backend.py @@ -542,8 +542,18 @@ class Root(object): # copy spec/sources shutil.copy(spec, self.makeChrootPath(self.builddir, "SPECS")) - os.rmdir(self.makeChrootPath(self.builddir, "SOURCES")) - shutil.copytree(sources, self.makeChrootPath(self.builddir, "SOURCES")) + + # Resolve any symlinks + sources = os.path.realpath(sources) + + if os.path.isdir(sources): + os.rmdir(self.makeChrootPath(self.builddir, "SOURCES")) + shutil.copytree(sources, self.makeChrootPath(self.builddir, "SOURCES")) + else: + shutil.copy(sources, self.makeChrootPath(self.builddir, "SOURCES")) + + spec = self.makeChrootPath(self.builddir, "SPECS", os.path.basename(spec)) + chrootspec = spec.replace(self.makeChrootPath(), '') # get rid of rootdir prefix spec = self.makeChrootPath(self.builddir, "SPECS", os.path.basename(spec)) chrootspec = spec.replace(self.makeChrootPath(), '') # get rid of rootdir prefix |