From e2985c8d9abfde3a50a805199e7b5b26a324372f Mon Sep 17 00:00:00 2001
From: Sebastien Luttringer <sebastien.luttringer@smartjog.com>
Date: Fri, 28 Oct 2011 16:03:15 +0200
Subject: [PATCH] script without execution bit are not added in image

---
 installsystems/image.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/installsystems/image.py b/installsystems/image.py
index 0b34136..c0c4f79 100644
--- a/installsystems/image.py
+++ b/installsystems/image.py
@@ -331,6 +331,10 @@ class SourceImage(Image):
             if not re.match("\d+-.*\.py$", fi):
                 debug("%s skipped: invalid name" % fi)
                 continue
+            # check execution bit
+            if not os.access(fp, os.X_OK):
+                debug("%s skipped: not executable" % fi)
+                continue
             # adding file
             ti = tarball.gettarinfo(fp, arcname=os.path.join(basedirectory, fi))
             ti.mode = 0755
@@ -349,12 +353,17 @@ class SourceImage(Image):
         arrowlevel(1)
         # checking each file
         for fi in sorted(os.listdir(directory)):
+            fp = os.path.join(directory, fi)
             # check name
             if not re.match("\d+-.*\.py$", fi):
                 debug("%s skipped: invalid name" % fi)
                 continue
+            # check execution bit
+            if not os.access(fp, os.X_OK):
+                debug("%s skipped: not executable" % fi)
+                continue
             # compiling file
-            fs = open(os.path.join(directory, fi), "rb").read()
+            fs = open(fp, "rb").read()
             compile(fs, fi, mode="exec")
             arrow(fi)
         arrowlevel(-1)
-- 
GitLab