Skip to content

Commit

Permalink
Initial checkin of hookin-based RubyPorts
Browse files Browse the repository at this point in the history
  • Loading branch information
leahneukirchen committed Feb 16, 2008
0 parents commit 4af0575
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*~
bin/*
*/*
14 changes: 14 additions & 0 deletions hook-bin.rb
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
70 changes: 70 additions & 0 deletions hook-get.rb
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)
}

0 comments on commit 4af0575

Please sign in to comment.