From 2a116a805046de76e736cf366d70dc371f509aee Mon Sep 17 00:00:00 2001
From: Sebastien Luttringer <sebastien.luttringer@smartjog.com>
Date: Thu, 13 Oct 2011 16:32:35 +0200
Subject: [PATCH] Add changelog to images

Add a changelog file inside isimage with a custom format which allow
image creator to quickly show update between images
---
 installsystems/image.py    | 20 ++++++++++++++++++++
 installsystems/template.py |  4 ++++
 2 files changed, 24 insertions(+)

diff --git a/installsystems/image.py b/installsystems/image.py
index 8fb8d39..fca7dfa 100644
--- a/installsystems/image.py
+++ b/installsystems/image.py
@@ -84,6 +84,9 @@ class SourceImage(Image):
             # create description example from template
             arrow("Creating description example")
             open(os.path.join(path, "description"), "w").write(istemplate.description)
+            # create changelog example from template
+            arrow("Creating description example")
+            open(os.path.join(path, "changelog"), "w").write(istemplate.changelog)
             # create parser example from template
             arrow("Creating parser script example")
             open(os.path.join(parser_path, "01-parser.py"), "w").write(istemplate.parser)
@@ -168,6 +171,15 @@ class SourceImage(Image):
         # add .description.json
         arrow("Add description.json")
         tarball.add_str("description.json", description, tarfile.REGTYPE, 0444)
+        # add changelog
+        changelog_path = os.path.join(self.base_path, "changelog")
+        if os.path.exists(changelog_path):
+            arrow("Add changelog")
+            ti = tarball.gettarinfo(changelog_path, "changelog")
+            ti.uid = ti.gid = 0
+            ti.mode = 0644
+            ti.uname = ti.gname = "root"
+            tarball.addfile(ti, open(changelog_path, "rb"))
         # add .format
         arrow("Add format")
         tarball.add_str("format", self.format, tarfile.REGTYPE, 0444)
@@ -905,3 +917,11 @@ class Payload(object):
             raise Exception("Downloading payload %s failed: Invalid MD5" % self.name)
         # settings file orginal rights
         istools.chrights(dest, self.uid, self.gid, self.mode, self.mtime)
+
+
+class Changelog(object):
+    '''
+    Object representing a changelog in memory
+    '''
+    def __init__(self):
+        pass
diff --git a/installsystems/template.py b/installsystems/template.py
index 2bbf81f..d1056b0 100644
--- a/installsystems/template.py
+++ b/installsystems/template.py
@@ -9,6 +9,10 @@ description =
 author =
 """
 
+changelog = """==== 1 ====
+- Initial version
+"""
+
 parser = """# -*- python -*-
 # -*- coding: utf-8 -*-
 
-- 
GitLab