diff -ur rubyscript2exe-0.1.21.tar.gz/rubyscript2exe/README rubyscript2exe-0.2.0.tar.gz/rubyscript2exe/README --- rubyscript2exe-0.1.21.tar.gz/rubyscript2exe/README 2004-07-26 18:46:52.000000000 +0200 +++ rubyscript2exe-0.2.0.tar.gz/rubyscript2exe/README 2004-12-04 00:13:27.000000000 +0100 @@ -4,5 +4,7 @@ Usage: ruby init.rb application[.rb[w]] [--rubyscript2exe-rubyw|--rubyscript2exe-ruby] +On Linux, there´s no difference between ruby and rubyw. + For more information, see -http://www.erikveen.dds.nl/rubyscript2exe/ . +http://www.erikveen.dds.nl/rubyscript2exe/index.html . diff -ur rubyscript2exe-0.1.21.tar.gz/rubyscript2exe/eee.pas rubyscript2exe-0.2.0.tar.gz/rubyscript2exe/eee.pas --- rubyscript2exe-0.1.21.tar.gz/rubyscript2exe/eee.pas 2004-08-04 23:02:04.000000000 +0200 +++ rubyscript2exe-0.2.0.tar.gz/rubyscript2exe/eee.pas 2004-12-08 14:07:51.000000000 +0100 @@ -1,6 +1,8 @@ {$mode DELPHI} -{$R eee.res} +{$IFDEF WIN32} + {$R eee.res} +{$ENDIF} uses @@ -49,6 +51,48 @@ parms : string; quotedparms : string; justextract : boolean; + currentdir : string[255]; + + +procedure getdir2(drivenr: byte; var dir: string[255]); + +begin + + {$IFDEF LINUX} // Foutje indien bovenliggende dirs niet benaderbaar zijn. + if currentdir = ´´ then begin + if (paramcount > 3) then begin + currentdir := paramstr(4); + end + else begin + currentdir := getenv(´PWD´); // PWD wordt alleen gezet als het parent process een shell is. + end; + end; + + dir := currentdir; + {$ELSE} + getdir(drivenr, dir); + {$ENDIF} + +end; + + +procedure chdir2(dir: string[255]); + +begin + + {$IFDEF LINUX} // Foutje indien bovenliggende dirs niet benaderbaar zijn. + if copy(dir, 1, 1) <> ´/´ then begin + dir := currentdir + ´/´ + dir; + end; + + currentdir := dir; + + chdir(dir); + {$ELSE} + chdir(dir); + {$ENDIF} + +end; procedure recursivedelete(var path: string[255]); @@ -61,8 +105,8 @@ begin - getdir(0, dir); - chdir(path); + getdir2(0, dir); + chdir2(path); findfirst(´*.*´, anyfile or directory, sr); while(doserror = 0) do begin @@ -90,7 +134,7 @@ end; findclose(sr); - chdir(dir); + chdir2(dir); {$I-} rmdir(path + slash); @@ -227,8 +271,8 @@ pakin_d(outfile, ´d´, tekst, entry, t); - getdir(0, dir); - chdir(entry); + getdir2(0, dir); + chdir2(entry); findfirst(´*.*´, anyfile or directory, sr); while(doserror = 0) do begin @@ -248,7 +292,7 @@ end; findclose(sr); - chdir(dir); + chdir2(dir); end; @@ -305,7 +349,7 @@ assign(eeefile, paramstr(1)); reset(eeefile); - if (paramcount > 2) then begin + if (paramcount > 2) then begin assign(infile, paramstr(3)); t.exename := paramstr(3); end @@ -390,6 +434,7 @@ c : string; p : string; i : longint; + sr : searchrec; begin @@ -398,6 +443,16 @@ h := h; {$IFDEF LINUX} + findfirst(workdir + ´/eee.sh´, archive, sr); + if (doserror = 0) then begin + c := ´/bin/sh´; + p := ´-c "chmod +x ´ + workdir + ´/eee.sh"´; + executeprocess(c, p); + end; + {$ENDIF} + + {$IFDEF LINUX} + i := 0; c := getenv(´SHELL´); p := ´-c "´ + tekst + ´"´; {$ELSE} @@ -424,6 +479,7 @@ p : string; i : longint; dir : string[255]; + sr : searchrec; begin @@ -432,6 +488,16 @@ h := h; {$IFDEF LINUX} + findfirst(workdir + ´/eee.sh´, archive, sr); + if (doserror = 0) then begin + c := ´/bin/sh´; + p := ´-c "chmod +x ´ + workdir + ´/eee.sh"´; + executeprocess(c, p); + end; + {$ENDIF} + + {$IFDEF LINUX} + i := 0; c := getenv(´SHELL´); p := ´-c "´ + tekst + ´"´; {$ELSE} @@ -446,10 +512,10 @@ end; {$ENDIF} - getdir(0, dir); - chdir(workdir); + getdir2(0, dir); + chdir2(workdir); executeprocess(c, p); - chdir(dir); + chdir2(dir); end; @@ -460,8 +526,8 @@ randomize; - getdir(0, dir); - chdir(tempdir); + getdir2(0, dir); + chdir2(tempdir); {$I-} repeat str(random(1000), s); @@ -471,7 +537,7 @@ {$I+} workdir := tempdir + slash + workdir; - chdir(dir); + chdir2(dir); assign(infile, paramstr(0)); reset(infile, 1); @@ -582,7 +648,6 @@ tempdir := ´/tmp´ end; - me := ´EEE: Dit is mijn herkennigsstring voor het herkennen van pakin of pakuit mode.´; justextract := false; diff -ur rubyscript2exe-0.1.21.tar.gz/rubyscript2exe/ev/dependencies.rb rubyscript2exe-0.2.0.tar.gz/rubyscript2exe/ev/dependencies.rb --- rubyscript2exe-0.1.21.tar.gz/rubyscript2exe/ev/dependencies.rb 2004-08-05 00:02:39.000000000 +0200 +++ rubyscript2exe-0.2.0.tar.gz/rubyscript2exe/ev/dependencies.rb 2004-12-08 14:07:51.000000000 +0100 @@ -1,6 +1,6 @@ def dlls(file, path=File.dirname(file)) - # Only the dependencies in the same directory as the executable. + # Only the dependencies in the same directory as the executable or the given directory. todo = [] res = [] @@ -30,3 +30,44 @@ res end + +def ldds(file, notthedefaults=true) + + # All dependencies. + + todo = [] + res = [] + tempfile = "/tmp/ev.dependencies.%d.tmp" % Process.pid + + todo << File.expand_path(file) + + while todo.length > 0 + todo2 = todo + todo = [] + + todo2.each do |file| + File.copy(file, tempfile) # Libraries on Debian are no executables. + File.chmod(0755, tempfile) + + `ldd #{tempfile}`.split(/\r*\n/).collect{|line| line.split(/\s+/)[3]}.each do |lib| + if not lib.nil? and File.file?(lib) and not res.include?(lib) + todo << lib + res << lib + end + end + + File.delete(tempfile) + end + end + + # http://www.linuxbase.org/spec/refspecs/LSB_1.3.0/gLSB/gLSB/rlibraries.html + # http://www.linuxbase.org/spec/refspecs/LSB_1.3.0/IA32/spec/rlibraries.html + + lsb_common = ["libX11.so.6", "libXt.so.6", "libGL.so.1", "libXext.so.6", "libICE.so.6", "libSM.so.6", "libdl.so.2", "libcrypt.so.1", "libz.so.1", "libncurses.so.5", "libutil.so.1", "libpthread.so.0", "libpam.so.0", "libgcc_s.so.1"] + lsb_ia32 = ["libm.so.6", "libdl.so.2", "libcrypt.so.1", "libc.so.6", "libpthread.so.0", "ld-lsb.so.1"] + lsb = lsb_common + lsb_ia32 + + res.delete_if{|s| lsb.include?(File.basename(s))} if notthedefaults + + res +end diff -ur rubyscript2exe-0.1.21.tar.gz/rubyscript2exe/ev/ftools.rb rubyscript2exe-0.2.0.tar.gz/rubyscript2exe/ev/ftools.rb --- rubyscript2exe-0.1.21.tar.gz/rubyscript2exe/ev/ftools.rb 2004-08-05 00:02:39.000000000 +0200 +++ rubyscript2exe-0.2.0.tar.gz/rubyscript2exe/ev/ftools.rb 2004-12-08 14:07:51.000000000 +0100 @@ -54,9 +54,11 @@ end def self.find(entry=nil, mask=nil) - entry = @dir if entry.nil? + entry = "." if entry.nil? - entry.gsub!(/[\/\\]*$/, "") unless entry.nil? + entry = entry.gsub!(/[\/\\]*$/, "") unless entry.nil? + + mask = /^#{mask}$/i if mask.kind_of?(String) res = [] @@ -65,11 +67,19 @@ res += ["%s/" % entry] if mask.nil? or entry =~ mask - Dir.chdir(entry) - Dir.new(".").each do |e| - res += Dir.find(e, mask).collect{|e| entry+"/"+e} unless [".", ".."].include?(e) + 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 - Dir.chdir(pdir) + rescue Errno::EACCES => error + puts error + end else res += [entry] if mask.nil? or entry =~ mask end @@ -82,6 +92,7 @@ def self.rollbackup(file, mode=nil) backupfile = file + ".RB.BACKUP" controlfile = file + ".RB.CONTROL" + res = nil File.touch(file) unless File.file?(file) @@ -107,10 +118,10 @@ if block_given? if mode.nil? - yield + res = yield else File.open(file, mode) do |f| - yield(f) + res = yield(f) end end end @@ -122,11 +133,9 @@ # Return, like File.open - if block_given? - return nil - else - return File.open(file, (mode or "r")) - end + res = File.open(file, (mode or "r")) unless block_given? + + res end def self.touch(file) diff -ur rubyscript2exe-0.1.21.tar.gz/rubyscript2exe/ev/oldandnewlocation.rb rubyscript2exe-0.2.0.tar.gz/rubyscript2exe/ev/oldandnewlocation.rb --- rubyscript2exe-0.1.21.tar.gz/rubyscript2exe/ev/oldandnewlocation.rb 2004-08-05 00:02:39.000000000 +0200 +++ rubyscript2exe-0.2.0.tar.gz/rubyscript2exe/ev/oldandnewlocation.rb 2004-12-08 14:07:51.000000000 +0100 @@ -1,5 +1,27 @@ +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 @@ -42,3 +64,37 @@ 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 + + Dir.chdir(dir) + res = yield + Dir.chdir(pdir) + else + res = File.expand_path(file, dir) unless file.nil? + end + + res + end +end diff -ur rubyscript2exe-0.1.21.tar.gz/rubyscript2exe/init.rb rubyscript2exe-0.2.0.tar.gz/rubyscript2exe/init.rb --- rubyscript2exe-0.1.21.tar.gz/rubyscript2exe/init.rb 2004-08-05 00:02:02.000000000 +0200 +++ rubyscript2exe-0.2.0.tar.gz/rubyscript2exe/init.rb 2004-12-08 13:48:37.000000000 +0100 @@ -3,13 +3,27 @@ require "ev/ftools" require "rbconfig" +exit if ARGV.include?("--rubyscript2exe-exit") + def backslashes(s) s = s.gsub(/^\.\//, "").gsub(/\//, "\\\\") if windows? s end +def linux? + not windows? and not cygwin? # Hack ??? +end + +def linux? + not windows? and not cygwin? # Hack ??? +end + def windows? - not (target_os.downcase =~ /32/).nil? # Hack ??? + not (target_os.downcase =~ /32/).nil? # Hack ??? +end + +def cygwin? + not (target_os.downcase =~ /cyg/).nil? # Hack ??? end def target_os @@ -18,6 +32,20 @@ script = ARGV.shift +if script.nil? + $stderr.puts <<-EOF + + Usage: ruby init.rb application[.rb[w]] [--rubyscript2exe-rubyw|--rubyscript2exe-ruby] + + On Linux, there´s no difference between ruby and rubyw. + + For more information, see + http://www.erikveen.dds.nl/rubyscript2exe/index.html . + EOF + + exit 1 +end + rubyw = false rubyw = true if script =~ /\.rbw$/ rubyw = false if ARGV.include?("--rubyscript2exe-ruby") @@ -25,68 +53,129 @@ ARGV.delete_if{|arg| arg =~ /^--rubyscript2exe-/} -bindir = Config::CONFIG["bindir"] +bindir1 = Config::CONFIG["bindir"] +libdir1 = Config::CONFIG["libdir"] +bindir2 = tmplocation("bin/") +libdir2 = tmplocation("lib/") +appdir2 = tmplocation("app/") -if not script.nil? - script = "#{script}.rb" if not script =~ /\.rbw?$/ - app = File.basename(script.gsub(/\.rbw?$/, "")) - libdir = File.expand_path("lib") +script = "#{script}.rb" unless script =~ /\.rbw?$/ +app = File.basename(script.gsub(/\.rbw?$/, "")) - $stderr.puts "Tracing #{app}..." +$stderr.puts "Tracing #{app}..." - libs = $:.collect{|a| " -I " + a} +libs = $:.collect{|a| " -I " + a} - oldlocation do - system(backslashes("#{bindir}/ruby #{libs.join(" ")} -r ´#{newlocation("require2lib.rb")}´ ´#{script}´ ´#{libdir}´ ") + ARGV.collect{|a| "´" + a + "´"}.join(" ")) - end +oldlocation do + system(backslashes("#{bindir1}/ruby #{libs.join(" ")} -r ´#{newlocation("require2lib.rb")}´ ´#{script}´ ´#{libdir2}´ ") + ARGV.collect{|a| "´" + a + "´"}.join(" ")) +end - $stderr.puts "Copying files..." +$stderr.puts "Copying files..." - Dir.mkdir("bin") - Dir.mkdir("app") +Dir.mkdir(bindir2) unless File.directory?(bindir2) +Dir.mkdir(libdir2) unless File.directory?(libdir2) +Dir.mkdir(appdir2) unless File.directory?(appdir2) + +if linux? + rubyexe = "#{bindir1}/ruby" +else + rubyexe = "#{bindir1}/ruby.exe" + rubywexe = "#{bindir1}/rubyw.exe" +end - File.copy("#{bindir}/ruby.exe" , "bin/ruby.exe" ) - File.copy("#{bindir}/rubyw.exe" , "bin/rubyw.exe" ) - File.copy("#{oldlocation(script)}" , "app/app.rb" ) - - dlls("#{bindir}/ruby.exe").each do |dll| - file = File.basename(dll) - File.copy(dll, "bin/#{file}") - end +if linux? + tocopy = ldds(rubyexe) + tocopy << rubyexe if File.file?(rubyexe) +else + tocopy = dlls(rubyexe) + tocopy << rubyexe if File.file?(rubyexe) + tocopy << rubywexe if File.file?(rubywexe) +end - Dir.find(libdir, /\.so$/).each do |file| - dlls(file, bindir).each do |dll| - file = File.basename(dll) - File.copy(dll, "bin/#{file}") - end - end +tocopy.each do |s1| + file = File.basename(s1) + s2 = File.expand_path(file, bindir2) + + $stderr.puts "Copying #{s1} ..." + File.copy(s1, s2) unless File.file?(s2) +end + +begin + s1 = oldlocation(script) + s2 = File.expand_path("app.rb", appdir2) + + $stderr.puts "Copying #{s1} ..." + File.copy(s1, s2) unless File.file?(s2) +end + +if linux? + tocopy = Dir.find(libdir2, /\.so$/).collect{|file| ldds(file)}.flatten.sort.uniq +else + tocopy = Dir.find(libdir2, /\.so$/).collect{|file| dlls(file, bindir1)}.flatten.sort.uniq +end - $stderr.puts "Creating #{app}.exe..." +tocopy.each do |s1| + file = File.basename(s1) + s2 = File.expand_path(file, bindir2) - File.open("app.eee", "w") do |f| - f.puts "r bin" - f.puts "r lib" - f.puts "r app" + $stderr.puts "Copying #{s1} ..." + File.copy(s1, s2) unless File.file?(s2) +end - rubyexe = "ruby.exe" - rubyexe = "rubyw.exe" if rubyw +eeeexe = "eee.exe" +eeeexe = "eeew.exe" if rubyw +eeeexe = "eee.bin" if linux? +appexe = "#{app}.exe" +appexe = "#{app}.bin" if linux? +appico = "#{app}.ico" + +$stderr.puts "Creating #{appexe} ..." + +if linux? + File.open(tmplocation("eee.sh"), "w") do |f| + f.puts "PDIR=$1;shift" + f.puts "DIR=$(pwd)" + f.puts "cd $PDIR" + f.puts " chmod +x bin/ruby" + f.puts " export PATH=$(pwd)/bin:$PATH" + f.puts " export LD_LIBRARY_PATH=$(pwd)/bin:LD_LIBRARY_PATH" + f.puts "cd $DIR" + f.puts "$*" + end +end +File.open(tmplocation("app.eee"), "w") do |f| + rubyexe = "ruby.exe" + rubyexe = "rubyw.exe" if rubyw + rubyexe = "ruby" if linux? + + f.puts "r bin" + f.puts "r lib" + f.puts "f eee.sh" if linux? + f.puts "r app" + if linux? + f.puts "c source %tempdir%/eee.sh %tempdir% %tempdir%/bin/#{rubyexe} -I %tempdir%/lib %tempdir%/app/app.rb %quotedparms%" + else f.puts "c %tempdir%/bin/#{rubyexe} -I %tempdir%/lib %tempdir%/app/app.rb %quotedparms%" end +end + +from = newlocation(eeeexe) +to = tmplocation(eeeexe) - eeeexe = "eee.exe" - eeeexe = "eeew.exe" if rubyw - appexe = "#{app}.exe" - appico = "#{app}.ico" +File.copy(from, to) unless from == to +File.chmod(0755, to) if linux? - system(backslashes("./eee app.eee #{appexe} #{eeeexe}")) +tmplocation do + system(backslashes("#{(linux? or cygwin?) ? "./" : ""}#{eeeexe} app.eee #{appexe} #{eeeexe} #{Dir.pwd}")) +end - oldlocation do - from = newlocation(appexe) - to = oldlocation(appexe) +from = tmplocation(appexe) +to = oldlocation(appexe) - File.copy(from, to) unless from == to +File.copy(from, to) unless from == to +File.chmod(0755, to) if linux? - system(backslashes("reshacker -modify #{newlocation(appexe)}, #{appexe}, #{appico}, icon,appicon,")) if File.file?(appico) - end +oldlocation do + system(backslashes("reshacker -modify #{newlocation(appexe)}, #{appexe}, #{appico}, icon,appicon,")) if File.file?(appico) and (windows? or cygwin?) end diff -ur rubyscript2exe-0.1.21.tar.gz/rubyscript2exe/require2lib.rb rubyscript2exe-0.2.0.tar.gz/rubyscript2exe/require2lib.rb --- rubyscript2exe-0.1.21.tar.gz/rubyscript2exe/require2lib.rb 2004-08-05 00:02:39.000000000 +0200 +++ rubyscript2exe-0.2.0.tar.gz/rubyscript2exe/require2lib.rb 2004-12-08 14:07:51.000000000 +0100 @@ -1,9 +1,21 @@ require "ftools" require "rbconfig" +$require2lib_loaded = [] + +module Kernel + alias :old_load :load + def load(filename, wrap=false) + $require2lib_loaded << filename unless $require2lib_loaded.include?(filename) + + old_load(filename, wrap) + end +end + module Require JUSTEV = ARGV.include?("--require2lib-justev") JUSTSITE = ARGV.include?("--require2lib-justsite") + VERBOSE = ARGV.include?("--require2lib-verbose") ARGV.delete_if do |arg| arg =~ /^--require2lib-/ @@ -25,7 +37,7 @@ File.makedirs(LIBDIR) - $".each do |req| + ($" + $require2lib_loaded).each do |req| if not JUSTEV or req =~ /^ev\// catch :found do $:.each do |lib| @@ -34,10 +46,10 @@ if File.file?(fromfile) unless fromfile == tofile or fromfile == THISFILE - if JUSTSITE and fromfile.include?(SITEDIR) - $stderr.puts "Skipped #{fromfile} ." + if JUSTSITE and not fromfile.include?(SITEDIR) + $stderr.puts "Skipped #{fromfile} ." if VERBOSE else - #$stderr.puts "Found #{fromfile} ." + $stderr.puts "Found #{fromfile} ." if VERBOSE File.makedirs(File.dirname(tofile)) File.copy(fromfile, tofile) Binary files rubyscript2exe-0.1.21.tar.gz/rubyscript2exe/eee.bin and rubyscript2exe-0.2.0.tar.gz/rubyscript2exe/eee.bin differ Binary files rubyscript2exe-0.1.21.tar.gz/rubyscript2exe/eee.exe and rubyscript2exe-0.2.0.tar.gz/rubyscript2exe/eee.exe differ Binary files rubyscript2exe-0.1.21.tar.gz/rubyscript2exe/eeew.exe and rubyscript2exe-0.2.0.tar.gz/rubyscript2exe/eeew.exe differ