diff -ur tar2rubyscript-0.4.1.tar.gz/tar2rubyscript/init.rb tar2rubyscript-0.4.2.tar.gz/tar2rubyscript/init.rb --- tar2rubyscript-0.4.1.tar.gz/tar2rubyscript/init.rb 2004-12-18 14:58:32.000000000 +0100 +++ tar2rubyscript-0.4.2.tar.gz/tar2rubyscript/init.rb 2004-12-27 11:16:27.000000000 +0100 @@ -42,6 +42,8 @@ script = File.open(scriptfile){|f| f.read} if File.file?(tarfile) + $stderr.puts "Found archive..." + archive = File.open(tarfile, "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")} end @@ -51,15 +53,19 @@ Dir.chdir(tarfile) if File.file?("tar2rubyscript.bat") - $stderr.puts "\".\\tar2rubyscript.bat\"" + $stderr.puts "Running tar2rubyscript.bat ..." + system(".\\tar2rubyscript.bat") end if File.file?("tar2rubyscript.sh") - $stderr.puts "\". ./tar2rubyscript.sh\"" + $stderr.puts "Running tar2rubyscript.sh ..." + system("sh -c \". ./tar2rubyscript.sh\"") end + $stderr.puts "Creating archive..." + Dir.chdir("..") begin @@ -74,6 +80,8 @@ end if not licensefile.nil? and not licensefile.empty? + $stderr.puts "Adding license..." + lic = File.open(licensefile){|f| f.readlines} lic.collect! do |line| @@ -87,6 +95,8 @@ rbfile = tarfile.gsub(/\.tar$/, "") + ".rb" if (rbfile.nil? or File.basename(rbfile) == "-") +$stderr.puts "Creating #{File.basename(rbfile)} ..." + File.open(rbfile, "wb") do |f| f.write script f.write "\n" diff -ur tar2rubyscript-0.4.1.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.4.2.tar.gz/tar2rubyscript/tarrubyscript.rb --- tar2rubyscript-0.4.1.tar.gz/tar2rubyscript/tarrubyscript.rb 2004-12-18 12:29:29.000000000 +0100 +++ tar2rubyscript-0.4.2.tar.gz/tar2rubyscript/tarrubyscript.rb 2004-12-26 22:15:10.000000000 +0100 @@ -21,9 +21,11 @@ # Tar2RubyScript constants -ShowContent = ARGV.include?("--tar2rubyscript-list") -JustExtract = ARGV.include?("--tar2rubyscript-justextract") -ToTar = ARGV.include?("--tar2rubyscript-totar") +unless defined?(BLOCKSIZE) + ShowContent = ARGV.include?("--tar2rubyscript-list") + JustExtract = ARGV.include?("--tar2rubyscript-justextract") + ToTar = ARGV.include?("--tar2rubyscript-totar") +end ARGV.concat [] @@ -33,35 +35,37 @@ # Tar constants -BLOCKSIZE = 512 +unless defined?(BLOCKSIZE) + BLOCKSIZE = 512 -NAMELEN = 100 -MODELEN = 8 -UIDLEN = 8 -GIDLEN = 8 -CHKSUMLEN = 8 -SIZELEN = 12 -MAGICLEN = 8 -MODTIMELEN = 12 -UNAMELEN = 32 -GNAMELEN = 32 -DEVLEN = 8 - -TMAGIC = "ustar" -GNU_TMAGIC = "ustar " -SOLARIS_TMAGIC = "ustar\00000" - -MAGICS = [TMAGIC, GNU_TMAGIC, SOLARIS_TMAGIC] - -LF_OLDFILE = ´\0´ -LF_FILE = ´0´ -LF_LINK = ´1´ -LF_SYMLINK = ´2´ -LF_CHAR = ´3´ -LF_BLOCK = ´4´ -LF_DIR = ´5´ -LF_FIFO = ´6´ -LF_CONTIG = ´7´ + NAMELEN = 100 + MODELEN = 8 + UIDLEN = 8 + GIDLEN = 8 + CHKSUMLEN = 8 + SIZELEN = 12 + MAGICLEN = 8 + MODTIMELEN = 12 + UNAMELEN = 32 + GNAMELEN = 32 + DEVLEN = 8 + + TMAGIC = "ustar" + GNU_TMAGIC = "ustar " + SOLARIS_TMAGIC = "ustar\00000" + + MAGICS = [TMAGIC, GNU_TMAGIC, SOLARIS_TMAGIC] + + LF_OLDFILE = ´\0´ + LF_FILE = ´0´ + LF_LINK = ´1´ + LF_SYMLINK = ´2´ + LF_CHAR = ´3´ + LF_BLOCK = ´4´ + LF_DIR = ´5´ + LF_FIFO = ´6´ + LF_CONTIG = ´7´ +end class Dir def self.rm_rf(entry) @@ -221,11 +225,13 @@ end class Content + @@count = 0 unless defined?(@@count) + def initialize @archive = File.open(File.expand_path(__FILE__), "rb"){|f| f.read}.gsub(/\r/, "").split(/\n\n/)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift temp = ENV["TEMP"] temp = "/tmp" if temp.nil? - @tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}" + @tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}.#{@@count += 1}" end def list @@ -247,17 +253,29 @@ end class TempSpace + @@count = 0 unless defined?(@@count) + def initialize @archive = File.open(File.expand_path(__FILE__), "rb"){|f| f.read}.gsub(/\r/, "").split(/\n\n/)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift @olddir = Dir.pwd temp = ENV["TEMP"] temp = "/tmp" if temp.nil? - @tempdir = "#{temp}/tar2rubyscript.d.#{Process.pid}" - @tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}" + @tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}.#{@@count += 1}" + @tempdir = "#{temp}/tar2rubyscript.d.#{Process.pid}.#{@@count}" @@tempspace = self @newdir = @tempdir + + @touchthread = + Thread.new do + loop do + sleep 60*60 + + touch(@tempdir) + touch(@tempfile) + end + end end def extract @@ -292,6 +310,7 @@ end at_exit do + @touchthread.kill # Close all File objects, opened in init.rb . @@ -316,6 +335,32 @@ self end + def touch(entry) + entry = entry.gsub!(/[\/\\]*$/, "") unless entry.nil? + + return unless File.exists?(entry) + + if File.directory?(entry) + pdir = Dir.pwd + + begin + Dir.chdir(entry) + + begin + Dir.new(".").each do |e| + touch(e) unless [".", ".."].include?(e) + end + ensure + Dir.chdir(pdir) + end + rescue Errno::EACCES => error + puts error + end + else + File.utime(Time.now, File.mtime(entry), entry) + end + end + def oldlocation(file="") if block_given? pdir = Dir.pwd @@ -362,11 +407,13 @@ end class Extract + @@count = 0 unless defined?(@@count) + def initialize @archive = File.open(File.expand_path(__FILE__), "rb"){|f| f.read}.gsub(/\r/, "").split(/\n\n/)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift temp = ENV["TEMP"] temp = "/tmp" if temp.nil? - @tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}" + @tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}.#{@@count += 1}" end def extract @@ -432,6 +479,7 @@ TempSpace.new.extract.cleanup $:.unshift(newlocation) + $:.push(oldlocation) newlocation do if __FILE__ == $0