[PATCH] handle symlinks in BuildMavenTask._zip_dir()

Mike McLean mikem at redhat.com
Thu Jun 4 15:58:09 UTC 2015


---
 builder/kojid | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/builder/kojid b/builder/kojid
index dcd0840..ad2cf1f 100755
--- a/builder/kojid
+++ b/builder/kojid
@@ -1281,7 +1281,17 @@ class BuildMavenTask(BaseBuildTask):
                     dirnames.remove(skip)
             for filename in filenames:
                 filepath = os.path.join(dirpath, filename)
-                zfo.write(filepath, filepath[roottrim:])
+                if os.path.islink(filepath):
+                    content = os.readlink(filepath)
+                    st = os.lstat(filepath)
+                    mtime = time.localtime(st.st_mtime)
+                    info = zipfile.ZipInfo(filepath[roottrim:])
+                    info.external_attr |= 0120000 << 16L # symlink file type
+                    info.compress_type = zipfile.ZIP_STORED
+                    info.date_time = mtime[:6]
+                    zfo.writestr(info, content)
+                else:
+                    zfo.write(filepath, filepath[roottrim:])
         zfo.close()
 
     def checkHost(self, hostdata):
-- 
1.9.3



More information about the koji-devel mailing list