diff -ur rubyscript2exe-0.1.4.tar.gz/rubyscript2exe/eee.pas rubyscript2exe-0.1.5.tar.gz/rubyscript2exe/eee.pas --- rubyscript2exe-0.1.4.tar.gz/rubyscript2exe/eee.pas 2003-10-20 21:15:29.000000000 +0200 +++ rubyscript2exe-0.1.5.tar.gz/rubyscript2exe/eee.pas 2003-10-26 18:51:45.000000000 +0100 @@ -1,3 +1,5 @@ +{$mode DELPHI} + uses Dos; @@ -27,6 +29,8 @@ klasse : string[1]; tekst : string[255]; s : string[255]; + c : string[255]; + p : string[255]; b : array[0..10000000] of byte; h : header; t : tail; @@ -212,13 +216,19 @@ end; if (h.klasse = ´c´) then begin - exec(getenv(´COMSPEC´), ´/c ´ + h.tekst); + i := pos(´ ´, h.tekst); + c := copy(h.tekst, 1, i-1); + p := copy(h.tekst, i+1, 255); + exec(c, p); end; if (h.klasse = ´t´) then begin getdir(0, dir); chdir(workdir); - exec(getenv(´COMSPEC´), ´/c ´ + h.tekst); + i := pos(´ ´, h.tekst); + c := copy(h.tekst, 1, i-1); + p := copy(h.tekst, i+1, 255); + exec(c, p); chdir(dir); end; end; diff -ur rubyscript2exe-0.1.4.tar.gz/rubyscript2exe/ev/oldandnewlocation.rb rubyscript2exe-0.1.5.tar.gz/rubyscript2exe/ev/oldandnewlocation.rb --- rubyscript2exe-0.1.4.tar.gz/rubyscript2exe/ev/oldandnewlocation.rb 2003-10-20 21:44:17.000000000 +0200 +++ rubyscript2exe-0.1.5.tar.gz/rubyscript2exe/ev/oldandnewlocation.rb 2003-10-29 17:05:57.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 rubyscript2exe-0.1.4.tar.gz/rubyscript2exe/init.rb rubyscript2exe-0.1.5.tar.gz/rubyscript2exe/init.rb --- rubyscript2exe-0.1.4.tar.gz/rubyscript2exe/init.rb 2003-10-20 21:17:22.000000000 +0200 +++ rubyscript2exe-0.1.5.tar.gz/rubyscript2exe/init.rb 2003-10-27 23:57:39.000000000 +0100 @@ -3,12 +3,21 @@ app = ARGV.shift +RubyW = ARGV.include?("--rubyscript2exe-rubyw") + +ARGV.delete_if do |arg| + arg =~ /^--rubyscript2exe-/ +end + Config::CONFIG["bindir"].gsub!(/\//, "\\") Config::CONFIG["LIBRUBY_SO"].gsub!(/\//, "\\") olddir = oldlocation.gsub!(/\//, "\\") newdir = newlocation.gsub!(/\//, "\\") +ruby = "ruby" +ruby = "rubyw" if RubyW + if not app.nil? app = app.dup.gsub(/\.rb$/, "") @@ -18,53 +27,40 @@ tar = FileTest.file?("tar.exe") system("copy #{newdir}\\tar.exe . > nul:") if not tar - system("ruby -r #{newdir}\\require2tar.rb #{app}.rb #{ARGV.join(" ")}") # eval ??? + system("#{Config::CONFIG["bindir"]}\\ruby -r #{newdir}\\require2tar.rb #{app}.rb #{ARGV.join(" ")}") # eval ??? system("del tar.exe > nul:") if not tar end puts "Gathering files..." - system("copy #{Config::CONFIG["bindir"]}\\ruby.exe . > nul:") - system("copy #{Config::CONFIG["bindir"]}\\rubyw.exe . > nul:") + system("copy #{Config::CONFIG["bindir"]}\\#{ruby}.exe . > nul:") system("copy #{Config::CONFIG["bindir"]}\\#{Config::CONFIG["LIBRUBY_SO"]} . > nul:") system("move #{olddir}\\rubyrequired.tar . > nul:") system("copy #{olddir}\\#{app}.rb app.rb > nul:") puts "Packing..." - system("gzip #{Config::CONFIG["LIBRUBY_SO"]}") - system("gzip rubyrequired.tar") - system("gzip app.rb") + system("#{Config::CONFIG["bindir"]}\\ruby tar2rubyscript.rb rubyrequired.tar") File.open("app.eee", "w") do |f| - f.puts "f gzip.exe" - f.puts "f tar.exe" - f.puts "f ruby.exe" - f.puts "f rubyw.exe" - f.puts "f #{Config::CONFIG["LIBRUBY_SO"]}.gz" - f.puts "f rubyrequired.tar.gz" - f.puts "f app.rb.gz" - - f.puts "t gzip -d #{Config::CONFIG["LIBRUBY_SO"]}.gz" - f.puts "t gzip -d rubyrequired.tar.gz" - f.puts "t gzip -d app.rb.gz" + f.puts "f #{ruby}.exe" + f.puts "f #{Config::CONFIG["LIBRUBY_SO"]}" + f.puts "f rubyrequired.rb" + f.puts "f app.rb" - f.puts "t tar xf rubyrequired.tar" + f.puts "t #{ruby} rubyrequired.rb --tar2rubyscript-justextract" - f.puts "c %tempdir%\\ruby -I %tempdir%\\rubyrequired %tempdir%\\app.rb %parms%" + f.puts "c %tempdir%\\#{ruby} -I %tempdir%\\rubyrequired %tempdir%\\app.rb %parms%" end puts "Creating #{app}.exe..." - system("eee.exe app.eee #{olddir}\\#{app}.exe") - - system("del ruby.exe > nul:") - system("del rubyw.exe > nul:") - system("del #{Config::CONFIG["LIBRUBY_SO"]}.gz > nul:") - system("del rubyrequired.tar.gz > nul:") - system("del app.rb.gz > nul:") - system("del app.eee > nul:") + if RubyW + system("eeew.exe app.eee #{olddir}\\#{app}.exe") + else + system("eee.exe app.eee #{olddir}\\#{app}.exe") + end end # def copy ??? diff -ur rubyscript2exe-0.1.4.tar.gz/rubyscript2exe/tar2rubyscript.rb rubyscript2exe-0.1.5.tar.gz/rubyscript2exe/tar2rubyscript.rb --- rubyscript2exe-0.1.4.tar.gz/rubyscript2exe/tar2rubyscript.rb 2003-10-29 17:05:58.000000000 +0100 +++ rubyscript2exe-0.1.5.tar.gz/rubyscript2exe/tar2rubyscript.rb 2003-10-29 17:05:57.000000000 +0100 @@ -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) + $stderr.puts "#{tarfile} doesn´t exist." + exit +end + +if not licensefile.nil? and not FileTest.file?(licensefile) + $stderr.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") + $stderr.puts "\".\\tar2rubyscript.bat\"" + system(".\\tar2rubyscript.bat") + end + + if FileTest.file?("tar2rubyscript.sh") + $stderr.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 rubyscript2exe-0.1.4.tar.gz/rubyscript2exe/tarrubyscript.rb rubyscript2exe-0.1.5.tar.gz/rubyscript2exe/tarrubyscript.rb --- rubyscript2exe-0.1.4.tar.gz/rubyscript2exe/tarrubyscript.rb 2003-10-29 17:05:58.000000000 +0100 +++ rubyscript2exe-0.1.5.tar.gz/rubyscript2exe/tarrubyscript.rb 2003-10-29 17:05:57.000000000 +0100 @@ -0,0 +1,365 @@ +# 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. + +# Tar2RubyScript constants + +JustExtract = ARGV.include?("--tar2rubyscript-justextract") +ToTar = ARGV.include?("--tar2rubyscript-totar") + +ARGV.concat [] + +ARGV.delete_if do |arg| + arg =~ /^--tar2rubyscript-/ +end + +# Tar constants + +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 = ´ustar00´ + +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´ + +class Reader + def initialize(filehandle) + @fp = filehandle + end + + def extract + each do |entry| + entry.extract + end + end + + def each + @fp.rewind + + while entry = next_entry + yield(entry) + end + end + + def next_entry + buf = @fp.read(BLOCKSIZE) + + if buf.length < BLOCKSIZE or buf == "\000" * BLOCKSIZE + entry = nil + else + entry = Entry.new(buf, @fp) + end + + entry + end +end + +class Entry + attr_reader(:header, :data) + + 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 + 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 #{@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 + end + else + puts "Couldn´t handle entry #{@header.name}" + end + end + + #File.chown(@header.uid, @header.gid, @header.name) + #File.utime(Time.now, @header.mtime, @header.name) + end + end +end + +class Header + attr_reader(:name, :uid, :gid, :size, :mtime, :uname, :gname, :mode) + + 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´] + + begin + converted = [] + 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 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] == ´/´ + @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 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 + @olddir = Dir.pwd + temp = ENV["TEMP"] + temp = "/tmp" if temp.nil? + @tempdir = "#{temp}/tar2rubyscript.d.#{Process.pid}" + @tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}" + + @@tempspace = self + + @newdir=@tempdir + end + + def extract + Dir.mkdir(@tempdir) if not FileTest.exists?(@tempdir) + + newlocation do + + # Create the temp environment. + + 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.dup + if FileTest.directory?(entry) + @newdir = "#{@tempdir}/#{entry}" + end + end + end + + # Remember all File objects. + + @ioobjects = [] + ObjectSpace::each_object(File) do |obj| + @ioobjects << obj + end + + at_exit do + + # Close all File objects, opened in init.rb . + + ObjectSpace::each_object(File) do |obj| + obj.close if (not obj.closed? and not @ioobjects.include?(obj)) + end + + # Remove the temp environment. + + Dir.chdir(@olddir) + + recursivedelete(@tempfile) + recursivedelete(@tempdir) + end + end + + def recursivedelete(entry) + if FileTest.file?(entry) + File.delete(entry) + end + + 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) + + Dir.rmdir(entry) + end + end + + def oldlocation(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 + + 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 + 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 + 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 + temp = ENV["TEMP"] + temp = "/tmp" if temp.nil? + @tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}" + end + + def extract + begin + File.open(@tempfile, "wb") {|f| f.write @archive} + File.open(@tempfile, "rb") {|f| Reader.new(f).extract} + ensure + File.delete(@tempfile) + end + 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(/\.rb$/, ".tar") + end + + def extract + File.open(@tarfile, "wb") {|f| f.write @archive} + 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 + if ToTar + MakeTar.new.extract + else + TempSpace.new.extract + + newlocation do + load "init.rb" + end + end +end Binary files rubyscript2exe-0.1.4.tar.gz/rubyscript2exe/eee.exe and rubyscript2exe-0.1.5.tar.gz/rubyscript2exe/eee.exe differ Binary files rubyscript2exe-0.1.4.tar.gz/rubyscript2exe/eeew.exe and rubyscript2exe-0.1.5.tar.gz/rubyscript2exe/eeew.exe differ Binary files rubyscript2exe-0.1.4.tar.gz/rubyscript2exe/gzip.exe and rubyscript2exe-0.1.5.tar.gz/rubyscript2exe/gzip.exe differ