aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/go.rb
blob: 66042e4388d9785ac97a6e57efce7a84456bb31a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require 'formula'
require 'hardware'

class Go < Formula
  if ARGV.include? "--use-git"
    url 'https://github.com/tav/go.git', :tag => 'release.r57.2'
    head 'https://github.com/tav/go.git'
  else
    url 'http://go.googlecode.com/hg/', :revision => 'release.r57.2'
    head 'http://go.googlecode.com/hg/'
  end
  version 'r57.2'
  homepage 'http://golang.org'

  skip_clean 'bin'

  def options
    [["--use-git", "Use git mirror instead of official hg repository"]]
  end

  def patches
    # Fix an egrep error; already present upstream.
    # Remove when r58 is tagged.
    DATA unless ARGV.build_head?
  end

  def install
    ENV.j1 # Building in parallel fails
    prefix.install %w[src include test doc misc lib favicon.ico AUTHORS]
    Dir.chdir prefix
    mkdir %w[pkg bin]

    Dir.chdir 'src' do
      # Some tests fail on Lion, so do this instead of "./all.bash"
      system "./make.bash"
    end

    # Don't need the src folder, but do keep the Makefiles as Go projects use these
    Dir['src/*'].each{|f| rm_rf f unless f.match(/^src\/(pkg|Make)/) }
    rm_rf %w[include test]
  end
end

__END__
diff --git a/src/pkg/deps.bash b/src/pkg/deps.bash
index a8e3dfc..2095ec1 100755
--- a/src/pkg/deps.bash
+++ b/src/pkg/deps.bash
@@ -15,7 +15,13 @@ fi
 
 # Get list of directories from Makefile
 dirs=$(gomake --no-print-directory echo-dirs)
-dirpat=$(echo $dirs C | sed 's/ /|/g; s/.*/^(&)$/')
+dirpat=$(echo $dirs C | awk '{
+	for(i=1;i<=NF;i++){ 
+		x=$i
+		gsub("/", "\\/", x)
+		printf("/^(%s)$/\n", x)
+	}
+}')
 
 for dir in $dirs; do (
 	cd $dir || exit 1
@@ -30,7 +36,7 @@ for dir in $dirs; do (
 	deps=$(
 		sed -n '/^import.*"/p; /^import[ \t]*(/,/^)/p' $sources /dev/null |
 		cut -d '"' -f2 |
-		egrep "$dirpat" |
+		awk "$dirpat" |
 		grep -v "^$dir\$" |
 		sed 's/$/.install/' |
 		sed 's;^C\.install;runtime/cgo.install;' |