Permalink
Browse files

Initial checkin of hookin-based RubyPorts

  • Loading branch information...
0 parents commit 4af0575a224969a2608a8262105e15d5496c637b @chneukirchen committed Feb 16, 2008
Showing with 87 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +14 −0 hook-bin.rb
  3. +70 −0 hook-get.rb
@@ -0,0 +1,3 @@
+*~
+bin/*
+*/*
@@ -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
@@ -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.