-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial checkin of hookin-based RubyPorts
- Loading branch information
0 parents
commit 4af0575
Showing
3 changed files
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*~ | ||
bin/* | ||
*/* |
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,14 @@ | ||
#!/usr/bin/env ruby -w | ||
|
||
require 'fileutils' | ||
|
||
FileUtils.mkdir_p "bin" | ||
|
||
Dir["*/bin/*"].each { |bin| | ||
FileUtils.ln_s File.expand_path(bin), "bin", :force => true, :verbose => true | ||
} | ||
|
||
FileUtils.ln_s File.expand_path("hook-bin.rb"), "bin/hook-bin", | ||
:force => true, :verbose => true | ||
FileUtils.ln_s File.expand_path("hook-get.rb"), "bin/hook-get", | ||
:force => true, :verbose => true |
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,70 @@ | ||
#!/usr/bin/env ruby -w | ||
|
||
class HookGet | ||
def initialize | ||
@hooked_in = false | ||
end | ||
|
||
def run(file) | ||
instance_eval File.read(file), file, 1 | ||
hookin unless hooked_in? | ||
end | ||
|
||
def sh(*args) | ||
puts args.join(" ") | ||
system(*args) | ||
end | ||
|
||
def build(*args) | ||
Dir.chdir(pkgpath) { sh(*args) } | ||
end | ||
|
||
def darcs(repo, tag=nil) | ||
if tag | ||
sh "darcs", "get", "--partial", "--tag=#{tag}", pkgpath | ||
else | ||
sh "darcs", "get", "--partial", pkgpath | ||
end | ||
end | ||
|
||
def git(repo, head="HEAD") | ||
sh "git", "clone", "-n", repo, pkgpath | ||
sh "GIT_DIR=#{pkgpath} git checkout #{head}" | ||
end | ||
|
||
def svn(url) | ||
sh "svn", "co", "-q", url, pkgpath | ||
end | ||
|
||
def tar_gz(url) | ||
sh "curl -L #{url} | tar xz" | ||
end | ||
|
||
def tar_bz2(url) | ||
sh "curl -L #{url} | tar xj" | ||
end | ||
|
||
def gem(url) | ||
sh "mkdir -p #{pkgpath} && curl -L #{url} | tar xO data.tar.gz | tar xzm -C #{pkgpath}" | ||
end | ||
|
||
def package(name, version=nil) | ||
@pkgname = name | ||
@pkgversion = version | ||
@pkgpath = name + (version ? "-#{version}" : "") | ||
end | ||
|
||
attr_reader :pkgpath, :pkgversion, :pkgname | ||
def hooked_in? | ||
@hooked_in | ||
end | ||
|
||
def hookin(name=pkgpath, paths=[pkgpath + "/lib"]) | ||
sh "hookin", "add", name, *paths | ||
@hooked_in = true | ||
end | ||
end | ||
|
||
ARGV.each { |file| | ||
HookGet.new.run(file) | ||
} |