puts puts #----------------------------- Set Globals ---------------------------- $ruby_version = "1.8.6" $installer_version = "186-27" $root_dir = Dir.getwd $root_dir.gsub!('/', '\\') puts "ROOT_DIR = #{$root_dir}" require 'package.rb' require 'utils.rb' include Utils #----------------------------- Tasks ---------------------------- task :default => [:All] task :All => [:Ruby, :RubySrc, :OpenSSL, :Apps, :GUIs, :XML_Parsers, :Database, :Win32, :Other, :OtherBinary, :Post_Build] task :Apps => [:fxri, :SciTE] task :GUIs => [:FXRuby, :OpenGL, :GLUT, :SWin, :VRuby] task :XML_Parsers => [:Expat, :XMLParser, :Hpricot] task :Database => [:RubyDBI, :DBD_ODBC] task :Win32 => [:windows_pr, :win32_file_stat, :win32_file, :win32_clipboard, :win32_dir, :win32_eventlog, :win32_process, :win32_sapi, :win32_sound] task :Other => [:log4r, :ProgrammingRuby, :ruby_fcgi] task :OtherBinary => [:Iconv, :readline, :PDCurses, :GDBM] task :Post_Build => [:patches, :check_dll, :release_notes] #----------------------------- Ruby ---------------------------- # # This is where we log the stuff # that was installed during the # bootstrap step. # task :Ruby do Package.new("ruby-mswin32", "ruby-1.8.6-p287", nil ) do TOC.add("zlib-lib", "1.2.3") TOC.add("ZLib", "0.6.0") TOC.add("RubyGems", "1.3.1") TOC.add("Rake", "0.8.1") Dir.chdir("#{$root_dir}\\local-sources"); copy("ruby.ico", "ruby") copy("rubyw.ico", "ruby") end end #----------------------------- RubySrc ---------------------------- # task :RubySrc => [:Ruby] do Package.new("RubySrc", "1.8.6-p287", "ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p287.tar.gz", "ruby-1.8.6-p287" ) do Dir.chdir("#{$root_dir}\\downloads") copy_if_dest_empty("ruby-1.8.6-p287", "ruby\\src") Dir.chdir("#{$root_dir}\\ruby\\src\\ruby-1.8.6-p287") # copy misc (Emacs) files to /misc if file_missing?('ruby\\misc\ruby-mode.el') then copy_contents('misc', 'ruby/misc') else puts '** ruby misc already installed **' end # copy samples programs if file_missing?('ruby\\samples\\RubySrc-1.8.6-p287\\sample\\biorhythm.rb') then samples("sample") else puts '** ruby samples already installed **' end end end #----------------------------- FXRuby ---------------------------- task :FXRuby => [:Ruby, :FXRuby16] task :FXRuby16 => [:Ruby] do Package.new("FXRuby", "1.6.16", "gem install fxruby -v '1.6.16' --remote --no-rdoc", NO_DIRECTORY, 'fxruby-1.6.16-x86-mswin32', '==>> ==>> HINT: Choose option "1. fxruby 1.6.16 (x86-mswin32)"' ) do end end #----------------------------- fxri ---------------------------- task :fxri => [:Ruby, :FXRuby16] do Package.new("FXri", "0.3.6", "gem install fxri -v 0.3.6 --remote", NO_DIRECTORY, 'fxri-0.3.6' ) do # fxri.rb to replace deprecated "require_gem" with "gem" file_path = "#{$root_dir}\\ruby\\lib\\ruby\\gems\\1.8\\gems\\fxri-0.3.6\\fxri.rb" edit_file(file_path) do |line| if line =~ /require_gem/ line.sub(/require_gem/, 'gem') else nil end end end end #----------------------------- FreeRIDE ---------------------------- # #task :FreeRIDE => [:Ruby] do #Package.new("FreeRIDE", # "0.9.6", # "http://rubyforge.halostatue.info/freeride/freeride-0.9.6.tar.gz", # "freeride-0.9.6" # ) do # Dir.chdir("#{$root_dir}\\downloads"); # copy_contents_if_dest_empty("freeride-0.9.6", "freeride") # optional component # Dir.chdir("#{$root_dir}\\local-sources\\freeride"); # copy("runw.bat", "freeride") # end #end #----------------------------- SciTE ---------------------------- task :SciTE => [:Ruby] do Package.new("SciTE", "1.76", "http://internap.dl.sourceforge.net/sourceforge/scintilla/wscite176.zip", "wscite" ) do Dir.chdir("#{$root_dir}\\downloads"); copy_contents_if_dest_empty("wscite", "scite") # optional component # patch ruby.properties to specify the proper path to the help file Dir.chdir("#{$root_dir}\\scite"); file_path = "#{$root_dir}\\scite\\ruby.properties" edit_file(file_path) do |line| if line =~ /c:\\apps\\ruby\\ProgrammingRuby.chm/ line.sub(/c:\\apps\\ruby\\ProgrammingRuby.chm/, '..\\doc\\ProgrammingRuby.chm') else nil end end end end #----------------------------- Notepad++ ---------------------------- #task :NotepadPP => [:Ruby] do #Package.new("Notepad++", # "3.4", # "http://easynews.dl.sourceforge.net/sourceforge/notepad-plus/npp.3.4.bin.zip", # "npp.3.4.bin" # ) do # Dir.chdir("#{$root_dir}\\downloads"); # copy_contents_if_dest_empty("npp.3.4.bin", "notepad-pp") # optional component # end #end #----------------------------- OpenGL ---------------------------- task :OpenGL => [:Ruby, :FXRuby] do Package.new("OpenGL", "0.60.0", "gem install ruby-opengl -v '0.60.0' --remote", NO_DIRECTORY, 'ruby-opengl-0.60.0-x86-mswin32' ) do end end #----------------------------- GLUT ---------------------------- task :GLUT => [:Ruby, :OpenGL] do Package.new("GLUT", "3.7.6", "http://www.xmission.com/~nate/glut/glut-3.7.6-bin.zip", "glut-3.7.6-bin" ) do if file_missing?('ruby\\bin\\glut32.dll') then copy "glut32.dll", "ruby\\bin" copy "glut32.lib", "ruby\\bin" doc("README-win32.txt") else puts '** already installed **' end end end #----------------------------- Expat ---------------------------- task :Expat => [:Ruby] do Package.new("Expat", "2.0.1", "http://easynews.dl.sourceforge.net/sourceforge/expat/expat-win32bin-2.0.1.exe", "expat_win32bin_2_0_1", nil, "==>> ==>> HINT: Install to #{$root_dir}\\downloads\\expat_win32bin_2_0_1" ) do export_includes("Expat","Source/lib") export_libs("Expat", "Bin") if (!File.exists?("#{$root_dir}\\ruby\\bin\\libexpat.dll")) then Dir.chdir('Bin'); copy("libexpat.dll", "ruby\\bin") copy("libexpatw.dll", "ruby\\bin") doc("Changes.txt", "COPYING.txt", "Doc", "README.txt") end end end #----------------------------- XMLParser ---------------------------- task :XMLParser => [:Ruby, :Expat] do Package.new("XMLParser", "0.6.8", "http://www.yoshidam.net/xmlparser-0.6.8.tar.gz", "xmlparser", nil, 'HINT: See Patch-184 directory for a modified version of xmlparser.c that corrects compile errors in version 0.6.8' ) do set_include include_for('Expat') set_lib lib_for('Expat') edit_file "extconf.rb" do |line| case line when /^cwd=`pwd`/ "cwd = Dir.pwd" when /^perl_archlib =/ "#" when /have_library\("expat"/ line.sub(/have_library\("expat"/, 'have_library("libexpat"') when /\$CFLAGS \+\=/ line.sub(/\$CFLAGS \+\=/, '$CPPFLAGS +=') else nil end end extconf '--with-xmlparse-lib='+lib_for('Expat') + ' --with-xmlparse-include=' +include_for('Expat') doc("README") samples("samples") end end #----------------------------- Hpricot ---------------------------- task :Hpricot => [:Ruby] do Package.new("Hpricot", "0.6.164", "gem install hpricot -v '0.6.164' --remote --no-rdoc", NO_DIRECTORY, 'hpricot-0.6.164-x86-mswin32', '==>> ==>> HINT: Choose option "3. hpricot 0.6.164 (x86-mswin32)"' ) do end end #----------------------------- RubyDBI ---------------------------- task :RubyDBI => [:Ruby] do Package.new("RubyDBI", "0.2.2", "http://files.rubyforge.vm.bytemark.co.uk/ruby-dbi/dbi-0.2.2.tar.gz", "dbi-0.2.2" ) do if (!File.exists?("#{$root_dir}\\ruby\\lib\\ruby\\site_ruby\\1.8\\dbi.rb")) then FileUtils.rm_f("#{$root_dir}\\bin\\sqlsh.rb") setup "--with=dbi,dbd_proxy,dbd_odbc" doc("LICENSE", "README") else puts '** already installed **' end end end #----------------------------- DBD/ODBC ---------------------------- task :DBD_ODBC => [:Ruby, :RubyDBI] do Package.new("DBD/ODBC", "0.9995", "http://www.ch-werner.de/rubyodbc/ruby-odbc-0.9995.tar.gz", "ruby-odbc-0.9995" ) do if (!File.exists?("#{$root_dir}\\ruby\\lib\\ruby\\site_ruby\\1.8\\i386-msvcrt\\odbc.so")) then sentinel = "require 'mkmf'" patch_macros = 'COMMON_HEADERS << "\n#ifndef WIN32\n#define WIN32\n#endif"' gsub_file 'extconf.rb', /(#{Regexp.escape(sentinel)})/mi do |match| "#{match}\n#{patch_macros}\n" end extconf doc("README", "doc", "COPYING","ChangeLog") else puts '** already installed **' end end end #----------------------------- libfcgi ------------------------- task :libfcgi => [:Ruby] do Package.new("libfcgi", "2.4.0", "http://fastcgi.com/dist/fcgi-2.4.0.tar.gz", "fcgi-2.4.0" ) do export_includes("libfcgi", "include") export_libs("libfcgi", "libfcgi/Release") if (!File.exist?("#{$root_dir}\\ruby\\bin\\libfcgi.dll")) then sh %{nmake -f Makefile.nt} Dir.chdir("libfcgi/Release") do copy("libfcgi.dll", "ruby\\bin") end doc("README", "LICENSE.TERMS", "doc") else puts '** already installed **' end end end #----------------------------- ruby-fcgi ----------------------- task :ruby_fcgi => [:Ruby, :libfcgi] do Package.new("ruby-fcgi", "0.8.7", "http://rubyforge.rubyuser.de/fcgi/ruby-fcgi-0.8.7.tar.gz", "ruby-fcgi-0.8.7" ) do if (!File.exist?("#{$root_dir}\\ruby\\lib\\ruby\\site_ruby\\1.8\\i386-msvcrt\\fcgi.so")) then Dir.chdir("ext/fcgi") do edit_file("extconf.rb") do |line| case line when /have_header/ 'if (have_header("fcgiapp.h") || have_header("fastcgi/fcgiapp.h")) && (have_library("fcgi", "FCGX_Accept") || have_library("libfcgi", "FCGX_Accept"))' else nil end end patch_header = "#include " patch_call = "flags = fcntl(fd, F_GETFL);" edit_file("fcgi.c") do |line| case line when /#{Regexp.escape(patch_header)}/ "#ifndef _WIN32\n#{patch_header}\n#endif\n" when /#{Regexp.escape(patch_call)}/ " /* #{patch_call} */" else nil end end extconf '--with-fcgi-lib='+lib_for('libfcgi') + ' --with-fcgi-include=' +include_for('libfcgi') end patch_signal = "trap('SIGPIPE','IGNORE')" edit_file("lib/fcgi.rb") do |line| case line when /#{Regexp.escape(patch_signal)}/ "#{patch_signal} rescue nil" else nil end end installrb "config --without-ext" installrb "install" doc("README", "README.signals", "ChangeLog") else puts '** already installed **' end end end #----------------------------- SWin ---------------------------- task :SWin => [:Ruby] do Package.new("SWin", "070409", "http://www.osk.3web.ne.jp/~nyasu/vruby/raa/vrswin070409.zip", "vrswin070409" ) do if (!File.exists?("#{$root_dir}\\ruby\\lib\\ruby\\site_ruby\\1.8\\i386-msvcrt\\swin.so")) then Dir.chdir('swin') extconf else puts '** already installed **' end end end #----------------------------- VRuby ---------------------------- task :VRuby => [:Ruby, :SWin] do Package.new("VRuby", "080229", "http://www.osk.3web.ne.jp/~nyasu/vruby/raa/vruby080229.zip", "vruby080229" ) do if (!File.exists?("#{$root_dir}\\ruby\\lib\\ruby\\site_ruby\\1.8\\vr\\vruby.rb")) then run "echo # >> vrinstall.rb" edit_file "vrinstall.rb" do |line| if line =~ /\$stdin/ "c = 'Y'" else nil end end run "#{$root_dir}\\ruby\\bin\\ruby vrinstall.rb -cui" else puts '** already installed **' end end end #----------------------------- Win32 Utils ---------------------------- def win32_util(name, version, test_filename) test_file = "ruby\\lib\\ruby\\gems\\1.8\\gems\\#{name}-#{version}-x86-mswin32\\lib\\win32\\#{test_filename}" if file_missing?(test_file) then Package.new(name, version, "gem install #{name} -v #{version} --remote", NO_DIRECTORY, '#{name}-#{version}' ) do end else TOC.add(name, version) puts puts "-------- #{name} #{version} --------" puts '** already installed **' end end task :windows_pr => [:Ruby] do win32_util("win32-api", "1.2.0", "") end task :windows_pr => [:Ruby] do win32_util("windows-api", "0.2.4", "") end task :windows_pr => [:Ruby] do win32_util("windows-pr", "0.9.3", "") end task :win32_file_stat => [:Ruby] do win32_util("win32-file-stat", "1.3.1", "file\\stat.rb") end task :win32_file => [:Ruby] do win32_util("win32-file", "0.5.5", "file.rb") end task :win32_clipboard => [:Ruby] do win32_util("win32-clipboard", "0.4.4", "clipboard.rb") end task :win32_dir => [:Ruby] do win32_util("win32-dir", "0.3.2", "dir.rb") end task :win32_eventlog => [:Ruby] do win32_util("win32-eventlog", "0.5.0", "eventlog.rb") end task :win32_process => [:Ruby] do win32_util("win32-process", "0.5.9", "process.rb") end task :win32_sapi => [:Ruby] do win32_util("win32-sapi", "0.1.4", "sapi5.rb") end task :win32_sound => [:Ruby] do win32_util("win32-sound", "0.4.1", "sound.rb") end #----------------------------- log4r ---------------------------- task :log4r => [:Ruby] do Package.new("log4r", "1.0.5", "gem install log4r -v 1.0.5 --remote", NO_DIRECTORY, 'log4r-1.0.5' ) do end end #----------------------------- ProgrammingRuby ---------------------------- task :ProgrammingRuby => [:Ruby] do name = "Programming Ruby" version = "1st Edition" puts puts "-------- #{name} #{version} --------" TOC.add(name, version) Dir.chdir($root_dir + "\\local-sources"); copy("ProgrammingRuby.chm", "ruby\\doc") end #----------------------------- OpenSSL ---------------------------- task :OpenSSL => [:Ruby] do Package.new("OpenSSL", "0.9.8d", "http://jarp.does.notwork.org/win32/openssl-0.9.8d-2-mswin32.zip", "openssl-0.9.8d-2-mswin32" ) do if file_missing?('ruby\\bin\\libeay32.dll') then copy "bin", "ruby" copy "doc", "ruby" else puts '** already installed **' end end end #----------------------------- GDBM ---------------------------- task :GDBM => [:Ruby] do Package.new("GDBM", "1.8.3-1", "http://jarp.does.notwork.org/win32/gdbm-1.8.3-1-mswin32.zip", "gdbm-1.8.3-1-mswin32" ) do if file_missing?('ruby\\bin\\gdbm.dll') then copy "bin", "ruby" copy "doc", "ruby" else puts '** already installed **' end end end #----------------------------- PDCurses ---------------------------- task :PDCurses => [:Ruby] do Package.new("PDCurses", "2.60-1", "http://jarp.does.notwork.org/win32/pdcurses-2.60-1-mswin32.zip", "pdcurses-2.60-1-mswin32" ) do if file_missing?('ruby\\bin\\pdcurses.dll') then copy "bin", "ruby" copy "doc", "ruby" else puts '** already installed **' end end end #----------------------------- readline ---------------------------- task :readline => [:Ruby] do Package.new("readline", "4.3-2", "http://jarp.does.notwork.org/win32/readline-4.3-2-mswin32.zip", "readline-4.3-2-mswin32" ) do if file_missing?('ruby\\bin\\readline.dll') then copy "bin", "ruby" copy "doc", "ruby" else puts '** already installed **' end end end #----------------------------- Iconv ---------------------------- task :Iconv => [:Ruby] do Package.new("Iconv", "1.8", "http://www.meadowy.org/meadow/dists/snapshot/old/iconv-1.8.win32.zip", "iconv-1.8.win32" ) do if file_missing?('ruby\\bin\\iconv.dll') then Dir.chdir('lib') copy "iconv.dll", "ruby\\bin" Dir.chdir('..\\util') copy "iconv.exe", "ruby\\bin" else puts '** already installed **' end end end #----------------------------- Apply Patches ---------------------------- task :patches => [:Ruby] do Package.new("Installer-Patches", "1.8.6", nil ) do # get rid of *.cmd files # the patch will replace them with location-independent batch files Dir.chdir("#{$root_dir}\\ruby\\bin") # DEPRECATED: no need to remove RubyGems files anymore. #['gem', 'gem_mirror', 'gem_server', 'gemwhich', 'gemlock', 'gemri'].each do |f| # run "del #{f}.cmd" #end run 'del fxri.*' Dir.chdir("#{$root_dir}\\local-sources\\Patch-186") do copy_contents("bat-files", "ruby\\bin") end Dir.chdir("#{$root_dir}\\local-sources\\Patch-185") do copy_contents("scite", "scite") end # cleanup paths from the generated stub scripts path = Dir.pwd Dir.chdir("#{$root_dir}\\ruby\\bin") do Dir.glob("*.bat").each do |bat| puts "patching #{bat}..." bat =~ /(.*)\.(.*$)/ script = $1 sentinel = "@\"ruby.exe\" \"#{path}/#{script}\" %1 %2 %3 %4 %5 %6 %7 %8 %9" gsub_file bat, /(#{Regexp.escape(sentinel)})/mi do |match| "@\"ruby.exe\" \"C:/Ruby/bin/#{script}\" %1 %2 %3 %4 %5 %6 %7 %8 %9" end end end # The following is getting "access denied" on opensll.so, so I have commented it out # and output a message at the end of the build saying to do this manually. #Dir.chdir("#{$root_dir}\\ruby\\lib\\ruby\\1.8\\i386-mswin32") #run 'del openssl.so' #Dir.chdir("#{$root_dir}\\local-sources\\Patch-185") #copy_contents("openssl", "ruby\\lib\\ruby\\1.8\\i386-mswin32") end end #----------------------------- Verify *dll & *.so files ---------------------------- task :check_dll => [:Ruby] do puts puts "-------- Check DLLs --------" # This will list all DLL/SO files that do not use msvcrt.dll # (VC++ 7.1 uses: msvcr71.dll) # Note: VC++ must be on the path because this runs the dumpbin utility # if "false" == ENV['check_dlls'] puts " " puts "!!! Not checking DLL versions (because ENV['check_dlls'] is false)." puts "!!! Remember to remove this when doing your final build." else FileUtils.cd($root_dir) puts "The following DLLs were not compiled with VC++ 6.0:" puts Dir["**/*.{dll,so}"].each {|so| IO.popen("dumpbin -imports #{so}"){|f| f.grep(/^\s*(ms\w+\.dll)\s*$/i){ dll=$1;puts "#{so}: #{dll}" if (/msvcrt/i !~ dll) && (/msvcp60/i !~ dll) } } } end end #----------------------------- Make Release Notes ---------------------------- task :release_notes => [:Ruby] do # # Make release notes for this version from the template # puts puts "-------- Make Release Notes --------" File.open("#{$root_dir}\\ruby\\ReleaseNotes.txt", "w") do |file| file.puts " Ruby Installer for Windows Ruby Version #{$ruby_version} Installer Version #{$installer_version} ------------------------------ RELEASE NOTES ------------------------------ Contents: Version: -------- -------- " file.puts TOC.getList().join("\n") file.puts file.puts IO.readlines("#{$root_dir}\\ReleaseNotes_suffix.txt") end FileUtils.cp("#{$root_dir}\\ChangeLog.txt", "#{$root_dir}\\ruby\\ChangeLog.txt") #################### DELETE this message when it is no longer needed ################# puts puts puts puts puts "################## A T T E N T I O N ##################" puts "################## " puts "################## Manually copy 'openssl.so' " puts "################## from 'local-sources\\Patch-185\opensll'" puts "################## to 'ruby\\lib\\ruby\\1.8\\i386-mswin32'" puts puts puts puts end