aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/aescrypt-packetizer.rb
blob: b3134991a4aa44f0bfc6957fe178588e2fcc1486 (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
require "formula"

class AescryptPacketizer < Formula
  homepage "https://www.aescrypt.com"
  url "https://www.aescrypt.com/download/v3/linux/aescrypt-3.0.9.tgz"
  sha256 "3f3590f9b7e50039611ba9c0cf1cae1b188a44bd39cfc41553db7ec5709c0882"

  bottle do
    cellar :any
    sha1 "9332b85915d37899948db1d69c2703baba61e50e" => :yosemite
    sha1 "a0bff6bff8e0476badc312dabdb6a936f8ed6507" => :mavericks
    sha1 "2b9d8e775d1abf5bdf5ad0ba9a948deb498bdcf2" => :mountain_lion
  end

  head do
    url "https://github.com/paulej/AESCrypt.git"

    depends_on "automake" => :build
    depends_on "autoconf" => :build
    depends_on "libtool" => :build
  end

  depends_on :xcode => :build

  option "with-default-names", "Build with the binaries named as expected upstream"

  def install
    if build.head?
      cd "linux"
      system "autoreconf", "-ivf"
      system "./configure", "prefix=#{prefix}", "--enable-iconv",
              "--disable-gui"
      system "make", "install"
    end

    if build.stable?
      cd "src"
      # https://www.aescrypt.com/mac_aes_crypt.html
      inreplace "Makefile", "#LIBS=-liconv", "LIBS=-liconv"
      system "make", "prefix=#{prefix}"

      bin.install "aescrypt"
      bin.install "aescrypt_keygen"
    end

    # To prevent conflict with our other aescrypt, rename the binaries.
    if build.without? "default-names"
      mv "#{bin}/aescrypt", "#{bin}/paescrypt"
      mv "#{bin}/aescrypt_keygen", "#{bin}/paescrypt_keygen"
    end
  end

  def caveats; <<-EOS.undent
    To avoid conflicting with our other AESCrypt package the binaries
    have been renamed paescrypt and paescrypt_keygen, unless you chose
    to exercise the default-names option.
    EOS
  end

  test do
    path = testpath/"secret.txt"
    original_contents = "What grows when it eats, but dies when it drinks?"
    path.write original_contents

    system bin/"paescrypt", "-e", "-p", "fire", path
    assert File.exist?("#{path}.aes")

    system bin/"paescrypt", "-d", "-p", "fire", "#{path}.aes"
    assert_equal original_contents, path.read
  end
end