From 521bbd66531ad09adc2133041907ba1328a7ca13 Mon Sep 17 00:00:00 2001
From: Sebastien Luttringer <sebastien.luttringer@smartjog.com>
Date: Tue, 18 Oct 2011 16:08:25 +0200
Subject: [PATCH] fix extracting payload with utf8 filenames

tarfile module fail to extract tarball with utf8 filenames when destination is an unicode
string. We need to convert dest as utf-8 string to restore an expected behaviour
---
 installsystems/image.py    | 5 +++--
 installsystems/template.py | 8 ++++----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/installsystems/image.py b/installsystems/image.py
index e507818..311890a 100644
--- a/installsystems/image.py
+++ b/installsystems/image.py
@@ -628,7 +628,9 @@ class PackageImage(Image):
         # launch payload extract
         if payload:
             for payname in self.payload:
-                dest = os.path.join(directory, "payload", payname)
+                # here we need to decode payname which is in unicode to escape
+                # tarfile to encode filename of file inside tarball inside unicode
+                dest = os.path.join(directory, "payload", payname.encode("utf-8"))
                 arrow("Extracting payload %s in %s" % (payname, dest))
                 self.payload[payname].extract(dest, force=force)
 
@@ -994,7 +996,6 @@ class Changelog(dict):
             version = max(self)
         # in non verbose mode display only asked version if exists
         if not verbose and version not in self:
-            print "chich"
             return
         out('#light##yellow#Changelog:#reset#')
         # display asked version
diff --git a/installsystems/template.py b/installsystems/template.py
index ba22994..0b9697e 100644
--- a/installsystems/template.py
+++ b/installsystems/template.py
@@ -2,14 +2,14 @@
 # -*- coding: utf-8 -*-
 # Started 12/05/2011 by Seblu <seblu@seblu.net>
 
-description = """[image]
+description = u"""[image]
 name =
 version =
 description =
 author =
 """
 
-changelog = """[1]
+changelog = u"""[1]
 - Initial version
 """
 
@@ -36,7 +36,7 @@ parser.add_argument("target", type=str, action=TargetAction,
 # vim:set ts=2 sw=2 noet:
 """
 
-setup = """# -*- python -*-
+setup = u"""# -*- python -*-
 # -*- coding: utf-8 -*-
 
 # image object is a reference to current image
@@ -52,7 +52,7 @@ arrow("hostname: %s" % namespace.hostname)
 # vim:set ts=2 sw=2 noet:
 """
 
-createdb = """
+createdb = u"""
 CREATE TABLE image (md5 TEXT NOT NULL PRIMARY KEY,
                     name TEXT NOT NULL,
                     version INTEGER NOT NULL,
-- 
GitLab