/[gentoo-x86]/eclass/bitcoincore.eclass
Gentoo

Contents of /eclass/bitcoincore.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Tue Jul 14 11:51:39 2015 UTC (3 years, 3 months ago) by blueness
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +25 -14 lines
Update for bitcoind 0.11.0.

1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/bitcoincore.eclass,v 1.4 2015/05/27 00:18:02 blueness Exp $
4 #
5 # @ECLASS: bitcoincore.eclass
6 # @MAINTAINER:
7 # Luke Dashjr <luke_gentoo_bitcoin@dashjr.org>
8 # @BLURB: common code for Bitcoin Core ebuilds
9 # @DESCRIPTION:
10 # This eclass is used in Bitcoin Core ebuilds (bitcoin-qt, bitcoind,
11 # libbitcoinconsensus) to provide a single common place for the common ebuild
12 # stuff.
13 #
14 # The eclass provides all common dependencies as well as common use flags.
15
16 has "${EAPI:-0}" 5 || die "EAPI=${EAPI} not supported"
17
18 if [[ ! ${_BITCOINCORE_ECLASS} ]]; then
19
20 in_bcc_iuse() {
21 local liuse=( ${BITCOINCORE_IUSE} )
22 has "${1}" "${liuse[@]#[+-]}"
23 }
24
25 in_bcc_policy() {
26 local liuse=( ${BITCOINCORE_POLICY_PATCHES} )
27 has "${1}" "${liuse[@]#[+-]}"
28 }
29
30 DB_VER="4.8"
31 inherit autotools db-use eutils
32
33 if [ -z "$BITCOINCORE_COMMITHASH" ]; then
34 inherit git-2
35 fi
36
37 fi
38
39 EXPORT_FUNCTIONS src_prepare src_test src_install
40
41 if in_bcc_iuse ljr || in_bcc_iuse 1stclassmsg || in_bcc_iuse zeromq || [ -n "$BITCOINCORE_POLICY_PATCHES" ]; then
42 EXPORT_FUNCTIONS pkg_pretend
43 fi
44
45 if [[ ! ${_BITCOINCORE_ECLASS} ]]; then
46
47 # @ECLASS-VARIABLE: BITCOINCORE_COMMITHASH
48 # @DESCRIPTION:
49 # Set this variable before the inherit line, to the upstream commit hash.
50
51 # @ECLASS-VARIABLE: BITCOINCORE_IUSE
52 # @DESCRIPTION:
53 # Set this variable before the inherit line, to the USE flags supported.
54
55 # @ECLASS-VARIABLE: BITCOINCORE_LJR_DATE
56 # @DESCRIPTION:
57 # Set this variable before the inherit line, to the datestamp of the ljr
58 # patchset.
59
60 # @ECLASS-VARIABLE: BITCOINCORE_POLICY_PATCHES
61 # @DESCRIPTION:
62 # Set this variable before the inherit line, to a space-delimited list of
63 # supported policies.
64
65 MyPV="${PV/_/}"
66 MyPN="bitcoin"
67 MyP="${MyPN}-${MyPV}"
68
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}"
74
75 case "${PV}" in
76 0.10*)
77 BITCOINCORE_SERIES="0.10.x"
78 LIBSECP256K1_DEPEND="=dev-libs/libsecp256k1-0.0.0_pre20141212"
79 case "${PVR}" in
80 0.10.2)
81 BITCOINCORE_RBF_DIFF="16f45600c8c372a738ffef544292864256382601...a23678edc70204599299459a206709a00e039db7"
82 BITCOINCORE_RBF_PATCHFILE="${MyPN}-rbf-v0.10.2.patch"
83 ;;
84 *)
85 BITCOINCORE_RBF_DIFF="16f45600c8c372a738ffef544292864256382601...4890416cde655559eba09d3fd6f79db7d0d6314a"
86 BITCOINCORE_RBF_PATCHFILE="${MyPN}-rbf-v0.10.2-r1.patch"
87 ;;
88 esac
89 BITCOINCORE_XT_DIFF="047a89831760ff124740fe9f58411d57ee087078...d4084b62c42c38bfe302d712b98909ab26ecce2f"
90 ;;
91 0.11*)
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"
96 ;;
97 9999*)
98 BITCOINCORE_SERIES="9999"
99 LIBSECP256K1_DEPEND=">dev-libs/libsecp256k1-0.0.0_pre20150422"
100 ;;
101 *)
102 die "Unrecognised version"
103 ;;
104 esac
105
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"
110
111 HOMEPAGE="https://github.com/bitcoin/bitcoin"
112
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"
116 else
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"
120 fi
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} )"
124 fi
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} )"
127 fi
128 S="${WORKDIR}/${MyPN}-${BITCOINCORE_COMMITHASH}"
129 fi
130
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}"
137 else
138 iuse_def=
139 fi
140 new_BITCOINCORE_IUSE="$new_BITCOINCORE_IUSE ${iuse_def}bitcoin_policy_${mypolicy}"
141 done
142 echo $new_BITCOINCORE_IUSE
143 }
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 )"
147 fi
148
149 BITCOINCORE_COMMON_DEPEND="
150 ${OPENSSL_DEPEND}
151 "
152 if [ "${BITCOINCORE_NEED_LIBSECP256K1}" = "1" ]; then
153 BITCOINCORE_COMMON_DEPEND="${BITCOINCORE_COMMON_DEPEND} $LIBSECP256K1_DEPEND"
154 fi
155 if [ "${PN}" != "libbitcoinconsensus" ]; then
156 BITCOINCORE_COMMON_DEPEND="${BITCOINCORE_COMMON_DEPEND} >=dev-libs/boost-1.52.0[threads(+)]"
157 fi
158 bitcoincore_common_depend_use() {
159 in_bcc_iuse "$1" || return
160 BITCOINCORE_COMMON_DEPEND="${BITCOINCORE_COMMON_DEPEND} $1? ( $2 )"
161 }
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
168 sys-apps/sed
169 "
170 if [ "${BITCOINCORE_NEED_LEVELDB}" = "1" ]; then
171 RDEPEND="${RDEPEND} virtual/bitcoin-leveldb"
172 fi
173 if in_bcc_iuse ljr && [ "$BITCOINCORE_SERIES" = "0.10.x" ]; then
174 DEPEND="${DEPEND} ljr? ( dev-vcs/git )"
175 fi
176
177 bitcoincore_policymsg() {
178 local USEFlag="bitcoin_policy_$1"
179 in_iuse "${USEFlag}" || return
180 if use "${USEFlag}"; then
181 [ -n "$2" ] && einfo "$2"
182 else
183 [ -n "$3" ] && einfo "$3"
184 fi
185 bitcoincore_policymsg_flag=true
186 }
187
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
193 fi
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}"
210 }
211
212 bitcoincore_prepare() {
213 if [ -n "${BITCOINCORE_NO_SYSLIBS}" ]; then
214 true
215 elif [ "${PV}" = "9999" ]; then
216 epatch "${FILESDIR}/${PV}-syslibs.patch"
217 else
218 epatch "$(LJR_PATCH syslibs)"
219 fi
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
226 else
227 epatch "$(LJR_PATCH ljrF)"
228 fi
229 fi
230 if use_if_iuse 1stclassmsg; then
231 epatch "$(LJR_PATCH 1stclassmsg)"
232 fi
233 if use_if_iuse xt; then
234 epatch "${DISTDIR}/${BITCOINXT_PATCHFILE}"
235 fi
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
241 rbf)
242 epatch "${DISTDIR}/${BITCOINCORE_RBF_PATCHFILE}"
243 ;;
244 *)
245 epatch "$(LJR_PATCH ${mypolicy})"
246 ;;
247 esac
248 done
249 }
250
251 bitcoincore_autoreconf() {
252 eautoreconf
253 rm -r src/leveldb || die
254 rm -r src/secp256k1 || die
255 }
256
257 bitcoincore_src_prepare() {
258 bitcoincore_prepare
259 bitcoincore_autoreconf
260 }
261
262 bitcoincore_conf() {
263 local my_econf=
264 if use_if_iuse upnp; then
265 my_econf="${my_econf} --with-miniupnpc --enable-upnp-default"
266 else
267 my_econf="${my_econf} --without-miniupnpc --disable-upnp-default"
268 fi
269 if use_if_iuse test; then
270 my_econf="${my_econf} --enable-tests"
271 else
272 my_econf="${my_econf} --disable-tests"
273 fi
274 if use_if_iuse wallet; then
275 my_econf="${my_econf} --enable-wallet"
276 else
277 my_econf="${my_econf} --disable-wallet"
278 fi
279 if [ -z "${BITCOINCORE_NO_SYSLIBS}" ]; then
280 my_econf="${my_econf} --disable-util-cli --disable-util-tx"
281 else
282 my_econf="${my_econf} --without-utils"
283 fi
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"
287 fi
288 econf \
289 --disable-ccache \
290 --disable-static \
291 --with-system-libsecp256k1 \
292 --without-libs \
293 --without-daemon \
294 --without-gui \
295 ${my_econf} \
296 "$@"
297 }
298
299 bitcoincore_src_test() {
300 emake check
301 }
302
303 bitcoincore_src_install() {
304 default
305 [ "${PN}" = "libbitcoinconsensus" ] || rm "${D}/usr/bin/test_bitcoin"
306 }
307
308 _BITCOINCORE_ECLASS=1
309 fi

  ViewVC Help
Powered by ViewVC 1.1.20