[CentOS-devel] [PATCH 1/4] If outdir is not checked into git when sources() is called, create the appropriate directory (RESOLVES: 0007297)

Sat Jul 5 04:48:57 UTC 2014
Brian Stinson <bstinson at ksu.edu>

This commit also moves a comment that was checked in on the wrong line
---
 src/centpkg/__init__.py |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/src/centpkg/__init__.py b/src/centpkg/__init__.py
index eff2a72..7eff083 100644
--- a/src/centpkg/__init__.py
+++ b/src/centpkg/__init__.py
@@ -110,8 +110,20 @@ class Commands(pyrpkg.Commands):
                 csum, file = archive.strip().split(None, 1)
             except ValueError:
                 raise pyrpkg.rpkgError('Malformed sources file.')
-            # See if we already have a valid copy downloaded
+
+            # If a directory is specified in the metadata file, append it to
+            # outdir
+            if os.path.dirname(file):
+                outdir = os.path.join(self.path, os.path.dirname(file))
+                file = os.path.basename(file)
+
+            # Create the output directory if it's not checked into git
+            if not os.path.exists(outdir):
+                self.log.info("Creating OUTDIR: {0}".format(outdir))
+                os.makedirs(outdir)
+
             outfile = os.path.join(outdir, file)
+            # See if we already have a valid copy downloaded
             if os.path.exists(outfile):
                 if self._verify_file(outfile, csum, self.lookasidehash):
                     continue
-- 
1.7.1