Permalink
Browse files

Remove the explicit 'sudo' in favour of environment variable which de…

…faults to 'sudo' on non windows platforms. For a trial install this allows for the fol lowing at the

    export MERB_SUDO=echo
    rake install_gems

    But, the intent of this changes is to allow for local gem installs.  E.g. ones that don't require root access.

This version introduces a helper file: merb_rake_helper.rb to reuse the same check in the subproject Rakefiles.

Signed-off-by: Michael S. Klishin <michael@novemberain.com>
  • Loading branch information...
1 parent 7ab8e4a commit c61341aeef7c55d448ca70cc73d11de81396267c @ericdwhite ericdwhite committed with michaelklishin May 20, 2008
View
@@ -9,6 +9,7 @@ end
require "rake/clean"
require "rake/gempackagetask"
+require "merb_rake_helper"
require 'fileutils'
include FileUtils
@@ -50,9 +51,6 @@ end
CLEAN.include ["**/.*.sw?", "pkg", "lib/*.bundle", "*.gem", "doc/rdoc", ".config", "coverage", "cache", "lib/merb-more.rb"]
-windows = (PLATFORM =~ /win32|cygwin/) rescue nil
-
-SUDO = windows ? "" : "sudo"
Rake::GemPackageTask.new(merb_more_spec) do |package|
package.gem_spec = merb_more_spec
@@ -67,8 +65,8 @@ install_home = ENV['GEM_HOME'] ? "-i #{ENV['GEM_HOME']}" : ""
desc "Install it all"
task :install => [:install_gems, :package] do
- sh %{#{SUDO} gem install #{install_home} --local pkg/merb-more-#{Merb::MORE_VERSION}.gem --no-update-sources}
- sh %{#{SUDO} gem install #{install_home} --local pkg/merb-#{Merb::MORE_VERSION}.gem --no-update-sources}
+ sh %{#{sudo} gem install #{install_home} --local pkg/merb-more-#{Merb::MORE_VERSION}.gem --no-update-sources}
+ sh %{#{sudo} gem install #{install_home} --local pkg/merb-#{Merb::MORE_VERSION}.gem --no-update-sources}
end
desc "Build the merb-more gems"
@@ -88,7 +86,7 @@ end
desc "Uninstall the merb-more sub-gems"
task :uninstall_gems do
gems.each do |sub_gem|
- sh %{#{SUDO} gem uninstall #{sub_gem}}
+ sh %{#{sudo} gem uninstall #{sub_gem}}
end
end
@@ -1,5 +1,6 @@
require 'rubygems'
require 'rake/gempackagetask'
+require '../merb_rake_helper'
PLUGIN = "merb-action-args"
NAME = "merb-action-args"
@@ -34,14 +35,14 @@ end
install_home = ENV['GEM_HOME'] ? "-i #{ENV['GEM_HOME']}" : ""
task :install => [:package] do
- sh %{sudo gem install #{install_home} pkg/#{NAME}-#{VERSION} --no-update-sources}
+ sh %{#{sudo} gem install #{install_home} pkg/#{NAME}-#{VERSION} --no-update-sources}
end
namespace :jruby do
desc "Run :package and install the resulting .gem with jruby"
task :install => :package do
- sh %{#{SUDO} jruby -S gem install #{install_home} pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
+ sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
end
end
View
@@ -1,5 +1,6 @@
require 'rubygems'
require 'rake/gempackagetask'
+require '../merb_rake_helper'
PLUGIN = "merb-assets"
NAME = "merb-assets"
@@ -31,14 +32,14 @@ Rake::GemPackageTask.new(spec) do |pkg|
end
task :install => [:package] do
- sh %{sudo gem install pkg/#{NAME}-#{VERSION} --no-update-sources}
+ sh %{#{sudo} gem install pkg/#{NAME}-#{VERSION} --no-update-sources}
end
namespace :jruby do
desc "Run :package and install the resulting .gem with jruby"
task :install => :package do
- sh %{#{SUDO} jruby -S gem install pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
+ sh %{#{sudo} jruby -S gem install pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
end
end
View
@@ -1,5 +1,6 @@
require 'rubygems'
require 'rake/gempackagetask'
+require '../merb_rake_helper'
PLUGIN = "merb-builder"
NAME = "merb-builder"
@@ -34,14 +35,14 @@ end
install_home = ENV['GEM_HOME'] ? "-i #{ENV['GEM_HOME']}" : ""
task :install => [:package] do
- sh %{sudo gem install #{install_home} pkg/#{NAME}-#{VERSION} --no-update-sources}
+ sh %{#{sudo} gem install #{install_home} pkg/#{NAME}-#{VERSION} --no-update-sources}
end
namespace :jruby do
desc "Run :package and install the resulting .gem with jruby"
task :install => :package do
- sh %{#{SUDO} jruby -S gem install #{install_home} pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
+ sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
end
end
View
@@ -2,6 +2,7 @@ require 'rubygems'
require "rake/rdoctask"
require 'rake/gempackagetask'
require "spec/rake/spectask"
+require '../merb_rake_helper'
PLUGIN = "merb-cache"
NAME = "merb-cache"
@@ -66,14 +67,14 @@ end
install_home = ENV['GEM_HOME'] ? "-i #{ENV['GEM_HOME']}" : ""
task :install => [:package] do
- sh %{sudo gem install #{install_home} pkg/#{NAME}-#{MERB_CACHE_VERSION} --no-update-sources}
+ sh %{#{sudo} gem install #{install_home} pkg/#{NAME}-#{MERB_CACHE_VERSION} --no-update-sources}
end
namespace :jruby do
desc "Run :package and install the resulting .gem with jruby"
task :install => :package do
- sh %{#{SUDO} jruby -S gem install #{install_home} pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
+ sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
end
end
View
@@ -1,5 +1,6 @@
require 'rubygems'
require 'rake/gempackagetask'
+require '../merb_rake_helper'
PLUGIN = "merb-freezer"
NAME = "merb-freezer"
@@ -31,16 +32,17 @@ Rake::GemPackageTask.new(spec) do |pkg|
pkg.gem_spec = spec
end
+
desc "install merb-freezer"
task :install => [:package] do
- sh %{sudo gem install pkg/#{NAME}-#{VERSION} --no-update-sources}
+ sh %{#{sudo} gem install pkg/#{NAME}-#{VERSION} --no-update-sources}
end
namespace :jruby do
desc "Run :package and install the resulting .gem with jruby"
task :install => :package do
- sh %{#{SUDO} jruby -S gem install pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
+ sh %{#{sudo} jruby -S gem install pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
end
end
@@ -1,15 +1,11 @@
require 'find'
+require '../../../merb_rake_helper'
module FreezerMode
-
- def sudo
- windows = (PLATFORM =~ /win32|cygwin/) rescue nil
- sudo = windows ? "" : "sudo"
- end
-
+
def gitmodules
File.join(Dir.pwd, ".gitmodules")
- end
-
+ end
+
# Uses the Git submodules to freeze a component
#
def submodules_freeze
@@ -34,9 +30,9 @@ def submodules_freeze
else
puts "Creating submodule for #{@component} ..."
if framework_component?
- `cd #{Dir.pwd} & git-submodule --quiet add #{Freezer.components[@component.gsub("merb-", '')]} #{File.basename(freezer_dir)}/#{@component}`
+ `cd #{Dir.pwd} & git-submodule --quiet add #{Freezer.components[@component.gsub("merb-", '')]} #{File.basename(freezer_dir)}/#{@component}`
else
- `cd #{Dir.pwd} & git-submodule --quiet add #{@component} gems/submodules/#{@component.match(/.*\/(.*)\..{3}$/)[1]}`
+ `cd #{Dir.pwd} & git-submodule --quiet add #{@component} gems/submodules/#{@component.match(/.*\/(.*)\..{3}$/)[1]}`
end
if $?.success?
`git-submodule init`
@@ -46,7 +42,7 @@ def submodules_freeze
end
end
end
-
+
# Uses rubygems to freeze the components locally
#
def rubygems_freeze
@@ -55,14 +51,14 @@ def rubygems_freeze
puts "#{action} #{@component} and dependencies from rubygems"
`#{sudo} gem #{action} #{@component} --no-rdoc --no-ri -i #{framework_component? ? 'framework' : 'gems'}`
end
-
+
def create_freezer_dir(path)
unless File.directory?(path)
puts "Creating freezer directory ..."
FileUtils.mkdir_p(path)
end
end
-
+
protected
# returns true if submodules are used
@@ -76,10 +72,10 @@ def in_submodule?(component)
def managed?(component)
File.directory?(File.join(freezer_dir, component)) || in_submodule?(component)
end
-
+
def in_path?(bin)
`which #{bin}`
!$?.nil? && $?.success?
end
-
-end
+
+end
View
@@ -1,5 +1,6 @@
require 'rubygems'
require 'rake/gempackagetask'
+require '../merb_rake_helper'
GEM = "merb-gen"
VERSION = "0.9.4"
@@ -36,14 +37,15 @@ Rake::GemPackageTask.new(spec) do |pkg|
pkg.gem_spec = spec
end
+
install_home = ENV['GEM_HOME'] ? "-i #{ENV['GEM_HOME']}" : ""
namespace :jruby do
task :install do
- sh %{sudo jruby -S gem install #{install_home} pkg/#{GEM}-#{VERSION} --no-update-sources}
+ sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{GEM}-#{VERSION} --no-update-sources}
end
end
task :install => [:package] do
- sh %{sudo gem install #{install_home} pkg/#{GEM}-#{VERSION} --no-update-sources}
+ sh %{#{sudo} gem install #{install_home} pkg/#{GEM}-#{VERSION} --no-update-sources}
end
@@ -2,6 +2,7 @@ require 'rubygems'
require 'rake/gempackagetask'
require 'rubygems/specification'
require 'date'
+require '../merb_rake_helper'
PLUGIN = "<%= base_name %>"
NAME = "<%= base_name %>"
@@ -34,7 +35,7 @@ end
desc "install the plugin locally"
task :install => [:package] do
- sh %{sudo gem install pkg/#{NAME}-#{VERSION} --no-update-sources}
+ sh %{#{sudo} gem install pkg/#{NAME}-#{VERSION} --no-update-sources}
end
desc "create a gemspec file"
@@ -48,7 +49,7 @@ namespace :jruby do
desc "Run :package and install the resulting .gem with jruby"
task :install => :package do
- sh %{#{SUDO} jruby -S gem install pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
+ sh %{#{sudo} jruby -S gem install pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
end
-
-end
+
+end
View
@@ -1,5 +1,6 @@
require 'rubygems'
require 'rake/gempackagetask'
+require '../merb_rake_helper'
PLUGIN = "merb-haml"
NAME = "merb-haml"
@@ -34,14 +35,14 @@ end
install_home = ENV['GEM_HOME'] ? "-i #{ENV['GEM_HOME']}" : ""
task :install => [:package] do
- sh %{sudo gem install #{install_home} pkg/#{NAME}-#{VERSION} --no-update-sources}
+ sh %{#{sudo} gem install #{install_home} pkg/#{NAME}-#{VERSION} --no-update-sources}
end
namespace :jruby do
desc "Run :package and install the resulting .gem with jruby"
task :install => :package do
- sh %{#{SUDO} jruby -S gem install #{install_home} pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
+ sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
end
end
View
@@ -1,6 +1,7 @@
require 'rubygems'
require 'rake/gempackagetask'
require "spec/rake/spectask"
+require '../merb_rake_helper'
PLUGIN = "merb-mailer"
NAME = "merb-mailer"
@@ -35,14 +36,14 @@ end
install_home = ENV['GEM_HOME'] ? "-i #{ENV['GEM_HOME']}" : ""
task :install => [:package] do
- sh %{sudo gem install #{install_home} pkg/#{NAME}-#{VERSION} --no-update-sources}
+ sh %{#{sudo} gem install #{install_home} pkg/#{NAME}-#{VERSION} --no-update-sources}
end
namespace :jruby do
desc "Run :package and install the resulting .gem with jruby"
task :install => :package do
- sh %{#{SUDO} jruby -S gem install #{install_home} pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
+ sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
end
end
View
@@ -1,6 +1,7 @@
require 'rubygems'
require 'rake/gempackagetask'
require "spec/rake/spectask"
+require '../merb_rake_helper'
PLUGIN = "merb-parts"
NAME = "merb-parts"
@@ -31,17 +32,18 @@ Rake::GemPackageTask.new(spec) do |pkg|
pkg.gem_spec = spec
end
+
install_home = ENV['GEM_HOME'] ? "-i #{ENV['GEM_HOME']}" : ""
task :install => [:package] do
- sh %{sudo gem install #{install_home} pkg/#{NAME}-#{VERSION} --no-update-sources}
+ sh %{#{sudo} gem install #{install_home} pkg/#{NAME}-#{VERSION} --no-update-sources}
end
namespace :jruby do
desc "Run :package and install the resulting .gem with jruby"
task :install => :package do
- sh %{#{SUDO} jruby -S gem install #{install_home} pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
+ sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
end
end
View
@@ -0,0 +1,5 @@
+def sudo
+ windows = (PLATFORM =~ /win32|cygwin/) rescue nil
+ ENV['MERB_SUDO'] ||= "sudo"
+ sudo = windows ? "" : ENV['MERB_SUDO']
+end

0 comments on commit c61341a

Please sign in to comment.