aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/vpnc.rb
blob: 9d105ee636ee001c13a27efcd8f4d7bd9b3627ef (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
require 'formula'

class Vpnc <Formula
  url 'http://www.unix-ag.uni-kl.de/~massar/vpnc/vpnc-0.5.3.tar.gz'
  homepage 'http://www.unix-ag.uni-kl.de/~massar/vpnc/'
  sha256 '46cea3bd02f207c62c7c6f2f22133382602baeda1dc320747809e94881414884'

  depends_on 'libgcrypt'
  depends_on 'libgpg-error'

  def skip_clean? path
    path == etc or path == var
  end

  def options
    [
      ["--hybrid", "Use vpnc hybrid authentication."]
    ]
  end

  def install
    ENV.gcc_4_2
    ENV.no_optimization 
    ENV.deparallelize

    inreplace ["vpnc-script.in", "vpnc-disconnect"] do |s|
      s.gsub! "/var/run/vpnc", (var + 'run/vpnc')
    end

    inreplace "vpnc.8.template" do |s|
      s.gsub! "/etc/vpnc", (etc + 'vpnc')
    end

    inreplace "Makefile" do |s|
      s.change_make_var! "PREFIX", prefix
      s.change_make_var! "ETCDIR", (etc + 'vpnc')

      s.gsub! /^#OPENSSL/, "OPENSSL" if ARGV.include? "--hybrid"
    end

    inreplace "config.c" do |s|
      s.gsub! "/etc/vpnc", (etc + 'vpnc')
      s.gsub! "/var/run/vpnc", (var + 'run/vpnc')
    end

    system "make"
    (var + 'run/vpnc').mkpath
    system "make install"
  end

  def caveats
    <<-END_CAVEATS
    Formula contribute hybrid option for vpnc hybrid authentification.
    To install use:
      brew install vpnc --hybrid
    END_CAVEATS
  end
end