|
| 1 | +class Libxcrypt < Formula |
| 2 | + desc "Extended crypt library for descrypt, md5crypt, bcrypt, and others" |
| 3 | + homepage "https://github.com/besser82/libxcrypt" |
| 4 | + url "https://github.com/besser82/libxcrypt/releases/download/v4.4.36/libxcrypt-4.4.36.tar.xz" |
| 5 | + sha256 "e5e1f4caee0a01de2aee26e3138807d6d3ca2b8e67287966d1fefd65e1fd8943" |
| 6 | + license "LGPL-2.1-or-later" |
| 7 | + |
| 8 | + livecheck do |
| 9 | + url :stable |
| 10 | + strategy :github_latest |
| 11 | + end |
| 12 | + |
| 13 | + bottle do |
| 14 | + root_url "https://github.com/gromgit/homebrew-core-aarch64_linux/releases/download/libxcrypt-4.4.36" |
| 15 | + sha256 cellar: :any_skip_relocation, aarch64_linux: "555a7fa3314db9771803f4e46f1fc231fd48b9b180f10a503c12ec786d322378" |
| 16 | + end |
| 17 | + |
| 18 | + keg_only :provided_by_macos |
| 19 | + |
| 20 | + link_overwrite "include/crypt.h" |
| 21 | + link_overwrite "lib/libcrypt.so" |
| 22 | + |
| 23 | + def install |
| 24 | + system "./configure", *std_configure_args, |
| 25 | + "--disable-static", |
| 26 | + "--disable-obsolete-api", |
| 27 | + "--disable-xcrypt-compat-files", |
| 28 | + "--disable-failure-tokens", |
| 29 | + "--disable-valgrind" |
| 30 | + system "make", "install" |
| 31 | + end |
| 32 | + |
| 33 | + test do |
| 34 | + (testpath/"test.c").write <<~EOS |
| 35 | + #include <crypt.h> |
| 36 | + #include <errno.h> |
| 37 | + #include <stdio.h> |
| 38 | + #include <string.h> |
| 39 | +
|
| 40 | + int main() |
| 41 | + { |
| 42 | + char *hash = crypt("abc", "$2b$05$abcdefghijklmnopqrstuu"); |
| 43 | +
|
| 44 | + if (errno) { |
| 45 | + fprintf(stderr, "Received error: %s", strerror(errno)); |
| 46 | + return errno; |
| 47 | + } |
| 48 | + if (hash == NULL) { |
| 49 | + fprintf(stderr, "Hash is NULL"); |
| 50 | + return -1; |
| 51 | + } |
| 52 | + if (strcmp(hash, "$2b$05$abcdefghijklmnopqrstuuRWUgMyyCUnsDr8evYotXg5ZXVF/HhzS")) { |
| 53 | + fprintf(stderr, "Unexpected hash output"); |
| 54 | + return -1; |
| 55 | + } |
| 56 | +
|
| 57 | + return 0; |
| 58 | + } |
| 59 | + EOS |
| 60 | + system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lcrypt", "-o", "test" |
| 61 | + system "./test" |
| 62 | + end |
| 63 | +end |
0 commit comments