You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by bo...@apache.org on 2010/11/24 01:45:24 UTC

svn commit: r1038404 - in /buildr/trunk: CHANGELOG buildr.gemspec lib/buildr/packaging.rb lib/buildr/packaging/zip.rb spec/packaging/archive_spec.rb

Author: boisvert
Date: Wed Nov 24 00:45:23 2010
New Revision: 1038404

URL: http://svn.apache.org/viewvc?rev=1038404&view=rev
Log:
BUILDR-546 Upgrade to Rubyzip 0.9.4 (Michael Guymon)

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

Modified: buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=1038404&r1=1038403&r2=1038404&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Wed Nov 24 00:45:23 2010
@@ -5,6 +5,7 @@
 * Added:  BUILDR-537 Shell tasks should use JAVA_OPTS by default
 * Added:  BUILDR-538 Shell tasks should support passing :java_args
 * Change: BUILDR-540 Upgrade to rspec 2.1.0
+* Change: BUILDR-546 Upgrade to Rubyzip 0.9.4 (Michael Guymon)
 * Fixed:  BUILDR-542 Release task:  SVN tagging fails if parent tag directory
           does not exist yet (Gerolf Seitz)
 * Fixed:  BUILDR-543 POMs are installed and uploaded twice when using artifacts

Modified: buildr/trunk/buildr.gemspec
URL: http://svn.apache.org/viewvc/buildr/trunk/buildr.gemspec?rev=1038404&r1=1038403&r2=1038404&view=diff
==============================================================================
--- buildr/trunk/buildr.gemspec (original)
+++ buildr/trunk/buildr.gemspec Wed Nov 24 00:45:23 2010
@@ -54,7 +54,7 @@ for those one-off tasks, with a language
   spec.add_dependency 'builder',              '2.1.2'
   spec.add_dependency 'net-ssh',              '2.0.23'
   spec.add_dependency 'net-sftp',             '2.0.4'
-  spec.add_dependency 'rubyzip',              '0.9.1'
+  spec.add_dependency 'rubyzip',              '0.9.4'
   spec.add_dependency 'highline',             '1.5.1'
   spec.add_dependency 'json_pure',            '1.4.3'
   spec.add_dependency 'rubyforge',            '2.0.3'

Modified: buildr/trunk/lib/buildr/packaging.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging.rb?rev=1038404&r1=1038403&r2=1038404&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/packaging.rb (original)
+++ buildr/trunk/lib/buildr/packaging.rb Wed Nov 24 00:45:23 2010
@@ -20,5 +20,6 @@ require 'buildr/packaging/archive'
 require 'buildr/packaging/ziptask'
 require 'buildr/packaging/tar'
 require 'buildr/packaging/gems'
+require 'buildr/packaging/zip'
 autoload :Zlib, 'zlib'
-autoload :Zip, 'buildr/packaging/zip'
+

Modified: buildr/trunk/lib/buildr/packaging/zip.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/zip.rb?rev=1038404&r1=1038403&r2=1038404&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/packaging/zip.rb (original)
+++ buildr/trunk/lib/buildr/packaging/zip.rb Wed Nov 24 00:45:23 2010
@@ -17,17 +17,19 @@
 if RUBY_VERSION >= '1.9.0' # Required to properly load RubyZip under Ruby 1.9
   $LOADED_FEATURES.unshift 'ftools'
   require 'fileutils'
+
   def File.move(source, dest)
     FileUtils.move source, dest
   end
+
   def File.rm_rf(path)
     FileUtils.rm_rf path
   end
 end
+
 require 'zip/zip'
 require 'zip/zipfilesystem'
 
-
 module Zip #:nodoc:
 
   class ZipCentralDirectory #:nodoc:
@@ -69,5 +71,108 @@ module Zip #:nodoc:
         all? { |pattern| content =~ pattern }
     end
 
+    # Override of write_c_dir_entry to fix comments being set to a fixnum instead of string
+    def write_c_dir_entry(io) #:nodoc:all
+      case @fstype
+        when FSTYPE_UNIX
+          ft = nil
+          case @ftype
+            when :file
+              ft = 010
+              @unix_perms ||= 0644
+            when :directory
+              ft = 004
+              @unix_perms ||= 0755
+            when :symlink
+              ft = 012
+              @unix_perms ||= 0755
+            else
+              raise ZipInternalError, "unknown file type #{self.inspect}"
+          end
+
+          @externalFileAttributes = (ft << 12 | (@unix_perms & 07777)) << 16
+      end
+
+      io <<
+        [0x02014b50,
+         @version,                  # version of encoding software
+         @fstype,                   # filesystem type
+         10,                        # @versionNeededToExtract
+         0,                         # @gp_flags
+         @compression_method,
+         @time.to_binary_dos_time,  # @lastModTime
+         @time.to_binary_dos_date,  # @lastModDate
+         @crc,
+         @compressed_size,
+         @size,
+         @name ? @name.length : 0,
+         @extra ? @extra.c_dir_length : 0,
+         @comment ? comment.to_s.length : 0,
+         0,                         # disk number start
+         @internalFileAttributes,   # file type (binary=0, text=1)
+         @externalFileAttributes,   # native filesystem attributes
+         @localHeaderOffset,
+         @name,
+         @extra,
+         @comment
+      ].pack('VCCvvvvvVVVvvvvvVV')
+
+      io << @name
+      io << (@extra ? @extra.to_c_dir_bin : "")
+      io << @comment
+    end
+
+    # Override write_c_dir_entry to fix comments being set to a fixnum instead of string
+    def write_c_dir_entry(io) #:nodoc:all
+      @comment = "" if @comment.nil? || @comment == -1  # Hack fix @comment being nil or fixnum -1
+
+      case @fstype
+        when FSTYPE_UNIX
+          ft = nil
+          case @ftype
+            when :file
+              ft = 010
+              @unix_perms ||= 0644
+            when :directory
+              ft = 004
+              @unix_perms ||= 0755
+            when :symlink
+              ft = 012
+              @unix_perms ||= 0755
+            else
+              raise ZipInternalError, "unknown file type #{self.inspect}"
+          end
+
+          @externalFileAttributes = (ft << 12 | (@unix_perms & 07777)) << 16
+      end
+
+      io <<
+        [0x02014b50,
+         @version,                  # version of encoding software
+         @fstype,                   # filesystem type
+         10,                        # @versionNeededToExtract
+         0,                         # @gp_flags
+         @compression_method,
+         @time.to_binary_dos_time,  # @lastModTime
+         @time.to_binary_dos_date,  # @lastModDate
+         @crc,
+         @compressed_size,
+         @size,
+         @name ? @name.length : 0,
+         @extra ? @extra.c_dir_length : 0,
+         @comment ? @comment.length : 0,
+         0,                         # disk number start
+         @internalFileAttributes,   # file type (binary=0, text=1)
+         @externalFileAttributes,   # native filesystem attributes
+         @localHeaderOffset,
+         @name,
+         @extra,
+         @comment].pack('VCCvvvvvVVVvvvvvVV')
+
+      io << @name
+      io << (@extra ? @extra.to_c_dir_bin : "")
+      io << @comment
+
+    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=1038404&r1=1038403&r2=1038404&view=diff
==============================================================================
--- buildr/trunk/spec/packaging/archive_spec.rb (original)
+++ buildr/trunk/spec/packaging/archive_spec.rb Wed Nov 24 00:45:23 2010
@@ -430,16 +430,16 @@ describe "ZipTask" do
   # they are stricter than rubyzip
   def checkZip(file)
     return unless File.exist?(file)
-    empty = true
     zip = Java.java.util.zip.ZipInputStream.new(Java.java.io.FileInputStream.new(file))
+    zip_entry_count = 0
     while entry = zip.getNextEntry do
       # just iterate over all entries
-      empty = false
+      zip_entry_count = zip_entry_count + 1
     end
     zip.close()
 
     # jar tool fails with "ZipException: error in opening zip file" if empty
-    unless empty
+    if zip_entry_count > 0
       sh "#{File.join(ENV['JAVA_HOME'], 'bin', 'jar')} tvf #{file}"
     end
   end