1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: bitcoincore.eclass
7 # Luke Dashjr <luke_gentoo_bitcoin@dashjr.org>
8 # @BLURB: common code for Bitcoin Core ebuilds
10 # This eclass is used in Bitcoin Core ebuilds (bitcoin-qt, bitcoind,
11 # libbitcoinconsensus) to provide a single common place for the common ebuild
14 # The eclass provides all common dependencies as well as common use flags.
16 has "${EAPI:-0}" 5 || die "EAPI=${EAPI} not supported"
18 if [[ ! ${_BITCOINCORE_ECLASS} ]]; then
21 local liuse=( ${BITCOINCORE_IUSE} )
22 has "${1}" "${liuse[@]#[+-]}"
26 local liuse=( ${BITCOINCORE_POLICY_PATCHES} )
27 has "${1}" "${liuse[@]#[+-]}"
31 inherit autotools db-use eutils
33 if [ -z "$BITCOINCORE_COMMITHASH" ]; then
39 EXPORT_FUNCTIONS src_prepare src_test src_install
41 if in_bcc_iuse ljr || in_bcc_iuse 1stclassmsg || in_bcc_iuse zeromq || [ -n "$BITCOINCORE_POLICY_PATCHES" ]; then
42 EXPORT_FUNCTIONS pkg_pretend
45 if [[ ! ${_BITCOINCORE_ECLASS} ]]; then
47 # @ECLASS-VARIABLE: BITCOINCORE_COMMITHASH
49 # Set this variable before the inherit line, to the upstream commit hash.
51 # @ECLASS-VARIABLE: BITCOINCORE_IUSE
53 # Set this variable before the inherit line, to the USE flags supported.
55 # @ECLASS-VARIABLE: BITCOINCORE_LJR_DATE
57 # Set this variable before the inherit line, to the datestamp of the ljr
60 # @ECLASS-VARIABLE: BITCOINCORE_POLICY_PATCHES
62 # Set this variable before the inherit line, to a space-delimited list of
69 # These are expected to change in future versions
70 DOCS="${DOCS} doc/README.md doc/release-notes.md"
71 OPENSSL_DEPEND="dev-libs/openssl:0[-bindist]"
72 WALLET_DEPEND="sys-libs/db:$(db_ver_to_slot "${DB_VER}")[cxx]"
73 [ -n "${BITCOINCORE_LJR_PV}" ] || BITCOINCORE_LJR_PV="${PV}"
77 BITCOINCORE_SERIES="0.10.x"
78 LIBSECP256K1_DEPEND="=dev-libs/libsecp256k1-0.0.0_pre20141212"
81 BITCOINCORE_RBF_DIFF="16f45600c8c372a738ffef544292864256382601...a23678edc70204599299459a206709a00e039db7"
82 BITCOINCORE_RBF_PATCHFILE="${MyPN}-rbf-v0.10.2.patch"
85 BITCOINCORE_RBF_DIFF="16f45600c8c372a738ffef544292864256382601...4890416cde655559eba09d3fd6f79db7d0d6314a"
86 BITCOINCORE_RBF_PATCHFILE="${MyPN}-rbf-v0.10.2-r1.patch"
89 BITCOINCORE_XT_DIFF="047a89831760ff124740fe9f58411d57ee087078...d4084b62c42c38bfe302d712b98909ab26ecce2f"
92 BITCOINCORE_SERIES="0.11.x"
93 LIBSECP256K1_DEPEND="=dev-libs/libsecp256k1-0.0.0_pre20150423"
94 BITCOINCORE_RBF_DIFF="5f032c75eefb0fe8ff79ed9595da1112c05f5c4a...660b96d24916b8ef4e0677e5d6162e24e2db447e"
95 BITCOINCORE_RBF_PATCHFILE="${MyPN}-rbf-v0.11.0rc3.patch"
98 BITCOINCORE_SERIES="9999"
99 LIBSECP256K1_DEPEND=">dev-libs/libsecp256k1-0.0.0_pre20150422"
102 die "Unrecognised version"
106 LJR_PV() { echo "${BITCOINCORE_LJR_PV}.${1}${BITCOINCORE_LJR_DATE}"; }
107 LJR_PATCHDIR="${MyPN}-$(LJR_PV ljr).patches"
108 LJR_PATCH() { echo "${WORKDIR}/${LJR_PATCHDIR}/${MyPN}-$(LJR_PV ljr).$@.patch"; }
109 LJR_PATCH_DESC="http://luke.dashjr.org/programs/${MyPN}/files/${MyPN}d/luke-jr/${BITCOINCORE_SERIES}/$(LJR_PV ljr)/${MyPN}-$(LJR_PV ljr).desc.txt"
111 HOMEPAGE="https://github.com/bitcoin/bitcoin"
113 if [ -z "$BITCOINCORE_COMMITHASH" ]; then
114 EGIT_PROJECT='bitcoin'
115 EGIT_REPO_URI="git://github.com/bitcoin/bitcoin.git https://github.com/bitcoin/bitcoin.git"
117 SRC_URI="https://github.com/${MyPN}/${MyPN}/archive/${BITCOINCORE_COMMITHASH}.tar.gz -> ${MyPN}-v${PV}${BITCOINCORE_SRC_SUFFIX}.tgz"
118 if [ -z "${BITCOINCORE_NO_SYSLIBS}" ]; then
119 SRC_URI="${SRC_URI} http://luke.dashjr.org/programs/${MyPN}/files/${MyPN}d/luke-jr/${BITCOINCORE_SERIES}/$(LJR_PV ljr)/${LJR_PATCHDIR}.txz -> ${LJR_PATCHDIR}.tar.xz"
121 if in_bcc_iuse xt; then
122 BITCOINXT_PATCHFILE="${MyPN}xt-v${PV}.patch"
123 SRC_URI="${SRC_URI} xt? ( https://github.com/bitcoinxt/bitcoinxt/compare/${BITCOINCORE_XT_DIFF}.diff -> ${BITCOINXT_PATCHFILE} )"
125 if in_bcc_policy rbf; then
126 SRC_URI="${SRC_URI} bitcoin_policy_rbf? ( https://github.com/petertodd/bitcoin/compare/${BITCOINCORE_RBF_DIFF}.diff -> ${BITCOINCORE_RBF_PATCHFILE} )"
128 S="${WORKDIR}/${MyPN}-${BITCOINCORE_COMMITHASH}"
131 bitcoincore_policy_iuse() {
132 local mypolicy iuse_def new_BITCOINCORE_IUSE=
133 for mypolicy in ${BITCOINCORE_POLICY_PATCHES}; do
134 if [[ "${mypolicy:0:1}" =~ ^[+-] ]]; then
135 iuse_def=${mypolicy:0:1}
136 mypolicy="${mypolicy:1}"
140 new_BITCOINCORE_IUSE="$new_BITCOINCORE_IUSE ${iuse_def}bitcoin_policy_${mypolicy}"
142 echo $new_BITCOINCORE_IUSE
144 IUSE="$IUSE $BITCOINCORE_IUSE $(bitcoincore_policy_iuse)"
145 if in_bcc_policy rbf && in_bcc_iuse xt; then
146 REQUIRED_USE="${REQUIRED_USE} bitcoin_policy_rbf? ( !xt )"
149 BITCOINCORE_COMMON_DEPEND="
152 if [ "${BITCOINCORE_NEED_LIBSECP256K1}" = "1" ]; then
153 BITCOINCORE_COMMON_DEPEND="${BITCOINCORE_COMMON_DEPEND} $LIBSECP256K1_DEPEND"
155 if [ "${PN}" != "libbitcoinconsensus" ]; then
156 BITCOINCORE_COMMON_DEPEND="${BITCOINCORE_COMMON_DEPEND} >=dev-libs/boost-1.52.0[threads(+)]"
158 bitcoincore_common_depend_use() {
159 in_bcc_iuse "$1" || return
160 BITCOINCORE_COMMON_DEPEND="${BITCOINCORE_COMMON_DEPEND} $1? ( $2 )"
162 bitcoincore_common_depend_use upnp net-libs/miniupnpc
163 bitcoincore_common_depend_use wallet "${WALLET_DEPEND}"
164 bitcoincore_common_depend_use zeromq net-libs/zeromq
165 RDEPEND="${RDEPEND} ${BITCOINCORE_COMMON_DEPEND}"
166 DEPEND="${DEPEND} ${BITCOINCORE_COMMON_DEPEND}
167 >=app-shells/bash-4.1
170 if [ "${BITCOINCORE_NEED_LEVELDB}" = "1" ]; then
171 RDEPEND="${RDEPEND} virtual/bitcoin-leveldb"
173 if in_bcc_iuse ljr && [ "$BITCOINCORE_SERIES" = "0.10.x" ]; then
174 DEPEND="${DEPEND} ljr? ( dev-vcs/git )"
177 bitcoincore_policymsg() {
178 local USEFlag="bitcoin_policy_$1"
179 in_iuse "${USEFlag}" || return
180 if use "${USEFlag}"; then
181 [ -n "$2" ] && einfo "$2"
183 [ -n "$3" ] && einfo "$3"
185 bitcoincore_policymsg_flag=true
188 bitcoincore_pkg_pretend() {
189 bitcoincore_policymsg_flag=false
190 if use_if_iuse ljr || use_if_iuse 1stclassmsg || use_if_iuse xt || use_if_iuse zeromq; then
191 einfo "Extra functionality improvements to Bitcoin Core are enabled."
192 bitcoincore_policymsg_flag=true
194 bitcoincore_policymsg cltv \
195 "CLTV policy is enabled: Your node will recognise and assist OP_CHECKLOCKTIMEVERIFY (BIP65) transactions." \
196 "CLTV policy is disabled: Your node will not recognise OP_CHECKLOCKTIMEVERIFY (BIP65) transactions."
197 bitcoincore_policymsg cpfp \
198 "CPFP policy is enabled: If you mine, you will give consideration to child transaction fees to pay for their parents." \
199 "CPFP policy is disabled: If you mine, you will ignore transactions unless they have sufficient fee themselves, even if child transactions offer a fee to cover their cost."
200 bitcoincore_policymsg dcmp \
201 "Data Carrier Multi-Push policy is enabled: Your node will assist transactions with at most a single multiple-'push' data carrier output." \
202 "Data Carrier Multi-Push policy is disabled: Your node will assist transactions with at most a single data carrier output with only a single 'push'."
203 bitcoincore_policymsg rbf \
204 "Replace By Fee policy is enabled: Your node will preferentially mine and relay transactions paying the highest fee, regardless of receive order." \
205 "Replace By Fee policy is disabled: Your node will only accept the first transaction seen consuming a conflicting input, regardless of fee offered by later ones."
206 bitcoincore_policymsg spamfilter \
207 "Enhanced spam filter is enabled: A blacklist (seen as controversial by some) will be used by your node. This may impact your ability to use some services (see link for a list)." \
208 "Enhanced spam filter is disabled: Your node will not be checking for notorious spammers, and may assist them."
209 $bitcoincore_policymsg_flag && einfo "For more information on any of the above, see ${LJR_PATCH_DESC}"
212 bitcoincore_prepare() {
213 if [ -n "${BITCOINCORE_NO_SYSLIBS}" ]; then
215 elif [ "${PV}" = "9999" ]; then
216 epatch "${FILESDIR}/${PV}-syslibs.patch"
218 epatch "$(LJR_PATCH syslibs)"
220 if use_if_iuse ljr; then
221 if [ "${BITCOINCORE_SERIES}" = "0.10.x" ]; then
222 # Regular epatch won't work with binary files
223 local patchfile="$(LJR_PATCH ljrF)"
224 einfo "Applying ${patchfile##*/} ..."
225 git apply --whitespace=nowarn "${patchfile}" || die
227 epatch "$(LJR_PATCH ljrF)"
230 if use_if_iuse 1stclassmsg; then
231 epatch "$(LJR_PATCH 1stclassmsg)"
233 if use_if_iuse xt; then
234 epatch "${DISTDIR}/${BITCOINXT_PATCHFILE}"
236 use_if_iuse zeromq && epatch "$(LJR_PATCH zeromq)"
237 for mypolicy in ${BITCOINCORE_POLICY_PATCHES}; do
238 mypolicy="${mypolicy#[-+]}"
239 use bitcoin_policy_${mypolicy} || continue
240 case "${mypolicy}" in
242 epatch "${DISTDIR}/${BITCOINCORE_RBF_PATCHFILE}"
245 epatch "$(LJR_PATCH ${mypolicy})"
251 bitcoincore_autoreconf() {
253 rm -r src/leveldb || die
254 rm -r src/secp256k1 || die
257 bitcoincore_src_prepare() {
259 bitcoincore_autoreconf
264 if use_if_iuse upnp; then
265 my_econf="${my_econf} --with-miniupnpc --enable-upnp-default"
267 my_econf="${my_econf} --without-miniupnpc --disable-upnp-default"
269 if use_if_iuse test; then
270 my_econf="${my_econf} --enable-tests"
272 my_econf="${my_econf} --disable-tests"
274 if use_if_iuse wallet; then
275 my_econf="${my_econf} --enable-wallet"
277 my_econf="${my_econf} --disable-wallet"
279 if [ -z "${BITCOINCORE_NO_SYSLIBS}" ]; then
280 my_econf="${my_econf} --disable-util-cli --disable-util-tx"
282 my_econf="${my_econf} --without-utils"
284 if [ "${BITCOINCORE_NEED_LEVELDB}" = "1" ]; then
285 # Passing --with-system-leveldb fails if leveldb is not installed, so only use it for targets that use LevelDB
286 my_econf="${my_econf} --with-system-leveldb"
291 --with-system-libsecp256k1 \
299 bitcoincore_src_test() {
303 bitcoincore_src_install() {
305 [ "${PN}" = "libbitcoinconsensus" ] || rm "${D}/usr/bin/test_bitcoin"
308 _BITCOINCORE_ECLASS=1