diff -ur rubyscript2exe-none.tar.gz/rubyscript2exe/LICENSE rubyscript2exe-0.1.tar.gz/rubyscript2exe/LICENSE --- rubyscript2exe-none.tar.gz/rubyscript2exe/LICENSE 2004-06-23 00:35:18.000000000 +0200 +++ rubyscript2exe-0.1.tar.gz/rubyscript2exe/LICENSE 2003-10-17 22:08:10.000000000 +0200 @@ -0,0 +1,15 @@ +# Copyright Erik Veenstra <rubyscript2exe@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 rubyscript2exe-none.tar.gz/rubyscript2exe/README rubyscript2exe-0.1.tar.gz/rubyscript2exe/README --- rubyscript2exe-none.tar.gz/rubyscript2exe/README 2004-06-23 00:35:18.000000000 +0200 +++ rubyscript2exe-0.1.tar.gz/rubyscript2exe/README 2003-10-17 22:07:54.000000000 +0200 @@ -0,0 +1,4 @@ +Usage: ruby init.rb application[.rb] + +For more information, see +http://www.erikveen.dds.nl/rubyscript2tar/ . diff -ur rubyscript2exe-none.tar.gz/rubyscript2exe/eee.pas rubyscript2exe-0.1.tar.gz/rubyscript2exe/eee.pas --- rubyscript2exe-none.tar.gz/rubyscript2exe/eee.pas 2004-06-23 00:35:18.000000000 +0200 +++ rubyscript2exe-0.1.tar.gz/rubyscript2exe/eee.pas 2003-10-19 19:55:59.000000000 +0200 @@ -0,0 +1,216 @@ +uses + + Dos; + +type + + header = record + klasse : string[1]; + tekst : string[255]; + length : longint; + end; + + tail = record + length : longint; + number : longint; + who : string[255]; + end; + +var + + tempdir : string; + workdir : string; + me : string; + infile : file of byte; + outfile : file of byte; + eeefile : Text; + klasse : string[1]; + tekst : string[255]; + s : string[255]; + b : array[0..10000000] of byte; + h : header; + t : tail; + teller : longint; + i : longint; + dir : string; + parms : string; + +begin + + tempdir := ´c:\tmp´; + tempdir := getenv(´TEMP´); + + me := ´Dit is mij herkennigsstring´; + + parms := ´´; + for teller := 1 to paramcount do begin + if (parms = ´´) then begin + parms := paramstr(teller); + end + else begin + parms := parms + ´ ´ + paramstr(teller); + end; + end; + + filemode := 0; + + assign(infile, paramstr(0)); + reset(infile, 1); + blockread(infile, b, filesize(infile)-sizeof(t)); + blockread(infile, t, sizeof(t)); + close(infile); + + if (t.who <> me) then begin + + // Pak in. + + assign(outfile, paramstr(2)); + rewrite(outfile, 1); + + assign(eeefile, paramstr(1)); + reset(eeefile); + + assign(infile, paramstr(0)); + reset(infile, 1); + blockread(infile, b, sizeof(b), t.length); + blockwrite(outfile, b, t.length); + close(infile); + + t.number := 0; + + repeat + readln(eeefile, s); + + if (not (s = ´´) and not (copy(s, 1, 1) = ´#´)) then begin + klasse := copy(s, 1, 1); + tekst := copy(s, 3, 255); + + if (klasse = ´f´) then begin + h.klasse := klasse; + h.tekst := tekst; + + // writeln(h.klasse, ´ ´, h.tekst); + + assign(infile, h.tekst); + reset(infile, 1); + + h.length := filesize(infile); + + blockread(infile, b, sizeof(b), h.length); + + blockwrite(outfile, h, sizeof(h)); + blockwrite(outfile, b, h.length); + + close(infile); + end; + + if (klasse = ´c´) then begin + h.klasse := klasse; + h.tekst := tekst; + h.length := 0; + + // writeln(h.klasse, ´ ´, h.tekst); + + blockwrite(outfile, h, sizeof(h)); + end; + + if (klasse = ´t´) then begin + h.klasse := klasse; + h.tekst := tekst; + h.length := 0; + + // writeln(h.klasse, ´ ´, h.tekst); + + blockwrite(outfile, h, sizeof(h)); + end; + + t.number := t.number + 1; + end; + until eof(eeefile); + + t.who := me; + + blockwrite(outfile, t, sizeof(t)); + + close(eeefile); + + close(outfile); + + end + + else begin + + // Pak uit. + + randomize; + + getdir(0, dir); + chdir(tempdir); + {$I-} + repeat + str(random(1000), s); + workdir := ´eee.´ + s; + mkdir(workdir); + until (ioresult = 0); + {$I+} + + workdir := tempdir + ´\´ + workdir; + chdir(dir); + + assign(infile, paramstr(0)); + reset(infile, 1); + blockread(infile, b, t.length); + + try + + for teller := 1 to t.number do begin + blockread(infile, h, sizeof(h)); + + s := ´%tempdir%´; + i := pos(s, h.tekst); + while (i > 0) do begin + h.tekst := copy(h.tekst, 1, i-1) + workdir + copy(h.tekst, i+length(s), 255); + i := pos(s, h.tekst); + end; + + s := ´%parms%´; + i := pos(s, h.tekst); + while (i > 0) do begin + h.tekst := copy(h.tekst, 1, i-1) + parms + copy(h.tekst, i+length(s), 255); + i := pos(s, h.tekst); + end; + + // writeln(h.klasse, ´ ´, h.tekst); + + if (h.klasse = ´f´) then begin + blockread(infile, b, h.length); + + assign(outfile, workdir + ´\´ + h.tekst); + rewrite(outfile, 1); + blockwrite(outfile, b, h.length); + close(outfile); + end; + + if (h.klasse = ´c´) then begin + exec(getenv(´COMSPEC´), ´/c ´ + h.tekst); + end; + + if (h.klasse = ´t´) then begin + getdir(0, dir); + chdir(workdir); + exec(getenv(´COMSPEC´), ´/c ´ + h.tekst); + chdir(dir); + end; + end; + + finally + + close(infile); + + exec(getenv(´COMSPEC´), ´/c deltree /y ´ + workdir + ´ > nul:´); + + end; + + end; + +end. diff -ur rubyscript2exe-none.tar.gz/rubyscript2exe/ev/oldandnewlocation.rb rubyscript2exe-0.1.tar.gz/rubyscript2exe/ev/oldandnewlocation.rb --- rubyscript2exe-none.tar.gz/rubyscript2exe/ev/oldandnewlocation.rb 2004-06-23 00:35:18.000000000 +0200 +++ rubyscript2exe-0.1.tar.gz/rubyscript2exe/ev/oldandnewlocation.rb 2003-10-17 22:08:37.000000000 +0200 @@ -0,0 +1,19 @@ +def oldlocation(file="") + if block_given? + res = yield + else + res = File.expand_path(file, ".") if not file.nil? + end + + res +end + +def newlocation(file="") + if block_given? + res = yield + else + res = File.expand_path(file, ".") if not file.nil? + end + + res +end diff -ur rubyscript2exe-none.tar.gz/rubyscript2exe/init.rb rubyscript2exe-0.1.tar.gz/rubyscript2exe/init.rb --- rubyscript2exe-none.tar.gz/rubyscript2exe/init.rb 2004-06-23 00:35:18.000000000 +0200 +++ rubyscript2exe-0.1.tar.gz/rubyscript2exe/init.rb 2003-10-17 22:08:37.000000000 +0200 @@ -0,0 +1,77 @@ +require "ev/oldandnewlocation" +require "rbconfig" + +app = ARGV.shift + +Config::CONFIG["bindir"].gsub!(/\//, "\\") +Config::CONFIG["LIBRUBY_SO"].gsub!(/\//, "\\") + +olddir = oldlocation.gsub!(/\//, "\\") +newdir = newlocation.gsub!(/\//, "\\") + +if not app.nil? + app = app.dup.gsub(/\.rb$/, "") + + puts "Gathering files..." + + system("copy #{Config::CONFIG["bindir"]}\\ruby.exe . > nul:") + system("copy #{Config::CONFIG["bindir"]}\\rubyw.exe . > nul:") + system("copy #{Config::CONFIG["bindir"]}\\#{Config::CONFIG["LIBRUBY_SO"]} . > nul:") + + system("copy #{olddir}\\#{app}.rb app.rb > nul:") + + puts "Tracing #{app} ..." + + oldlocation do + tar = FileTest.file?("tar.exe") + system("copy #{newdir}\\tar.exe . > nul:") if not tar + + system("ruby -r #{newdir}\\require2tar.rb #{app}.rb #{ARGV.join(" ")}") + + system("del tar.exe > nul:") if not tar + end + + system("move #{olddir}\\rubyrequired.tar . > nul:") + + puts "Packing..." + + system("gzip #{Config::CONFIG["LIBRUBY_SO"]}") + system("gzip rubyrequired.tar") + system("gzip app.rb") + + 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 "t tar xf rubyrequired.tar" + + f.puts "c %tempdir%\\ruby -I %tempdir%\\rubyrequired %tempdir%\\app.rb %parms%" + end + + if FileTest.file?("c:\\gnu\\root\\bin\\win32\\fpc.exe") + puts "Creating eee.exe ..." + + system("c:\\gnu\\root\\bin\\win32\\fpc.exe -gl -S2 eee") + system("copy eee.exe s:\\ > nul:") + end + + puts "Creating #{app}.exe ..." + + system("eee.exe app.eee #{olddir}\\#{app}.exe") + + system("del ruby.exe") + system("del rubyw.exe") + system("del #{Config::CONFIG["LIBRUBY_SO"]}.gz") + system("del rubyrequired.tar.gz") + system("del app.rb.gz") + system("del app.eee") +end diff -ur rubyscript2exe-none.tar.gz/rubyscript2exe/require2tar.rb rubyscript2exe-0.1.tar.gz/rubyscript2exe/require2tar.rb --- rubyscript2exe-none.tar.gz/rubyscript2exe/require2tar.rb 2004-06-23 00:35:18.000000000 +0200 +++ rubyscript2exe-0.1.tar.gz/rubyscript2exe/require2tar.rb 2003-10-17 22:08:37.000000000 +0200 @@ -0,0 +1,110 @@ +JustCopy = ARGV.include?("--require2tar-justcopy") +JustEV = ARGV.include?("--require2tar-justev") + +ARGV.delete_if do |arg| + arg =~ /^--require2tar-/ +end + +at_exit do + include Require + + createtar +end + +module Require + + def createtar + temp = ENV["TEMP"] + temp = "/tmp" if temp.nil? + tmpdir = File.expand_path("rubyrequired2tar.#{Process.pid}", temp) + tardir = "rubyrequired" + tarfile = "rubyrequired.tar" + todir = File.expand_path(tardir, tmpdir) + + mkdirs("#{todir}/") + + $".delete_if{|req| not req =~ /^ev\//} if JustEV + + $".each do |req| + found = false + + $:.each do |lib| + if not found + file = File.expand_path(req, lib) + if FileTest.file?(file) + found = true + fromfile = file + tofile = File.expand_path(req, todir) + tofile = req if JustCopy + + #puts "Found #{fromfile} ." + + copy(fromfile, tofile) + end + end + end + + if not found + puts "Can´t find #{req} ." + end + end + + if not JustCopy + copy("tar.exe", File.expand_path("tar.exe", tmpdir)) if FileTest.file?("tar.exe") + + pdir = Dir.pwd + s = "tar chf #{File.expand_path(tarfile)} #{tardir}" + Dir.chdir(tmpdir) + puts "Creating #{tarfile} ..." + + system(s) + Dir.chdir(pdir) + end + + recursivedelete(tmpdir) + end + + def copy(fromfile, tofile) + mkdirs(tofile) + + if not FileTest.file?(tofile) + File.open(tofile, "wb") do |f| + f.write(File.new(fromfile, "rb").read) + end + end + end + + def mkdirs(file) + dir, file = file.gsub(/[\/\\]/, "/").split(/\//, 2) + + if not file.nil? + dir = "#{dir}/" + + Dir.mkdir(dir) if not FileTest.directory?(dir) + + pdir = Dir.pwd + Dir.chdir(dir) + mkdirs(file) + Dir.chdir(pdir) + 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 + +end diff -ur rubyscript2exe-none.tar.gz/rubyscript2exe/tar2rubyscript.rb rubyscript2exe-0.1.tar.gz/rubyscript2exe/tar2rubyscript.rb --- rubyscript2exe-none.tar.gz/rubyscript2exe/tar2rubyscript.rb 2004-06-23 00:35:18.000000000 +0200 +++ rubyscript2exe-0.1.tar.gz/rubyscript2exe/tar2rubyscript.rb 2003-10-17 22:08:37.000000000 +0200 @@ -0,0 +1,81 @@ +scriptfile = ARGV.shift +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("..") + + IO.popen("tar ch #{tarfile.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.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-none.tar.gz/rubyscript2exe/tarrubyscript.rb rubyscript2exe-0.1.tar.gz/rubyscript2exe/tarrubyscript.rb --- rubyscript2exe-none.tar.gz/rubyscript2exe/tarrubyscript.rb 2004-06-23 00:35:18.000000000 +0200 +++ rubyscript2exe-0.1.tar.gz/rubyscript2exe/tarrubyscript.rb 2003-10-17 22:08:37.000000000 +0200 @@ -0,0 +1,305 @@ +# Tar2RubyScript constants + +JustExtract = ARGV.include?("--tar2rubyscript-justextract") + +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 ´ + +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 @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 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}" + + @newdir=@tempdir + end + + def eval + 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 + + # Execute init.rb . + + newlocation do + File.open("init.rb") do |f| + instance_eval(f.read) + end + 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 +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 + + # Create the temp environment. + + File.open(@tempfile, "wb") {|f| f.write @archive} + File.open(@tempfile, "rb") {|f| Reader.new(f).extract} + + ensure + + # Remove the temp environment. + + File.delete(@tempfile) + + end + end +end + +if JustExtract + Extract.new.extract +else + TempSpace.new.eval +end Binary files rubyscript2exe-none.tar.gz/rubyscript2exe/eee.exe and rubyscript2exe-0.1.tar.gz/rubyscript2exe/eee.exe differ Binary files rubyscript2exe-none.tar.gz/rubyscript2exe/gzip.exe and rubyscript2exe-0.1.tar.gz/rubyscript2exe/gzip.exe differ Binary files rubyscript2exe-none.tar.gz/rubyscript2exe/tar.exe and rubyscript2exe-0.1.tar.gz/rubyscript2exe/tar.exe differ