forked from drnic/sake-tasks
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added git:src:install task and more 'how to develop new tasks' info i…
…n README
- Loading branch information
Showing
4 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace 'git' do | ||
namespace 'src' do | ||
desc "Downloads and installs latest version of git" | ||
task :install => "git:src:latest_version" do | ||
download_url = ENV['GIT_DOWNLOAD_URL'] | ||
git_package = File.basename(download_url) | ||
git_src_folder = git_package.gsub(/.tar.gz/, '') | ||
target_base_folder = '/usr/local' | ||
usr_src_folder = File.join(target_base_folder, 'src') | ||
require "fileutils" | ||
FileUtils.mkdir_p usr_src_folder | ||
FileUtils.chdir usr_src_folder do | ||
if File.exists?(git_package) | ||
puts "File #{git_package} already downloaded, skipping download..." | ||
else | ||
`wget #{download_url}` | ||
end | ||
|
||
if File.exists?(git_src_folder) | ||
puts "Removing existing #{git_src_folder} source" | ||
FileUtils.rm_rf git_src_folder | ||
end | ||
|
||
puts "Unpacking #{git_src_folder}" | ||
`tar xfv #{git_package}` | ||
|
||
FileUtils.chdir git_src_folder do | ||
puts "Installing to #{target_base_folder}" | ||
sh "make prefix=#{target_base_folder} all" | ||
sh "sudo make prefix=#{target_base_folder} install all" | ||
end | ||
end | ||
|
||
puts "Run 'sake git:manpages:install' to install manpages for #{`git --version`}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace 'git' do | ||
namespace 'src' do | ||
task :latest_version do | ||
require "rubygems" | ||
begin | ||
gem 'hpricot' | ||
require 'hpricot' | ||
rescue LoadError | ||
puts "REQUIREMENT: Hpricot" | ||
puts "Installation: sudo gem install hpricot" | ||
exit | ||
end | ||
require "open-uri" | ||
doc = open('http://git.or.cz/').read | ||
if download_url = doc.match(%r{http://kernel.org/pub/software/scm/git/git-([\d.]+).tar.gz}) | ||
ENV['GIT_DOWNLOAD_URL'] = download_url[0] | ||
puts "Current git src version: #{$1}" | ||
end | ||
end | ||
end | ||
end |