require "rbconfig" def linux? not windows? and not cygwin? end def windows? not (target_os.downcase =~ /32/).nil? end def cygwin? not (target_os.downcase =~ /cyg/).nil? end def target_os Config::CONFIG["target_os"] or "" end namespace :build do desc "Build a single executable Lite version" task :lite do LITE_PKG_FOLDER = "#{RAILS_ROOT}/pkg/#{PKG_NAME}_lite_#{PKG_VERSION}" TARRED_RUBY = "#{PKG_NAME}_lite_#{PKG_VERSION}".gsub(/\./, "-") if windows? FileUtils.rm_rf "#{RAILS_ROOT}/pkg" Dir.mkdir "#{RAILS_ROOT}/pkg" Dir.mkdir "#{LITE_PKG_FOLDER}" puts "Packaging all ruby into one file with tar2rubyscript..." cmd = "cmd /c tar2rubyscript #{RAILS_ROOT}" system cmd puts "Organizing files..." FileUtils.move "../#{TARRED_RUBY}.rb", "#{LITE_PKG_FOLDER}" FileUtils.copy "db/default.sqlite", "#{LITE_PKG_FOLDER}/slimarray_production.sqlite" FileUtils.copy "db/default.sqlite", "#{LITE_PKG_FOLDER}/slimarray_development.sqlite" FileUtils.copy "db/default.sqlite", "#{LITE_PKG_FOLDER}/slimarray_test.sqlite" puts "Creating executable with rubyscript2exe (press Ctrl-C when WEBrick is finished booting..." cmd = "cmd /c rubyscript2exe #{LITE_PKG_FOLDER}/#{TARRED_RUBY}.rb" system cmd FileUtils.move "#{TARRED_RUBY}.exe", "#{LITE_PKG_FOLDER}/#{PKG_NAME}_lite.exe" FileUtils.rm "#{LITE_PKG_FOLDER}/#{TARRED_RUBY}.rb" puts "Now just create a zip file from ../dist/slimarray_lite" else FileUtils.rm_rf "#{RAILS_ROOT}/pkg" Dir.mkdir "#{RAILS_ROOT}/pkg" Dir.mkdir "#{LITE_PKG_FOLDER}" puts "Packaging all ruby into one file with tar2rubyscript..." cmd = "tar2rubyscript #{RAILS_ROOT}" system cmd puts "Organizing files..." FileUtils.move "../#{TARRED_RUBY}.rb", "#{LITE_PKG_FOLDER}" FileUtils.copy "db/default.sqlite", "#{LITE_PKG_FOLDER}/slimarray_production.sqlite" FileUtils.copy "db/default.sqlite", "#{LITE_PKG_FOLDER}/slimarray_development.sqlite" FileUtils.copy "db/default.sqlite", "#{LITE_PKG_FOLDER}/slimarray_test.sqlite" puts "Creating executable with rubyscript2exe (press Ctrl-C when WEBrick is finished booting..." cmd = "rubyscript2exe #{LITE_PKG_FOLDER}/#{TARRED_RUBY}.rb" system cmd FileUtils.move "#{TARRED_RUBY}_linux", "#{LITE_PKG_FOLDER}/#{PKG_NAME}_lite_linux" FileUtils.rm "#{LITE_PKG_FOLDER}/#{TARRED_RUBY}.rb" puts "Packaging everything into a .tar.gz file..." cmd = "cd #{RAILS_ROOT}/pkg; tar zcf #{PKG_NAME}_lite_#{PKG_VERSION}.tar.gz #{PKG_NAME}_lite_#{PKG_VERSION}" system cmd end end end