Commit 6c0cf33c authored by Sebastien Luttringer's avatar Sebastien Luttringer
Browse files

add option -p to build

build -p recreate payload file if already exsits
parent 2e85b8fb
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ def c_build(parser, args):
    # load source image
    simg = SourceImage(args.path)
    # do the job
    simg.build(force=args.force, check=not args.no_check)
    simg.build(force=args.force, force_payload=args.payload, check=not args.no_check)
    # compute building time
    t1 = time.time()
    dt = int(t1 - t0)
@@ -370,7 +370,9 @@ p_build = subparsers.add_parser("build", help=c_build.__doc__.lower())
p_build.add_argument("-c", "--no-check", action="store_true", default=False,
                     help="do not check compilation before adding scripts")
p_build.add_argument("-f", "--force", action="store_true", default=False,
                     help="overwrite existing image")
                     help="rebuild image if already exists")
p_build.add_argument("-p", "--payload", action="store_true", default=False,
                     help="rebuild payloads if already exists")
p_build.add_argument("path", nargs="?", default=".")
p_build.set_defaults(func=c_build)

+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ _is() {
            (( args > 2 )) && _filedir '?(u)isimage'
            ;;
	build)
            [[ "$cur" == -* ]] && _opt '-h --help -f --force -c --no-check' && return 0
            [[ "$cur" == -* ]] && _opt '-h --help -f --force -p --payload -c --no-check' && return 0
	    _count_args
            (( args == 2 )) && _filedir -d
            ;;
+4 −4
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ class SourceImage(Image):
        if not os.path.exists(os.path.join(self.base_path, "description")):
            raise Exception("No description file")

    def build(self, force=False, check=True):
    def build(self, force=False, force_payload=False, check=True):
        '''
        Create packaged image
        '''
@@ -168,7 +168,7 @@ class SourceImage(Image):
            self.check_scripts(self.parser_path)
            self.check_scripts(self.setup_path)
        # Create payload files
        payloads = self.create_payloads()
        payloads = self.create_payloads(force=force_payload)
        # generate a JSON description
        jdesc = self.generate_json_description(payloads)
        # creating scripts tarball
@@ -204,7 +204,7 @@ class SourceImage(Image):
        tarball.close()
        arrowlevel(-1)

    def create_payloads(self):
    def create_payloads(self, force=False):
        '''
        Create all data payloads in current directory
        Doesn't compute md5 during creation because tarball can
@@ -231,7 +231,7 @@ class SourceImage(Image):
                                        Payload.extension)
            source_stat = os.stat(source_path)
            isdir = stat.S_ISDIR(source_stat.st_mode)
            if os.path.exists(dest_path):
            if os.path.exists(dest_path) and not force:
                arrow("Payload %s already exists" % dest_path)
            else:
                arrow("Creating payload %s" % dest_path)