You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by as...@apache.org on 2009/07/02 19:19:27 UTC

svn commit: r790686 - in /buildr/trunk: CHANGELOG lib/buildr/packaging/ziptask.rb spec/packaging/archive_spec.rb

Author: assaf
Date: Thu Jul  2 17:19:27 2009
New Revision: 790686

URL: http://svn.apache.org/viewvc?rev=790686&view=rev
Log:
Fixed: BUILDR-23 Support for setting file mode when packaging (Ittay Dror).

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=790686&r1=790685&r2=790686&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Thu Jul  2 17:19:27 2009
@@ -1,10 +1,11 @@
 1.3.5 (Pending)
 * Added:  Interactive shell (REPL) support
-* Change: Monkey-Patched FileUtils::sh on JRuby to use POSIX `system`
 * Added:  BUILDR-56 Download Scala artifacts if not available locally
 * Added:  Mandriva (urpmi) installation support (with help from Franck Villaume).
 * Added:  BUILDR-163 cobertura:check (Marko Sibakov, Daniel Spiewak).
+* Change: Monkey-Patched FileUtils::sh on JRuby to use POSIX `system`
 * Change: Updated to Rake 0.8.7, RSpec 1.2.6 and JRuby-openssl 0.5.1.
+* Fixed:  BUILDR-23 Support for setting file mode when packaging (Ittay Dror).
 * Fixed:  BUILDR-290 Dependencies cannot be downloaded over SSL.
 
 1.3.4 (2009-04-21)

Modified: buildr/trunk/lib/buildr/packaging/ziptask.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/ziptask.rb?rev=790686&r1=790685&r2=790686&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/packaging/ziptask.rb (original)
+++ buildr/trunk/lib/buildr/packaging/ziptask.rb Thu Jul  2 17:19:27 2009
@@ -74,8 +74,9 @@
           elsif content.nil? || File.directory?(content.to_s)
             mkpath.call path
           else
-            zip.put_next_entry(path, compression_level)
+            entry = zip.put_next_entry(path, compression_level)
             File.open content.to_s, 'rb' do |is|
+              entry.unix_perms = is.stat.mode & 07777
               while data = is.read(4096)
                 zip << data
               end
@@ -155,6 +156,7 @@
             dest = File.expand_path(dest, target.to_s)
             trace "Extracting #{dest}"
             mkpath File.dirname(dest) rescue nil
+            entry.restore_permissions = true
             entry.extract(dest) { true }
           end
         end

Modified: buildr/trunk/spec/packaging/archive_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/packaging/archive_spec.rb?rev=790686&r1=790685&r2=790686&view=diff
==============================================================================
--- buildr/trunk/spec/packaging/archive_spec.rb (original)
+++ buildr/trunk/spec/packaging/archive_spec.rb Thu Jul  2 17:19:27 2009
@@ -375,6 +375,15 @@
     archive(@archive).invoke
     inspect_archive { |archive| archive.keys.should include('code/') }
   end
+
+  it 'should preserve file permissions' do
+    write 'src/main/bin/hello', 'echo hi'
+    chmod 0777,  'src/main/bin/hello'
+    zip('foo.zip').include('src/main/bin/*').invoke
+    unzip('target' => 'foo.zip').extract
+    (File.stat('target/hello').mode & 0777).should == 0777
+  end
+
 end