Commit 7a7dc2fb authored by Sebastien Luttringer's avatar Sebastien Luttringer
Browse files

build command correclty handle ctrl+c and kill -15

parent 0d0be3d9
Loading
Loading
Loading
Loading
+42 −29
Original line number Diff line number Diff line
@@ -182,6 +182,7 @@ class SourceImage(Image):
        arrow("Creating image tarball")
        arrowlevel(1)
        arrow("Name %s" % self.image_name)
        try:
            try:
                tarball = Tarball.open(self.image_name, mode="w:gz", dereference=True)
            except Exception as e:
@@ -202,6 +203,9 @@ class SourceImage(Image):
            self._add_scripts(tarball, self.setup_path)
            # closing tarball file
            tarball.close()
        except (SystemExit, KeyboardInterrupt):
            if os.path.exists(self.image_name):
                os.unlink(self.image_name)
        arrowlevel(-1)

    def create_payloads(self, force=False):
@@ -268,6 +272,10 @@ class SourceImage(Image):
                        filter=self._create_payload_tarball_filter)
            tarball.close()
            dfo.close()
        except (SystemExit, KeyboardInterrupt):
            if os.path.exists(tar_path):
                os.unlink(tar_path)
            raise
        except Exception as e:
            raise Exception("Unable to create payload tarball %s: %s" % (tar_path, e))

@@ -285,6 +293,7 @@ class SourceImage(Image):
        Create a payload file
        Only gzipping it
        '''
        try:
            fsource = PipeFile(source, "r", progressbar=True)
            # open file not done in GzipFile, to escape writing of filename
            # in gzip file. This change md5.
@@ -295,6 +304,10 @@ class SourceImage(Image):
            fsource.consume(fdest)
            fsource.close()
            fdest.close()
        except (SystemExit, KeyboardInterrupt):
            if os.path.exists(dest):
                os.unlink(dest)
            raise

    def _add_scripts(self, tarball, directory):
        '''