jackett 0.22.1382
[Homebrew/homebrew-core.git] / Formula / b / bitcoin.rb
blobd29fce38515d9f8e5d5e3393afbba17080fb7457
1 class Bitcoin < Formula
2   desc "Decentralized, peer to peer payment network"
3   homepage "https://bitcoincore.org/"
4   url "https://bitcoincore.org/bin/bitcoin-core-28.1/bitcoin-28.1.tar.gz"
5   sha256 "c5ae2dd041c7f9d9b7c722490ba5a9d624f7e9a089c67090615e1ba4ad0883ba"
6   license all_of: [
7     "MIT",
8     "BSD-3-Clause", # src/crc32c, src/leveldb
9     "BSL-1.0", # src/tinyformat.h
10     "Sleepycat", # resource("bdb")
11   ]
12   head "https://github.com/bitcoin/bitcoin.git", branch: "master"
14   livecheck do
15     url "https://bitcoincore.org/en/download/"
16     regex(/latest version.*?v?(\d+(?:\.\d+)+)/i)
17   end
19   bottle do
20     sha256 cellar: :any,                 arm64_sequoia: "3b8dd7b2f87fdd035a1a43fb33d815ca5d1b579051f39be65abdea52207787e4"
21     sha256 cellar: :any,                 arm64_sonoma:  "a194275ef4a83ec4ba833598c7e5ae6b90aaee12e3e48141563d4d5c3db58f7c"
22     sha256 cellar: :any,                 arm64_ventura: "6b7ae606988258139e4b8d97d662758d10c4c93c34cc3d05242f274c971cd387"
23     sha256 cellar: :any,                 sonoma:        "448277b6d5eea93cf8fed2417f752034f720b851cb5eae337863646af75bd78b"
24     sha256 cellar: :any,                 ventura:       "3f3dd8b5c72068db2277535f3c449a9338a2079b398376aeebc3963ba78c6f1c"
25     sha256 cellar: :any_skip_relocation, x86_64_linux:  "a5bf3062a9b43ad8e522cf102e21496973249ca5dedada6620e659bec5dc1ae5"
26   end
28   depends_on "autoconf" => :build
29   depends_on "automake" => :build
30   depends_on "boost" => :build
31   depends_on "libtool" => :build
32   depends_on "pkgconf" => :build
33   depends_on "libevent"
34   depends_on macos: :big_sur
35   depends_on "miniupnpc"
36   depends_on "zeromq"
38   uses_from_macos "sqlite"
40   on_linux do
41     depends_on "util-linux" => :build # for `hexdump`
42   end
44   fails_with :gcc do
45     version "10"
46     cause "Requires C++ 20"
47   end
49   # berkeley db should be kept at version 4
50   # https://github.com/bitcoin/bitcoin/blob/master/doc/build-osx.md
51   # https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md
52   resource "bdb" do
53     url "https://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz"
54     sha256 "12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef"
56     # Fix build with recent clang
57     patch do
58       url "https://raw.githubusercontent.com/Homebrew/formula-patches/4c55b1/berkeley-db%404/clang.diff"
59       sha256 "86111b0965762f2c2611b302e4a95ac8df46ad24925bbb95a1961542a1542e40"
60     end
61     # Fix -flat_namespace being used on Big Sur and later.
62     patch do
63       url "https://raw.githubusercontent.com/Homebrew/formula-patches/03cf8088210822aa2c1ab544ed58ea04c897d9c4/libtool/configure-pre-0.4.2.418-big_sur.diff"
64       sha256 "83af02f2aa2b746bb7225872cab29a253264be49db0ecebb12f841562d9a2923"
65       directory "dist"
66     end
67   end
69   # Skip two tests that currently fail in the brew CI
70   patch do
71     url "https://github.com/fanquake/bitcoin/commit/9b03fb7603709395faaf0fac409465660bbd7d81.patch?full_index=1"
72     sha256 "1d56308672024260e127fbb77f630b54a0509c145e397ff708956188c96bbfb3"
73   end
75   def install
76     # https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md#berkeley-db
77     # https://github.com/bitcoin/bitcoin/blob/master/depends/packages/bdb.mk
78     resource("bdb").stage do
79       with_env(CFLAGS: ENV.cflags) do
80         # Fix compile with newer Clang
81         ENV.append "CFLAGS", "-Wno-implicit-function-declaration" if DevelopmentTools.clang_build_version >= 1200
82         # BerkeleyDB requires you to build everything from the build_unix subdirectory
83         cd "build_unix" do
84           system "../dist/configure", "--disable-replication",
85                                       "--disable-shared",
86                                       "--enable-cxx",
87                                       *std_configure_args(prefix: buildpath/"bdb")
88           system "make", "libdb_cxx-4.8.a", "libdb-4.8.a"
89           system "make", "install_lib", "install_include"
90         end
91       end
92     end
94     system "./autogen.sh"
95     system "./configure", "--disable-silent-rules",
96                           "--with-boost-libdir=#{Formula["boost"].opt_lib}",
97                           "BDB_LIBS=-L#{buildpath}/bdb/lib -ldb_cxx-4.8",
98                           "BDB_CFLAGS=-I#{buildpath}/bdb/include",
99                           *std_configure_args
100     system "make", "install"
101     pkgshare.install "share/rpcauth"
102   end
104   service do
105     run opt_bin/"bitcoind"
106   end
108   test do
109     system bin/"test_bitcoin"
111     # Test that we're using the right version of `berkeley-db`.
112     port = free_port
113     bitcoind = spawn bin/"bitcoind", "-regtest", "-rpcport=#{port}", "-listen=0", "-datadir=#{testpath}",
114                                      "-deprecatedrpc=create_bdb"
115     sleep 15
116     # This command will fail if we have too new a version.
117     system bin/"bitcoin-cli", "-regtest", "-datadir=#{testpath}", "-rpcport=#{port}",
118                               "createwallet", "test-wallet", "false", "false", "", "false", "false"
119   ensure
120     Process.kill "TERM", bitcoind
121   end