From 6d123432aa5d6a2656ebee5c56f40b4ce5cecf4d Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Thu, 29 Nov 2012 12:41:45 +0100 Subject: [PATCH 01/12] adjust example db config and tell the install script to install all databases --- config/database.yml.example | 18 +++++++++--------- setup.rb | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/config/database.yml.example b/config/database.yml.example index 96d5e4cade..80898b9405 100644 --- a/config/database.yml.example +++ b/config/database.yml.example @@ -27,13 +27,13 @@ test: password: encoding: utf8 -test_pgsql: - adapter: postgresql - database: openproject_test - host: localhost - username: postgres - password: "postgres" +#test_pgsql: + #adapter: postgresql + #database: openproject_test + #host: localhost + #username: postgres + #password: "postgres" -test_sqlite3: - adapter: sqlite3 - database: db/test.sqlite3 +#test_sqlite3: + #adapter: sqlite3 + #database: db/test.sqlite3 diff --git a/setup.rb b/setup.rb index c61f180c07..b09cc9c0cd 100755 --- a/setup.rb +++ b/setup.rb @@ -108,7 +108,7 @@ def setup_openproject if check_for_db_yaml p "Creating database" - return false unless system("rake db:create") and migrate_core and migrate_plugins + return false unless system("rake db:create:all") and migrate_core and migrate_plugins else return false end From d4f5b9fe0bf72059b48204580f6e1a080dd8d7a1 Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Thu, 29 Nov 2012 21:23:00 +0100 Subject: [PATCH 02/12] introduce parameters for script --- setup.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/setup.rb b/setup.rb index b09cc9c0cd..594df1a9a9 100755 --- a/setup.rb +++ b/setup.rb @@ -1,6 +1,7 @@ #!/usr/bin/env ruby require 'yaml' +$parsed_options = nil def abort_installation! p "Something went wrong :(" @@ -59,6 +60,24 @@ def check_for_db_yaml end end +def parse_argv(option) + return $parsed_options if $parsed_options + + params_hash = {} + + name = nil + ARGV.each do |param| + if param[0,2] == "--" + name = param + params_hash[name] = [] + else + params_hash[name] << param + end + end + + $parsed_options = params_hash[option] ? params_hash[option].inject(""){|result,a| result + a + " "} : "" +end + def checkout_default_plugins exec_dir = Dir.pwd + "/vendor" plugin_install_dir = Dir.pwd + "/vendor/plugins/" From 61372daca3414b18f40a38de5cc6d94fcda7d9d2 Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Thu, 29 Nov 2012 21:23:23 +0100 Subject: [PATCH 03/12] support without options for bundler --- setup.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.rb b/setup.rb index 594df1a9a9..298edfb04e 100755 --- a/setup.rb +++ b/setup.rb @@ -120,7 +120,7 @@ end def setup_openproject p "Installing Gems via Bundler" - unless system("bundle install --without rmagick") + unless system("bundle install --without rmagick " + parse_argv("--without")) return false end From 4666e5b0c68aa6387537e21bc3a06ee3882ece85 Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Thu, 29 Nov 2012 21:24:44 +0100 Subject: [PATCH 04/12] support forced install where database is dropped and plugin files are deleted and re-checked out --- setup.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/setup.rb b/setup.rb index 298edfb04e..d580442aa6 100755 --- a/setup.rb +++ b/setup.rb @@ -1,6 +1,8 @@ #!/usr/bin/env ruby require 'yaml' +require 'fileutils' + $parsed_options = nil def abort_installation! @@ -90,6 +92,14 @@ def checkout_default_plugins Dir.chdir exec_dir plugin_path = File.join(exec_dir, key) + + if parse_argv("--force") and File.exists?(plugin_path) + + puts "Deleting #{plugin_path}.." + FileUtils.rm_rf(plugin_path) + return false + end + if mod_config.keys.include?("repository") and not File.exists?(plugin_path) system "git clone #{mod_config["repository"]} #{key}" end @@ -125,7 +135,11 @@ def setup_openproject end if check_for_db_yaml - p "Creating database" + puts "Creating database" + + if parse_argv("--force") + return false unless system("rake db:drop:all") + end return false unless system("rake db:create:all") and migrate_core and migrate_plugins else From 492898a1e62f9d2e3df734f9e000c303775c7a11 Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Thu, 29 Nov 2012 21:28:06 +0100 Subject: [PATCH 05/12] abort program correctly --- setup.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/setup.rb b/setup.rb index d580442aa6..e3a992b440 100755 --- a/setup.rb +++ b/setup.rb @@ -171,18 +171,17 @@ def install check_ruby_version - if not check_bundler or not check_git - abort_installation! + if not check_bundler or not check_git # check for dependencies + return abort_installation! end - unless checkout_default_plugins - abort_installation! + unless checkout_default_plugins # clone plugins + return abort_installation! end Dir.chdir ROOT - return abort_installation! unless setup_openproject - p "Installation Succeeded" + return abort_installation! unless setup_openproject # Start installation end ROOT = Dir.pwd From 58e30107502debfb9b357db8b9ea53c253aeaa43 Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Thu, 29 Nov 2012 21:29:19 +0100 Subject: [PATCH 06/12] remove unused code --- setup.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/setup.rb b/setup.rb index e3a992b440..f330abe54d 100755 --- a/setup.rb +++ b/setup.rb @@ -150,12 +150,6 @@ def setup_openproject system("rake generate_session_store") end -def bundle_default_plugins - unless system("bundle install --without rmagick") - return false - end -end - def migrate_plugins p "Migrate Plugins" return system("rake db:migrate:plugins") From 04bbf8480e3f90a6403a1b1b300c882b3680a386 Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Thu, 29 Nov 2012 21:30:11 +0100 Subject: [PATCH 07/12] replace p with puts for nice logging --- setup.rb | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/setup.rb b/setup.rb index f330abe54d..10c0e88e3b 100755 --- a/setup.rb +++ b/setup.rb @@ -6,56 +6,56 @@ require 'fileutils' $parsed_options = nil def abort_installation! - p "Something went wrong :(" - p "Installation aborted." + puts "Something went wrong :(" + puts "Installation aborted." return false end def check_ruby_version - p "Checking Ruby Version" + puts "Checking Ruby Version" ruby_version = `ruby --version` version_check = ruby_version.scan("ruby 1.8.7") patchlevel_check = ruby_version.scan("patchlevel 370") if version_check.empty? - p "It seems you are not using the recommended ruby version." - p "Please make sure you have installed 'ruby 1.8.7 (2012-02-08 patchlevel 370)'" + puts "It seems you are not using the recommended ruby version." + puts "Please make sure you have installed 'ruby 1.8.7 (2012-02-08 patchlevel 370)'" elsif patchlevel_check.empty? - p "It seems you are not running the recommended patch level." - p "To avoid unexpected problems we would recommend to install 'ruby 1.8.7 (2012-02-08 patchlevel 370)'" + puts "It seems you are not running the recommended patch level." + puts "To avoid unexpected problems we would recommend to install 'ruby 1.8.7 (2012-02-08 patchlevel 370)'" else - p "Found" + puts "Found" end end def check_bundler - p "Checking Bundler" + puts "Checking Bundler" unless system "bundle --version > /dev/null" - p "It seems bundler is not installed. Please install bundler before running setup.rb." - p "For bundler and more information visit: http://gembundler.com/" + puts "It seems bundler is not installed. Please install bundler before running setup.rb." + puts "For bundler and more information visit: http://gembundler.com/" return false else - p "Found" + puts "Found" return true end end def check_git - p "Checking git" + puts "Checking git" unless system "git --version > /dev/null" - p "It seems git is not installed. Please install git before running setup.rb." + puts "It seems git is not installed. Please install git before running setup.rb." return false else - p "Found" + puts "Found" return true end end def check_for_db_yaml unless File.exists?(ROOT + '/config/database.yml') - p "Please configure your database before installing openProject." - p "Create and configure config/database.yml to do that." + puts "Please configure your database before installing openProject." + puts "Create and configure config/database.yml to do that." return false else return true @@ -128,8 +128,7 @@ def checkout_default_plugins end def setup_openproject - p "Installing Gems via Bundler" - + puts "Installing Gems via Bundler" unless system("bundle install --without rmagick " + parse_argv("--without")) return false end @@ -146,22 +145,22 @@ def setup_openproject return false end - p "Generate Session Store" + puts "Generate Session Store" system("rake generate_session_store") end def migrate_plugins - p "Migrate Plugins" + puts "Migrate Plugins" return system("rake db:migrate:plugins") end def migrate_core - p "Migrate Core" + puts "Migrate Core" return system("rake db:migrate") end def install - p 'Installing openProject...' + puts 'Installing openProject...' check_ruby_version @@ -176,6 +175,7 @@ def install Dir.chdir ROOT return abort_installation! unless setup_openproject # Start installation + puts "Installation Succeeded" end ROOT = Dir.pwd From 2960e27231620be75fa6fea9e601c7e1176e97b7 Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Thu, 29 Nov 2012 21:50:47 +0100 Subject: [PATCH 08/12] return nil to support bool options --- setup.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.rb b/setup.rb index 10c0e88e3b..cc796573af 100755 --- a/setup.rb +++ b/setup.rb @@ -77,7 +77,7 @@ def parse_argv(option) end end - $parsed_options = params_hash[option] ? params_hash[option].inject(""){|result,a| result + a + " "} : "" + $parsed_options = params_hash[option] ? params_hash[option].inject(""){|result,a| result + a + " "} : nil end def checkout_default_plugins From c3ccb3b1f3a36900897d4f8165abc6f64ad218a6 Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Fri, 30 Nov 2012 10:29:17 +0100 Subject: [PATCH 09/12] remove debug code --- setup.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.rb b/setup.rb index cc796573af..f912c87f42 100755 --- a/setup.rb +++ b/setup.rb @@ -97,7 +97,6 @@ def checkout_default_plugins puts "Deleting #{plugin_path}.." FileUtils.rm_rf(plugin_path) - return false end if mod_config.keys.include?("repository") and not File.exists?(plugin_path) From 507d4f8dc0881797b0587aa14dbadb6342073ed7 Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Fri, 30 Nov 2012 10:30:06 +0100 Subject: [PATCH 10/12] execute force only once for all plugins --- setup.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.rb b/setup.rb index f912c87f42..7963650dd8 100755 --- a/setup.rb +++ b/setup.rb @@ -87,14 +87,14 @@ def checkout_default_plugins config = YAML.load_file(default_plugin_file) + forced = parse_argv("--force") config.each_pair do |key, mod_config| Dir.chdir exec_dir plugin_path = File.join(exec_dir, key) - if parse_argv("--force") and File.exists?(plugin_path) - + if forced and File.exists?(plugin_path) puts "Deleting #{plugin_path}.." FileUtils.rm_rf(plugin_path) end From 3f6d1d6f4262be4cae0c6f030cd71395eca00ef7 Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Fri, 30 Nov 2012 10:31:17 +0100 Subject: [PATCH 11/12] bugfixing - without option now works with more than one gem --- setup.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/setup.rb b/setup.rb index 7963650dd8..a6064126e1 100755 --- a/setup.rb +++ b/setup.rb @@ -62,8 +62,12 @@ def check_for_db_yaml end end +def concatenate_options(parsed_options, option) + return parsed_options[option] ? parsed_options[option].inject(""){|result,a| result + a + " "} : nil +end + def parse_argv(option) - return $parsed_options if $parsed_options + return concatenate_options($parsed_options, option) if $parsed_options params_hash = {} @@ -77,7 +81,8 @@ def parse_argv(option) end end - $parsed_options = params_hash[option] ? params_hash[option].inject(""){|result,a| result + a + " "} : nil + $parsed_options = params_hash + return concatenate_options($parsed_options, option) end def checkout_default_plugins @@ -128,10 +133,11 @@ end def setup_openproject puts "Installing Gems via Bundler" - unless system("bundle install --without rmagick " + parse_argv("--without")) + unless system("bundle install --without rmagick " + parse_argv("--without").to_s) return false end + if check_for_db_yaml puts "Creating database" From 0cfb355980a1b291e00d6711ac54e9d8139bb639 Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Fri, 30 Nov 2012 10:36:27 +0100 Subject: [PATCH 12/12] make output look fresh --- setup.rb | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/setup.rb b/setup.rb index a6064126e1..a7b460480e 100755 --- a/setup.rb +++ b/setup.rb @@ -3,59 +3,60 @@ require 'yaml' require 'fileutils' +$output_prefix = "==> " $parsed_options = nil def abort_installation! - puts "Something went wrong :(" - puts "Installation aborted." + puts $output_prefix + "Something went wrong :(" + puts $output_prefix + "Installation aborted." return false end def check_ruby_version - puts "Checking Ruby Version" + puts $output_prefix + "Checking Ruby Version" ruby_version = `ruby --version` version_check = ruby_version.scan("ruby 1.8.7") patchlevel_check = ruby_version.scan("patchlevel 370") if version_check.empty? - puts "It seems you are not using the recommended ruby version." - puts "Please make sure you have installed 'ruby 1.8.7 (2012-02-08 patchlevel 370)'" + puts $output_prefix + "It seems you are not using the recommended ruby version." + puts $output_prefix + "Please make sure you have installed 'ruby 1.8.7 (2012-02-08 patchlevel 370)'" elsif patchlevel_check.empty? - puts "It seems you are not running the recommended patch level." - puts "To avoid unexpected problems we would recommend to install 'ruby 1.8.7 (2012-02-08 patchlevel 370)'" + puts $output_prefix + "It seems you are not running the recommended patch level." + puts $output_prefix + "To avoid unexpected problems we would recommend to install 'ruby 1.8.7 (2012-02-08 patchlevel 370)'" else - puts "Found" + puts $output_prefix + "Found" end end def check_bundler - puts "Checking Bundler" + puts $output_prefix + "Checking Bundler" unless system "bundle --version > /dev/null" - puts "It seems bundler is not installed. Please install bundler before running setup.rb." - puts "For bundler and more information visit: http://gembundler.com/" + puts $output_prefix + "It seems bundler is not installed. Please install bundler before running setup.rb." + puts $output_prefix + "For bundler and more information visit: http://gembundler.com/" return false else - puts "Found" + puts $output_prefix + "Found" return true end end def check_git - puts "Checking git" + puts $output_prefix + "Checking git" unless system "git --version > /dev/null" - puts "It seems git is not installed. Please install git before running setup.rb." + puts $output_prefix + "It seems git is not installed. Please install git before running setup.rb." return false else - puts "Found" + puts $output_prefix + "Found" return true end end def check_for_db_yaml unless File.exists?(ROOT + '/config/database.yml') - puts "Please configure your database before installing openProject." - puts "Create and configure config/database.yml to do that." + puts $output_prefix + "Please configure your database before installing OpenProject." + puts $output_prefix + "Create and configure config/database.yml to do that." return false else return true @@ -100,7 +101,7 @@ def checkout_default_plugins if forced and File.exists?(plugin_path) - puts "Deleting #{plugin_path}.." + puts $output_prefix + "Deleting #{plugin_path}.." FileUtils.rm_rf(plugin_path) end @@ -132,14 +133,14 @@ def checkout_default_plugins end def setup_openproject - puts "Installing Gems via Bundler" + puts $output_prefix + "Installing Gems via Bundler" unless system("bundle install --without rmagick " + parse_argv("--without").to_s) return false end if check_for_db_yaml - puts "Creating database" + puts $output_prefix + "Creating database" if parse_argv("--force") return false unless system("rake db:drop:all") @@ -150,22 +151,22 @@ def setup_openproject return false end - puts "Generate Session Store" + puts $output_prefix + "Generate Session Store" system("rake generate_session_store") end def migrate_plugins - puts "Migrate Plugins" + puts $output_prefix + "Migrate Plugins" return system("rake db:migrate:plugins") end def migrate_core - puts "Migrate Core" + puts $output_prefix + "Migrate Core" return system("rake db:migrate") end def install - puts 'Installing openProject...' + puts $output_prefix + 'Installing OpenProject...' check_ruby_version @@ -180,7 +181,7 @@ def install Dir.chdir ROOT return abort_installation! unless setup_openproject # Start installation - puts "Installation Succeeded" + puts $output_prefix + "Installation Succeeded" end ROOT = Dir.pwd