]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
DEVINF-84: pre-remove existing orig.tar.gz on every build
authorMathias Klette <mathias.klette@profitbricks.com>
Tue, 15 May 2012 17:08:03 +0000 (19:08 +0200)
committerMathias Klette <mathias.klette@profitbricks.com>
Tue, 15 May 2012 17:08:03 +0000 (19:08 +0200)
debian_build.py

index 8979b8bee63e3971dd336884989e3ceee2ddefa3..4798f24d737d9811a9c740b1f994a374b58e8f3a 100755 (executable)
@@ -9,6 +9,7 @@ import git
 import errno
 import atexit
 import shutil
+import fnmatch
 import logging
 import optparse
 import datetime
@@ -425,6 +426,33 @@ if __name__ == '__main__':
     else:
          raise Exception('unhandled branch, failing.')
 
+    # cleanup existing *orig.tar.gz
+    cmd = [BIN_SUDO, BIN_RM, '-f', fnmatch.filter(os.listdir('../build-area/'),'*.orig.tar.gz')]
+    cmdobj = subprocess.Popen(
+            cmd,
+            shell=False,
+            cwd='/',
+            close_fds=True,
+            stdout=sys.stdout,
+            stderr=sys.stderr,
+            env={'':''}
+    )
+
+    logger.debug(
+            'Trying to call "%s" 
+            %(' '.join(cmd))
+    )
+
+    ret = cmdobj.wait()
+    if ret:
+        _str = (
+                'Cmd "%s" returned non-zero (exitcode: %s).'
+                %(' '.join(cmd), ret)
+        )
+        logger.debug(_str)
+        raise Exception(_str)
+
+
     logger.info('dist: %s' %(pb_suite))
     cmd = ['figlet-figlet', '-t', 'dist: %s' %(pb_suite)]
     subprocess.check_call(cmd)