Author: boisvert
Date: Thu Jul 19 01:08:36 2012
New Revision: 1363195

URL: http://svn.apache.org/viewvc?rev=1363195&view=rev
Log:
BUILDR-646 TGZ files do not keep their permissions when extracted via 
Buildr::Unzip#extract

Modified:
    buildr/trunk/CHANGELOG
    buildr/trunk/lib/buildr/packaging/ziptask.rb
    buildr/trunk/spec/packaging/archive_spec.rb

Modified: buildr/trunk/CHANGELOG
URL: 
http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=1363195&r1=1363194&r2=1363195&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Thu Jul 19 01:08:36 2012
@@ -1,4 +1,6 @@
 1.4.8 (Pending)
+* Fixed:  BUILDR-646 TGZ files do not keep their permissions when extracted
+          via Buildr::Unzip#extract
 * Added:  Add add_exploded_ear_artifact and add_exploded_ejb_artifact to the 
idea project extension.
 * Change: Default to using Checkstyle 5.5 in the checkstyle addon.
 * Fixed:  Fix the add_exploded_war_artifact method on the idea project by 
adding in missing method

Modified: buildr/trunk/lib/buildr/packaging/ziptask.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/ziptask.rb?rev=1363195&r1=1363194&r2=1363195&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/packaging/ziptask.rb (original)
+++ buildr/trunk/lib/buildr/packaging/ziptask.rb Thu Jul 19 01:08:36 2012
@@ -157,8 +157,8 @@ module Buildr
                   dest = File.expand_path(dest, target.to_s)
                   trace "Extracting #{dest}"
                   mkpath File.dirname(dest) rescue nil
-                  #entry.restore_permissions = true
-                  File.open(dest, 'wb') {|f| f.write entry.read}
+                  File.open(dest, 'wb', entry.mode) {|f| f.write entry.read}
+                  File.chmod(entry.mode, dest)
                 end
               end
             end

Modified: buildr/trunk/spec/packaging/archive_spec.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/spec/packaging/archive_spec.rb?rev=1363195&r1=1363194&r2=1363195&view=diff
==============================================================================
--- buildr/trunk/spec/packaging/archive_spec.rb (original)
+++ buildr/trunk/spec/packaging/archive_spec.rb Thu Jul 19 01:08:36 2012
@@ -411,6 +411,23 @@ describe TarTask do
     yield entries if block_given?
     entries
   end
+
+  # chmod is not reliable on Windows
+  unless Buildr::Util.win_os?
+    it 'should preserve file permissions' do
+      # with JRuby it's important to use absolute paths with File.chmod()
+      # http://jira.codehaus.org/browse/JRUBY-3300
+      hello = File.expand_path('src/main/bin/hello')
+      write hello, 'echo hi'
+      File.chmod(0777,  hello)
+      fail("Failed to set permission on #{hello}") unless 
(File.stat(hello).mode & 0777) == 0777
+
+      tar('foo.tgz').include('src/main/bin/*').invoke
+      unzip('target' => 'foo.tgz').extract
+      (File.stat('target/hello').mode & 0777).should == 0777
+    end
+  end
+
 end
 
 


Reply via email to