From 591f4c242853f87741a92f3131592055bc7ef5da Mon Sep 17 00:00:00 2001 From: Jakukyo Friel Date: Tue, 3 May 2016 22:25:38 +0800 Subject: [PATCH] Add `sudo` support for source installer. --- lib/sprinkle/installers/source.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/sprinkle/installers/source.rb b/lib/sprinkle/installers/source.rb index 40389c7..71d3cc2 100644 --- a/lib/sprinkle/installers/source.rb +++ b/lib/sprinkle/installers/source.rb @@ -47,12 +47,16 @@ module Installers # source 'http://magicbeansland.com/latest-1.1.1.tar.gz' do # prefix '/usr/local' # - # pre :prepare { 'echo "Here we go folks."' } - # post :extract { 'echo "I believe..."' } - # pre :build { 'echo "Cross your fingers!"' } + # pre :prepare, 'echo "Here we go folks."' + # post :extract, 'echo "I believe..."' + # pre :build, 'echo "Cross your fingers!"' # end # end # + # Be careful! Hooks will get logged via appending '>> LOG_FILE 2&>1'. + # Thus if you use '>> FILE' in hooks, the output won't go to the FILE + # you specified. You can use '| tee -a FILE' instead. + # # Fourth, specifying a custom archive name because the downloaded file name # differs from the source URL: # @@ -158,7 +162,7 @@ def build_commands #:nodoc: def install_commands #:nodoc: return custom_install_commands if custom_install? - [ in_build_dir(with_log("#{install_command || "make install"}",:install)) ] + [ in_build_dir(with_log("#{install_command || "#{sudo_cmd}make install"}",:install)) ] end def custom_install? #:nodoc: @@ -189,7 +193,7 @@ def post_commands(stage) #:nodoc: end - # dress is overriden from the base Sprinkle::Installers::Installer class so that the command changes + # dress is overridden from the base Sprinkle::Installers::Installer class so that the command changes # directory to the build directory first. Also, the result of the command is logged. def dress(commands, pre_or_post, stage) chdir = "cd #{build_dir} && "