diff --git a/bin/is b/bin/is index d54e2a54fc5b46d467f19fcd1dd1a37155284ef9..a4722024abb1c5e322fbf52742f787ee846c7f09 100755 --- a/bin/is +++ b/bin/is @@ -177,7 +177,8 @@ def c_extract(parser, args): ''' repoman = load_repositories(args) img, repo = select_image(args.image, repoman, args.best) - img.extract(args.path, payload=args.payload, force=args.force) + img.extract(args.path, payload=args.payload, force=args.force, + gendescription=args.gendescription) def c_get(parser, args): ''' @@ -398,6 +399,8 @@ p_diff.set_defaults(func=c_diff) # extract command parser p_extract = subparsers.add_parser("extract", help=c_extract.__doc__.lower()) +p_extract.add_argument("-D", action="store_true", dest="gendescription", default=False, + help="generate a description file from metadata") p_extract.add_argument("-p", action="store_true", dest="payload", default=False, help="extract payloads") p_extract.add_argument("-f", "--force", action="store_true", default=False, diff --git a/installsystems/image.py b/installsystems/image.py index 4e3e52ee4b543cbb7717f03256f174c0476d097c..b80f3e56cea8f8e616faad942ef510adebdd62d8 100644 --- a/installsystems/image.py +++ b/installsystems/image.py @@ -83,7 +83,11 @@ class SourceImage(Image): # create dict of file to create examples = {} # create description example from template - examples["description"] = {"path": "description", "content": istemplate.description} + examples["description"] = {"path": "description", + "content": istemplate.description % {"name": "", + "version": "", + "description": "", + "author": ""}} # create changelog example from template examples["changelog"] = {"path": "changelog", "content": istemplate.changelog} # create parser example from template @@ -618,7 +622,7 @@ class PackageImage(Image): self.payload[payname].info self.payload[payname].download(directory, force=force) - def extract(self, directory, force=False, payload=False): + def extract(self, directory, force=False, payload=False, gendescription=False): ''' Extract content of the image inside a repository ''' @@ -630,6 +634,11 @@ class PackageImage(Image): # extract content arrow("Extracting image in %s" % directory) self._tarball.extractall(directory) + # generate description file from description.json + if gendescription: + arrow("Generating description file in %s" % directory) + with open(os.path.join(directory, "description"), "w") as f: + f.write(istemplate.description % self._metadata) # launch payload extract if payload: for payname in self.payload: diff --git a/installsystems/template.py b/installsystems/template.py index 0b9697ef8e383163690609cf334b9367600ce973..b23caff5ecf9c452d94730aa479855e863fe35e1 100644 --- a/installsystems/template.py +++ b/installsystems/template.py @@ -3,10 +3,10 @@ # Started 12/05/2011 by Seblu <seblu@seblu.net> description = u"""[image] -name = -version = -description = -author = +name = %(name)s +version = %(version)s +description = %(description)s +author = %(author)s """ changelog = u"""[1]