-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhets-binary.rb
94 lines (79 loc) · 2.81 KB
/
hets-binary.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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
require "formula"
class HetsBinary < Formula
# Both the version and the sha1 need to be adjusted when a new
# dmg-version of hets is released.
version '2014-06-13'
sha1 '300c5106747547f324fe4dc28649d7c2aba42ba2'
# General settings: should not change usually
@@dmg_file = "Hets-#{version}.dmg"
@@nightly_url = "http://www.informatik.uni-bremen.de/agbkb/forschung/formal_methods/CoFI/hets/intel-mac/daily/hets.bz2"
homepage "http://www.informatik.uni-bremen.de/agbkb/forschung/formal_methods/CoFI/hets/index_e.htm"
url "http://www.informatik.uni-bremen.de/agbkb/forschung/formal_methods/CoFI/hets/intel-mac/dmgs/#{@@dmg_file}"
# Options
option 'with-nightly', 'uses nightly version of the binary, also includes hets-update'
option 'with-updater', 'installs the updater script but does not run it'
conflicts_with 'hets'
depends_on :x11
def install
dmg_content = '/Volumes/Hets'
app_dir = prefix.join('Hets.app')
hets_dir = app_dir.join('Contents/Resources')
binary = hets_dir.join('hets')
system("hdiutil attach -quiet #{@@dmg_file}")
system("cp -r #{dmg_content}/Hets.app #{app_dir}")
# install hets in bin as script which sets according
# environment variables
# (taken and adjusted from script file in hets root dir)
bin.mkdir
bin.join("hets").open('w') do |f|
f.write <<-BASH
#!/bin/bash
export PATH=#{hets_dir}/uDrawGraph-3.1/bin:$PATH
export HETS_LIB=#{hets_dir}/Hets-lib
export HETS_OWL_TOOLS=#{hets_dir}/hets-owl-tools
export HETS_APROVE=$HETS_OWL_TOOLS/AProVE.jar
export HETS_ONTODMU=$HETS_OWL_TOOLS/OntoDMU.jar
export PELLET_PATH=#{hets_dir}/pellet
"#{hets_dir}/hets" "$@"
BASH
end
system("hdiutil detach -quiet #{dmg_content}")
# automatically install latest nightly build
if build.with? 'nightly'
system("curl -O #{@@nightly_url}")
system("bunzip2 hets.bz2")
system("mv hets #{binary}")
system("chmod +x #{binary}")
end
# hets updater script to manually fetch latest nightly build
if build.with?('nightly') || build.with?('updater')
bin.join("hets-update").open('w') do |f|
f.write <<-BASH
#!/bin/bash
echo 'Downloading current nightly build of hets binary...'
curl -q -o /tmp/hets.bz2 #{@@nightly_url}
bunzip2 /tmp/hets.bz2
echo -n 'Installing file...'
mv /tmp/hets #{binary}
chmod +x #{binary}
echo 'done'
BASH
end
end
end
def caveats
the_caveats = ''
if build.with? 'nightly'
the_caveats += <<-EOS.undent
We've updated your hets binary to the latest nightly version.
EOS
end
if build.with?('nightly') || build.with?('updater')
the_caveats += <<-EOS.undent
We've also installed the `hets-update` script into your PATH
which will fetch you the latest nightly hets binary.
EOS
end
return the_caveats
end
end