]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
fix
authorMathias Klette <mathias.klette@profitbricks.com>
Wed, 16 May 2012 14:23:03 +0000 (16:23 +0200)
committerMathias Klette <mathias.klette@profitbricks.com>
Wed, 16 May 2012 14:23:03 +0000 (16:23 +0200)
debian_build.py

index 8fab1b8179cd3311ace648d7d92429775fa1264d..73d6c051d978da3274ab8dbe849b7026b2263dfc 100755 (executable)
@@ -429,30 +429,31 @@ if __name__ == '__main__':
     # cleanup existing *orig.tar.gz
     if os.path.isdir(BUILD_AREA):
         files = [os.path.join(BUILD_AREA,file) for file in fnmatch.filter(os.listdir(BUILD_AREA),'*.orig.tar.gz')]
-        logger.debug('Previous upstream tarball(s) found: %s' %( files ))
-        cmd = [BIN_SUDO, BIN_RM, '-v', " ".join(files)]
-        cmdobj = subprocess.Popen(
-                cmd,
-                shell=False,
-                cwd='/',
-                close_fds=True,
-                stdout=subprocess.PIPE,
-                stderr=subprocess.STDOUT,
-                env={'':''}
-        )
+        if len(files) > 0:
+            logger.debug('Previous upstream tarball(s) found: %s' %( files ))
+            cmd = [BIN_SUDO, BIN_RM, '-v', " ".join(files)]
+            cmdobj = subprocess.Popen(
+                    cmd,
+                    shell=False,
+                    cwd='/',
+                    close_fds=True,
+                    stdout=subprocess.PIPE,
+                    stderr=subprocess.STDOUT,
+                    env={'':''}
+            )
     
-        logger.debug('Calling "%s" ..' %(' '.join(cmd)))
-        ret = cmdobj.wait()
-        for line in cmdobj.stdout.readlines():
-            logger.debug('%s' %(line))
+            logger.debug('Calling "%s" ..' %(' '.join(cmd)))
+            ret = cmdobj.wait()
+            for line in cmdobj.stdout.readlines():
+                logger.debug('%s' %(line))
 
-        if ret:
-            _str = (
-                'Cmd "%s" returned non-zero (exitcode: %s).'
-                %(' '.join(cmd), ret)
-            )
-            logger.debug(_str)
-            raise Exception(_str)
+            if ret:
+                _str = (
+                    'Cmd "%s" returned non-zero (exitcode: %s).'
+                    %(' '.join(cmd), ret)
+                )
+                logger.debug(_str)
+                raise Exception(_str)
 
         files = [os.path.join(BUILD_AREA,file) for file in fnmatch.filter(os.listdir(BUILD_AREA),'*.orig.tar.gz')]
         logger.debug('Previous upstream tarball(s) found: %s' %( files ))