forked from agordon/bin_scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gordon_bin_scripts.rb
40 lines (36 loc) · 1.54 KB
/
gordon_bin_scripts.rb
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
require 'formula'
class GordonBinScripts < Formula
homepage 'https://github.com/agordon/bin_scripts'
head 'https://github.com/agordon/bin_scripts.git'
if build.head?
depends_on :autoconf => :build
depends_on :automake => :build
end
def install
if build.head?
# Ugly hack: The build system extracts the version from either ".git" (if cloned)
# or from ".tarball-version" (if from a proper dist tarball).
# But here, HomeBrew clones (shallowly) first, then extract to a separate directory,
# So there's neither ".git" nor ".tarball-version".
#
# Here, we go back to the GIT directory, 'unshallow' the repository
# (unshallow requires git version 1.8.3 or later), then extract the version.
# If 'unshallowing' failed, fallback to the SHA1 of the current version.
ohai "Trying to extract version from Git Repository"
git_repo = "#{HOMEBREW_CACHE}/#{name}--git"
prog_version = `(cd #{git_repo} ; git fetch --unshallow ; ./config/git-version-gen v )`
prog_version.chomp!
if prog_version == "UNKNOWN"
git_version = `(cd #{git_repo} ; git describe --always )`
git_version.chomp!
prog_version = "0.0.0-#{git_version}-HomeBrew-Git"
end
ohai "Detected Git version = #{prog_version}"
system "echo '#{prog_version}' > .tarball-version"
end
system 'sh', './bootstrap.sh'
system './configure', "--prefix=#{prefix}"
system 'make'
system 'make', 'install'
end
end