diff options
author | Matt Whitlock <gentoo@mattwhitlock.name> | 2023-09-21 17:41:32 -0400 |
---|---|---|
committer | Florian Schmaus <flow@gentoo.org> | 2023-10-09 12:54:05 +0200 |
commit | 380aad5fc649a00ae46644c130fb9a3b8970ee09 (patch) | |
tree | 06dd5d244d7c641fc95ce86c6193c3234e864f4f /net-p2p/bitcoin-core | |
parent | dev-python/pyside2-tools: add 5.15.11 (diff) | |
download | gentoo-380aad5fc649a00ae46644c130fb9a3b8970ee09.tar.gz gentoo-380aad5fc649a00ae46644c130fb9a3b8970ee09.tar.bz2 gentoo-380aad5fc649a00ae46644c130fb9a3b8970ee09.zip |
net-p2p/bitcoin-core-25.0: introduce combined package
This package combines:
- dev-util/bitcoin-tx (always installed)
- net-libs/libbitcoinconsensus (installed if USE="libs")
- net-p2p/bitcoin-cli (installed if USE="bitcoin-cli")
- net-p2p/bitcoind (installed if USE="daemon")
- net-p2p/bitcoin-qt (installed if USE="qt5")
To ease the transition, new ebuilds of the above packages at version
25.0 are added. These are empty packages that simply RDEPEND upon
net-p2p/bitcoin-core with the necessary USE flags.
Two new USE flags are introduced to control whether to embed internal
copies of LevelDB and libsecp256k1 into Bitcoin Core or to dynamically
link with the system-installed libraries.
The "sqlite" USE flag is now enabled by default, as descriptor wallets
are no longer experimental and are indeed now the default.
The "wallet" USE flag has been dropped, as it was redundant. If "berkdb"
and/or "sqlite" is enabled, then you get wallet support. If neither is
enabled, then you don't.
When a wallet is enabled, the 'bitcoin-wallet' utility is now installed.
The OpenRC init script has been overhauled to use -daemonwait so that
startup of other services needing bitcoind will be deferred until after
bitcoind is ready to accept RPCs.
The datadir that has long been located at the awkward
/var/lib/bitcoin/.bitcoin/ is migrating to /var/lib/bitcoind/. On
systems where the older path exists, the ebuild installs a symlink at
the new path, so that the system service will continue to work, and
emits an ewarn instructing the user to run the pkg_config() function to
perform the migration on their system.
The init scripts now specify the location for the debug log file,
defaulting to /var/log/bitcoind/debug.log, instead of allowing it to be
written by default to /var/lib/bitcoin/.bitcoin/debug.log. It's an
important distinction, as /var/log may be located on a different storage
volume than /var/lib.
Closes: https://bugs.gentoo.org/890261
Signed-off-by: Matt Whitlock <gentoo@mattwhitlock.name>
Closes: https://github.com/gentoo/gentoo/pull/32978
Signed-off-by: Florian Schmaus <flow@gentoo.org>
Diffstat (limited to 'net-p2p/bitcoin-core')
-rw-r--r-- | net-p2p/bitcoin-core/Manifest | 1 | ||||
-rw-r--r-- | net-p2p/bitcoin-core/bitcoin-core-25.0.ebuild | 340 | ||||
-rw-r--r-- | net-p2p/bitcoin-core/files/25.0-syslibs.patch | 275 | ||||
-rw-r--r-- | net-p2p/bitcoin-core/files/bitcoin-qt.protocol | 11 | ||||
-rw-r--r-- | net-p2p/bitcoin-core/files/bitcoind.logrotate-r1 | 8 | ||||
-rw-r--r-- | net-p2p/bitcoin-core/files/bitcoind.openrc | 89 | ||||
-rw-r--r-- | net-p2p/bitcoin-core/files/init.patch | 43 | ||||
-rw-r--r-- | net-p2p/bitcoin-core/files/org.bitcoin.bitcoin-qt.desktop | 15 | ||||
-rw-r--r-- | net-p2p/bitcoin-core/metadata.xml | 33 |
9 files changed, 815 insertions, 0 deletions
diff --git a/net-p2p/bitcoin-core/Manifest b/net-p2p/bitcoin-core/Manifest new file mode 100644 index 000000000000..c4ed0f3bcb9e --- /dev/null +++ b/net-p2p/bitcoin-core/Manifest @@ -0,0 +1 @@ +DIST bitcoin-25.0.tar.gz 12413133 BLAKE2B 34f725e8c69ee3eb25d2a0c796f7688b3727603a4a34eb7ef4dd140c9b2995ecf28c60bfa45ad22614dcd445c9ddfdadd8dbb45dfbb9327c4b5dbe50c7ae9a11 SHA512 2be57fc760fa12d291dcf946522838b2e791e24e5dd98de20b5b72af2269269a66539c5bddce590e6cdb6464fd5ecb530cf549edc188ee6f08b4365fdcf850a2 diff --git a/net-p2p/bitcoin-core/bitcoin-core-25.0.ebuild b/net-p2p/bitcoin-core/bitcoin-core-25.0.ebuild new file mode 100644 index 000000000000..0ed41f21df48 --- /dev/null +++ b/net-p2p/bitcoin-core/bitcoin-core-25.0.ebuild @@ -0,0 +1,340 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +PYTHON_COMPAT=( python3_{10..12} ) + +inherit autotools bash-completion-r1 db-use desktop python-any-r1 systemd xdg-utils + +DESCRIPTION="Reference implementation of the Bitcoin cryptocurrency" +HOMEPAGE="https://bitcoincore.org/" +SRC_URI="https://bitcoincore.org/bin/${P}/${P/-core}.tar.gz" +S="${WORKDIR}/${P/-core}" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86 ~amd64-linux ~x86-linux" +# IUSE="+cli" doesn't work due to https://bugs.gentoo.org/831045#c3 +IUSE="+asm +berkdb +bitcoin-cli +daemon dbus examples +external-signer kde libs +man nat-pmp +qrcode qt5 +sqlite system-leveldb +system-libsecp256k1 systemtap test upnp zeromq" +RESTRICT="!test? ( test )" + +REQUIRED_USE=" + dbus? ( qt5 ) + kde? ( qt5 ) + qrcode? ( qt5 ) + system-leveldb? ( || ( daemon qt5 ) ) +" +# dev-libs/univalue is now bundled, as upstream dropped support for system copy +# and their version in the Bitcoin repo has deviated a fair bit from upstream. +# Upstream also seems very inactive. +RDEPEND=" + !<dev-util/bitcoin-tx-25.0 + >=dev-libs/boost-1.81.0:= + >=dev-libs/libevent-2.1.12:= + berkdb? ( >=sys-libs/db-4.8.30:$(db_ver_to_slot 4.8)=[cxx] ) + bitcoin-cli? ( !<net-p2p/bitcoin-cli-25.0 ) + daemon? ( + !<net-p2p/bitcoind-25.0 + acct-group/bitcoin + acct-user/bitcoin + ) + libs? ( !<net-libs/libbitcoinconsensus-25.0 ) + nat-pmp? ( >=net-libs/libnatpmp-20220705:= ) + qrcode? ( >=media-gfx/qrencode-4.1.1:= ) + qt5? ( + !<net-p2p/bitcoin-qt-25.0 + >=dev-qt/qtcore-5.15.5:5 + >=dev-qt/qtgui-5.15.5:5 + >=dev-qt/qtnetwork-5.15.5:5 + >=dev-qt/qtwidgets-5.15.5:5 + dbus? ( >=dev-qt/qtdbus-5.15.5:5 ) + ) + sqlite? ( >=dev-db/sqlite-3.38.5:= ) + system-leveldb? ( virtual/bitcoin-leveldb ) + system-libsecp256k1? ( >=dev-libs/libsecp256k1-0.3.1:=[recovery,schnorr] ) + upnp? ( >=net-libs/miniupnpc-2.2.2:= ) + zeromq? ( >=net-libs/zeromq-4.3.4:= ) +" +DEPEND=" + ${RDEPEND} + systemtap? ( >=dev-util/systemtap-4.8 ) +" +BDEPEND=" + virtual/pkgconfig + daemon? ( + acct-group/bitcoin + acct-user/bitcoin + ) + qt5? ( >=dev-qt/linguist-tools-5.15.5:5 ) + test? ( ${PYTHON_DEPS} ) +" +IDEPEND=" + qt5? ( dev-util/desktop-file-utils ) +" + +DOCS=( + doc/bips.md + doc/bitcoin-conf.md + doc/descriptors.md + doc/files.md + doc/i2p.md + doc/JSON-RPC-interface.md + doc/multisig-tutorial.md + doc/p2p-bad-ports.md + doc/psbt.md + doc/reduce-memory.md + doc/reduce-traffic.md + doc/release-notes.md + doc/REST-interface.md + doc/tor.md +) + +PATCHES=( + "${FILESDIR}/25.0-syslibs.patch" + "${FILESDIR}/init.patch" +) + +pkg_setup() { + use test && python-any-r1_pkg_setup +} + +src_prepare() { + default + ! use system-leveldb || rm -r src/leveldb || die + if use system-libsecp256k1 ; then + rm -r src/secp256k1 || die + sed -e '/^DIST_SUBDIRS *=/s/\bsecp256k1\b//' -i src/Makefile.am || die + else + pushd src/secp256k1 >/dev/null || die + AT_NOELIBTOOLIZE=yes eautoreconf + popd >/dev/null || die + fi + eautoreconf + + # we say --disable-util-util, so we can't test bitcoin-util + sed -ne '/^ {/{h;:0;n;H;/^ }/!b0;g;\|"exec": *"\./bitcoin-util"|d};p' \ + -i test/util/data/bitcoin-util-test.json || die + + sed -e 's/^\(complete -F _bitcoind\b\).*$/\1'"$(usev daemon ' bitcoind')$(usev qt5 ' bitcoin-qt')/" \ + -i contrib/completions/bash/bitcoind.bash-completion || die +} + +src_configure() { + local wallet ; if use berkdb || use sqlite ; then wallet=enable ; else wallet=disable ; fi + local myeconfargs=( + --disable-static + --${wallet}-wallet + $(use_with sqlite) + $(use_with berkdb bdb) + $(use_enable systemtap usdt) + $(use_with upnp miniupnpc) + $(use_with nat-pmp natpmp) + $(use_enable test tests) + --disable-bench + --disable-fuzz{,-binary} + $(use_with qrcode qrencode) + --disable-ccache + $(use_enable asm) + $(use_enable zeromq zmq) + $(use_enable man) + $(use_enable external-signer) + --with-utils + $(use_enable {bitcoin,util}-cli) + --enable-util-tx + --${wallet}-util-wallet + --disable-util-util + $(use_with libs) + $(use_with daemon) + $(use_with qt5 gui qt5) + $(use_with dbus qtdbus) + $(use_with system-leveldb) + $(use_with system-libsecp256k1) + ) + econf "${myeconfargs[@]}" +} + +src_install() { + use external-signer && DOCS+=( doc/external-signer.md ) + use berkdb || use sqlite && DOCS+=( doc/managing-wallets.md ) + use libs && DOCS+=( doc/shared-libraries.md ) + use systemtap && DOCS+=( doc/tracing.md ) + use zeromq && DOCS+=( doc/zmq.md ) + + default + + find "${ED}" -type f -name '*.la' -delete || die + ! use test || rm -f -- "${ED}"/usr/bin/test_bitcoin{,-qt} || die + + newbashcomp contrib/completions/bash/bitcoin-tx.bash-completion bitcoin-tx + use bitcoin-cli && newbashcomp contrib/completions/bash/bitcoin-cli.bash-completion bitcoin-cli + use daemon || use qt5 && newbashcomp contrib/completions/bash/bitcoind.bash-completion bitcoind + + if use daemon ; then + insinto /etc/bitcoin + sed -ne 's/ To use, copy this file$//p;Tp;:0;n;/save the file\.$/!b0;d;:p;p' \ + share/examples/bitcoin.conf >"${ED}/etc/bitcoin/bitcoin.conf" || die + fowners bitcoin:bitcoin /etc/bitcoin/bitcoin.conf + fperms 0660 /etc/bitcoin/bitcoin.conf + + newconfd contrib/init/bitcoind.openrcconf bitcoind + newinitd "${FILESDIR}/bitcoind.openrc" bitcoind + systemd_newunit contrib/init/bitcoind.service bitcoind.service + + keepdir /var/lib/bitcoind + fperms 0750 /var/lib/bitcoind + fowners bitcoin:bitcoin /var/lib/bitcoind + dosym -r {/etc/bitcoin,/var/lib/bitcoind}/bitcoin.conf + + insinto /etc/logrotate.d + newins "${FILESDIR}/bitcoind.logrotate-r1" bitcoind + fi + + if use qt5 ; then + insinto /usr/share/icons/hicolor/scalable/apps + newins src/qt/res/src/bitcoin.svg bitcoin128.svg + + domenu "${FILESDIR}/org.bitcoin.bitcoin-qt.desktop" + + if use kde ; then + insinto /usr/share/kservices5 + doins "${FILESDIR}/bitcoin-qt.protocol" + fi + fi + + if use examples ; then + docinto examples + dodoc -r contrib/{linearize,qos} + use zeromq && dodoc -r contrib/zmq + fi +} + +efmt() { + : ${1:?} ; local l ; while read -r l ; do "${!#}" "${l}" ; done < <(fmt "${@:1:$#-1}") +} + +pkg_preinst() { + if use daemon && [[ -d "${EROOT}/var/lib/bitcoin/.bitcoin" ]] ; then + if [[ -h "${EROOT}/var/lib/bitcoin/.bitcoin" ]] ; then + dosym -r /var/lib/bitcoin{d,/.bitcoin} + elif [[ ! -e "${EROOT}/var/lib/bitcoind" || -h "${EROOT}/var/lib/bitcoind" ]] ; then + efmt ewarn <<-EOF + Your bitcoind data directory is located at ${EPREFIX}/var/lib/bitcoin/.bitcoin, + a deprecated location. To perform an automated migration to + ${EPREFIX}/var/lib/bitcoind, first shut down any running bitcoind instances + that may be using the deprecated path, and then run: + + # emerge --config ${CATEGORY}/${PN} + EOF + insinto /var/lib/bitcoin + mv -- "${ED}/var/lib/bitcoin"{d,/.bitcoin} || die + dosym -r {/etc/,/var/lib/bitcoin/.}bitcoin/bitcoin.conf + dosym -r /var/lib/bitcoin{/.bitcoin,d} + fi + fi + + if use kde && [[ -d "${EROOT}/usr/share/kde4" ]] ; then + dosym -r /usr/share/{kservices5,kde4/services}/bitcoin-qt.protocol + fi +} + +pkg_postinst() { + # we don't use xdg.eclass because it adds unconditional IDEPENDs + if use qt5 ; then + xdg_desktop_database_update + xdg_icon_cache_update + fi + + if use daemon && [[ -z "${REPLACING_VERSIONS}" ]] ; then + efmt -su elog <<-EOF + To have ${PN} automatically use Tor when it's running, be sure your \ + 'torrc' config file has 'ControlPort' and 'CookieAuthentication' set up \ + correctly, and: + - Using an init script: add the 'bitcoin' user to the 'tor' user group. + - Running bitcoind directly: add that user to the 'tor' user group. + EOF + fi +} + +pkg_postrm() { + if use qt5 ; then + xdg_desktop_database_update + xdg_icon_cache_update + fi +} + +pkg_config() { + if [[ -d "${EROOT}/var/lib/bitcoin/.bitcoin" && ! -h "${EROOT}/var/lib/bitcoin/.bitcoin" ]] && + [[ ! -e "${EROOT}/var/lib/bitcoind" || -h "${EROOT}/var/lib/bitcoind" ]] + then + in_use() { + : ${1:?} ; local each + if command -v fuser >/dev/null ; then + fuser "${@}" >/dev/null 2>&1 + elif command -v lsof >/dev/null ; then + for each ; do + lsof -- "${each}" && return + done >/dev/null 2>&1 + elif mountpoint -q /proc ; then + { find /proc/[0-9]*/{cwd,exe,fd} -type l -exec readlink -- {} + + awk '{ print $6 }' /proc/[0-9]*/maps + } 2>/dev/null | grep -Fqx -f <(printf '%s\n' "${@}" ; readlink -m -- "${@}") + else + return 13 + fi + } + ebegin "Checking that ${EPREFIX}/var/lib/bitcoin/.bitcoin is not in use" + in_use "${EROOT}/var/lib/bitcoin/.bitcoin"{,/.lock} + case $? in + 0) + eend 1 + efmt eerror <<-EOF + ${EPREFIX}/var/lib/bitcoin/.bitcoin is currently in use. Please stop any + running bitcoind instances that may be using this data directory, and then + retry this migration. + EOF + die "${EPREFIX}/var/lib/bitcoin/.bitcoin is in use" + ;; + 13) + eend 1 + if [[ "${BITCOIND_IS_NOT_RUNNING}" != 1 ]] ; then + efmt eerror <<-EOF + Found no way to check whether ${EPREFIX}/var/lib/bitcoin/.bitcoin is in use. + Do you have /proc mounted? To force the migration without checking, re-run + this command with BITCOIND_IS_NOT_RUNNING=1. + EOF + die "could not check whether ${EPREFIX}/var/lib/bitcoin/.bitcoin is in use" + fi + ;; + *) + eend 0 + ;; + esac + + # find all relative symlinks that point outside the data dir + local -A symlinks + cd -- "${EROOT}/var/lib/bitcoin/.bitcoin" || die + local each ; while read -r -d '' each ; do + local target=$(readlink -- "${each}") && [[ "${target}" == ../* ]] && + target=$(readlink -e -- "${each}") && [[ "${target}" != "${EROOT}/var/lib/bitcoin/.bitcoin/"* ]] && + symlinks["${each}"]="${target}" + done < <(find -type l -print0) + + einfo "Moving your ${EPREFIX}/var/lib/bitcoin/.bitcoin to ${EPREFIX}/var/lib/bitcoind." + rm -f -- "${EROOT}/var/lib/bitcoind" || die + mv --no-clobber --no-copy --no-target-directory -- "${EROOT}/var/lib/bitcoin"{/.bitcoin,d} || + die "Failed to move your ${EPREFIX}/var/lib/bitcoin/.bitcoin to ${EPREFIX}/var/lib/bitcoind." + + # fix up the relative symlinks + cd -- "${EROOT}/var/lib/bitcoind" || die + for each in "${!symlinks[@]}" ; do + ln -fnrs -- "${symlinks[${each}]}" "${each}" # keep going even if this fails + done + + einfo 'Creating a transitional symlink for your convenience.' + ln -fnrsv -- "${EROOT}/var/lib/bitcoin"{d,/.bitcoin} + einfo 'You may remove this link when you no longer need it.' + else + einfo 'Nothing to do.' + fi +} diff --git a/net-p2p/bitcoin-core/files/25.0-syslibs.patch b/net-p2p/bitcoin-core/files/25.0-syslibs.patch new file mode 100644 index 000000000000..525ae129abbb --- /dev/null +++ b/net-p2p/bitcoin-core/files/25.0-syslibs.patch @@ -0,0 +1,275 @@ +From b4cc8c4437eea107d2d821b1282051756c47a6b6 Mon Sep 17 00:00:00 2001 +From: Matt Whitlock <bitcoin@mattwhitlock.name> +Date: Sun, 17 Sep 2023 10:29:27 -0400 +Subject: [PATCH] support linking against system-installed leveldb and + libsecp256k1 + +- Abort if runtime leveldb != compiled-against leveldb. + +Originally based on 22.0-fix_build_without_leveldb.patch. +--- + configure.ac | 71 +++++++++++++++++++++++++++++++++++++-- + src/Makefile.am | 13 ++++++- + src/Makefile.test.include | 2 ++ + src/dbwrapper.cpp | 27 ++++++++++++++- + src/dbwrapper.h | 8 +++++ + src/kernel/checks.cpp | 7 ++++ + 6 files changed, 124 insertions(+), 4 deletions(-) + +diff --git a/configure.ac b/configure.ac +index c6dc5a6875..3507a81b7a 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1358,6 +1358,22 @@ if test "$enable_fuzz_binary" = "yes"; then + CHECK_RUNTIME_LIB + fi + ++dnl Check for libsecp256k1, only if explicitly requested ++AC_ARG_WITH([system-libsecp256k1], ++ [AS_HELP_STRING([--with-system-libsecp256k1], ++ [Build with system libsecp256k1 (default is no; DANGEROUS; NOT SUPPORTED)])], ++ [system_libsecp256k1=$withval], ++ [system_libsecp256k1=no]) ++AS_IF([test x$system_libsecp256k1 != xno],[ ++ PKG_CHECK_MODULES([libsecp256k1],[libsecp256k1],,[true]) ++],[ ++ libsecp256k1_CFLAGS='-I$(srcdir)/secp256k1/include' ++ libsecp256k1_LIBS='secp256k1/libsecp256k1.la' ++]) ++AM_CONDITIONAL([EMBEDDED_LIBSECP256K1],[test x$system_libsecp256k1 = xno]) ++AC_SUBST(libsecp256k1_CFLAGS) ++AC_SUBST(libsecp256k1_LIBS) ++ + if test "$enable_wallet" != "no"; then + dnl Check for libdb_cxx only if wallet enabled + if test "$use_bdb" != "no"; then +@@ -1415,6 +1431,55 @@ if test "$build_bitcoind$bitcoin_enable_qt$use_bench$use_tests" = "nononono"; th + use_zmq=no + fi + ++dnl Check for leveldb, only if explicitly requested ++AC_ARG_WITH([system-leveldb], ++ [AS_HELP_STRING([--with-system-leveldb], ++ [Build with system LevelDB (default is no; DANGEROUS; NOT SUPPORTED)])], ++ [system_leveldb=$withval], ++ [system_leveldb=no]) ++AC_ARG_VAR([leveldb_CFLAGS],[C compiler flags for system-leveldb]) ++AC_ARG_VAR([leveldb_LIBS],[linker flags for system-leveldb]) ++AS_IF([test x$system_leveldb != xno],[ ++ TEMP_CPPFLAGS="$CPPFLAGS" ++ TEMP_LIBS="$LIBS" ++ CPPFLAGS="$leveldb_CFLAGS" ++ LIBS="$leveldb_LIBS" ++ AC_SEARCH_LIBS([leveldb_open],[leveldb],[leveldb_LIBS="$LIBS"], ++ [AC_MSG_ERROR([leveldb library not found; using --with-system-leveldb is not supported anyway])]) ++ AC_CHECK_HEADER([leveldb/filter_policy.h],[], ++ [AC_MSG_ERROR([LevelDB headers not found; using --with-system-leveldb is not supported anyway])]) ++ AC_CHECK_HEADER([leveldb/helpers/memenv.h],[], ++ [AC_MSG_ERROR([LevelDB headers not found; using --with-system-leveldb is not supported anyway])]) ++ ++ AC_MSG_CHECKING([for library containing leveldb::NewMemEnv]) ++ for searchlib in "" "-lmemenv" ERR; do ++ if test "x$searchlib" = "xERR"; then ++ AC_MSG_RESULT([no]) ++ AC_MSG_ERROR([LevelDB's memenv helper not found; using --with-system-leveldb is not supported anyway]) ++ fi ++ LIBS="$searchlib $leveldb_LIBS" ++ AC_LINK_IFELSE([AC_LANG_PROGRAM([ ++ #include <leveldb/env.h> ++ #include <leveldb/helpers/memenv.h> ++ ],[ ++ leveldb::Env *myenv = leveldb::NewMemEnv(leveldb::Env::Default()); ++ delete myenv; ++ ]) ++ ],[ ++ AC_MSG_RESULT([$searchlib]) ++ break ++ ]) ++ done ++ leveldb_LIBS="$LIBS" ++ LIBS="$TEMP_LIBS" ++ CPPFLAGS="$TEMP_CPPFLAGS" ++],[ ++ AC_DEFINE([EMBEDDED_LEVELDB],[1],[Define to use the bundled LevelDB sources]) ++]) ++AM_CONDITIONAL([EMBEDDED_LEVELDB],[test x$system_leveldb = xno]) ++AC_SUBST(leveldb_CFLAGS) ++AC_SUBST(leveldb_LIBS) ++ + dnl Check for libminiupnpc (optional) + if test "$use_upnp" != "no"; then + TEMP_CPPFLAGS="$CPPFLAGS" +@@ -1989,8 +2054,10 @@ CPPFLAGS_TEMP="$CPPFLAGS" + unset CPPFLAGS + CPPFLAGS="$CPPFLAGS_TEMP" + +-ac_configure_args="${ac_configure_args} --disable-shared --with-pic --enable-benchmark=no --enable-module-recovery --disable-module-ecdh" +-AC_CONFIG_SUBDIRS([src/secp256k1]) ++AM_COND_IF([EMBEDDED_LIBSECP256K1],[ ++ ac_configure_args="${ac_configure_args} --disable-shared --with-pic --enable-benchmark=no --enable-module-recovery --disable-module-ecdh" ++ AC_CONFIG_SUBDIRS([src/secp256k1]) ++]) + + AC_OUTPUT + +diff --git a/src/Makefile.am b/src/Makefile.am +index 1d7004ac86..c7d6fdbc39 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -24,7 +24,7 @@ check_PROGRAMS = + TESTS = + BENCHMARKS = + +-BITCOIN_INCLUDES=-I$(builddir) -I$(srcdir)/$(MINISKETCH_INCLUDE_DIR_INT) -I$(srcdir)/secp256k1/include -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT) $(LEVELDB_CPPFLAGS) ++BITCOIN_INCLUDES=-I$(builddir) -I$(srcdir)/$(MINISKETCH_INCLUDE_DIR_INT) $(libsecp256k1_CFLAGS) -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) + + LIBBITCOIN_NODE=libbitcoin_node.a + LIBBITCOIN_COMMON=libbitcoin_common.a +@@ -33,7 +33,11 @@ LIBBITCOIN_CLI=libbitcoin_cli.a + LIBBITCOIN_UTIL=libbitcoin_util.a + LIBBITCOIN_CRYPTO_BASE=crypto/libbitcoin_crypto_base.la + LIBBITCOINQT=qt/libbitcoinqt.a ++if EMBEDDED_LIBSECP256K1 + LIBSECP256K1=secp256k1/libsecp256k1.la ++else ++LIBSECP256K1=$(libsecp256k1_LIBS) ++endif + + if ENABLE_ZMQ + LIBBITCOIN_ZMQ=libbitcoin_zmq.a +@@ -68,8 +72,10 @@ LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_ARM_SHANI) + endif + noinst_LTLIBRARIES += $(LIBBITCOIN_CRYPTO) + ++if EMBEDDED_LIBSECP256K1 + $(LIBSECP256K1): $(wildcard secp256k1/src/*.h) $(wildcard secp256k1/src/*.c) $(wildcard secp256k1/include/*) + $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) ++endif + + # Make is not made aware of per-object dependencies to avoid limiting building parallelization + # But to build the less dependent modules first, we manually select their order here: +@@ -1105,7 +1111,12 @@ endif + include Makefile.minisketch.include + + include Makefile.crc32c.include ++if EMBEDDED_LEVELDB + include Makefile.leveldb.include ++else ++LEVELDB_CPPFLAGS = $(leveldb_CFLAGS) ++LIBLEVELDB = $(leveldb_LIBS) ++endif + + include Makefile.test_util.include + include Makefile.test_fuzz.include +diff --git a/src/Makefile.test.include b/src/Makefile.test.include +index 15d5a17cec..9a7397f20f 100644 +--- a/src/Makefile.test.include ++++ b/src/Makefile.test.include +@@ -384,7 +384,9 @@ if ENABLE_BENCH + $(BENCH_BINARY) -sanity-check -priority-level=high + endif + endif ++if EMBEDDED_LIBSECP256K1 + $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check ++endif + + if ENABLE_TESTS + UNIVALUE_TESTS = univalue/test/object univalue/test/unitester +diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp +index 2aade14ef4..279037ef01 100644 +--- a/src/dbwrapper.cpp ++++ b/src/dbwrapper.cpp +@@ -20,13 +20,38 @@ + #include <leveldb/db.h> + #include <leveldb/env.h> + #include <leveldb/filter_policy.h> +-#include <leveldb/helpers/memenv/memenv.h> ++#if EMBEDDED_LEVELDB ++# include <leveldb/helpers/memenv/memenv.h> ++#else ++# include <leveldb/helpers/memenv.h> ++#endif + #include <leveldb/iterator.h> + #include <leveldb/options.h> + #include <leveldb/status.h> + #include <memory> + #include <optional> + ++#if !EMBEDDED_LEVELDB ++#include <node/interface_ui.h> ++#include <util/translation.h> ++#include <leveldb/c.h> ++bool dbwrapper_SanityCheck() ++{ ++ unsigned long header_version = (leveldb::kMajorVersion << 16) | leveldb::kMinorVersion; ++ unsigned long library_version = (leveldb_major_version() << 16) | leveldb_minor_version(); ++ ++ if (header_version != library_version) { ++ InitError(Untranslated(strprintf("Compiled with LevelDB %d.%d, but linked with LevelDB %d.%d (incompatible).", ++ leveldb::kMajorVersion, leveldb::kMinorVersion, ++ leveldb_major_version(), leveldb_minor_version() ++ ))); ++ return false; ++ } ++ ++ return true; ++} ++#endif ++ + class CBitcoinLevelDBLogger : public leveldb::Logger { + public: + // This code is adapted from posix_logger.h, which is why it is using vsprintf. +diff --git a/src/dbwrapper.h b/src/dbwrapper.h +index 35782edca6..0e306d7d9c 100644 +--- a/src/dbwrapper.h ++++ b/src/dbwrapper.h +@@ -5,6 +5,10 @@ + #ifndef BITCOIN_DBWRAPPER_H + #define BITCOIN_DBWRAPPER_H + ++#if defined(HAVE_CONFIG_H) ++#include <config/bitcoin-config.h> ++#endif ++ + #include <clientversion.h> + #include <logging.h> + #include <serialize.h> +@@ -54,6 +58,10 @@ struct DBParams { + DBOptions options{}; + }; + ++#if !EMBEDDED_LEVELDB ++bool dbwrapper_SanityCheck(); ++#endif ++ + class dbwrapper_error : public std::runtime_error + { + public: +diff --git a/src/kernel/checks.cpp b/src/kernel/checks.cpp +index 4c303c172c..a8867c3aa5 100644 +--- a/src/kernel/checks.cpp ++++ b/src/kernel/checks.cpp +@@ -4,6 +4,7 @@ + + #include <kernel/checks.h> + ++#include <dbwrapper.h> + #include <key.h> + #include <random.h> + #include <util/time.h> +@@ -15,6 +16,12 @@ namespace kernel { + + std::optional<bilingual_str> SanityChecks(const Context&) + { ++#if !EMBEDDED_LEVELDB ++ if (!dbwrapper_SanityCheck()) { ++ return Untranslated("Database sanity check failure. Aborting."); ++ } ++#endif ++ + if (!ECC_InitSanityCheck()) { + return Untranslated("Elliptic curve cryptography sanity check failure. Aborting."); + } +-- +2.42.0 + diff --git a/net-p2p/bitcoin-core/files/bitcoin-qt.protocol b/net-p2p/bitcoin-core/files/bitcoin-qt.protocol new file mode 100644 index 000000000000..014588d53679 --- /dev/null +++ b/net-p2p/bitcoin-core/files/bitcoin-qt.protocol @@ -0,0 +1,11 @@ +[Protocol] +exec=bitcoin-qt '%u' +protocol=bitcoin +input=none +output=none +helper=true +listing= +reading=false +writing=false +makedir=false +deleting=false diff --git a/net-p2p/bitcoin-core/files/bitcoind.logrotate-r1 b/net-p2p/bitcoin-core/files/bitcoind.logrotate-r1 new file mode 100644 index 000000000000..bcaff58d9fb9 --- /dev/null +++ b/net-p2p/bitcoin-core/files/bitcoind.logrotate-r1 @@ -0,0 +1,8 @@ +/var/log/bitcoin/debug.log { + missingok + weekly + sharedscripts + postrotate + killall -HUP bitcoind + endscript +} diff --git a/net-p2p/bitcoin-core/files/bitcoind.openrc b/net-p2p/bitcoin-core/files/bitcoind.openrc new file mode 100644 index 000000000000..7d16e975e5e5 --- /dev/null +++ b/net-p2p/bitcoin-core/files/bitcoind.openrc @@ -0,0 +1,89 @@ +#!/sbin/openrc-run + +: ${BITCOIND_CONFIGFILE:=/etc/bitcoin/bitcoin.conf} +: ${BITCOIND_PIDDIR:=/run/bitcoind} +: ${BITCOIND_PIDFILE:=${BITCOIND_PIDDIR}/${SVCNAME}.pid} +: ${BITCOIND_DATADIR:=/var/lib/bitcoind} +: ${BITCOIND_LOGDIR:=/var/log/bitcoind} +: ${BITCOIND_USER:=${BITCOIN_USER:-bitcoin}} +: ${BITCOIND_GROUP:=bitcoin} +: ${BITCOIND_BIN:=/usr/bin/bitcoind} +: ${BITCOIND_NICE:=${NICELEVEL:-0}} +: ${BITCOIND_OPTS=${BITCOIN_OPTS}} + +name="Bitcoin Core daemon" +description="Bitcoin cryptocurrency P2P network daemon" + +required_files="${BITCOIND_CONFIGFILE}" +pidfile="${BITCOIND_PIDFILE}" +in_background_fake="start" + +depend() { + need localmount net +} + +start_pre() { + checkpath -f --mode 0660 --owner "${BITCOIND_USER}:${BITCOIND_GROUP}" "${BITCOIND_CONFIGFILE}" + checkpath -d --mode 0750 --owner "${BITCOIND_USER}:${BITCOIND_GROUP}" "${BITCOIND_DATADIR}" + checkpath -d --mode 0755 --owner "${BITCOIND_USER}:${BITCOIND_GROUP}" "${BITCOIND_LOGDIR}" + checkpath -d --mode 0755 --owner "${BITCOIND_USER}:${BITCOIND_GROUP}" "${BITCOIND_PIDDIR}" + checkconfig +} + +start() { + ebegin "Starting ${name}" + mark_service_inactive + if start-stop-daemon \ + --pidfile="${BITCOIND_PIDFILE}" \ + --chdir="${BITCOIND_DATADIR}" \ + --user="${BITCOIND_USER}:${BITCOIND_GROUP}" \ + --nice="${BITCOIND_NICE}" \ + --exec="${BITCOIND_BIN}" \ + -- \ + -daemonwait \ + -pid="${BITCOIND_PIDFILE}" \ + -conf="${BITCOIND_CONFIGFILE}" \ + -datadir="${BITCOIND_DATADIR}" \ + -debuglogfile="${BITCOIND_LOGDIR}/debug.log" \ + ${BITCOIND_OPTS} + then + chmod g+r "${BITCOIND_DATADIR}/.cookie" + IN_BACKGROUND=yes rc-service "${SVCNAME}" --quiet start + else + rc-service "${SVCNAME}" --quiet zap + fi & +} + +stop() { + ebegin "Stopping ${name}" + start-stop-daemon --stop \ + --pidfile="${BITCOIND_PIDFILE}" \ + --retry="${BITCOIND_SIGTERM_TIMEOUT}" \ + --exec="${BITCOIND_BIN}" + eend $? +} + +checkconfig() { + if grep -qs '^rpcuser=' "${BITCOIND_CONFIGFILE}" && + ! grep -qs '^rpcpassword=' "${BITCOIND_CONFIGFILE}" + then + eerror "" + eerror "ERROR: You must set a secure rpcpassword to run bitcoind." + eerror "The setting must appear in ${BITCOIND_CONFIGFILE}" + eerror "" + eerror "This password is security critical to securing wallets " + eerror "and must not be the same as the rpcuser setting." + eerror "You can generate a suitable random password using the following " + eerror "command from the shell:" + eerror "" + eerror "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'" + eerror "" + eerror "It is recommended that you also set alertnotify so you are " + eerror "notified of problems:" + eerror "" + eerror "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\"" \ + "admin@foo.com" + eerror "" + return 1 + fi +} diff --git a/net-p2p/bitcoin-core/files/init.patch b/net-p2p/bitcoin-core/files/init.patch new file mode 100644 index 000000000000..7b78217fe8a7 --- /dev/null +++ b/net-p2p/bitcoin-core/files/init.patch @@ -0,0 +1,43 @@ +--- a/contrib/init/bitcoind.openrcconf ++++ b/contrib/init/bitcoind.openrcconf +@@ -4,14 +4,17 @@ + #BITCOIND_CONFIGFILE="/etc/bitcoin/bitcoin.conf" + + # What directory to write pidfile to? (created and owned by $BITCOIND_USER) +-#BITCOIND_PIDDIR="/var/run/bitcoind" ++#BITCOIND_PIDDIR="/run/bitcoind" + + # What filename to give the pidfile +-#BITCOIND_PIDFILE="${BITCOIND_PIDDIR}/bitcoind.pid" ++#BITCOIND_PIDFILE="${BITCOIND_PIDDIR}/${SVCNAME}.pid" + + # Where to write bitcoind data (be mindful that the blockchain is large) + #BITCOIND_DATADIR="/var/lib/bitcoind" + ++# Where to write the debug.log file ++#BITCOIND_LOGDIR="/var/log/bitcoind" ++ + # User and group to own bitcoind process + #BITCOIND_USER="bitcoin" + #BITCOIND_GROUP="bitcoin" +--- a/contrib/init/bitcoind.service ++++ b/contrib/init/bitcoind.service +@@ -21,6 +21,7 @@ Wants=network-online.target + ExecStart=/usr/bin/bitcoind -daemonwait \ + -pid=/run/bitcoind/bitcoind.pid \ + -conf=/etc/bitcoin/bitcoin.conf \ ++ -debuglogfile=/var/log/bitcoind/debug.log \ + -datadir=/var/lib/bitcoind + + # Make sure the config directory is readable by the service user +@@ -51,6 +52,10 @@ RuntimeDirectoryMode=0710 + ConfigurationDirectory=bitcoin + ConfigurationDirectoryMode=0710 + ++# /var/log/bitcoind ++LogsDirectory=bitcoind ++LogsDirectoryMode=0755 ++ + # /var/lib/bitcoind + StateDirectory=bitcoind + StateDirectoryMode=0710 diff --git a/net-p2p/bitcoin-core/files/org.bitcoin.bitcoin-qt.desktop b/net-p2p/bitcoin-core/files/org.bitcoin.bitcoin-qt.desktop new file mode 100644 index 000000000000..21ae68c21b74 --- /dev/null +++ b/net-p2p/bitcoin-core/files/org.bitcoin.bitcoin-qt.desktop @@ -0,0 +1,15 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Name=Bitcoin Core +Comment=Connect to the Bitcoin P2P Network +Comment[de]=Verbinde mit dem Bitcoin peer-to-peer Netzwerk +Comment[fr]=Bitcoin, monnaie virtuelle cryptographique pair à pair +Comment[tr]=Bitcoin, eşten eşe kriptografik sanal para birimi +Exec=bitcoin-qt %u +Terminal=false +Type=Application +Icon=bitcoin128 +MimeType=x-scheme-handler/bitcoin; +Categories=Office;Finance;P2P;Network;Qt; +StartupWMClass=Bitcoin-qt diff --git a/net-p2p/bitcoin-core/metadata.xml b/net-p2p/bitcoin-core/metadata.xml new file mode 100644 index 000000000000..3c0338bb1ad9 --- /dev/null +++ b/net-p2p/bitcoin-core/metadata.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> + <maintainer type="person" proxied="yes"> + <email>gentoo@mattwhitlock.name</email> + <name>Matt Whitlock</name> + </maintainer> + <maintainer type="project" proxied="proxy"> + <email>proxy-maint@gentoo.org</email> + <name>Proxy Maintainers</name> + </maintainer> + <use> + <flag name="asm">Enable assembly for optimization</flag> + <flag name="berkdb">Support legacy wallets in Berkeley DB format</flag> + <flag name="bitcoin-cli">Build and install bitcoin-cli command line interface</flag> + <flag name="daemon">Build and install bitcoind daemon</flag> + <flag name="external-signer">Include support for external wallet signer programs</flag> + <flag name="libs">Build and install libbitcoinconsensus</flag> + <flag name="nat-pmp">Enable NAT-PMP port forwarding</flag> + <flag name="qrcode">Enable generation of QR Codes for receiving payments</flag> + <flag name="qt5">Build and install Bitcoin-Qt GUI</flag> + <flag name="sqlite">Support descriptor wallets in SQLite format</flag> + <flag name="system-leveldb">Link with virtual/bitcoin-leveldb rather than embedding an internal copy</flag> + <flag name="system-libsecp256k1">Link with dev-libs/libsecp256k1 rather than embedding an internal copy</flag> + <flag name="systemtap">Enable SystemTAP/DTrace tracing</flag> + <flag name="upnp">Enable Universal Plug and Play</flag> + <flag name="zeromq">Report blocks and transactions via zeromq</flag> + </use> + <upstream> + <remote-id type="github">bitcoin/bitcoin</remote-id> + <remote-id type="cpe">cpe:/a:bitcoin:bitcoin_core</remote-id> + </upstream> +</pkgmetadata> |