From 07e374f0cd5b6901f703c29b8c9612d6c777ee0a Mon Sep 17 00:00:00 2001
From: Seblu <sebastien.luttringer@smartjog.com>
Date: Thu, 26 May 2011 17:28:17 +0200
Subject: [PATCH] Fix bad deferencing in directory in /data of image

---
 bin/isimage             | 2 +-
 bin/isinstall           | 2 ++
 installsystems/image.py | 9 +++++----
 installsystems/tools.py | 6 +++---
 4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/bin/isimage b/bin/isimage
index 7686381..a43a04b 100755
--- a/bin/isimage
+++ b/bin/isimage
@@ -40,7 +40,7 @@ def build(options):
     for d in ("", "parser", "setup", "data"):
         rp = os.path.join(options.path, d)
         if not os.path.exists(rp):
-            error("Missing directory: %s" % rp)
+            error("Missing directory: %s" % d)
         if not os.path.isdir(rp):
             error("Not a directory: %s" % rp)
         if not os.access(rp, os.R_OK|os.X_OK):
diff --git a/bin/isinstall b/bin/isinstall
index c6df9f8..65cf142 100755
--- a/bin/isinstall
+++ b/bin/isinstall
@@ -73,3 +73,5 @@ try:
     pkg.run_setup({"args": args})
 except Exception as e:
     error(e)
+except KeyboardInterrupt:
+    warn("Keyboard Interrupted")
diff --git a/installsystems/image.py b/installsystems/image.py
index 03debe3..7340427 100644
--- a/installsystems/image.py
+++ b/installsystems/image.py
@@ -11,7 +11,6 @@ import stat
 import datetime
 import time
 import json
-import hashlib
 import StringIO
 import ConfigParser
 import subprocess
@@ -19,10 +18,10 @@ import json
 import tarfile
 import re
 import installsystems.template
+import installsystems.tools as istools
 from installsystems.printer import *
 from installsystems.tarball import Tarball
 
-
 class Image(object):
     '''Abstract class of images'''
 
@@ -185,15 +184,17 @@ class SourceImage(Image):
     def create_data_tarball(self, tar_path, data_path):
         '''Create a data tarball'''
         dname = os.path.basename(data_path)
+        # not derefence for directory. Verbatim copy.
+        ddref = False if os.path.isdir(data_path) else True
         try:
             # opening file
             if self.pbzip2_path:
                 tb = open(tar_path, mode="w")
                 p = subprocess.Popen(self.pbzip2_path, shell=False, close_fds=True,
                                      stdin=subprocess.PIPE, stdout=tb.fileno())
-                tarball = Tarball.open(mode="w|", dereference=True, fileobj=p.stdin)
+                tarball = Tarball.open(mode="w|", dereference=ddref, fileobj=p.stdin)
             else:
-                tarball = Tarball.open(tar_path, "w:bz2", dereference=True)
+                tarball = Tarball.open(tar_path, "w:bz2", dereference=ddref)
             tarball.add(data_path, arcname=dname, recursive=True)
             # closing tarball file
             tarball.close()
diff --git a/installsystems/tools.py b/installsystems/tools.py
index 3e86de2..694b676 100644
--- a/installsystems/tools.py
+++ b/installsystems/tools.py
@@ -7,15 +7,15 @@ InstallSystems Generic Tools Library
 '''
 
 import os
-from installsystems.image import Image
+import hashlib
 
-def md5sum(self, path):
+def md5sum(path):
     '''Compute md5 of a file'''
     m = hashlib.md5()
     m.update(open(path, "r").read())
     return m.hexdigest()
 
-def cp(self, source, destination):
+def cp(source, destination):
     '''Copy a source to destination. Take care of path type'''
     stype = path_type(source)
     dtype = path_type(destination)
-- 
GitLab