Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 7 additions & 67 deletions Formula/b/bitcoin.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
class Bitcoin < Formula
desc "Decentralized, peer to peer payment network"
homepage "https://bitcoincore.org/"
url "https://bitcoincore.org/bin/bitcoin-core-29.1/bitcoin-29.1.tar.gz"
sha256 "067f624ae273b0d85a1554ffd7c098923351a647204e67034df6cc1dfacfa06b"
url "https://bitcoincore.org/bin/bitcoin-core-30.0/bitcoin-30.0.tar.gz"
sha256 "9b472a4d51dfed9aa9d0ded2cb8c7bcb9267f8439a23a98f36eb509c1a5e6974"
license all_of: [
"MIT",
"BSD-3-Clause", # src/crc32c, src/leveldb
"BSL-1.0", # src/tinyformat.h
"Sleepycat", # resource("bdb")
]
head "https://github.com/bitcoin/bitcoin.git", branch: "master"

livecheck do
url "https://bitcoincore.org/en/download/"
Expand All @@ -24,16 +24,10 @@ class Bitcoin < Formula
sha256 x86_64_linux: "b7290cd2f6e3e5b41170d1d3fd7c7460c4a715bdb97cd5205655a68c454383cc"
end

head do
url "https://github.com/bitcoin/bitcoin.git", branch: "master"

# Move to stable block when updated to v30.0
depends_on "capnp" => :build
end

depends_on "boost" => :build
depends_on "cmake" => :build
depends_on "pkgconf" => :build
depends_on "capnp"
depends_on "libevent"
depends_on macos: :sonoma # Needs C++20 features not available on Ventura
depends_on "zeromq"
Expand All @@ -46,57 +40,14 @@ class Bitcoin < Formula
end

fails_with :gcc do
version "10"
version "11"
cause "Requires C++ 20"
end

# berkeley db should be kept at version 4
# https://github.com/bitcoin/bitcoin/blob/master/doc/build-osx.md
# https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md
resource "bdb" do
url "https://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz"
sha256 "12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef"

# Fix build with recent clang
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/4c55b1/berkeley-db%404/clang.diff"
sha256 "86111b0965762f2c2611b302e4a95ac8df46ad24925bbb95a1961542a1542e40"
end
# Fix -flat_namespace being used on Big Sur and later.
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/03cf8088210822aa2c1ab544ed58ea04c897d9c4/libtool/configure-pre-0.4.2.418-big_sur.diff"
sha256 "83af02f2aa2b746bb7225872cab29a253264be49db0ecebb12f841562d9a2923"
directory "dist"
end
end

def install
# https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md#berkeley-db
# https://github.com/bitcoin/bitcoin/blob/master/depends/packages/bdb.mk
resource("bdb").stage do
with_env(CFLAGS: ENV.cflags) do
# Fix compile with newer Clang
ENV.append "CFLAGS", "-Wno-implicit-function-declaration" if DevelopmentTools.clang_build_version >= 1200
# Fix linking with static libdb
ENV.append "CFLAGS", "-fPIC" if OS.linux?

args = ["--disable-replication", "--disable-shared", "--enable-cxx"]
args << "--build=aarch64-unknown-linux-gnu" if OS.linux? && Hardware::CPU.arm? && Hardware::CPU.is_64_bit?

# BerkeleyDB requires you to build everything from the build_unix subdirectory
cd "build_unix" do
system "../dist/configure", *args, *std_configure_args(prefix: buildpath/"bdb")
system "make", "libdb_cxx-4.8.a", "libdb-4.8.a"
system "make", "install_lib", "install_include"
end
end
end

ENV.runtime_cpu_detection
ENV.llvm_clang if OS.mac? && MacOS.version == :ventura
args = %W[
-DWITH_BDB=ON
-DBerkeleyDB_INCLUDE_DIR:PATH=#{buildpath}/bdb/include
args = %w[
-DWITH_ZMQ=ON
]
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args
Expand All @@ -110,17 +61,6 @@ def install
end

test do
system bin/"test_bitcoin"

# Test that we're using the right version of `berkeley-db`.
port = free_port
bitcoind = spawn bin/"bitcoind", "-regtest", "-rpcport=#{port}", "-listen=0", "-datadir=#{testpath}",
"-deprecatedrpc=create_bdb"
sleep 15
# This command will fail if we have too new a version.
system bin/"bitcoin-cli", "-regtest", "-datadir=#{testpath}", "-rpcport=#{port}",
"createwallet", "test-wallet", "false", "false", "", "false", "false"
ensure
Process.kill "TERM", bitcoind
system bin/"bitcoin", "test"
end
end
Loading