diff -ur tar2rubyscript-none.tar.gz/tar2rubyscript/init.rb tar2rubyscript-0.1.tar.gz/tar2rubyscript/init.rb
--- tar2rubyscript-none.tar.gz/tar2rubyscript/init.rb 2006-03-08 17:52:41.074696950 +0100
+++ tar2rubyscript-0.1.tar.gz/tar2rubyscript/init.rb 2003-08-18 18:59:33.000000000 +0200
@@ -0,0 +1,17 @@
+scriptfile = "tarrubyscript.rb"
+tarfile = oldlocation(ARGV.shift)
+outfile = oldlocation(ARGV.shift)
+licensefile = oldlocation(ARGV.shift)
+
+script = File.new(scriptfile).read
+archive = [File.new(tarfile, "rb").read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")
+license = File.new(licensefile).read if not licensefile.nil?
+
+script = "# License, not of this script, but of the application it contains:\n\n" +license + "\n" + script if not licensefile.nil?
+
+script.gsub!(/%LINES%/, (script.split("\n", -1).length-1).to_s)
+
+File.open(outfile, "wb") do |f|
+ f.write script
+ f.write archive
+end
diff -ur tar2rubyscript-none.tar.gz/tar2rubyscript/README tar2rubyscript-0.1.tar.gz/tar2rubyscript/README
--- tar2rubyscript-none.tar.gz/tar2rubyscript/README 2006-03-08 17:52:41.075696939 +0100
+++ tar2rubyscript-0.1.tar.gz/tar2rubyscript/README 2003-08-18 18:54:13.000000000 +0200
@@ -0,0 +1,5 @@
+Usage: ruby tar2rubyscript.rb tarrubyscript.rb application.tar application.rb [licence.txt]
+
+Just ignore the existance of init.rb ...
+
+For more information, see http://www.erikveen.dds.nl/tar2rubyscript/ .
diff -ur tar2rubyscript-none.tar.gz/tar2rubyscript/tar2rubyscript.rb tar2rubyscript-0.1.tar.gz/tar2rubyscript/tar2rubyscript.rb
--- tar2rubyscript-none.tar.gz/tar2rubyscript/tar2rubyscript.rb 2006-03-08 17:52:41.072696973 +0100
+++ tar2rubyscript-0.1.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-08-18 18:59:33.000000000 +0200
@@ -0,0 +1,17 @@
+scriptfile = ARGV.shift
+tarfile = ARGV.shift
+outfile = ARGV.shift
+licensefile = ARGV.shift
+
+script = File.new(scriptfile).read
+archive = [File.new(tarfile, "rb").read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")
+license = File.new(licensefile).read if not licensefile.nil?
+
+script = "# License, not of this script, but of the application it contains:\n\n" +license + "\n" + script if not licensefile.nil?
+
+script.gsub!(/%LINES%/, (script.split("\n", -1).length-1).to_s)
+
+File.open(outfile, "wb") do |f|
+ f.write script
+ f.write archive
+end
diff -ur tar2rubyscript-none.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.1.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-none.tar.gz/tar2rubyscript/tarrubyscript.rb 2006-03-08 17:52:41.073696961 +0100
+++ tar2rubyscript-0.1.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-08-18 18:59:33.000000000 +0200
@@ -0,0 +1,253 @@
+# License of this script, not of the application it contains:
+
+# Copyright Erik Veenstra <tar2rubyscript@erikveen.dds.nl>
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License,
+# version 2, as published by the Free Software Foundation.
+
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330,
+# Boston, MA 02111-1307 USA
+
+LINES = %LINES%
+
+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 '
+
+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'
+
+class Reader
+ def initialize(filehandle)
+ @fp = filehandle
+ end
+
+ def each
+ @fp.rewind
+
+ while entry = next_entry
+ yield(entry)
+ end
+ end
+
+ def next_entry
+ buf = @fp.read(BLOCKSIZE)
+
+ if buf == "\000" * BLOCKSIZE
+ entry = nil
+ else
+ entry = Entry.new(buf, @fp)
+ end
+
+ entry
+ end
+
+ def extract
+ each do |entry|
+ entry.extract
+ end
+ end
+end
+
+class Entry
+ attr_reader(:header, :data)
+
+ def initialize(header, fp)
+ @header = Header.new(header)
+
+ if @header.file?
+ #puts "File: #{@header.name}, #{@header.size} bytes"
+
+ padding = (BLOCKSIZE - (@header.size % BLOCKSIZE)) % BLOCKSIZE
+
+ @data = fp.read(@header.size) if @header.size > 0
+ dummy = fp.read(padding) if padding > 0
+ end
+ end
+
+ def extract
+ if not @header.name.empty?
+ if @header.dir?
+ begin
+ Dir.mkdir(@header.name, @header.mode)
+ rescue SystemCallError => e
+ puts "Couldn't create dir: " + e.message
+ end
+ else
+ begin
+ File.open(@header.name, "wb") do |fp|
+ fp.write(@data)
+ fp.chmod(@header.mode)
+ end
+ rescue => e
+ puts "Couldn't create file: " + e.message
+ end
+ end
+
+ #File.utime(@header.mtime, Time.new, @header.name) # ???
+ end
+ end
+end
+
+class Header
+ attr_reader(:name, :size, :mtime, :uname, :gname, :mode)
+
+ def initialize(header)
+ types = ['str', 'oct', 'oct', 'oct', 'oct', 'time', 'oct', 'str', 'str', 'str', 'str', 'str', 'oct', 'oct']
+ fields = header.unpack('A100 A8 A8 A8 A12 A12 A8 A1 A100 A8 A32 A32 A8 A8')
+ converted = []
+
+ begin
+ while field = fields.shift
+ type = types.shift
+
+ case type
+ when 'str' then converted.push(field)
+ when 'oct' then converted.push(field.oct)
+ when 'time' then converted.push(Time::at(field.oct))
+ end
+ end
+
+ @name, @mode, @uid, @gid, @size, @mtime, @chksum, @linkflag, @linkname, @magic, @uname, @gname, @devmajor, @devminor = converted
+
+ @name.gsub!(/\.\//, "")
+
+ @raw = header
+ rescue ArgumentError => e
+ raise "Couldn't determine a real value for a field (#{field})"
+ end
+
+ raise "Magic header value '#{@magic}' is invalid." if @magic != TMAGIC and @magic != GNU_TMAGIC
+
+ @linkflag = LF_FILE if @linkflag == LF_OLDFILE or @linkflag == LF_CONTIG
+ @linkflag = LF_DIR if @name[-1] == '/' and @linkflag == LF_FILE
+ @linkname = @linkname[1,-1] if @linkname[0] == '/'
+ @size = 0 if @size < 0
+ @name = @linkname + '/' + @name if @linkname.size > 0
+ end
+
+ def file?
+ @linkflag == LF_FILE
+ end
+
+ def dir?
+ @linkflag == LF_DIR
+ end
+end
+
+class Jail
+ def initialize(code, ldir)
+ @ldir = ldir
+ @code = code
+ end
+
+ def eval
+ instance_eval(@code)
+ end
+
+ def oldlocation(file)
+ if not file.nil?
+ res = @ldir + "/" + file
+ res = file if file =~ /^\//
+ res = file if file =~ /^.:/
+ end
+
+ res
+ end
+end
+
+def rm(entry)
+ if FileTest.file?(entry)
+ File.delete(entry)
+ end
+
+ if FileTest.directory?(entry)
+ ldir = Dir.pwd
+
+ Dir.chdir(entry)
+ Dir.new(".").each do |e|
+ rm(e) if not [".", ".."].include?(e)
+ end
+ Dir.chdir(ldir)
+
+ Dir.rmdir(entry)
+ end
+end
+
+if FileTest.exists?("c:/")
+ WD = "c:/tmp"
+else
+ WD = "/tmp"
+end
+
+MF = "#{WD}/ear.f.#{Process.pid}"
+MP = "#{WD}/ear.d.#{Process.pid}"
+
+Dir.mkdir(WD) if not FileTest.exists?(WD)
+Dir.mkdir(MP)
+
+LDIR = Dir.pwd
+
+begin
+
+ archive = File.new($0, "rb").read.split(/\n/, LINES+1)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift
+
+ File.open(MF, "wb"){|f| f.write archive}
+
+ Dir.chdir(MP)
+
+ File.open(MF, "rb") do |fp|
+ Reader.new(fp).extract
+ end
+
+ entries = Dir.entries(".")
+ entries.delete(".")
+ entries.delete("..")
+
+ if entries.length == 1
+ entry = entries.shift
+ if FileTest.directory?(entry)
+ Dir.chdir(entry)
+ end
+ end
+
+ File.open("init.rb") do |f|
+ Jail.new(f.read, LDIR).eval
+ end
+
+ensure
+
+ Dir.chdir(LDIR)
+
+ rm(MF)
+ rm(MP)
+
+end
+
diff -ur tar2rubyscript-0.1.tar.gz/tar2rubyscript/init.rb tar2rubyscript-0.1.1.tar.gz/tar2rubyscript/init.rb
--- tar2rubyscript-0.1.tar.gz/tar2rubyscript/init.rb 2003-08-18 18:59:33.000000000 +0200
+++ tar2rubyscript-0.1.1.tar.gz/tar2rubyscript/init.rb 2003-08-19 21:03:03.000000000 +0200
@@ -3,11 +3,14 @@
outfile = oldlocation(ARGV.shift)
licensefile = oldlocation(ARGV.shift)
-script = File.new(scriptfile).read
-archive = [File.new(tarfile, "rb").read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")
-license = File.new(licensefile).read if not licensefile.nil?
+script = nil ; File.open(scriptfile) {|f| script = f.read}
+archive = nil ; File.open(tarfile, "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
-script = "# License, not of this script, but of the application it contains:\n\n" +license + "\n" + script if not licensefile.nil?
+if not licensefile.nil?
+ lic = nil ; File.open(licensefile) {|f| lic = f.read}
+
+ script = "# License, not of this script, but of the application it contains:\n\n" + lic + "\n" + script
+end
script.gsub!(/%LINES%/, (script.split("\n", -1).length-1).to_s)
diff -ur tar2rubyscript-0.1.tar.gz/tar2rubyscript/tar2rubyscript.rb tar2rubyscript-0.1.1.tar.gz/tar2rubyscript/tar2rubyscript.rb
--- tar2rubyscript-0.1.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-08-18 18:59:33.000000000 +0200
+++ tar2rubyscript-0.1.1.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-08-19 21:03:03.000000000 +0200
@@ -3,11 +3,14 @@
outfile = ARGV.shift
licensefile = ARGV.shift
-script = File.new(scriptfile).read
-archive = [File.new(tarfile, "rb").read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")
-license = File.new(licensefile).read if not licensefile.nil?
+script = nil ; File.open(scriptfile) {|f| script = f.read}
+archive = nil ; File.open(tarfile, "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
-script = "# License, not of this script, but of the application it contains:\n\n" +license + "\n" + script if not licensefile.nil?
+if not licensefile.nil?
+ lic = nil ; File.open(licensefile) {|f| lic = f.read}
+
+ script = "# License, not of this script, but of the application it contains:\n\n" + lic + "\n" + script
+end
script.gsub!(/%LINES%/, (script.split("\n", -1).length-1).to_s)
diff -ur tar2rubyscript-0.1.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.1.1.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.1.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-08-18 18:59:33.000000000 +0200
+++ tar2rubyscript-0.1.1.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-08-19 21:03:03.000000000 +0200
@@ -217,7 +217,9 @@
begin
- archive = File.new($0, "rb").read.split(/\n/, LINES+1)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift
+ archive = nil
+
+ File.open($0, "rb"){|f| archive = f.read.split(/\n/, LINES+1)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift}
File.open(MF, "wb"){|f| f.write archive}
diff -ur tar2rubyscript-0.1.1.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.1.2.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.1.1.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-08-19 21:03:03.000000000 +0200
+++ tar2rubyscript-0.1.2.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-08-27 23:12:20.000000000 +0200
@@ -163,13 +163,18 @@
end
class Jail
- def initialize(code, ldir)
+ def initialize(ldir)
@ldir = ldir
- @code = code
end
def eval
- instance_eval(@code)
+ File.open("init.rb") do |f|
+ instance_eval(f.read)
+ end
+
+ ObjectSpace::each_object(IO) do |obj|
+ obj.close rescue nil
+ end
end
def oldlocation(file)
@@ -207,11 +212,11 @@
WD = "/tmp"
end
-MF = "#{WD}/ear.f.#{Process.pid}"
-MP = "#{WD}/ear.d.#{Process.pid}"
+MF = "#{WD}/tar2rubyscript.f.#{Process.pid}"
+MP = "#{WD}/tar2rubyscript.d.#{Process.pid}"
Dir.mkdir(WD) if not FileTest.exists?(WD)
-Dir.mkdir(MP)
+Dir.mkdir(MP) if not FileTest.exists?(MP)
LDIR = Dir.pwd
@@ -240,9 +245,7 @@
end
end
- File.open("init.rb") do |f|
- Jail.new(f.read, LDIR).eval
- end
+ Jail.new(LDIR).eval
ensure
diff -ur tar2rubyscript-0.1.2.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.1.3.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.1.2.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-08-27 23:12:20.000000000 +0200
+++ tar2rubyscript-0.1.3.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-08-29 00:57:09.000000000 +0200
@@ -162,97 +162,103 @@
end
end
-class Jail
- def initialize(ldir)
- @ldir = ldir
+class TempSpace
+ def initialize
+ @archive = File.new($0, "rb").read.split(/\n/, LINES+1)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift
+ @orgdir = Dir.pwd
+ @workdir = "/tmp"
+ @workdir = "c:/tmp" if FileTest.exists?("c:/")
+ @tempdir = "#{@workdir}/tar2rubyscript.d.#{Process.pid}"
+ @tempfile = "#{@workdir}/tar2rubyscript.f.#{Process.pid}"
end
def eval
- File.open("init.rb") do |f|
- instance_eval(f.read)
- end
+ begin
- ObjectSpace::each_object(IO) do |obj|
- obj.close rescue nil
- end
- end
+ # Create the temp environment.
- def oldlocation(file)
- if not file.nil?
- res = @ldir + "/" + file
- res = file if file =~ /^\//
- res = file if file =~ /^.:/
- end
+ Dir.mkdir(@workdir) if not FileTest.exists?(@workdir)
+ Dir.mkdir(@tempdir) if not FileTest.exists?(@tempdir)
- res
- end
-end
+ Dir.chdir(@tempdir)
-def rm(entry)
- if FileTest.file?(entry)
- File.delete(entry)
- end
+ File.open(@tempfile, "wb") {|f| f.write @archive}
+ File.open(@tempfile, "rb") {|f| Reader.new(f).extract}
- if FileTest.directory?(entry)
- ldir = Dir.pwd
+ # Eventually look for a subdirectory.
- Dir.chdir(entry)
- Dir.new(".").each do |e|
- rm(e) if not [".", ".."].include?(e)
+ entries = Dir.entries(".")
+ entries.delete(".")
+ entries.delete("..")
+
+ if entries.length == 1
+ entry = entries.shift
+ if FileTest.directory?(entry)
+ Dir.chdir(entry)
+ end
end
- Dir.chdir(ldir)
- Dir.rmdir(entry)
- end
-end
+ # Remember all IO objects.
-if FileTest.exists?("c:/")
- WD = "c:/tmp"
-else
- WD = "/tmp"
-end
+ ioobjects = []
+ ObjectSpace::each_object(IO) do |obj|
+ ioobjects << obj.id
+ end
-MF = "#{WD}/tar2rubyscript.f.#{Process.pid}"
-MP = "#{WD}/tar2rubyscript.d.#{Process.pid}"
+ # Execute init.rb .
-Dir.mkdir(WD) if not FileTest.exists?(WD)
-Dir.mkdir(MP) if not FileTest.exists?(MP)
+ File.open("init.rb") do |f|
+ instance_eval(f.read)
+ end
-LDIR = Dir.pwd
+ ensure
-begin
+ # Close all IO objects, opened in init.rb .
- archive = nil
+ ObjectSpace::each_object(IO) do |obj|
+ obj.close rescue nil if not ioobjects.include?(obj.id)
+ end
- File.open($0, "rb"){|f| archive = f.read.split(/\n/, LINES+1)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift}
+ # Remove the temp environment.
- File.open(MF, "wb"){|f| f.write archive}
+ Dir.chdir(@orgdir)
- Dir.chdir(MP)
+ recursivedelete(@tempfile)
+ recursivedelete(@tempdir)
- File.open(MF, "rb") do |fp|
- Reader.new(fp).extract
end
+ end
- entries = Dir.entries(".")
- entries.delete(".")
- entries.delete("..")
-
- if entries.length == 1
- entry = entries.shift
- if FileTest.directory?(entry)
- Dir.chdir(entry)
- end
+ def recursivedelete(entry)
+ if FileTest.file?(entry)
+ File.delete(entry)
end
- Jail.new(LDIR).eval
+ if FileTest.directory?(entry)
+ pdir = Dir.pwd
+
+ Dir.chdir(entry)
+ Dir.new(".").each do |e|
+ recursivedelete(e) if not [".", ".."].include?(e)
+ end
+ Dir.chdir(pdir)
-ensure
+ Dir.rmdir(entry)
+ end
+ end
- Dir.chdir(LDIR)
+ def oldlocation(file)
+ res = file
- rm(MF)
- rm(MP)
+ if not file.nil?
+ res = @orgdir + "/" + file
+ res = file if file =~ /^\//
+ res = file if file =~ /^.:/
+ end
+ res
+ end
end
+TempSpace.new.eval
+
diff -ur tar2rubyscript-0.1.3.tar.gz/tar2rubyscript/init.rb tar2rubyscript-0.1.4.tar.gz/tar2rubyscript/init.rb
--- tar2rubyscript-0.1.3.tar.gz/tar2rubyscript/init.rb 2003-08-29 00:57:09.000000000 +0200
+++ tar2rubyscript-0.1.4.tar.gz/tar2rubyscript/init.rb 2003-08-31 23:04:22.000000000 +0200
@@ -12,9 +12,9 @@
script = "# License, not of this script, but of the application it contains:\n\n" + lic + "\n" + script
end
-script.gsub!(/%LINES%/, (script.split("\n", -1).length-1).to_s)
-
File.open(outfile, "wb") do |f|
f.write script
+ f.write "\n"
+ f.write "\n"
f.write archive
end
diff -ur tar2rubyscript-0.1.3.tar.gz/tar2rubyscript/tar2rubyscript.rb tar2rubyscript-0.1.4.tar.gz/tar2rubyscript/tar2rubyscript.rb
--- tar2rubyscript-0.1.3.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-08-29 00:57:09.000000000 +0200
+++ tar2rubyscript-0.1.4.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-08-31 23:04:22.000000000 +0200
@@ -12,9 +12,9 @@
script = "# License, not of this script, but of the application it contains:\n\n" + lic + "\n" + script
end
-script.gsub!(/%LINES%/, (script.split("\n", -1).length-1).to_s)
-
File.open(outfile, "wb") do |f|
f.write script
+ f.write "\n"
+ f.write "\n"
f.write archive
end
diff -ur tar2rubyscript-0.1.3.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.1.4.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.1.3.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-08-29 00:57:09.000000000 +0200
+++ tar2rubyscript-0.1.4.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-08-31 23:04:22.000000000 +0200
@@ -16,8 +16,6 @@
# Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
-LINES = %LINES%
-
BLOCKSIZE = 512
NAMELEN = 100
@@ -164,7 +162,7 @@
class TempSpace
def initialize
- @archive = File.new($0, "rb").read.split(/\n/, LINES+1)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift
+ @archive = File.new($0, "rb").read.gsub(/\r/, "").split(/\n\n/)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift
@orgdir = Dir.pwd
@workdir = "/tmp"
@workdir = "c:/tmp" if FileTest.exists?("c:/")
@@ -261,4 +259,3 @@
end
TempSpace.new.eval
-
diff -ur tar2rubyscript-0.1.4.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.1.5.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.1.4.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-08-31 23:04:22.000000000 +0200
+++ tar2rubyscript-0.1.5.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-09-09 21:53:33.000000000 +0200
@@ -16,6 +16,13 @@
# Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
+# Tar2RubyScript constants
+
+JustExtract = false
+ARGV.concat []
+
+# Tar constants
+
BLOCKSIZE = 512
NAMELEN = 100
@@ -171,50 +178,43 @@
end
def eval
- begin
# Create the temp environment.
- Dir.mkdir(@workdir) if not FileTest.exists?(@workdir)
- Dir.mkdir(@tempdir) if not FileTest.exists?(@tempdir)
+ Dir.mkdir(@workdir) if not FileTest.exists?(@workdir)
+ Dir.mkdir(@tempdir) if not FileTest.exists?(@tempdir)
- Dir.chdir(@tempdir)
+ Dir.chdir(@tempdir)
- File.open(@tempfile, "wb") {|f| f.write @archive}
- File.open(@tempfile, "rb") {|f| Reader.new(f).extract}
+ File.open(@tempfile, "wb") {|f| f.write @archive}
+ File.open(@tempfile, "rb") {|f| Reader.new(f).extract}
# Eventually look for a subdirectory.
- entries = Dir.entries(".")
- entries.delete(".")
- entries.delete("..")
-
- if entries.length == 1
- entry = entries.shift
- if FileTest.directory?(entry)
- Dir.chdir(entry)
- end
- end
-
- # Remember all IO objects.
-
- ioobjects = []
- ObjectSpace::each_object(IO) do |obj|
- ioobjects << obj.id
+ entries = Dir.entries(".")
+ entries.delete(".")
+ entries.delete("..")
+
+ if entries.length == 1
+ entry = entries.shift
+ if FileTest.directory?(entry)
+ Dir.chdir(entry)
end
+ end
- # Execute init.rb .
+ # Remember all File objects.
- File.open("init.rb") do |f|
- instance_eval(f.read)
- end
+ @ioobjects = []
+ ObjectSpace::each_object(File) do |obj|
+ @ioobjects << obj
+ end
- ensure
+ at_exit do
- # Close all IO objects, opened in init.rb .
+ # Close all File objects, opened in init.rb .
- ObjectSpace::each_object(IO) do |obj|
- obj.close rescue nil if not ioobjects.include?(obj.id)
+ ObjectSpace::each_object(File) do |obj|
+ obj.close if (not obj.closed? and not @ioobjects.include?(obj))
end
# Remove the temp environment.
@@ -225,6 +225,12 @@
recursivedelete(@tempdir)
end
+
+ # Execute init.rb .
+
+ File.open("init.rb") do |f|
+ instance_eval(f.read)
+ end
end
def recursivedelete(entry)
@@ -258,4 +264,43 @@
end
end
-TempSpace.new.eval
+class Extract
+ def initialize
+ @archive = File.new($0, "rb").read.gsub(/\r/, "").split(/\n\n/)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift
+ @orgdir = Dir.pwd
+ @workdir = "/tmp"
+ @workdir = "c:/tmp" if FileTest.exists?("c:/")
+ @tempdir = @orgdir
+ @tempfile = "#{@workdir}/tar2rubyscript.f.#{Process.pid}"
+ end
+
+ def extract
+ begin
+
+ # Create the temp environment.
+
+ Dir.mkdir(@workdir) if not FileTest.exists?(@workdir)
+ Dir.mkdir(@tempdir) if not FileTest.exists?(@tempdir)
+
+ Dir.chdir(@tempdir)
+
+ File.open(@tempfile, "wb") {|f| f.write @archive}
+ File.open(@tempfile, "rb") {|f| Reader.new(f).extract}
+
+ ensure
+
+ # Remove the temp environment.
+
+ Dir.chdir(@orgdir)
+
+ File.delete(@tempfile)
+
+ end
+ end
+end
+
+if JustExtract
+ Extract.new.extract
+else
+ TempSpace.new.eval
+end
diff -ur tar2rubyscript-0.1.5.tar.gz/tar2rubyscript/init.rb tar2rubyscript-0.2.tar.gz/tar2rubyscript/init.rb
--- tar2rubyscript-0.1.5.tar.gz/tar2rubyscript/init.rb 2003-09-09 21:53:33.000000000 +0200
+++ tar2rubyscript-0.2.tar.gz/tar2rubyscript/init.rb 2003-09-14 12:32:14.000000000 +0200
@@ -3,6 +3,15 @@
outfile = oldlocation(ARGV.shift)
licensefile = oldlocation(ARGV.shift)
+if outfile.nil?
+ puts "Usage: ruby tar2rubyscript.rb application.tar application.rb [license.txt]"
+
+ exit 1
+end
+
+raise "#{tarfile} doesn't exist." if not FileTest.file?(tarfile)
+raise "#{licensefile} doesn't exist." if (not licensefile.nil? and not FileTest.file?(licensefile))
+
script = nil ; File.open(scriptfile) {|f| script = f.read}
archive = nil ; File.open(tarfile, "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
diff -ur tar2rubyscript-0.1.5.tar.gz/tar2rubyscript/tar2rubyscript.rb tar2rubyscript-0.2.tar.gz/tar2rubyscript/tar2rubyscript.rb
--- tar2rubyscript-0.1.5.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-09-09 21:53:33.000000000 +0200
+++ tar2rubyscript-0.2.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-09-14 12:32:14.000000000 +0200
@@ -3,6 +3,15 @@
outfile = ARGV.shift
licensefile = ARGV.shift
+if outfile.nil?
+ puts "Usage: ruby tar2rubyscript.rb application.tar application.rb [license.txt]"
+
+ exit 1
+end
+
+raise "#{tarfile} doesn't exist." if not FileTest.file?(tarfile)
+raise "#{licensefile} doesn't exist." if (not licensefile.nil? and not FileTest.file?(licensefile))
+
script = nil ; File.open(scriptfile) {|f| script = f.read}
archive = nil ; File.open(tarfile, "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
diff -ur tar2rubyscript-0.1.5.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.2.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.1.5.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-09-09 21:53:33.000000000 +0200
+++ tar2rubyscript-0.2.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-09-14 12:32:14.000000000 +0200
@@ -16,9 +16,11 @@
# Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
+# License of this script, not of the application it contains:
+
# Tar2RubyScript constants
-JustExtract = false
+JustExtract = ARGV.include?("--tar2rubyscript-justextract")
ARGV.concat []
# Tar constants
@@ -226,6 +228,10 @@
end
+ ARGV.delete_if do |arg|
+ arg =~ /^--tar2rubyscript-/
+ end
+
# Execute init.rb .
File.open("init.rb") do |f|
diff -ur tar2rubyscript-0.2.tar.gz/tar2rubyscript/init.rb tar2rubyscript-0.3.tar.gz/tar2rubyscript/init.rb
--- tar2rubyscript-0.2.tar.gz/tar2rubyscript/init.rb 2003-09-14 12:32:14.000000000 +0200
+++ tar2rubyscript-0.3.tar.gz/tar2rubyscript/init.rb 2006-03-08 17:52:49.786599041 +0100
@@ -1,29 +0,0 @@
-scriptfile = "tarrubyscript.rb"
-tarfile = oldlocation(ARGV.shift)
-outfile = oldlocation(ARGV.shift)
-licensefile = oldlocation(ARGV.shift)
-
-if outfile.nil?
- puts "Usage: ruby tar2rubyscript.rb application.tar application.rb [license.txt]"
-
- exit 1
-end
-
-raise "#{tarfile} doesn't exist." if not FileTest.file?(tarfile)
-raise "#{licensefile} doesn't exist." if (not licensefile.nil? and not FileTest.file?(licensefile))
-
-script = nil ; File.open(scriptfile) {|f| script = f.read}
-archive = nil ; File.open(tarfile, "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
-
-if not licensefile.nil?
- lic = nil ; File.open(licensefile) {|f| lic = f.read}
-
- script = "# License, not of this script, but of the application it contains:\n\n" + lic + "\n" + script
-end
-
-File.open(outfile, "wb") do |f|
- f.write script
- f.write "\n"
- f.write "\n"
- f.write archive
-end
diff -ur tar2rubyscript-0.2.tar.gz/tar2rubyscript/README tar2rubyscript-0.3.tar.gz/tar2rubyscript/README
--- tar2rubyscript-0.2.tar.gz/tar2rubyscript/README 2003-08-18 18:54:13.000000000 +0200
+++ tar2rubyscript-0.3.tar.gz/tar2rubyscript/README 2003-09-21 18:01:58.000000000 +0200
@@ -1,5 +1,3 @@
Usage: ruby tar2rubyscript.rb tarrubyscript.rb application.tar application.rb [licence.txt]
-Just ignore the existance of init.rb ...
-
For more information, see http://www.erikveen.dds.nl/tar2rubyscript/ .
diff -ur tar2rubyscript-0.2.tar.gz/tar2rubyscript/tar2rubyscript.rb tar2rubyscript-0.3.tar.gz/tar2rubyscript/tar2rubyscript.rb
--- tar2rubyscript-0.2.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-09-14 12:32:14.000000000 +0200
+++ tar2rubyscript-0.3.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-09-21 19:15:48.000000000 +0200
@@ -1,19 +1,49 @@
-scriptfile = ARGV.shift
+scriptfile = "tarrubyscript.rb"
tarfile = ARGV.shift
outfile = ARGV.shift
licensefile = ARGV.shift
if outfile.nil?
puts "Usage: ruby tar2rubyscript.rb application.tar application.rb [license.txt]"
+ puts " or"
+ puts " ruby tar2rubyscript.rb application/ application.rb [license.txt]"
+ puts ""
+ puts "The second option needs the external program 'tar' for creating"
+ puts "the archive internally."
exit 1
end
-raise "#{tarfile} doesn't exist." if not FileTest.file?(tarfile)
+raise "#{tarfile} doesn't exist." if not FileTest.exist?(tarfile)
raise "#{licensefile} doesn't exist." if (not licensefile.nil? and not FileTest.file?(licensefile))
-script = nil ; File.open(scriptfile) {|f| script = f.read}
-archive = nil ; File.open(tarfile, "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+script = nil
+archive = nil
+
+File.open(scriptfile) {|f| script = f.read}
+
+if FileTest.file?(tarfile)
+ File.open(tarfile, "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+end
+
+tardir = tarfile.gsub(/[\/\\]$/, "")
+
+if FileTest.directory?(tardir)
+ orgdir = Dir.pwd
+
+ Dir.chdir(tardir)
+
+ if FileTest.file?("tar2rubyscript.sh")
+ puts "\". ./tar2rubyscript.sh\""
+ system(". ./tar2rubyscript.sh")
+ end
+
+ Dir.chdir("..")
+
+ IO.popen("tar ch #{tardir.sub(/.*[\/\\]/, "")}", "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+
+ Dir.chdir(orgdir)
+end
if not licensefile.nil?
lic = nil ; File.open(licensefile) {|f| lic = f.read}
diff -ur tar2rubyscript-0.2.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.3.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.2.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-09-14 12:32:14.000000000 +0200
+++ tar2rubyscript-0.3.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-09-21 19:15:48.000000000 +0200
@@ -257,7 +257,7 @@
end
end
- def oldlocation(file)
+ def oldlocation(file="")
res = file
if not file.nil?
diff -ur tar2rubyscript-0.3.tar.gz/tar2rubyscript/tar2rubyscript.rb tar2rubyscript-0.3.1.tar.gz/tar2rubyscript/tar2rubyscript.rb
--- tar2rubyscript-0.3.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-09-21 19:15:48.000000000 +0200
+++ tar2rubyscript-0.3.1.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-10-04 20:16:33.000000000 +0200
@@ -33,9 +33,14 @@
Dir.chdir(tardir)
+ if FileTest.file?("tar2rubyscript.bat")
+ puts "\".\\tar2rubyscript.bat\""
+ system(".\\tar2rubyscript.bat")
+ end
+
if FileTest.file?("tar2rubyscript.sh")
puts "\". ./tar2rubyscript.sh\""
- system(". ./tar2rubyscript.sh")
+ system("sh -c \". ./tar2rubyscript.sh\"")
end
Dir.chdir("..")
diff -ur tar2rubyscript-0.3.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.3.1.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.3.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-09-21 19:15:48.000000000 +0200
+++ tar2rubyscript-0.3.1.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-10-04 20:16:33.000000000 +0200
@@ -21,8 +21,13 @@
# Tar2RubyScript constants
JustExtract = ARGV.include?("--tar2rubyscript-justextract")
+
ARGV.concat []
+ARGV.delete_if do |arg|
+ arg =~ /^--tar2rubyscript-/
+end
+
# Tar constants
BLOCKSIZE = 512
@@ -56,6 +61,12 @@
@fp = filehandle
end
+ def extract
+ each do |entry|
+ entry.extract
+ end
+ end
+
def each
@fp.rewind
@@ -67,7 +78,7 @@
def next_entry
buf = @fp.read(BLOCKSIZE)
- if buf == "\000" * BLOCKSIZE
+ if buf.length < BLOCKSIZE or buf == "\000" * BLOCKSIZE
entry = nil
else
entry = Entry.new(buf, @fp)
@@ -75,12 +86,6 @@
entry
end
-
- def extract
- each do |entry|
- entry.extract
- end
- end
end
class Entry
@@ -90,8 +95,6 @@
@header = Header.new(header)
if @header.file?
- #puts "File: #{@header.name}, #{@header.size} bytes"
-
padding = (BLOCKSIZE - (@header.size % BLOCKSIZE)) % BLOCKSIZE
@data = fp.read(@header.size) if @header.size > 0
@@ -105,30 +108,35 @@
begin
Dir.mkdir(@header.name, @header.mode)
rescue SystemCallError => e
- puts "Couldn't create dir: " + e.message
+ puts "Couldn't create dir #{@header.name}: " + e.message
end
else
- begin
- File.open(@header.name, "wb") do |fp|
- fp.write(@data)
- fp.chmod(@header.mode)
+ if @header.file?
+ begin
+ File.open(@header.name, "wb") do |fp|
+ fp.write(@data)
+ fp.chmod(@header.mode)
+ end
+ rescue => e
+ puts "Couldn't create file #{@header.name}: " + e.message
end
- rescue => e
- puts "Couldn't create file: " + e.message
+ else
+ puts "Couldn't handle entry #{@header.name}"
end
end
- #File.utime(@header.mtime, Time.new, @header.name) # ???
+ #File.chown(@header.uid, @header.gid, @header.name)
+ #File.utime(Time.now, @header.mtime, @header.name)
end
end
end
class Header
- attr_reader(:name, :size, :mtime, :uname, :gname, :mode)
+ attr_reader(:name, :uid, :gid, :size, :mtime, :uname, :gname, :mode)
def initialize(header)
- types = ['str', 'oct', 'oct', 'oct', 'oct', 'time', 'oct', 'str', 'str', 'str', 'str', 'str', 'oct', 'oct']
fields = header.unpack('A100 A8 A8 A8 A12 A12 A8 A1 A100 A8 A32 A32 A8 A8')
+ types = ['str', 'oct', 'oct', 'oct', 'oct', 'time', 'oct', 'str', 'str', 'str', 'str', 'str', 'oct', 'oct']
converted = []
begin
@@ -144,7 +152,7 @@
@name, @mode, @uid, @gid, @size, @mtime, @chksum, @linkflag, @linkname, @magic, @uname, @gname, @devmajor, @devminor = converted
- @name.gsub!(/\.\//, "")
+ @name.gsub!(/^\.\//, "")
@raw = header
rescue ArgumentError => e
@@ -172,35 +180,37 @@
class TempSpace
def initialize
@archive = File.new($0, "rb").read.gsub(/\r/, "").split(/\n\n/)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift
- @orgdir = Dir.pwd
- @workdir = "/tmp"
- @workdir = "c:/tmp" if FileTest.exists?("c:/")
- @tempdir = "#{@workdir}/tar2rubyscript.d.#{Process.pid}"
- @tempfile = "#{@workdir}/tar2rubyscript.f.#{Process.pid}"
+ @olddir = Dir.pwd
+ @tmpdir = "/tmp"
+ @tmpdir = "c:/tmp" if FileTest.exists?("c:/")
+ @tempdir = "#{@tmpdir}/tar2rubyscript.d.#{Process.pid}"
+ @tempfile = "#{@tmpdir}/tar2rubyscript.f.#{Process.pid}"
+
+ @newdir=@tempdir
end
def eval
-
- # Create the temp environment.
-
- Dir.mkdir(@workdir) if not FileTest.exists?(@workdir)
+ Dir.mkdir(@tmpdir) if not FileTest.exists?(@tmpdir)
Dir.mkdir(@tempdir) if not FileTest.exists?(@tempdir)
- Dir.chdir(@tempdir)
+ newlocation do
+
+ # Create the temp environment.
- File.open(@tempfile, "wb") {|f| f.write @archive}
- File.open(@tempfile, "rb") {|f| Reader.new(f).extract}
+ File.open(@tempfile, "wb") {|f| f.write @archive}
+ File.open(@tempfile, "rb") {|f| Reader.new(f).extract}
# Eventually look for a subdirectory.
- entries = Dir.entries(".")
- entries.delete(".")
- entries.delete("..")
-
- if entries.length == 1
- entry = entries.shift
- if FileTest.directory?(entry)
- Dir.chdir(entry)
+ entries = Dir.entries(@tempdir)
+ entries.delete(".")
+ entries.delete("..")
+
+ if entries.length == 1
+ entry = @tempdir + "/" + entries.shift
+ if FileTest.directory?(entry)
+ @newdir = entry
+ end
end
end
@@ -221,21 +231,18 @@
# Remove the temp environment.
- Dir.chdir(@orgdir)
+ Dir.chdir(@olddir)
recursivedelete(@tempfile)
recursivedelete(@tempdir)
-
- end
-
- ARGV.delete_if do |arg|
- arg =~ /^--tar2rubyscript-/
end
# Execute init.rb .
- File.open("init.rb") do |f|
- instance_eval(f.read)
+ newlocation do
+ File.open("init.rb") do |f|
+ instance_eval(f.read)
+ end
end
end
@@ -258,12 +265,28 @@
end
def oldlocation(file="")
- res = file
+ if block_given?
+ pdir = Dir.pwd
+
+ Dir.chdir(@olddir)
+ res = yield
+ Dir.chdir(pdir)
+ else
+ res = File.expand_path(file, @olddir) if not file.nil?
+ end
+
+ res
+ end
- if not file.nil?
- res = @orgdir + "/" + file
- res = file if file =~ /^\//
- res = file if file =~ /^.:/
+ def newlocation(file="")
+ if block_given?
+ pdir = Dir.pwd
+
+ Dir.chdir(@newdir)
+ res = yield
+ Dir.chdir(pdir)
+ else
+ res = File.expand_path(file, @newdir) if not file.nil?
end
res
@@ -273,11 +296,9 @@
class Extract
def initialize
@archive = File.new($0, "rb").read.gsub(/\r/, "").split(/\n\n/)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift
- @orgdir = Dir.pwd
- @workdir = "/tmp"
- @workdir = "c:/tmp" if FileTest.exists?("c:/")
- @tempdir = @orgdir
- @tempfile = "#{@workdir}/tar2rubyscript.f.#{Process.pid}"
+ @tmpdir = "/tmp"
+ @tmpdir = "c:/tmp" if FileTest.exists?("c:/")
+ @tempfile = "#{@tmpdir}/tar2rubyscript.f.#{Process.pid}"
end
def extract
@@ -285,10 +306,7 @@
# Create the temp environment.
- Dir.mkdir(@workdir) if not FileTest.exists?(@workdir)
- Dir.mkdir(@tempdir) if not FileTest.exists?(@tempdir)
-
- Dir.chdir(@tempdir)
+ Dir.mkdir(@tmpdir) if not FileTest.exists?(@tmpdir)
File.open(@tempfile, "wb") {|f| f.write @archive}
File.open(@tempfile, "rb") {|f| Reader.new(f).extract}
@@ -297,8 +315,6 @@
# Remove the temp environment.
- Dir.chdir(@orgdir)
-
File.delete(@tempfile)
end
diff -ur tar2rubyscript-0.3.1.tar.gz/tar2rubyscript/LICENSE tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/LICENSE
--- tar2rubyscript-0.3.1.tar.gz/tar2rubyscript/LICENSE 2006-03-08 17:52:52.322570911 +0100
+++ tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/LICENSE 2003-10-10 14:06:46.000000000 +0200
@@ -0,0 +1,15 @@
+# Copyright Erik Veenstra <tar2rubyscript@erikveen.dds.nl>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License,
+# version 2, as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330,
+# Boston, MA 02111-1307 USA.
diff -ur tar2rubyscript-0.3.1.tar.gz/tar2rubyscript/README tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/README
--- tar2rubyscript-0.3.1.tar.gz/tar2rubyscript/README 2003-09-21 18:01:58.000000000 +0200
+++ tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/README 2003-10-10 18:09:04.000000000 +0200
@@ -1,3 +1,11 @@
-Usage: ruby tar2rubyscript.rb tarrubyscript.rb application.tar application.rb [licence.txt]
+Usage: ruby tar2rubyscript.rb application.tar [application.rb [licence.txt]]
+ or
+ ruby tar2rubyscript.rb application/ [application.rb [licence.txt]]
+
+The second variant needs the external program 'tar' for creating the
+archive internally. The first one doesn't.
+
+If "application.rb" is not provided, it will be determined from
+"application.tar" or "application/".
For more information, see http://www.erikveen.dds.nl/tar2rubyscript/ .
diff -ur tar2rubyscript-0.3.1.tar.gz/tar2rubyscript/tar2rubyscript.rb tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/tar2rubyscript.rb
--- tar2rubyscript-0.3.1.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-10-04 20:16:33.000000000 +0200
+++ tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-10-10 19:40:46.000000000 +0200
@@ -1,12 +1,14 @@
scriptfile = "tarrubyscript.rb"
tarfile = ARGV.shift
-outfile = ARGV.shift
+rbfile = ARGV.shift
licensefile = ARGV.shift
-if outfile.nil?
- puts "Usage: ruby tar2rubyscript.rb application.tar application.rb [license.txt]"
+tarfile.gsub!(/[\/\\]$/, "")
+
+if tarfile.nil?
+ puts "Usage: ruby tar2rubyscript.rb application.tar [application.rb [license.txt]]"
puts " or"
- puts " ruby tar2rubyscript.rb application/ application.rb [license.txt]"
+ puts " ruby tar2rubyscript.rb application/ [application.rb [license.txt]]"
puts ""
puts "The second option needs the external program 'tar' for creating"
puts "the archive internally."
@@ -14,8 +16,16 @@
exit 1
end
-raise "#{tarfile} doesn't exist." if not FileTest.exist?(tarfile)
-raise "#{licensefile} doesn't exist." if (not licensefile.nil? and not FileTest.file?(licensefile))
+if not FileTest.exist?(tarfile)
+ puts "#{tarfile} doesn't exist."
+ exit
+end
+
+if not licensefile.nil? and not FileTest.file?(licensefile)
+ puts "#{licensefile} doesn't exist."
+ exit
+end
+
script = nil
archive = nil
@@ -26,12 +36,10 @@
File.open(tarfile, "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
end
-tardir = tarfile.gsub(/[\/\\]$/, "")
-
-if FileTest.directory?(tardir)
+if FileTest.directory?(tarfile)
orgdir = Dir.pwd
- Dir.chdir(tardir)
+ Dir.chdir(tarfile)
if FileTest.file?("tar2rubyscript.bat")
puts "\".\\tar2rubyscript.bat\""
@@ -45,7 +53,7 @@
Dir.chdir("..")
- IO.popen("tar ch #{tardir.sub(/.*[\/\\]/, "")}", "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+ IO.popen("tar ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
Dir.chdir(orgdir)
end
@@ -56,7 +64,9 @@
script = "# License, not of this script, but of the application it contains:\n\n" + lic + "\n" + script
end
-File.open(outfile, "wb") do |f|
+rbfile = tarfile.gsub(/\.tar$/, "") + ".rb" if (rbfile.nil? or File.basename(rbfile) == "-")
+
+File.open(rbfile, "wb") do |f|
f.write script
f.write "\n"
f.write "\n"
diff -ur tar2rubyscript-0.3.1.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.3.1.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-10-04 20:16:33.000000000 +0200
+++ tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-10-10 19:40:46.000000000 +0200
@@ -1,20 +1,20 @@
# License of this script, not of the application it contains:
# Copyright Erik Veenstra <tar2rubyscript@erikveen.dds.nl>
-
+#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
-
+#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
-
+#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place, Suite 330,
-# Boston, MA 02111-1307 USA
+# Boston, MA 02111-1307 USA.
# License of this script, not of the application it contains:
diff -ur tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/README tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/README
--- tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/README 2003-10-10 18:09:04.000000000 +0200
+++ tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/README 2003-10-17 22:48:37.000000000 +0200
@@ -1,11 +1,12 @@
Usage: ruby tar2rubyscript.rb application.tar [application.rb [licence.txt]]
or
- ruby tar2rubyscript.rb application/ [application.rb [licence.txt]]
+ ruby tar2rubyscript.rb application[/] [application.rb [licence.txt]]
-The second variant needs the external program 'tar' for creating the
-archive internally. The first one doesn't.
+If "application.rb" is not provided or equals to "-", it will
+be derived from "application.tar" or "application/".
-If "application.rb" is not provided, it will be determined from
-"application.tar" or "application/".
+If a license is provided, it will be put at the beginning of
+The Application.
-For more information, see http://www.erikveen.dds.nl/tar2rubyscript/ .
+For more information, see
+http://www.erikveen.dds.nl/tar2rubyscript/ .
diff -ur tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/tar2rubyscript.rb tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tar2rubyscript.rb
--- tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-10-10 19:40:46.000000000 +0200
+++ tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-10-17 22:52:06.000000000 +0200
@@ -3,7 +3,7 @@
rbfile = ARGV.shift
licensefile = ARGV.shift
-tarfile.gsub!(/[\/\\]$/, "")
+tarfile.dup.gsub!(/[\/\\]$/, "")
if tarfile.nil?
puts "Usage: ruby tar2rubyscript.rb application.tar [application.rb [license.txt]]"
@@ -26,7 +26,6 @@
exit
end
-
script = nil
archive = nil
@@ -53,15 +52,27 @@
Dir.chdir("..")
- IO.popen("tar ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+ begin
+ tar = "tar"
+ IO.popen("#{tar} ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+ rescue
+ tar = newlocation("tar.exe")
+ IO.popen("#{tar} ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+ end
Dir.chdir(orgdir)
end
if not licensefile.nil?
- lic = nil ; File.open(licensefile) {|f| lic = f.read}
+ lic = nil ; File.open(licensefile) {|f| lic = f.readlines}
- script = "# License, not of this script, but of the application it contains:\n\n" + lic + "\n" + script
+ lic.collect! do |line|
+ line.gsub!(/[\r\n]/, "")
+ line = "# #{line}" unless line =~ /^[ \t]*#/
+ line
+ end
+
+ script = "# License, not of this script, but of the application it contains:\n#\n" + lic.join("\n") + "\n\n" + script
end
rbfile = tarfile.gsub(/\.tar$/, "") + ".rb" if (rbfile.nil? or File.basename(rbfile) == "-")
@@ -71,4 +82,5 @@
f.write "\n"
f.write "\n"
f.write archive
+ f.write "\n"
end
diff -ur tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-10-10 19:40:46.000000000 +0200
+++ tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-10-17 22:52:06.000000000 +0200
@@ -1,5 +1,5 @@
# License of this script, not of the application it contains:
-
+#
# Copyright Erik Veenstra <tar2rubyscript@erikveen.dds.nl>
#
# This program is free software; you can redistribute it and/or
@@ -16,8 +16,6 @@
# Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA.
-# License of this script, not of the application it contains:
-
# Tar2RubyScript constants
JustExtract = ARGV.include?("--tar2rubyscript-justextract")
@@ -137,9 +135,9 @@
def initialize(header)
fields = header.unpack('A100 A8 A8 A8 A12 A12 A8 A1 A100 A8 A32 A32 A8 A8')
types = ['str', 'oct', 'oct', 'oct', 'oct', 'time', 'oct', 'str', 'str', 'str', 'str', 'str', 'oct', 'oct']
- converted = []
begin
+ converted = []
while field = fields.shift
type = types.shift
@@ -181,16 +179,15 @@
def initialize
@archive = File.new($0, "rb").read.gsub(/\r/, "").split(/\n\n/)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift
@olddir = Dir.pwd
- @tmpdir = "/tmp"
- @tmpdir = "c:/tmp" if FileTest.exists?("c:/")
- @tempdir = "#{@tmpdir}/tar2rubyscript.d.#{Process.pid}"
- @tempfile = "#{@tmpdir}/tar2rubyscript.f.#{Process.pid}"
+ temp = ENV["TEMP"]
+ temp = "/tmp" if temp.nil?
+ @tempdir = "#{temp}/tar2rubyscript.d.#{Process.pid}"
+ @tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}"
@newdir=@tempdir
end
def eval
- Dir.mkdir(@tmpdir) if not FileTest.exists?(@tmpdir)
Dir.mkdir(@tempdir) if not FileTest.exists?(@tempdir)
newlocation do
@@ -202,14 +199,14 @@
# Eventually look for a subdirectory.
- entries = Dir.entries(@tempdir)
+ entries = Dir.entries(".")
entries.delete(".")
entries.delete("..")
if entries.length == 1
- entry = @tempdir + "/" + entries.shift
+ entry = entries.shift.dup
if FileTest.directory?(entry)
- @newdir = entry
+ @newdir = "#{@tempdir}/#{entry}"
end
end
end
@@ -296,9 +293,9 @@
class Extract
def initialize
@archive = File.new($0, "rb").read.gsub(/\r/, "").split(/\n\n/)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift
- @tmpdir = "/tmp"
- @tmpdir = "c:/tmp" if FileTest.exists?("c:/")
- @tempfile = "#{@tmpdir}/tar2rubyscript.f.#{Process.pid}"
+ temp = ENV["TEMP"]
+ temp = "/tmp" if temp.nil?
+ @tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}"
end
def extract
@@ -306,8 +303,6 @@
# Create the temp environment.
- Dir.mkdir(@tmpdir) if not FileTest.exists?(@tmpdir)
-
File.open(@tempfile, "wb") {|f| f.write @archive}
File.open(@tempfile, "rb") {|f| Reader.new(f).extract}
Binary files tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/tar.exe and tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tar.exe differ
diff -ur tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb
--- tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb 2006-03-08 17:52:54.865542869 +0100
+++ tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb 2003-10-23 23:15:17.000000000 +0200
@@ -0,0 +1,39 @@
+def oldlocation(file="")
+ if ENV.include?("OLDDIR")
+ dir = ENV["OLDDIR"]
+ else
+ dir = "."
+ end
+
+ if block_given?
+ pdir = Dir.pwd
+
+ Dir.chdir(dir)
+ res = yield
+ Dir.chdir(pdir)
+ else
+ res = File.expand_path(file, dir) if not file.nil?
+ end
+
+ res
+end
+
+def newlocation(file="")
+ if ENV.include?("NEWDIR")
+ dir = ENV["NEWDIR"]
+ else
+ dir = "."
+ end
+
+ if block_given?
+ pdir = Dir.pwd
+
+ Dir.chdir(dir)
+ res = yield
+ Dir.chdir(pdir)
+ else
+ res = File.expand_path(file, dir) if not file.nil?
+ end
+
+ res
+end
diff -ur tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/init.rb tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/init.rb
--- tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/init.rb 2006-03-08 17:52:54.861542913 +0100
+++ tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/init.rb 2003-10-19 19:16:01.000000000 +0200
@@ -0,0 +1,81 @@
+require "ev/oldandnewlocation"
+
+scriptfile = "tarrubyscript.rb"
+tarfile = oldlocation(ARGV.shift)
+rbfile = oldlocation(ARGV.shift)
+licensefile = oldlocation(ARGV.shift)
+
+if tarfile.nil?
+ exit 1
+end
+
+tarfile.dup.gsub!(/[\/\\]$/, "")
+
+if not FileTest.exist?(tarfile)
+ puts "#{tarfile} doesn't exist."
+ exit
+end
+
+if not licensefile.nil? and not FileTest.file?(licensefile)
+ puts "#{licensefile} doesn't exist."
+ exit
+end
+
+script = nil
+archive = nil
+
+File.open(scriptfile) {|f| script = f.read}
+
+if FileTest.file?(tarfile)
+ File.open(tarfile, "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+end
+
+if FileTest.directory?(tarfile)
+ orgdir = Dir.pwd
+
+ Dir.chdir(tarfile)
+
+ if FileTest.file?("tar2rubyscript.bat")
+ puts "\".\\tar2rubyscript.bat\""
+ system(".\\tar2rubyscript.bat")
+ end
+
+ if FileTest.file?("tar2rubyscript.sh")
+ puts "\". ./tar2rubyscript.sh\""
+ system("sh -c \". ./tar2rubyscript.sh\"")
+ end
+
+ Dir.chdir("..")
+
+ begin
+ tar = "tar"
+ IO.popen("#{tar} ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+ rescue
+ tar = newlocation("tar.exe")
+ IO.popen("#{tar} ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+ end
+
+ Dir.chdir(orgdir)
+end
+
+if not licensefile.nil?
+ lic = nil ; File.open(licensefile) {|f| lic = f.readlines}
+
+ lic.collect! do |line|
+ line.gsub!(/[\r\n]/, "")
+ line = "# #{line}" unless line =~ /^[ \t]*#/
+ line
+ end
+
+ script = "# License, not of this script, but of the application it contains:\n#\n" + lic.join("\n") + "\n\n" + script
+end
+
+rbfile = tarfile.gsub(/\.tar$/, "") + ".rb" if (rbfile.nil? or File.basename(rbfile) == "-")
+
+File.open(rbfile, "wb") do |f|
+ f.write script
+ f.write "\n"
+ f.write "\n"
+ f.write archive
+ f.write "\n"
+end
diff -ur tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/README tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/README
--- tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/README 2003-10-17 22:48:37.000000000 +0200
+++ tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/README 2003-10-19 19:17:19.000000000 +0200
@@ -1,6 +1,6 @@
-Usage: ruby tar2rubyscript.rb application.tar [application.rb [licence.txt]]
+Usage: ruby init.rb application.tar [application.rb [licence.txt]]
or
- ruby tar2rubyscript.rb application[/] [application.rb [licence.txt]]
+ ruby init.rb application[/] [application.rb [licence.txt]]
If "application.rb" is not provided or equals to "-", it will
be derived from "application.tar" or "application/".
diff -ur tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tar2rubyscript.rb tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/tar2rubyscript.rb
--- tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-10-17 22:52:06.000000000 +0200
+++ tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/tar2rubyscript.rb 2006-03-08 17:52:54.853543001 +0100
@@ -1,86 +0,0 @@
-scriptfile = "tarrubyscript.rb"
-tarfile = ARGV.shift
-rbfile = ARGV.shift
-licensefile = ARGV.shift
-
-tarfile.dup.gsub!(/[\/\\]$/, "")
-
-if tarfile.nil?
- puts "Usage: ruby tar2rubyscript.rb application.tar [application.rb [license.txt]]"
- puts " or"
- puts " ruby tar2rubyscript.rb application/ [application.rb [license.txt]]"
- puts ""
- puts "The second option needs the external program 'tar' for creating"
- puts "the archive internally."
-
- exit 1
-end
-
-if not FileTest.exist?(tarfile)
- puts "#{tarfile} doesn't exist."
- exit
-end
-
-if not licensefile.nil? and not FileTest.file?(licensefile)
- puts "#{licensefile} doesn't exist."
- exit
-end
-
-script = nil
-archive = nil
-
-File.open(scriptfile) {|f| script = f.read}
-
-if FileTest.file?(tarfile)
- File.open(tarfile, "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
-end
-
-if FileTest.directory?(tarfile)
- orgdir = Dir.pwd
-
- Dir.chdir(tarfile)
-
- if FileTest.file?("tar2rubyscript.bat")
- puts "\".\\tar2rubyscript.bat\""
- system(".\\tar2rubyscript.bat")
- end
-
- if FileTest.file?("tar2rubyscript.sh")
- puts "\". ./tar2rubyscript.sh\""
- system("sh -c \". ./tar2rubyscript.sh\"")
- end
-
- Dir.chdir("..")
-
- begin
- tar = "tar"
- IO.popen("#{tar} ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
- rescue
- tar = newlocation("tar.exe")
- IO.popen("#{tar} ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
- end
-
- Dir.chdir(orgdir)
-end
-
-if not licensefile.nil?
- lic = nil ; File.open(licensefile) {|f| lic = f.readlines}
-
- lic.collect! do |line|
- line.gsub!(/[\r\n]/, "")
- line = "# #{line}" unless line =~ /^[ \t]*#/
- line
- end
-
- script = "# License, not of this script, but of the application it contains:\n#\n" + lic.join("\n") + "\n\n" + script
-end
-
-rbfile = tarfile.gsub(/\.tar$/, "") + ".rb" if (rbfile.nil? or File.basename(rbfile) == "-")
-
-File.open(rbfile, "wb") do |f|
- f.write script
- f.write "\n"
- f.write "\n"
- f.write archive
- f.write "\n"
-end
diff -ur tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-10-17 22:52:06.000000000 +0200
+++ tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-10-22 18:52:06.000000000 +0200
@@ -187,7 +187,7 @@
@newdir=@tempdir
end
- def eval
+ def run
Dir.mkdir(@tempdir) if not FileTest.exists?(@tempdir)
newlocation do
@@ -319,5 +319,5 @@
if JustExtract
Extract.new.extract
else
- TempSpace.new.eval
+ TempSpace.new.run
end
diff -ur tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb tar2rubyscript-0.3.5.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb
--- tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb 2003-10-23 23:15:17.000000000 +0200
+++ tar2rubyscript-0.3.5.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb 2003-10-29 16:44:50.000000000 +0100
@@ -1,39 +1,42 @@
-def oldlocation(file="")
- if ENV.include?("OLDDIR")
+ENV["OLDDIR"] = Dir.pwd if not ENV.include?("OLDDIR")
+ENV["NEWDIR"] = Dir.pwd if not ENV.include?("NEWDIR")
+
+begin
+ oldlocation
+rescue NameError
+ def oldlocation(file="")
dir = ENV["OLDDIR"]
- else
- dir = "."
- end
- if block_given?
- pdir = Dir.pwd
+ if block_given?
+ pdir = Dir.pwd
- Dir.chdir(dir)
- res = yield
- Dir.chdir(pdir)
- else
- res = File.expand_path(file, dir) if not file.nil?
- end
+ Dir.chdir(dir)
+ res = yield
+ Dir.chdir(pdir)
+ else
+ res = File.expand_path(file, dir) if not file.nil?
+ end
- res
+ res
+ end
end
-def newlocation(file="")
- if ENV.include?("NEWDIR")
+begin
+ newlocation
+rescue NameError
+ def newlocation(file="")
dir = ENV["NEWDIR"]
- else
- dir = "."
- end
- if block_given?
- pdir = Dir.pwd
+ if block_given?
+ pdir = Dir.pwd
- Dir.chdir(dir)
- res = yield
- Dir.chdir(pdir)
- else
- res = File.expand_path(file, dir) if not file.nil?
- end
+ Dir.chdir(dir)
+ res = yield
+ Dir.chdir(pdir)
+ else
+ res = File.expand_path(file, dir) if not file.nil?
+ end
- res
+ res
+ end
end
diff -ur tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/init.rb tar2rubyscript-0.3.5.tar.gz/tar2rubyscript/init.rb
--- tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/init.rb 2003-10-19 19:16:01.000000000 +0200
+++ tar2rubyscript-0.3.5.tar.gz/tar2rubyscript/init.rb 2003-10-29 15:06:30.000000000 +0100
@@ -12,12 +12,12 @@
tarfile.dup.gsub!(/[\/\\]$/, "")
if not FileTest.exist?(tarfile)
- puts "#{tarfile} doesn't exist."
+ $stderr.puts "#{tarfile} doesn't exist."
exit
end
if not licensefile.nil? and not FileTest.file?(licensefile)
- puts "#{licensefile} doesn't exist."
+ $stderr.puts "#{licensefile} doesn't exist."
exit
end
@@ -36,12 +36,12 @@
Dir.chdir(tarfile)
if FileTest.file?("tar2rubyscript.bat")
- puts "\".\\tar2rubyscript.bat\""
+ $stderr.puts "\".\\tar2rubyscript.bat\""
system(".\\tar2rubyscript.bat")
end
if FileTest.file?("tar2rubyscript.sh")
- puts "\". ./tar2rubyscript.sh\""
+ $stderr.puts "\". ./tar2rubyscript.sh\""
system("sh -c \". ./tar2rubyscript.sh\"")
end
diff -ur tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.3.5.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-10-22 18:52:06.000000000 +0200
+++ tar2rubyscript-0.3.5.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-10-28 22:47:30.000000000 +0100
@@ -19,6 +19,7 @@
# Tar2RubyScript constants
JustExtract = ARGV.include?("--tar2rubyscript-justextract")
+ToTar = ARGV.include?("--tar2rubyscript-totar")
ARGV.concat []
@@ -41,8 +42,12 @@
UNAMELEN = 32
GNAMELEN = 32
DEVLEN = 8
+
TMAGIC = 'ustar'
GNU_TMAGIC = 'ustar '
+SOLARIS_TMAGIC = 'ustar00'
+
+MAGICS = [TMAGIC, GNU_TMAGIC, SOLARIS_TMAGIC]
LF_OLDFILE = '\0'
LF_FILE = '0'
@@ -157,7 +162,7 @@
raise "Couldn't determine a real value for a field (#{field})"
end
- raise "Magic header value '#{@magic}' is invalid." if @magic != TMAGIC and @magic != GNU_TMAGIC
+ raise "Magic header value '#{@magic}' is invalid." if not MAGICS.include?(@magic)
@linkflag = LF_FILE if @linkflag == LF_OLDFILE or @linkflag == LF_CONTIG
@linkflag = LF_DIR if @name[-1] == '/' and @linkflag == LF_FILE
@@ -184,10 +189,12 @@
@tempdir = "#{temp}/tar2rubyscript.d.#{Process.pid}"
@tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}"
+ @@tempspace = self
+
@newdir=@tempdir
end
- def run
+ def extract
Dir.mkdir(@tempdir) if not FileTest.exists?(@tempdir)
newlocation do
@@ -233,14 +240,6 @@
recursivedelete(@tempfile)
recursivedelete(@tempdir)
end
-
- # Execute init.rb .
-
- newlocation do
- File.open("init.rb") do |f|
- instance_eval(f.read)
- end
- end
end
def recursivedelete(entry)
@@ -288,6 +287,22 @@
res
end
+
+ def self.oldlocation(file="")
+ if block_given?
+ @@tempspace.oldlocation { yield }
+ else
+ @@tempspace.oldlocation(file)
+ end
+ end
+
+ def self.newlocation(file="")
+ if block_given?
+ @@tempspace.newlocation { yield }
+ else
+ @@tempspace.newlocation(file)
+ end
+ end
end
class Extract
@@ -300,24 +315,51 @@
def extract
begin
-
- # Create the temp environment.
-
File.open(@tempfile, "wb") {|f| f.write @archive}
File.open(@tempfile, "rb") {|f| Reader.new(f).extract}
-
ensure
+ File.delete(@tempfile)
+ end
+ end
+end
- # Remove the temp environment.
+class MakeTar
+ def initialize
+ @archive = File.new($0, "rb").read.gsub(/\r/, "").split(/\n\n/)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift
+ @tarfile = $0.gsub(/\.rb$/, ".tar")
+ end
- File.delete(@tempfile)
+ def extract
+ File.open(@tarfile, "wb") {|f| f.write @archive}
+ end
+end
- end
+def oldlocation(file="")
+ if block_given?
+ TempSpace.oldlocation { yield }
+ else
+ TempSpace.oldlocation(file)
+ end
+end
+
+def newlocation(file="")
+ if block_given?
+ TempSpace.newlocation { yield }
+ else
+ TempSpace.newlocation(file)
end
end
if JustExtract
Extract.new.extract
else
- TempSpace.new.run
+ if ToTar
+ MakeTar.new.extract
+ else
+ TempSpace.new.extract
+
+ newlocation do
+ load "init.rb"
+ end
+ end
end
diff -ur tar2rubyscript-0.3.5.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.3.6.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.3.5.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-10-28 22:47:30.000000000 +0100
+++ tar2rubyscript-0.3.6.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-11-08 19:22:36.000000000 +0100
@@ -191,7 +191,7 @@
@@tempspace = self
- @newdir=@tempdir
+ @newdir = @tempdir
end
def extract
@@ -358,6 +358,8 @@
else
TempSpace.new.extract
+ $0 = "./init.rb"
+
newlocation do
load "init.rb"
end
diff -ur tar2rubyscript-0.3.6.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.3.7.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.3.6.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-11-08 19:22:36.000000000 +0100
+++ tar2rubyscript-0.3.7.tar.gz/tar2rubyscript/tarrubyscript.rb 2004-02-22 10:50:03.000000000 +0100
@@ -43,9 +43,9 @@
GNAMELEN = 32
DEVLEN = 8
-TMAGIC = 'ustar'
-GNU_TMAGIC = 'ustar '
-SOLARIS_TMAGIC = 'ustar00'
+TMAGIC = "ustar"
+GNU_TMAGIC = "ustar "
+SOLARIS_TMAGIC = "ustar\00000"
MAGICS = [TMAGIC, GNU_TMAGIC, SOLARIS_TMAGIC]
@@ -162,7 +162,7 @@
raise "Couldn't determine a real value for a field (#{field})"
end
- raise "Magic header value '#{@magic}' is invalid." if not MAGICS.include?(@magic)
+ raise "Magic header value #{@magic.inspect} is invalid." if not MAGICS.include?(@magic)
@linkflag = LF_FILE if @linkflag == LF_OLDFILE or @linkflag == LF_CONTIG
@linkflag = LF_DIR if @name[-1] == '/' and @linkflag == LF_FILE
diff -ur tar2rubyscript-0.3.7.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.3.8.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.3.7.tar.gz/tar2rubyscript/tarrubyscript.rb 2004-02-22 10:50:03.000000000 +0100
+++ tar2rubyscript-0.3.8.tar.gz/tar2rubyscript/tarrubyscript.rb 2004-03-26 14:35:19.000000000 +0100
@@ -326,11 +326,11 @@
class MakeTar
def initialize
@archive = File.new($0, "rb").read.gsub(/\r/, "").split(/\n\n/)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift
- @tarfile = $0.gsub(/\.rb$/, ".tar")
+ @tarfile = $0.gsub(/\.rbw?$/, "") + ".tar"
end
def extract
- File.open(@tarfile, "wb") {|f| f.write @archive}
+ File.open(@tarfile, "wb") {|f| f.write @archive}
end
end
diff -ur tar2rubyscript-0.3.8.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb tar2rubyscript-0.4.0.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb
--- tar2rubyscript-0.3.8.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb 2004-03-26 15:12:40.000000000 +0100
+++ tar2rubyscript-0.4.0.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb 2004-12-03 23:13:40.000000000 +0100
@@ -1,11 +1,34 @@
-ENV["OLDDIR"] = Dir.pwd if not ENV.include?("OLDDIR")
-ENV["NEWDIR"] = Dir.pwd if not ENV.include?("NEWDIR")
+temp = (ENV["TMPDIR"] or ENV["TMP"] or ENV["TEMP"] or "/tmp").gsub(/\\/, "/")
+dir = "#{temp}/oldandnewlocation.#{Process.pid}"
+
+ENV["OLDDIR"] = Dir.pwd unless ENV.include?("OLDDIR")
+ENV["NEWDIR"] = File.dirname($0) unless ENV.include?("NEWDIR")
+ENV["TEMPDIR"] = dir unless ENV.include?("TEMPDIR")
+
+class Dir
+ def self.rm_rf(entry)
+ if File.ftype(entry) == "directory"
+ pdir = Dir.pwd
+
+ Dir.chdir(entry)
+ Dir.new(".").each do |e|
+ Dir.rm_rf(e) if not [".", ".."].include?(e)
+ end
+ Dir.chdir(pdir)
+
+ Dir.delete(entry)
+ else
+ File.delete(entry)
+ end
+ end
+end
begin
oldlocation
rescue NameError
def oldlocation(file="")
dir = ENV["OLDDIR"]
+ res = nil
if block_given?
pdir = Dir.pwd
@@ -14,7 +37,7 @@
res = yield
Dir.chdir(pdir)
else
- res = File.expand_path(file, dir) if not file.nil?
+ res = File.expand_path(file, dir) unless file.nil?
end
res
@@ -26,6 +49,41 @@
rescue NameError
def newlocation(file="")
dir = ENV["NEWDIR"]
+ res = nil
+
+ if block_given?
+ pdir = Dir.pwd
+
+ Dir.chdir(dir)
+ res = yield
+ Dir.chdir(pdir)
+ else
+ res = File.expand_path(file, dir) unless file.nil?
+ end
+
+ res
+ end
+end
+
+begin
+ tmplocation
+rescue NameError
+ dir = ENV["TEMPDIR"]
+
+ Dir.rm_rf(dir) if File.directory?(dir)
+ Dir.mkdir(dir)
+
+ at_exit do
+ if File.directory?(dir)
+ Dir.chdir(dir)
+ Dir.chdir("..")
+ Dir.rm_rf(dir)
+ end
+ end
+
+ def tmplocation(file="")
+ dir = ENV["TEMPDIR"]
+ res = nil
if block_given?
pdir = Dir.pwd
@@ -34,7 +92,7 @@
res = yield
Dir.chdir(pdir)
else
- res = File.expand_path(file, dir) if not file.nil?
+ res = File.expand_path(file, dir) unless file.nil?
end
res
diff -ur tar2rubyscript-0.3.8.tar.gz/tar2rubyscript/init.rb tar2rubyscript-0.4.0.tar.gz/tar2rubyscript/init.rb
--- tar2rubyscript-0.3.8.tar.gz/tar2rubyscript/init.rb 2004-03-20 18:42:23.000000000 +0100
+++ tar2rubyscript-0.4.0.tar.gz/tar2rubyscript/init.rb 2004-12-03 23:09:07.000000000 +0100
@@ -1,46 +1,61 @@
require "ev/oldandnewlocation"
+exit if ARGV.include?("--tar2rubyscript-exit")
+
scriptfile = "tarrubyscript.rb"
tarfile = oldlocation(ARGV.shift)
rbfile = oldlocation(ARGV.shift)
licensefile = oldlocation(ARGV.shift)
if tarfile.nil?
+ $stderr.puts <<-EOF
+
+ Usage: ruby init.rb application.tar [application.rb [licence.txt]]
+ or
+ ruby init.rb application[/] [application.rb [licence.txt]]
+
+ If \"application.rb\" is not provided or equals to \"-\", it will
+ be derived from \"application.tar\" or \"application/\".
+
+ If a license is provided, it will be put at the beginning of
+ The Application.
+
+ For more information, see
+ http://www.erikveen.dds.nl/tar2rubyscript/index.html .
+ EOF
+
exit 1
end
tarfile.dup.gsub!(/[\/\\]$/, "")
-if not FileTest.exist?(tarfile)
+if not File.exist?(tarfile)
$stderr.puts "#{tarfile} doesn't exist."
exit
end
-if not licensefile.nil? and not FileTest.file?(licensefile)
+if not licensefile.nil? and not licensefile.empty? and not File.file?(licensefile)
$stderr.puts "#{licensefile} doesn't exist."
exit
end
-script = nil
-archive = nil
-
-File.open(scriptfile) {|f| script = f.read}
+script = File.open(scriptfile){|f| f.read}
-if FileTest.file?(tarfile)
- File.open(tarfile, "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+if File.file?(tarfile)
+ archive = File.open(tarfile, "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
end
-if FileTest.directory?(tarfile)
- orgdir = Dir.pwd
+if File.directory?(tarfile)
+ pdir = Dir.pwd
Dir.chdir(tarfile)
- if FileTest.file?("tar2rubyscript.bat")
+ if File.file?("tar2rubyscript.bat")
$stderr.puts "\".\\tar2rubyscript.bat\""
system(".\\tar2rubyscript.bat")
end
- if FileTest.file?("tar2rubyscript.sh")
+ if File.file?("tar2rubyscript.sh")
$stderr.puts "\". ./tar2rubyscript.sh\""
system("sh -c \". ./tar2rubyscript.sh\"")
end
@@ -49,17 +64,17 @@
begin
tar = "tar"
- IO.popen("#{tar} ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+ archive = IO.popen("#{tar} ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
rescue
tar = newlocation("tar.exe")
- IO.popen("#{tar} ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+ archive = IO.popen("#{tar} ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
end
- Dir.chdir(orgdir)
+ Dir.chdir(pdir)
end
-if not licensefile.nil?
- lic = nil ; File.open(licensefile) {|f| lic = f.readlines}
+if not licensefile.nil? and not licensefile.empty?
+ lic = File.open(licensefile){|f| f.readlines}
lic.collect! do |line|
line.gsub!(/[\r\n]/, "")
diff -ur tar2rubyscript-0.3.8.tar.gz/tar2rubyscript/README tar2rubyscript-0.4.0.tar.gz/tar2rubyscript/README
--- tar2rubyscript-0.3.8.tar.gz/tar2rubyscript/README 2003-10-19 19:17:19.000000000 +0200
+++ tar2rubyscript-0.4.0.tar.gz/tar2rubyscript/README 2004-12-03 23:10:19.000000000 +0100
@@ -1,6 +1,10 @@
-Usage: ruby init.rb application.tar [application.rb [licence.txt]]
- or
- ruby init.rb application[/] [application.rb [licence.txt]]
+The best way to use Tar2RubyScript is the RB, not this TAR.GZ.
+The latter is just for playing with the internals. Both are
+available on the site.
+
+ Usage: ruby init.rb application.tar [application.rb [licence.txt]]
+ or
+ ruby init.rb application[/] [application.rb [licence.txt]]
If "application.rb" is not provided or equals to "-", it will
be derived from "application.tar" or "application/".
@@ -8,5 +12,8 @@
If a license is provided, it will be put at the beginning of
The Application.
+Parts of the code for Tar2RubyScript are based on code from
+Thomas Hurst <tom@hur.st>.
+
For more information, see
-http://www.erikveen.dds.nl/tar2rubyscript/ .
+http://www.erikveen.dds.nl/tar2rubyscript/index.html .
diff -ur tar2rubyscript-0.3.8.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.4.0.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.3.8.tar.gz/tar2rubyscript/tarrubyscript.rb 2004-03-26 14:35:19.000000000 +0100
+++ tar2rubyscript-0.4.0.tar.gz/tar2rubyscript/tarrubyscript.rb 2004-12-03 22:53:43.000000000 +0100
@@ -16,6 +16,9 @@
# Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA.
+# Parts of this code are based on code from Thomas Hurst
+# <tom@hur.st>.
+
# Tar2RubyScript constants
JustExtract = ARGV.include?("--tar2rubyscript-justextract")
@@ -59,6 +62,24 @@
LF_FIFO = '6'
LF_CONTIG = '7'
+class Dir
+ def self.rm_rf(entry)
+ if File.ftype(entry) == "directory"
+ pdir = Dir.pwd
+
+ Dir.chdir(entry)
+ Dir.new(".").each do |e|
+ rm_rf(e) if not [".", ".."].include?(e)
+ end
+ Dir.chdir(pdir)
+
+ Dir.delete(entry)
+ else
+ File.delete(entry)
+ end
+ end
+end
+
class Reader
def initialize(filehandle)
@fp = filehandle
@@ -182,7 +203,7 @@
class TempSpace
def initialize
- @archive = File.new($0, "rb").read.gsub(/\r/, "").split(/\n\n/)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift
+ @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?
@@ -195,7 +216,7 @@
end
def extract
- Dir.mkdir(@tempdir) if not FileTest.exists?(@tempdir)
+ Dir.mkdir(@tempdir) if not File.exists?(@tempdir)
newlocation do
@@ -212,7 +233,7 @@
if entries.length == 1
entry = entries.shift.dup
- if FileTest.directory?(entry)
+ if File.directory?(entry)
@newdir = "#{@tempdir}/#{entry}"
end
end
@@ -237,27 +258,17 @@
Dir.chdir(@olddir)
- recursivedelete(@tempfile)
- recursivedelete(@tempdir)
+ Dir.rm_rf(@tempfile)
+ Dir.rm_rf(@tempdir)
end
- end
- def recursivedelete(entry)
- if FileTest.file?(entry)
- File.delete(entry)
- end
-
- if FileTest.directory?(entry)
- pdir = Dir.pwd
+ self
+ end
- Dir.chdir(entry)
- Dir.new(".").each do |e|
- recursivedelete(e) if not [".", ".."].include?(e)
- end
- Dir.chdir(pdir)
+ def cleanup
+ @archive = nil
- Dir.rmdir(entry)
- end
+ self
end
def oldlocation(file="")
@@ -307,7 +318,7 @@
class Extract
def initialize
- @archive = File.new($0, "rb").read.gsub(/\r/, "").split(/\n\n/)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift
+ @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}"
@@ -320,17 +331,33 @@
ensure
File.delete(@tempfile)
end
+
+ self
+ end
+
+ def cleanup
+ @archive = nil
+
+ self
end
end
class MakeTar
def initialize
- @archive = File.new($0, "rb").read.gsub(/\r/, "").split(/\n\n/)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift
- @tarfile = $0.gsub(/\.rbw?$/, "") + ".tar"
+ @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
+ @tarfile = File.expand_path(__FILE__).gsub(/\.rbw?$/, "") + ".tar"
end
def extract
File.open(@tarfile, "wb") {|f| f.write @archive}
+
+ self
+ end
+
+ def cleanup
+ @archive = nil
+
+ self
end
end
@@ -351,17 +378,29 @@
end
if JustExtract
- Extract.new.extract
+ Extract.new.extract.cleanup
else
if ToTar
- MakeTar.new.extract
+ MakeTar.new.extract.cleanup
else
- TempSpace.new.extract
+ TempSpace.new.extract.cleanup
- $0 = "./init.rb"
+ $: << newlocation
newlocation do
- load "init.rb"
+ if __FILE__ == $0
+ $0.replace("./init.rb")
+
+ if File.file?("./init.rb")
+ load "./init.rb"
+ else
+ $stderr.puts "%s doesn't contain an init.rb ." % __FILE__
+ end
+ else
+ if File.file?("./init.rb")
+ load "./init.rb"
+ end
+ end
end
end
end
diff -ur tar2rubyscript-0.4.0.tar.gz/tar2rubyscript/init.rb tar2rubyscript-0.4.1.tar.gz/tar2rubyscript/init.rb
--- tar2rubyscript-0.4.0.tar.gz/tar2rubyscript/init.rb 2004-12-03 23:09:07.000000000 +0100
+++ tar2rubyscript-0.4.1.tar.gz/tar2rubyscript/init.rb 2004-12-18 14:58:32.000000000 +0100
@@ -2,7 +2,7 @@
exit if ARGV.include?("--tar2rubyscript-exit")
-scriptfile = "tarrubyscript.rb"
+scriptfile = newlocation("tarrubyscript.rb")
tarfile = oldlocation(ARGV.shift)
rbfile = oldlocation(ARGV.shift)
licensefile = oldlocation(ARGV.shift)
diff -ur tar2rubyscript-0.4.0.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.4.1.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.4.0.tar.gz/tar2rubyscript/tarrubyscript.rb 2004-12-03 22:53:43.000000000 +0100
+++ tar2rubyscript-0.4.1.tar.gz/tar2rubyscript/tarrubyscript.rb 2004-12-18 12:29:29.000000000 +0100
@@ -21,6 +21,7 @@
# Tar2RubyScript constants
+ShowContent = ARGV.include?("--tar2rubyscript-list")
JustExtract = ARGV.include?("--tar2rubyscript-justextract")
ToTar = ARGV.include?("--tar2rubyscript-totar")
@@ -91,6 +92,12 @@
end
end
+ def list
+ each do |entry|
+ entry.list
+ end
+ end
+
def each
@fp.rewind
@@ -153,6 +160,18 @@
#File.utime(Time.now, @header.mtime, @header.name)
end
end
+
+ def list
+ if not @header.name.empty?
+ if @header.dir?
+ puts "d %s" % [@header.name]
+ elsif @header.file?
+ puts "f %s (%s)" % [@header.name, @data.length]
+ else
+ puts "Couldn't handle entry #{@header.name}"
+ end
+ end
+ end
end
class Header
@@ -201,6 +220,32 @@
end
end
+class Content
+ 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}"
+ end
+
+ def list
+ begin
+ File.open(@tempfile, "wb") {|f| f.write @archive}
+ File.open(@tempfile, "rb") {|f| Reader.new(f).list}
+ ensure
+ File.delete(@tempfile)
+ end
+
+ self
+ end
+
+ def cleanup
+ @archive = nil
+
+ self
+ end
+end
+
class TempSpace
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
@@ -377,29 +422,29 @@
end
end
-if JustExtract
+if ShowContent
+ Content.new.list.cleanup
+elsif JustExtract
Extract.new.extract.cleanup
+elsif ToTar
+ MakeTar.new.extract.cleanup
else
- if ToTar
- MakeTar.new.extract.cleanup
- else
- TempSpace.new.extract.cleanup
+ TempSpace.new.extract.cleanup
- $: << newlocation
+ $:.unshift(newlocation)
- newlocation do
- if __FILE__ == $0
- $0.replace("./init.rb")
+ newlocation do
+ if __FILE__ == $0
+ $0.replace("./init.rb")
- if File.file?("./init.rb")
- load "./init.rb"
- else
- $stderr.puts "%s doesn't contain an init.rb ." % __FILE__
- end
+ if File.file?("./init.rb")
+ load "./init.rb"
else
- if File.file?("./init.rb")
- load "./init.rb"
- end
+ $stderr.puts "%s doesn't contain an init.rb ." % __FILE__
+ end
+ else
+ if File.file?("./init.rb")
+ load "./init.rb"
end
end
end
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
diff -ur tar2rubyscript-0.4.2.tar.gz/tar2rubyscript/ev/ftools.rb tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/ev/ftools.rb
--- tar2rubyscript-0.4.2.tar.gz/tar2rubyscript/ev/ftools.rb 2006-03-08 17:53:05.599426354 +0100
+++ tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/ev/ftools.rb 2005-01-13 23:06:37.000000000 +0100
@@ -0,0 +1,172 @@
+require "ftools"
+
+class Dir
+ def self.copy(from, to)
+ if File.directory?(from)
+ pdir = Dir.pwd
+ todir = File.expand_path(to)
+
+ File.mkpath(todir)
+
+ Dir.chdir(from)
+ Dir.new(".").each do |e|
+ Dir.copy(e, todir+"/"+e) if not [".", ".."].include?(e)
+ end
+ Dir.chdir(pdir)
+ else
+ todir = File.dirname(File.expand_path(to))
+
+ File.mkpath(todir)
+
+ File.copy(from, to)
+ end
+ end
+
+ def self.move(from, to)
+ Dir.copy(from, to)
+ Dir.rm_rf(from)
+ end
+
+ def self.rm_rf(entry)
+ if File.ftype(entry) == "directory"
+ pdir = Dir.pwd
+
+ Dir.chdir(entry)
+ Dir.new(".").each do |e|
+ Dir.rm_rf(e) if not [".", ".."].include?(e)
+ end
+ Dir.chdir(pdir)
+
+ begin
+ Dir.delete(entry)
+ rescue => e
+ $stderr.puts e.message
+ end
+ else
+ begin
+ File.delete(entry)
+ rescue => e
+ $stderr.puts e.message
+ end
+ end
+ end
+
+ def self.find(entry=nil, mask=nil)
+ entry = "." if entry.nil?
+
+ entry = entry.gsub(/[\/\\]*$/, "") unless entry.nil?
+
+ mask = /^#{mask}$/i if mask.kind_of?(String)
+
+ res = []
+
+ if File.directory?(entry)
+ pdir = Dir.pwd
+
+ res += ["%s/" % entry] if mask.nil? or entry =~ mask
+
+ begin
+ Dir.chdir(entry)
+
+ begin
+ Dir.new(".").each do |e|
+ res += Dir.find(e, mask).collect{|e| entry+"/"+e} unless [".", ".."].include?(e)
+ end
+ ensure
+ Dir.chdir(pdir)
+ end
+ rescue Errno::EACCES => e
+ $stderr.puts e.message
+ end
+ else
+ res += [entry] if mask.nil? or entry =~ mask
+ end
+
+ res
+ end
+end
+
+class File
+ def self.rollbackup(file, mode=nil)
+ backupfile = file + ".RB.BACKUP"
+ controlfile = file + ".RB.CONTROL"
+ res = nil
+
+ File.touch(file) unless File.file?(file)
+
+ # Rollback
+
+ if File.file?(backupfile) and File.file?(controlfile)
+ $stderr.puts "Restoring #{file}..."
+
+ File.copy(backupfile, file) # Rollback from phase 3
+ end
+
+ # Reset
+
+ File.delete(backupfile) if File.file?(backupfile) # Reset from phase 2 or 3
+ File.delete(controlfile) if File.file?(controlfile) # Reset from phase 3 or 4
+
+ # Backup
+
+ File.copy(file, backupfile) # Enter phase 2
+ File.touch(controlfile) # Enter phase 3
+
+ # The real thing
+
+ if block_given?
+ if mode.nil?
+ res = yield
+ else
+ File.open(file, mode) do |f|
+ res = yield(f)
+ end
+ end
+ end
+
+ # Cleanup
+
+ File.delete(backupfile) # Enter phase 4
+ File.delete(controlfile) # Enter phase 5
+
+ # Return, like File.open
+
+ res = File.open(file, (mode or "r")) unless block_given?
+
+ res
+ end
+
+ def self.touch(file)
+ if File.exists?(file)
+ File.utime(Time.now, File.mtime(file), file)
+ else
+ File.open(file, "a"){|f|}
+ end
+ end
+
+ def self.which(file)
+ res = nil
+
+ if windows?
+ file = file.gsub(/\.exe$/i, "") + ".exe"
+ sep = ";"
+ else
+ sep = ":"
+ end
+
+ catch :stop do
+ ENV["PATH"].split(/#{sep}/).reverse.each do |d|
+ if File.directory?(d)
+ Dir.new(d).each do |e|
+ if e.downcase == file.downcase
+ res = File.expand_path(e, d)
+ throw :stop
+ end
+ end
+ end
+ end
+ end
+
+ res
+ end
+end
diff -ur tar2rubyscript-0.4.2.tar.gz/tar2rubyscript/init.rb tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/init.rb
--- tar2rubyscript-0.4.2.tar.gz/tar2rubyscript/init.rb 2004-12-27 11:16:27.000000000 +0100
+++ tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/init.rb 2005-01-11 18:03:37.000000000 +0100
@@ -1,7 +1,36 @@
+$: << File.dirname(File.expand_path(__FILE__))
+
require "ev/oldandnewlocation"
+require "ev/ftools"
+require "rbconfig"
exit if ARGV.include?("--tar2rubyscript-exit")
+def backslashes(s)
+ s = s.gsub(/^\.\//, "").gsub(/\//, "\\\\") if windows?
+ s
+end
+
+def linux?
+ not windows? and not cygwin? # Hack ???
+end
+
+def windows?
+ not (target_os.downcase =~ /32/).nil? # Hack ???
+end
+
+def cygwin?
+ not (target_os.downcase =~ /cyg/).nil? # Hack ???
+end
+
+def target_os
+ Config::CONFIG["target_os"] or ""
+end
+
+PRESERVE = ARGV.include?("--tar2rubyscript-preserve")
+
+ARGV.delete_if{|arg| arg =~ /^--tar2rubyscript-/}
+
scriptfile = newlocation("tarrubyscript.rb")
tarfile = oldlocation(ARGV.shift)
rbfile = oldlocation(ARGV.shift)
@@ -27,7 +56,8 @@
exit 1
end
-tarfile.dup.gsub!(/[\/\\]$/, "")
+TARMODE = File.file?(tarfile)
+DIRMODE = File.directory?(tarfile)
if not File.exist?(tarfile)
$stderr.puts "#{tarfile} doesn't exist."
@@ -41,43 +71,68 @@
script = File.open(scriptfile){|f| f.read}
-if File.file?(tarfile)
- $stderr.puts "Found archive..."
+pdir = Dir.pwd
- archive = File.open(tarfile, "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
-end
+tmpdir = tmplocation(File.basename(tarfile))
+
+File.mkpath(tmpdir)
-if File.directory?(tarfile)
- pdir = Dir.pwd
+Dir.chdir(tmpdir)
- Dir.chdir(tarfile)
+ if TARMODE and not PRESERVE
+ begin
+ tar = "tar"
+ system(backslashes("#{tar} xf #{tarfile}"))
+ rescue
+ tar = backslashes(newlocation("tar.exe"))
+ system(backslashes("#{tar} xf #{tarfile}"))
+ end
+ end
+
+ if DIRMODE
+ Dir.copy(tarfile, ".")
+ end
- if File.file?("tar2rubyscript.bat")
+ entries = Dir.entries(".")
+ entries.delete(".")
+ entries.delete("..")
+
+ if entries.length == 1
+ entry = entries.shift.dup
+ if File.directory?(entry)
+ Dir.chdir(entry)
+ end
+ end
+
+ if File.file?("tar2rubyscript.bat") and windows?
$stderr.puts "Running tar2rubyscript.bat ..."
system(".\\tar2rubyscript.bat")
end
- if File.file?("tar2rubyscript.sh")
+ if File.file?("tar2rubyscript.sh") and (linux? or cygwin?)
$stderr.puts "Running tar2rubyscript.sh ..."
system("sh -c \". ./tar2rubyscript.sh\"")
end
- $stderr.puts "Creating archive..."
+Dir.chdir("..")
- Dir.chdir("..")
+ $stderr.puts "Creating archive..."
- begin
- tar = "tar"
- archive = IO.popen("#{tar} ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
- rescue
- tar = newlocation("tar.exe")
- archive = IO.popen("#{tar} ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+ if TARMODE and PRESERVE
+ archive = File.open(tarfile, "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+ else
+ begin
+ tar = "tar"
+ archive = IO.popen("#{tar} ch *", "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+ rescue
+ tar = backslashes(newlocation("tar.exe"))
+ archive = IO.popen("#{tar} ch *", "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+ end
end
- Dir.chdir(pdir)
-end
+Dir.chdir(pdir)
if not licensefile.nil? and not licensefile.empty?
$stderr.puts "Adding license..."
diff -ur tar2rubyscript-0.4.2.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.4.2.tar.gz/tar2rubyscript/tarrubyscript.rb 2004-12-26 22:15:10.000000000 +0100
+++ tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/tarrubyscript.rb 2005-01-11 21:33:08.000000000 +0100
@@ -25,46 +25,55 @@
ShowContent = ARGV.include?("--tar2rubyscript-list")
JustExtract = ARGV.include?("--tar2rubyscript-justextract")
ToTar = ARGV.include?("--tar2rubyscript-totar")
+ Preserve = ARGV.include?("--tar2rubyscript-preserve")
end
ARGV.concat []
-ARGV.delete_if do |arg|
- arg =~ /^--tar2rubyscript-/
-end
+ARGV.delete_if{|arg| arg =~ /^--tar2rubyscript-/}
+
+ARGV << "--tar2rubyscript-preserve" if Preserve
# Tar constants
unless defined?(BLOCKSIZE)
- BLOCKSIZE = 512
+ BLOCKSIZE = 512
NAMELEN = 100
MODELEN = 8
UIDLEN = 8
GIDLEN = 8
- CHKSUMLEN = 8
+ CHKSUMLEN = 8
SIZELEN = 12
- MAGICLEN = 8
- MODTIMELEN = 12
- UNAMELEN = 32
- GNAMELEN = 32
+ MAGICLEN = 8
+ MODTIMELEN = 12
+ UNAMELEN = 32
+ GNAMELEN = 32
DEVLEN = 8
TMAGIC = "ustar"
- GNU_TMAGIC = "ustar "
+ GNU_TMAGIC = "ustar "
SOLARIS_TMAGIC = "ustar\00000"
MAGICS = [TMAGIC, GNU_TMAGIC, SOLARIS_TMAGIC]
- LF_OLDFILE = '\0'
+ LF_OLDFILE = '\0'
LF_FILE = '0'
LF_LINK = '1'
- LF_SYMLINK = '2'
+ LF_SYMLINK = '2'
LF_CHAR = '3'
- LF_BLOCK = '4'
+ LF_BLOCK = '4'
LF_DIR = '5'
LF_FIFO = '6'
- LF_CONTIG = '7'
+ LF_CONTIG = '7'
+
+ GNUTYPE_DUMPDIR = 'D'
+ GNUTYPE_LONGLINK = 'K' # Identifies the *next* file on the tape as having a long linkname.
+ GNUTYPE_LONGNAME = 'L' # Identifies the *next* file on the tape as having a long name.
+ GNUTYPE_MULTIVOL = 'M' # This is the continuation of a file that began on another volume.
+ GNUTYPE_NAMES = 'N' # For storing filenames that do not fit into the main header.
+ GNUTYPE_SPARSE = 'S' # This is for sparse files.
+ GNUTYPE_VOLHDR = 'V' # This file is a tape/volume header. Ignore it on extraction.
end
class Dir
@@ -78,9 +87,17 @@
end
Dir.chdir(pdir)
- Dir.delete(entry)
+ begin
+ Dir.delete(entry)
+ rescue => e
+ $stderr.puts e.message
+ end
else
- File.delete(entry)
+ begin
+ File.delete(entry)
+ rescue => e
+ $stderr.puts e.message
+ end
end
end
end
@@ -129,12 +146,24 @@
def initialize(header, fp)
@header = Header.new(header)
- if @header.file?
- padding = (BLOCKSIZE - (@header.size % BLOCKSIZE)) % BLOCKSIZE
-
- @data = fp.read(@header.size) if @header.size > 0
+ readdata =
+ lambda do |header|
+ padding = (BLOCKSIZE - (header.size % BLOCKSIZE)) % BLOCKSIZE
+ @data = fp.read(header.size) if header.size > 0
dummy = fp.read(padding) if padding > 0
end
+
+ readdata.call(@header)
+
+ if @header.longname?
+ gnuname = @data[0..-2]
+
+ header = fp.read(BLOCKSIZE)
+ @header = Header.new(header)
+ @header.name = gnuname
+
+ readdata.call(@header)
+ end
end
def extract
@@ -143,21 +172,19 @@
begin
Dir.mkdir(@header.name, @header.mode)
rescue SystemCallError => e
- puts "Couldn't create dir #{@header.name}: " + e.message
+ $stderr.puts "Couldn't create dir #{@header.name}: " + e.message
end
- else
- if @header.file?
- begin
- File.open(@header.name, "wb") do |fp|
- fp.write(@data)
- fp.chmod(@header.mode)
- end
- rescue => e
- puts "Couldn't create file #{@header.name}: " + e.message
+ elsif @header.file?
+ begin
+ File.open(@header.name, "wb") do |fp|
+ fp.write(@data)
+ fp.chmod(@header.mode)
end
- else
- puts "Couldn't handle entry #{@header.name}"
+ rescue => e
+ $stderr.puts "Couldn't create file #{@header.name}: " + e.message
end
+ else
+ $stderr.puts "Couldn't handle entry #{@header.name} (flag=#{@header.linkflag.inspect})."
end
#File.chown(@header.uid, @header.gid, @header.name)
@@ -168,18 +195,19 @@
def list
if not @header.name.empty?
if @header.dir?
- puts "d %s" % [@header.name]
+ $stderr.puts "d %s" % [@header.name]
elsif @header.file?
- puts "f %s (%s)" % [@header.name, @data.length]
+ $stderr.puts "f %s (%s)" % [@header.name, @header.size]
else
- puts "Couldn't handle entry #{@header.name}"
+ $stderr.puts "Couldn't handle entry #{@header.name} (flag=#{@header.linkflag.inspect})."
end
end
end
end
class Header
- attr_reader(:name, :uid, :gid, :size, :mtime, :uname, :gname, :mode)
+ attr_reader(:name, :uid, :gid, :size, :mtime, :uname, :gname, :mode, :linkflag)
+ attr_writer(:name)
def initialize(header)
fields = header.unpack('A100 A8 A8 A8 A12 A12 A8 A1 A100 A8 A32 A32 A8 A8')
@@ -222,6 +250,10 @@
def dir?
@linkflag == LF_DIR
end
+
+ def longname?
+ @linkflag == GNUTYPE_LONGNAME
+ end
end
class Content
@@ -279,7 +311,8 @@
end
def extract
- Dir.mkdir(@tempdir) if not File.exists?(@tempdir)
+ Dir.rm_rf(@tempdir) if File.exists?(@tempdir)
+ Dir.mkdir(@tempdir)
newlocation do
@@ -354,7 +387,7 @@
Dir.chdir(pdir)
end
rescue Errno::EACCES => error
- puts error
+ $stderr.puts error
end
else
File.utime(Time.now, File.mtime(entry), entry)
@@ -481,18 +514,28 @@
$:.unshift(newlocation)
$:.push(oldlocation)
+ s = ENV["PATH"].dup
+ if Dir.pwd[1..2] == ":/" # Hack ???
+ s << ";#{newlocation.gsub(/\//, "\\")}"
+ s << ";#{oldlocation.gsub(/\//, "\\")}"
+ else
+ s << ":#{newlocation}"
+ s << ":#{oldlocation}"
+ end
+ ENV["PATH"] = s
+
newlocation do
if __FILE__ == $0
- $0.replace("./init.rb")
+ $0.replace(File.expand_path("./init.rb"))
if File.file?("./init.rb")
- load "./init.rb"
+ load File.expand_path("./init.rb")
else
$stderr.puts "%s doesn't contain an init.rb ." % __FILE__
end
else
if File.file?("./init.rb")
- load "./init.rb"
+ load File.expand_path("./init.rb")
end
end
end
diff -ur tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/ev/ftools.rb tar2rubyscript-0.4.4.tar.gz/tar2rubyscript/ev/ftools.rb
--- tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/ev/ftools.rb 2005-01-13 23:06:37.000000000 +0100
+++ tar2rubyscript-0.4.4.tar.gz/tar2rubyscript/ev/ftools.rb 2005-01-19 00:06:27.000000000 +0100
@@ -28,6 +28,8 @@
end
def self.rm_rf(entry)
+ File.chmod(0755, entry)
+
if File.ftype(entry) == "directory"
pdir = Dir.pwd
diff -ur tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb tar2rubyscript-0.4.4.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb
--- tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb 2005-01-13 23:06:37.000000000 +0100
+++ tar2rubyscript-0.4.4.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb 2005-01-19 00:06:27.000000000 +0100
@@ -7,6 +7,8 @@
class Dir
def self.rm_rf(entry)
+ File.chmod(0755, entry)
+
if File.ftype(entry) == "directory"
pdir = Dir.pwd
@@ -16,9 +18,17 @@
end
Dir.chdir(pdir)
- Dir.delete(entry)
+ begin
+ Dir.delete(entry)
+ rescue => e
+ $stderr.puts e.message
+ end
else
- File.delete(entry)
+ begin
+ File.delete(entry)
+ rescue => e
+ $stderr.puts e.message
+ end
end
end
end
diff -ur tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.4.4.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.4.3.tar.gz/tar2rubyscript/tarrubyscript.rb 2005-01-11 21:33:08.000000000 +0100
+++ tar2rubyscript-0.4.4.tar.gz/tar2rubyscript/tarrubyscript.rb 2005-01-17 21:20:28.000000000 +0100
@@ -78,12 +78,14 @@
class Dir
def self.rm_rf(entry)
+ File.chmod(0755, entry)
+
if File.ftype(entry) == "directory"
pdir = Dir.pwd
Dir.chdir(entry)
Dir.new(".").each do |e|
- rm_rf(e) if not [".", ".."].include?(e)
+ Dir.rm_rf(e) if not [".", ".."].include?(e)
end
Dir.chdir(pdir)
diff -ur tar2rubyscript-0.4.4.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb
--- tar2rubyscript-0.4.4.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb 2005-01-19 00:06:27.000000000 +0100
+++ tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb 2005-03-26 18:03:51.000000000 +0100
@@ -1,9 +1,9 @@
-temp = (ENV["TMPDIR"] or ENV["TMP"] or ENV["TEMP"] or "/tmp").gsub(/\\/, "/")
+temp = File.expand_path((ENV["TMPDIR"] or ENV["TMP"] or ENV["TEMP"] or "/tmp").gsub(/\\/, "/"))
dir = "#{temp}/oldandnewlocation.#{Process.pid}"
-ENV["OLDDIR"] = Dir.pwd unless ENV.include?("OLDDIR")
-ENV["NEWDIR"] = File.dirname($0) unless ENV.include?("NEWDIR")
-ENV["TEMPDIR"] = dir unless ENV.include?("TEMPDIR")
+ENV["OLDDIR"] = Dir.pwd unless ENV.include?("OLDDIR")
+ENV["NEWDIR"] = File.expand_path(File.dirname($0)) unless ENV.include?("NEWDIR")
+ENV["TEMPDIR"] = dir unless ENV.include?("TEMPDIR")
class Dir
def self.rm_rf(entry)
diff -ur tar2rubyscript-0.4.4.tar.gz/tar2rubyscript/init.rb tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/init.rb
--- tar2rubyscript-0.4.4.tar.gz/tar2rubyscript/init.rb 2005-01-17 17:41:56.000000000 +0100
+++ tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/init.rb 2005-01-29 19:41:14.000000000 +0100
@@ -123,13 +123,11 @@
if TARMODE and PRESERVE
archive = File.open(tarfile, "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
else
- begin
- tar = "tar"
- archive = IO.popen("#{tar} ch *", "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
- rescue
- tar = backslashes(newlocation("tar.exe"))
- archive = IO.popen("#{tar} ch *", "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
- end
+ what = "*"
+ what = "*.*" if windows?
+ tar = "tar"
+ tar = backslashes(newlocation("tar.exe")) if windows?
+ archive = IO.popen("#{tar} ch #{what}", "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
end
Dir.chdir(pdir)
diff -ur tar2rubyscript-0.4.4.tar.gz/tar2rubyscript/SUMMARY tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/SUMMARY
--- tar2rubyscript-0.4.4.tar.gz/tar2rubyscript/SUMMARY 2006-03-08 17:53:08.776392438 +0100
+++ tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/SUMMARY 2005-03-26 18:03:51.000000000 +0100
@@ -0,0 +1 @@
+A Tool for Distributing Ruby Applications
diff -ur tar2rubyscript-0.4.4.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.4.4.tar.gz/tar2rubyscript/tarrubyscript.rb 2005-01-17 21:20:28.000000000 +0100
+++ tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/tarrubyscript.rb 2005-03-11 17:10:09.000000000 +0100
@@ -265,6 +265,7 @@
@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?
+ temp = File.expand_path(temp)
@tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}.#{@@count += 1}"
end
@@ -294,6 +295,7 @@
@olddir = Dir.pwd
temp = ENV["TEMP"]
temp = "/tmp" if temp.nil?
+ temp = File.expand_path(temp)
@tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}.#{@@count += 1}"
@tempdir = "#{temp}/tar2rubyscript.d.#{Process.pid}.#{@@count}"
@@ -526,6 +528,8 @@
end
ENV["PATH"] = s
+ TAR2RUBYSCRIPT = true unless defined?(TAR2RUBYSCRIPT)
+
newlocation do
if __FILE__ == $0
$0.replace(File.expand_path("./init.rb"))
diff -ur tar2rubyscript-0.4.4.tar.gz/tar2rubyscript/VERSION tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/VERSION
--- tar2rubyscript-0.4.4.tar.gz/tar2rubyscript/VERSION 2006-03-08 17:53:08.774392459 +0100
+++ tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/VERSION 2005-03-26 18:03:51.000000000 +0100
@@ -0,0 +1 @@
+0.4.5
diff -ur tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/CHANGELOG tar2rubyscript-0.4.6.tar.gz/tar2rubyscript/CHANGELOG
--- tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/CHANGELOG 2006-03-08 17:53:10.277376504 +0100
+++ tar2rubyscript-0.4.6.tar.gz/tar2rubyscript/CHANGELOG 2005-06-20 23:56:31.000000000 +0200
@@ -0,0 +1,193 @@
+----------------------------------------------------------------
+
+0.4.6 - 21.06.2005
+
+* Added both temporary directories to $: and ENV["PATH"].
+
+----------------------------------------------------------------
+
+0.4.5 - 23.03.2005
+
+* newlocation is an absolute path.
+
+* ENV["TEMP"] is an absolute path.
+
+* Files to include are searched for with *.* instead of * (on
+ Windows).
+
+* Added TAR2RUBYSCRIPT.
+
+----------------------------------------------------------------
+
+0.4.4 - 18.01.2005
+
+* Fixed a bug concerning read-only files.
+
+----------------------------------------------------------------
+
+0.4.3 - 13.01.2005
+
+* The changes made by tar2rubyscript.bat and tar2rubyscript.sh
+ aren't permanent anymore.
+
+* tar2rubyscript.bat and tar2rubyscript.sh now work for the TAR
+ archive variant as well.
+
+* Added support for long filenames in GNU TAR archives
+ (GNUTYPE_LONGNAME).
+
+* Enhanced the deleting of the temporary files.
+
+* Added support for ENV["PATH"].
+
+* Fixed a bug concerning multiple require-ing of (different)
+ init.rb's.
+
+* Fixed a bug concerning backslashes when creating the TAR
+ archive.
+
+----------------------------------------------------------------
+
+0.4.2 - 27.12.2004
+
+* Added support for multiple library RBA's.
+
+* Added the hourly touching of the files.
+
+* Added oldlocation to $: .
+
+----------------------------------------------------------------
+
+0.4.1 - 18.12.2004
+
+* Added --tar2rubyscript-list.
+
+* Put the temporary directory on top of $:, instead of at the
+ end, so the embedded libraries are preferred over the locally
+ installed libraries.
+
+* Fixed a bug when executing init.rb from within another
+ directory.
+
+----------------------------------------------------------------
+
+0.4.0 - 03.12.2004
+
+* Like packing related application files into one RBA
+ application, now you can as well pack related library files
+ into one RBA library.
+
+----------------------------------------------------------------
+
+0.3.8 - 26.03.2004
+
+* Under some circumstances, the Ruby script was replaced by the
+ tar archive when using --tar2rubyscript-totar.
+
+----------------------------------------------------------------
+
+0.3.7 - 22.02.2004
+
+* "ustar00" on Solaris isn't "ustar00", but "ustar\00000".
+
+----------------------------------------------------------------
+
+0.3.6 - 08.11.2003
+
+* Made the common test if __file__ == $0 work.
+
+----------------------------------------------------------------
+
+0.3.5 - 29.10.2003
+
+* The instance_eval solution gave me lots of troubles. Replaced
+ it with load.
+
+* --tar2rubyscript-totar added.
+
+----------------------------------------------------------------
+
+0.3.4 - 23.10.2003
+
+* I used eval has a method of the object that executes init.rb.
+ That wasn't a good name. Renamed it.
+
+* oldandnewlocation.rb added. It contains dummy procedures for
+ oldlocation and newlocation.
+
+----------------------------------------------------------------
+
+0.3.3 - 17.10.2003
+
+* No need of tar.exe anymore.
+
+----------------------------------------------------------------
+
+0.3.2 - 10.10.2003
+
+* The name of the output file is derived if it's not provided.
+
+----------------------------------------------------------------
+
+0.3.1 - 04.10.2003
+
+* Execution of tar2rubyscript.sh or tar2rubyscript.bat is
+ added.
+
+* Methods oldlocation and newlocation are added.
+
+----------------------------------------------------------------
+
+0.3 - 21.09.2003
+
+* Input can be a directory as well. (External tar needed!)
+
+----------------------------------------------------------------
+
+0.2 - 14.09.2003
+
+* Handling of --tar2rubyscript-* parameters is added.
+
+* --tar2rubyscript-justextract added.
+
+----------------------------------------------------------------
+
+0.1.5 - 09.09.2003
+
+* The ensure block (which deleted the temporary files after
+ evaluating init.rb) is transformed to an on_exit block. Now
+ the application can perform an exit and trap signals.
+
+----------------------------------------------------------------
+
+0.1.4 - 31.08.2003
+
+* After editing with edit.com on win32, files are converted
+ from LF to CRLF. So the CR's has to be removed.
+
+----------------------------------------------------------------
+
+0.1.3 - 29.08.2003
+
+* A much better (final?) patch for the previous bug. All open
+ files, opened in init.rb, are closed, before deleting them.
+
+----------------------------------------------------------------
+
+0.1.2 - 27.08.2003
+
+* A better patch for the previous bug.
+
+----------------------------------------------------------------
+
+0.1.1 - 19.08.2003
+
+* A little bug concerning file locking under Windows is fixed.
+
+----------------------------------------------------------------
+
+0.1 - 18.08.2003
+
+* First release.
+
+----------------------------------------------------------------
diff -ur tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb tar2rubyscript-0.4.6.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb
--- tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb 2005-03-26 18:03:51.000000000 +0100
+++ tar2rubyscript-0.4.6.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb 2005-06-20 23:58:05.000000000 +0200
@@ -1,9 +1,10 @@
temp = File.expand_path((ENV["TMPDIR"] or ENV["TMP"] or ENV["TEMP"] or "/tmp").gsub(/\\/, "/"))
dir = "#{temp}/oldandnewlocation.#{Process.pid}"
-ENV["OLDDIR"] = Dir.pwd unless ENV.include?("OLDDIR")
-ENV["NEWDIR"] = File.expand_path(File.dirname($0)) unless ENV.include?("NEWDIR")
-ENV["TEMPDIR"] = dir unless ENV.include?("TEMPDIR")
+ENV["OLDDIR"] = Dir.pwd unless ENV.include?("OLDDIR")
+ENV["NEWDIR"] = File.expand_path(File.dirname($0)) unless ENV.include?("NEWDIR")
+ENV["OWNDIR"] = File.expand_path(File.dirname((caller[-1] or $0).gsub(/:\d+$/, ""))) unless ENV.include?("OWNDIR")
+ENV["TEMPDIR"] = dir unless ENV.include?("TEMPDIR")
class Dir
def self.rm_rf(entry)
@@ -76,6 +77,27 @@
end
begin
+ ownlocation
+rescue NameError
+ def ownlocation(file="")
+ dir = ENV["OWNDIR"]
+ res = nil
+
+ if block_given?
+ pdir = Dir.pwd
+
+ Dir.chdir(dir)
+ res = yield
+ Dir.chdir(pdir)
+ else
+ res = File.expand_path(file, dir) unless file.nil?
+ end
+
+ res
+ end
+end
+
+begin
tmplocation
rescue NameError
dir = ENV["TEMPDIR"]
diff -ur tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/init.rb tar2rubyscript-0.4.6.tar.gz/tar2rubyscript/init.rb
--- tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/init.rb 2005-01-29 19:41:14.000000000 +0100
+++ tar2rubyscript-0.4.6.tar.gz/tar2rubyscript/init.rb 2005-05-18 18:05:10.000000000 +0200
@@ -37,11 +37,14 @@
licensefile = oldlocation(ARGV.shift)
if tarfile.nil?
+ usagescript = "init.rb"
+ usagescript = "tar2rubyscript.rb" if defined?(TAR2RUBYSCRIPT)
+
$stderr.puts <<-EOF
- Usage: ruby init.rb application.tar [application.rb [licence.txt]]
+ Usage: ruby #{usagescript} application.tar [application.rb [licence.txt]]
or
- ruby init.rb application[/] [application.rb [licence.txt]]
+ ruby #{usagescript} application[/] [application.rb [licence.txt]]
If \"application.rb\" is not provided or equals to \"-\", it will
be derived from \"application.tar\" or \"application/\".
diff -ur tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.4.6.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/tarrubyscript.rb 2005-03-11 17:10:09.000000000 +0100
+++ tar2rubyscript-0.4.6.tar.gz/tar2rubyscript/tarrubyscript.rb 2005-06-16 21:08:46.000000000 +0200
@@ -426,6 +426,20 @@
res
end
+ def tmplocation(file="")
+ if block_given?
+ pdir = Dir.pwd
+
+ Dir.chdir(@tempdir)
+ res = yield
+ Dir.chdir(pdir)
+ else
+ res = File.expand_path(file, @tempdir) if not file.nil?
+ end
+
+ res
+ end
+
def self.oldlocation(file="")
if block_given?
@@tempspace.oldlocation { yield }
@@ -441,6 +455,14 @@
@@tempspace.newlocation(file)
end
end
+
+ def self.tmplocation(file="")
+ if block_given?
+ @@tempspace.tmplocation { yield }
+ else
+ @@tempspace.tmplocation(file)
+ end
+ end
end
class Extract
@@ -506,6 +528,14 @@
end
end
+def tmplocation(file="")
+ if block_given?
+ TempSpace.tmplocation { yield }
+ else
+ TempSpace.tmplocation(file)
+ end
+end
+
if ShowContent
Content.new.list.cleanup
elsif JustExtract
@@ -515,14 +545,17 @@
else
TempSpace.new.extract.cleanup
+ $:.unshift(tmplocation)
$:.unshift(newlocation)
$:.push(oldlocation)
s = ENV["PATH"].dup
if Dir.pwd[1..2] == ":/" # Hack ???
+ s << ";#{tmplocation.gsub(/\//, "\\")}"
s << ";#{newlocation.gsub(/\//, "\\")}"
s << ";#{oldlocation.gsub(/\//, "\\")}"
else
+ s << ":#{tmplocation}"
s << ":#{newlocation}"
s << ":#{oldlocation}"
end
diff -ur tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/VERSION tar2rubyscript-0.4.6.tar.gz/tar2rubyscript/VERSION
--- tar2rubyscript-0.4.5.tar.gz/tar2rubyscript/VERSION 2005-03-26 18:03:51.000000000 +0100
+++ tar2rubyscript-0.4.6.tar.gz/tar2rubyscript/VERSION 2005-06-20 23:58:05.000000000 +0200
@@ -1 +1 @@
-0.4.5
+0.4.6
diff -ur tar2rubyscript-0.4.6.tar.gz/tar2rubyscript/CHANGELOG tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/CHANGELOG
--- tar2rubyscript-0.4.6.tar.gz/tar2rubyscript/CHANGELOG 2005-06-20 23:56:31.000000000 +0200
+++ tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/CHANGELOG 2005-06-24 01:51:23.000000000 +0200
@@ -1,5 +1,12 @@
----------------------------------------------------------------
+0.4.7 - 24.06.2005
+
+* Fixed a serious bug concerning this message: "doesn't contain
+ an init.rb" (Sorry...)
+
+----------------------------------------------------------------
+
0.4.6 - 21.06.2005
* Added both temporary directories to $: and ENV["PATH"].
diff -ur tar2rubyscript-0.4.6.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.4.6.tar.gz/tar2rubyscript/tarrubyscript.rb 2005-06-16 21:08:46.000000000 +0200
+++ tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/tarrubyscript.rb 2005-06-24 02:01:28.000000000 +0200
@@ -426,7 +426,7 @@
res
end
- def tmplocation(file="")
+ def templocation(file="")
if block_given?
pdir = Dir.pwd
@@ -456,11 +456,11 @@
end
end
- def self.tmplocation(file="")
+ def self.templocation(file="")
if block_given?
- @@tempspace.tmplocation { yield }
+ @@tempspace.templocation { yield }
else
- @@tempspace.tmplocation(file)
+ @@tempspace.templocation(file)
end
end
end
@@ -528,11 +528,11 @@
end
end
-def tmplocation(file="")
+def templocation(file="")
if block_given?
- TempSpace.tmplocation { yield }
+ TempSpace.templocation { yield }
else
- TempSpace.tmplocation(file)
+ TempSpace.templocation(file)
end
end
@@ -545,17 +545,17 @@
else
TempSpace.new.extract.cleanup
- $:.unshift(tmplocation)
+ $:.unshift(templocation)
$:.unshift(newlocation)
$:.push(oldlocation)
s = ENV["PATH"].dup
if Dir.pwd[1..2] == ":/" # Hack ???
- s << ";#{tmplocation.gsub(/\//, "\\")}"
+ s << ";#{templocation.gsub(/\//, "\\")}"
s << ";#{newlocation.gsub(/\//, "\\")}"
s << ";#{oldlocation.gsub(/\//, "\\")}"
else
- s << ":#{tmplocation}"
+ s << ":#{templocation}"
s << ":#{newlocation}"
s << ":#{oldlocation}"
end
diff -ur tar2rubyscript-0.4.6.tar.gz/tar2rubyscript/VERSION tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/VERSION
--- tar2rubyscript-0.4.6.tar.gz/tar2rubyscript/VERSION 2005-06-20 23:58:05.000000000 +0200
+++ tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/VERSION 2005-06-24 02:03:13.000000000 +0200
@@ -1 +1 @@
-0.4.6
+0.4.7
diff -ur tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/CHANGELOG tar2rubyscript-0.4.8.tar.gz/tar2rubyscript/CHANGELOG
--- tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/CHANGELOG 2005-06-24 01:51:23.000000000 +0200
+++ tar2rubyscript-0.4.8.tar.gz/tar2rubyscript/CHANGELOG 2006-03-08 17:20:08.000000000 +0100
@@ -1,5 +1,16 @@
----------------------------------------------------------------
+0.4.8 - 08.03.2006
+
+* Fixed a bug concerning looping symlinks.
+
+* Fixed a bug concerning "Too many open files".
+
+* Added support for hard links and symbolic links (not on
+ Windows).
+
+----------------------------------------------------------------
+
0.4.7 - 24.06.2005
* Fixed a serious bug concerning this message: "doesn't contain
diff -ur tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/ev/ftools.rb tar2rubyscript-0.4.8.tar.gz/tar2rubyscript/ev/ftools.rb
--- tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/ev/ftools.rb 2005-06-24 02:03:13.000000000 +0200
+++ tar2rubyscript-0.4.8.tar.gz/tar2rubyscript/ev/ftools.rb 2006-03-08 17:52:37.000000000 +0100
@@ -9,8 +9,10 @@
File.mkpath(todir)
Dir.chdir(from)
- Dir.new(".").each do |e|
- Dir.copy(e, todir+"/"+e) if not [".", ".."].include?(e)
+ Dir.open(".") do |dir|
+ dir.each do |e|
+ Dir.copy(e, todir+"/"+e) if not [".", ".."].include?(e)
+ end
end
Dir.chdir(pdir)
else
@@ -28,14 +30,19 @@
end
def self.rm_rf(entry)
- File.chmod(0755, entry)
+ begin
+ File.chmod(0755, entry)
+ rescue
+ end
if File.ftype(entry) == "directory"
pdir = Dir.pwd
Dir.chdir(entry)
- Dir.new(".").each do |e|
- Dir.rm_rf(e) if not [".", ".."].include?(e)
+ Dir.open(".") do |dir|
+ dir.each do |e|
+ Dir.rm_rf(e) if not [".", ".."].include?(e)
+ end
end
Dir.chdir(pdir)
@@ -71,8 +78,10 @@
Dir.chdir(entry)
begin
- Dir.new(".").each do |e|
- res += Dir.find(e, mask).collect{|e| entry+"/"+e} unless [".", ".."].include?(e)
+ Dir.open(".") do |dir|
+ dir.each do |e|
+ res += Dir.find(e, mask).collect{|e| entry+"/"+e} unless [".", ".."].include?(e)
+ end
end
ensure
Dir.chdir(pdir)
@@ -84,7 +93,7 @@
res += [entry] if mask.nil? or entry =~ mask
end
- res
+ res.sort
end
end
@@ -159,11 +168,44 @@
catch :stop do
ENV["PATH"].split(/#{sep}/).reverse.each do |d|
if File.directory?(d)
- Dir.new(d).each do |e|
- if e.downcase == file.downcase
- res = File.expand_path(e, d)
- throw :stop
+ Dir.open(d) do |dir|
+ dir.each do |e|
+ if (linux? and e == file) or (windows? and e.downcase == file.downcase)
+ res = File.expand_path(e, d)
+ throw :stop
+ end
+ end
+ end
+ end
+ end
+ end
+
+ res
+ end
+
+ def self.same_content?(file1, file2, blocksize=4096)
+ res = false
+
+ if File.file?(file1) and File.file?(file2)
+ res = true
+
+ data1 = nil
+ data2 = nil
+
+ File.open(file1, "rb") do |f1|
+ File.open(file2, "rb") do |f2|
+ catch :not_the_same do
+ while (data1 = f1.read(blocksize))
+ data2 = f2.read(blocksize)
+
+ unless data1 == data2
+ res = false
+
+ throw :not_the_same
+ end
end
+
+ res = false if f2.read(blocksize)
end
end
end
diff -ur tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb tar2rubyscript-0.4.8.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb
--- tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb 2005-06-24 02:03:13.000000000 +0200
+++ tar2rubyscript-0.4.8.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb 2006-03-08 17:52:37.000000000 +0100
@@ -3,7 +3,7 @@
ENV["OLDDIR"] = Dir.pwd unless ENV.include?("OLDDIR")
ENV["NEWDIR"] = File.expand_path(File.dirname($0)) unless ENV.include?("NEWDIR")
-ENV["OWNDIR"] = File.expand_path(File.dirname((caller[-1] or $0).gsub(/:\d+$/, ""))) unless ENV.include?("OWNDIR")
+ENV["APPDIR"] = File.expand_path(File.dirname((caller[-1] or $0).gsub(/:\d+$/, ""))) unless ENV.include?("APPDIR")
ENV["TEMPDIR"] = dir unless ENV.include?("TEMPDIR")
class Dir
@@ -14,8 +14,10 @@
pdir = Dir.pwd
Dir.chdir(entry)
- Dir.new(".").each do |e|
- Dir.rm_rf(e) if not [".", ".."].include?(e)
+ Dir.open(".") do |dir|
+ dir.each do |e|
+ Dir.rm_rf(e) if not [".", ".."].include?(e)
+ end
end
Dir.chdir(pdir)
@@ -77,10 +79,10 @@
end
begin
- ownlocation
+ applocation
rescue NameError
- def ownlocation(file="")
- dir = ENV["OWNDIR"]
+ def applocation(file="")
+ dir = ENV["APPDIR"]
res = nil
if block_given?
diff -ur tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/init.rb tar2rubyscript-0.4.8.tar.gz/tar2rubyscript/init.rb
--- tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/init.rb 2005-06-24 01:18:21.000000000 +0200
+++ tar2rubyscript-0.4.8.tar.gz/tar2rubyscript/init.rb 2006-02-04 00:14:13.000000000 +0100
@@ -93,7 +93,15 @@
end
if DIRMODE
- Dir.copy(tarfile, ".")
+ dir = File.dirname(tarfile)
+ file = File.basename(tarfile)
+ begin
+ tar = "tar"
+ system(backslashes("#{tar} c -C #{dir} #{file} | #{tar} x"))
+ rescue
+ tar = backslashes(newlocation("tar.exe"))
+ system(backslashes("#{tar} c -C #{dir} #{file} | #{tar} x"))
+ end
end
entries = Dir.entries(".")
@@ -130,7 +138,7 @@
what = "*.*" if windows?
tar = "tar"
tar = backslashes(newlocation("tar.exe")) if windows?
- archive = IO.popen("#{tar} ch #{what}", "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
+ archive = IO.popen("#{tar} c #{what}", "rb"){|f| [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")}
end
Dir.chdir(pdir)
diff -ur tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/LICENSE tar2rubyscript-0.4.8.tar.gz/tar2rubyscript/LICENSE
--- tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/LICENSE 2003-10-19 18:43:27.000000000 +0200
+++ tar2rubyscript-0.4.8.tar.gz/tar2rubyscript/LICENSE 2005-06-26 13:05:01.000000000 +0200
@@ -13,3 +13,6 @@
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA.
+#
+# Parts of the code for Tar2RubyScript are based on code from
+# Thomas Hurst <tom@hur.st>.
diff -ur tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/README tar2rubyscript-0.4.8.tar.gz/tar2rubyscript/README
--- tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/README 2004-12-03 23:10:19.000000000 +0100
+++ tar2rubyscript-0.4.8.tar.gz/tar2rubyscript/README 2005-08-06 09:05:44.000000000 +0200
@@ -1,19 +1,24 @@
-The best way to use Tar2RubyScript is the RB, not this TAR.GZ.
-The latter is just for playing with the internals. Both are
-available on the site.
+----------------------------------------------------------------
- Usage: ruby init.rb application.tar [application.rb [licence.txt]]
- or
- ruby init.rb application[/] [application.rb [licence.txt]]
+Tar2RubyScript transforms a directory tree, containing your
+application, into one single Ruby script, along with some code
+to handle this archive. This script can be distributed to our
+friends. When they've installed Ruby, they just have to double
+click on it and your application is up and running!
-If "application.rb" is not provided or equals to "-", it will
-be derived from "application.tar" or "application/".
+So, it's a way of executing your application, not of installing
+it. You might think of it as the Ruby version of Java's JAR...
+Let's call it an RBA (Ruby Archive).
-If a license is provided, it will be put at the beginning of
-The Application.
-
-Parts of the code for Tar2RubyScript are based on code from
-Thomas Hurst <tom@hur.st>.
+"It's Ruby's JAR..."
For more information, see
http://www.erikveen.dds.nl/tar2rubyscript/index.html .
+
+----------------------------------------------------------------
+
+The best way to use Tar2RubyScript is the RB, not this TAR.GZ.
+The latter is just for playing with the internals. Both are
+available on the site.
+
+----------------------------------------------------------------
diff -ur tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.4.8.tar.gz/tar2rubyscript/tarrubyscript.rb
--- tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/tarrubyscript.rb 2005-06-24 02:01:28.000000000 +0200
+++ tar2rubyscript-0.4.8.tar.gz/tar2rubyscript/tarrubyscript.rb 2006-02-04 00:53:35.000000000 +0100
@@ -78,14 +78,19 @@
class Dir
def self.rm_rf(entry)
- File.chmod(0755, entry)
+ begin
+ File.chmod(0755, entry)
+ rescue
+ end
if File.ftype(entry) == "directory"
pdir = Dir.pwd
Dir.chdir(entry)
- Dir.new(".").each do |e|
- Dir.rm_rf(e) if not [".", ".."].include?(e)
+ Dir.open(".") do |d|
+ d.each do |e|
+ Dir.rm_rf(e) if not [".", ".."].include?(e)
+ end
end
Dir.chdir(pdir)
@@ -170,7 +175,19 @@
def extract
if not @header.name.empty?
- if @header.dir?
+ if @header.symlink?
+ begin
+ File.symlink(@header.linkname, @header.name)
+ rescue SystemCallError => e
+ $stderr.puts "Couldn't create symlink #{@header.name}: " + e.message
+ end
+ elsif @header.link?
+ begin
+ File.link(@header.linkname, @header.name)
+ rescue SystemCallError => e
+ $stderr.puts "Couldn't create link #{@header.name}: " + e.message
+ end
+ elsif @header.dir?
begin
Dir.mkdir(@header.name, @header.mode)
rescue SystemCallError => e
@@ -196,7 +213,11 @@
def list
if not @header.name.empty?
- if @header.dir?
+ if @header.symlink?
+ $stderr.puts "s %s -> %s" % [@header.name, @header.linkname]
+ elsif @header.link?
+ $stderr.puts "l %s -> %s" % [@header.name, @header.linkname]
+ elsif @header.dir?
$stderr.puts "d %s" % [@header.name]
elsif @header.file?
$stderr.puts "f %s (%s)" % [@header.name, @header.size]
@@ -208,7 +229,7 @@
end
class Header
- attr_reader(:name, :uid, :gid, :size, :mtime, :uname, :gname, :mode, :linkflag)
+ attr_reader(:name, :uid, :gid, :size, :mtime, :uname, :gname, :mode, :linkflag, :linkname)
attr_writer(:name)
def initialize(header)
@@ -230,6 +251,7 @@
@name, @mode, @uid, @gid, @size, @mtime, @chksum, @linkflag, @linkname, @magic, @uname, @gname, @devmajor, @devminor = converted
@name.gsub!(/^\.\//, "")
+ @linkname.gsub!(/^\.\//, "")
@raw = header
rescue ArgumentError => e
@@ -239,10 +261,8 @@
raise "Magic header value #{@magic.inspect} is invalid." if not MAGICS.include?(@magic)
@linkflag = LF_FILE if @linkflag == LF_OLDFILE or @linkflag == LF_CONTIG
- @linkflag = LF_DIR if @name[-1] == '/' and @linkflag == LF_FILE
- @linkname = @linkname[1,-1] if @linkname[0] == '/'
+ @linkflag = LF_DIR if @linkflag == LF_FILE and @name[-1] == '/'
@size = 0 if @size < 0
- @name = @linkname + '/' + @name if @linkname.size > 0
end
def file?
@@ -253,6 +273,14 @@
@linkflag == LF_DIR
end
+ def symlink?
+ @linkflag == LF_SYMLINK
+ end
+
+ def link?
+ @linkflag == LF_LINK
+ end
+
def longname?
@linkflag == GNUTYPE_LONGNAME
end
@@ -262,11 +290,13 @@
@@count = 0 unless defined?(@@count)
def initialize
+ @@count += 1
+
@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?
temp = File.expand_path(temp)
- @tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}.#{@@count += 1}"
+ @tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}.#{@@count}"
end
def list
@@ -291,12 +321,14 @@
@@count = 0 unless defined?(@@count)
def initialize
+ @@count += 1
+
@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?
temp = File.expand_path(temp)
- @tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}.#{@@count += 1}"
+ @tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}.#{@@count}"
@tempdir = "#{temp}/tar2rubyscript.d.#{Process.pid}.#{@@count}"
@@tempspace = self
@@ -384,8 +416,10 @@
Dir.chdir(entry)
begin
- Dir.new(".").each do |e|
- touch(e) unless [".", ".."].include?(e)
+ Dir.open(".") do |d|
+ d.each do |e|
+ touch(e) unless [".", ".."].include?(e)
+ end
end
ensure
Dir.chdir(pdir)
@@ -549,6 +583,8 @@
$:.unshift(newlocation)
$:.push(oldlocation)
+ verbose = $VERBOSE
+ $VERBOSE = nil
s = ENV["PATH"].dup
if Dir.pwd[1..2] == ":/" # Hack ???
s << ";#{templocation.gsub(/\//, "\\")}"
@@ -560,6 +596,7 @@
s << ":#{oldlocation}"
end
ENV["PATH"] = s
+ $VERBOSE = verbose
TAR2RUBYSCRIPT = true unless defined?(TAR2RUBYSCRIPT)
diff -ur tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/VERSION tar2rubyscript-0.4.8.tar.gz/tar2rubyscript/VERSION
--- tar2rubyscript-0.4.7.tar.gz/tar2rubyscript/VERSION 2005-06-24 02:03:13.000000000 +0200
+++ tar2rubyscript-0.4.8.tar.gz/tar2rubyscript/VERSION 2006-03-08 17:52:37.000000000 +0100
@@ -1 +1 @@
-0.4.7
+0.4.8