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 # RBF is bundled with ljr patchset since 0.11.1
95 if [ "${PVR}" = "0.11.0" ]; then
96 BITCOINCORE_RBF_DIFF="5f032c75eefb0fe8ff79ed9595da1112c05f5c4a...660b96d24916b8ef4e0677e5d6162e24e2db447e"
97 BITCOINCORE_RBF_PATCHFILE="${MyPN}-rbf-v0.11.0rc3.patch"
101 BITCOINCORE_SERIES="9999"
102 LIBSECP256K1_DEPEND=">dev-libs/libsecp256k1-0.0.0_pre20150422"
105 die "Unrecognised version"
109 LJR_PV() { echo "${BITCOINCORE_LJR_PV}.${1}${BITCOINCORE_LJR_DATE}"; }
110 LJR_PATCHDIR="${MyPN}-$(LJR_PV ljr).patches"
111 LJR_PATCH() { echo "${WORKDIR}/${LJR_PATCHDIR}/${MyPN}-$(LJR_PV ljr).$@.patch"; }
112 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"
114 HOMEPAGE="https://github.com/bitcoin/bitcoin"
116 if [ -z "$BITCOINCORE_COMMITHASH" ]; then
117 EGIT_PROJECT='bitcoin'
118 EGIT_REPO_URI="git://github.com/bitcoin/bitcoin.git https://github.com/bitcoin/bitcoin.git"
120 SRC_URI="https://github.com/${MyPN}/${MyPN}/archive/${BITCOINCORE_COMMITHASH}.tar.gz -> ${MyPN}-v${PV}${BITCOINCORE_SRC_SUFFIX}.tgz"
121 if [ -z "${BITCOINCORE_NO_SYSLIBS}" ]; then
122 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"
124 if in_bcc_iuse xt; then
125 BITCOINXT_PATCHFILE="${MyPN}xt-v${PV}.patch"
126 SRC_URI="${SRC_URI} xt? ( https://github.com/bitcoinxt/bitcoinxt/compare/${BITCOINCORE_XT_DIFF}.diff -> ${BITCOINXT_PATCHFILE} )"
128 if in_bcc_policy rbf && [ -n "${BITCOINCORE_RBF_DIFF}" ]; then
129 SRC_URI="${SRC_URI} bitcoin_policy_rbf? ( https://github.com/petertodd/bitcoin/compare/${BITCOINCORE_RBF_DIFF}.diff -> ${BITCOINCORE_RBF_PATCHFILE} )"
131 S="${WORKDIR}/${MyPN}-${BITCOINCORE_COMMITHASH}"
134 bitcoincore_policy_iuse() {
135 local mypolicy iuse_def new_BITCOINCORE_IUSE=
136 for mypolicy in ${BITCOINCORE_POLICY_PATCHES}; do
137 if [[ "${mypolicy:0:1}" =~ ^[+-] ]]; then
138 iuse_def=${mypolicy:0:1}
139 mypolicy="${mypolicy:1}"
143 new_BITCOINCORE_IUSE="$new_BITCOINCORE_IUSE ${iuse_def}bitcoin_policy_${mypolicy}"
145 echo $new_BITCOINCORE_IUSE
147 IUSE="$IUSE $BITCOINCORE_IUSE $(bitcoincore_policy_iuse)"
148 if in_bcc_policy rbf && in_bcc_iuse xt; then
149 REQUIRED_USE="${REQUIRED_USE} bitcoin_policy_rbf? ( !xt )"
152 BITCOINCORE_COMMON_DEPEND="
155 if [ "${BITCOINCORE_NEED_LIBSECP256K1}" = "1" ]; then
156 BITCOINCORE_COMMON_DEPEND="${BITCOINCORE_COMMON_DEPEND} $LIBSECP256K1_DEPEND"
158 if [ "${PN}" != "libbitcoinconsensus" ]; then
159 BITCOINCORE_COMMON_DEPEND="${BITCOINCORE_COMMON_DEPEND} >=dev-libs/boost-1.52.0[threads(+)]"
161 bitcoincore_common_depend_use() {
162 in_bcc_iuse "$1" || return
163 BITCOINCORE_COMMON_DEPEND="${BITCOINCORE_COMMON_DEPEND} $1? ( $2 )"
165 bitcoincore_common_depend_use upnp net-libs/miniupnpc
166 bitcoincore_common_depend_use wallet "${WALLET_DEPEND}"
167 bitcoincore_common_depend_use zeromq net-libs/zeromq
168 RDEPEND="${RDEPEND} ${BITCOINCORE_COMMON_DEPEND}"
169 DEPEND="${DEPEND} ${BITCOINCORE_COMMON_DEPEND}
170 >=app-shells/bash-4.1
173 if [ "${BITCOINCORE_NEED_LEVELDB}" = "1" ]; then
174 RDEPEND="${RDEPEND} virtual/bitcoin-leveldb"
176 if in_bcc_iuse ljr && [ "$BITCOINCORE_SERIES" = "0.10.x" ]; then
177 DEPEND="${DEPEND} ljr? ( dev-vcs/git )"
180 bitcoincore_policymsg() {
181 local USEFlag="bitcoin_policy_$1"
182 in_iuse "${USEFlag}" || return
183 if use "${USEFlag}"; then
184 [ -n "$2" ] && einfo "$2"
186 [ -n "$3" ] && einfo "$3"
188 bitcoincore_policymsg_flag=true
191 bitcoincore_pkg_pretend() {
192 bitcoincore_policymsg_flag=false
193 if use_if_iuse ljr || use_if_iuse 1stclassmsg || use_if_iuse xt || use_if_iuse zeromq; then
194 einfo "Extra functionality improvements to Bitcoin Core are enabled."
195 bitcoincore_policymsg_flag=true
197 bitcoincore_policymsg cltv \
198 "CLTV policy is enabled: Your node will recognise and assist OP_CHECKLOCKTIMEVERIFY (BIP65) transactions." \
199 "CLTV policy is disabled: Your node will not recognise OP_CHECKLOCKTIMEVERIFY (BIP65) transactions."
200 bitcoincore_policymsg cpfp \
201 "CPFP policy is enabled: If you mine, you will give consideration to child transaction fees to pay for their parents." \
202 "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."
203 bitcoincore_policymsg dcmp \
204 "Data Carrier Multi-Push policy is enabled: Your node will assist transactions with at most a single multiple-'push' data carrier output." \
205 "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'."
206 bitcoincore_policymsg rbf \
207 "Replace By Fee policy is enabled: Your node will preferentially mine and relay transactions paying the highest fee, regardless of receive order." \
208 "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."
209 bitcoincore_policymsg spamfilter \
210 "Enhanced spam filter policy is enabled: Your node will identify notorious spam scripts and avoid assisting them. This may impact your ability to use some services (see link for a list)." \
211 "Enhanced spam filter policy is disabled: Your node will not be checking for notorious spam scripts, and may assist them."
212 $bitcoincore_policymsg_flag && einfo "For more information on any of the above, see ${LJR_PATCH_DESC}"
215 bitcoincore_prepare() {
217 if [ -n "${BITCOINCORE_NO_SYSLIBS}" ]; then
219 elif [ "${PV}" = "9999" ]; then
220 epatch "${FILESDIR}/${PV}-syslibs.patch"
222 epatch "$(LJR_PATCH syslibs)"
224 if use_if_iuse ljr; then
225 if [ "${BITCOINCORE_SERIES}" = "0.10.x" ]; then
226 # Regular epatch won't work with binary files
227 local patchfile="$(LJR_PATCH ljrF)"
228 einfo "Applying ${patchfile##*/} ..."
229 git apply --whitespace=nowarn "${patchfile}" || die
231 epatch "$(LJR_PATCH ljrF)"
234 if use_if_iuse 1stclassmsg; then
235 epatch "$(LJR_PATCH 1stclassmsg)"
237 if use_if_iuse xt; then
238 epatch "${DISTDIR}/${BITCOINXT_PATCHFILE}"
240 use_if_iuse zeromq && epatch "$(LJR_PATCH zeromq)"
241 for mypolicy in ${BITCOINCORE_POLICY_PATCHES}; do
242 mypolicy="${mypolicy#[-+]}"
243 use bitcoin_policy_${mypolicy} || continue
244 case "${mypolicy}" in
246 if [ -n "${BITCOINCORE_RBF_PATCHFILE}" ]; then
247 epatch "${DISTDIR}/${BITCOINCORE_RBF_PATCHFILE}"
249 epatch "$(LJR_PATCH ${mypolicy})"
253 epatch "$(LJR_PATCH ${mypolicy})"
259 bitcoincore_autoreconf() {
261 rm -r src/leveldb || die
262 rm -r src/secp256k1 || die
265 bitcoincore_src_prepare() {
267 bitcoincore_autoreconf
272 if use_if_iuse upnp; then
273 my_econf="${my_econf} --with-miniupnpc --enable-upnp-default"
275 my_econf="${my_econf} --without-miniupnpc --disable-upnp-default"
277 if use_if_iuse test; then
278 my_econf="${my_econf} --enable-tests"
280 my_econf="${my_econf} --disable-tests"
282 if use_if_iuse wallet; then
283 my_econf="${my_econf} --enable-wallet"
285 my_econf="${my_econf} --disable-wallet"
287 if [ -z "${BITCOINCORE_NO_SYSLIBS}" ]; then
288 my_econf="${my_econf} --disable-util-cli --disable-util-tx"
290 my_econf="${my_econf} --without-utils"
292 if [ "${BITCOINCORE_NEED_LEVELDB}" = "1" ]; then
293 # Passing --with-system-leveldb fails if leveldb is not installed, so only use it for targets that use LevelDB
294 my_econf="${my_econf} --with-system-leveldb"
299 --with-system-libsecp256k1 \
307 bitcoincore_src_test() {
311 bitcoincore_src_install() {
313 [ "${PN}" = "libbitcoinconsensus" ] || rm "${D}/usr/bin/test_bitcoin"
316 _BITCOINCORE_ECLASS=1