Merge #12079: Improve prioritisetransaction test coverage
[bitcoinplatinum.git] / contrib / rpm / bitcoin.spec
blob7c4d933ee05a41ea41d02a358c9b0f4ba3f638e9
1 %define bdbv 4.8.30
2 %global selinux_variants mls strict targeted
4 %if 0%{?_no_gui:1}
5 %define _buildqt 0
6 %define buildargs --with-gui=no
7 %else
8 %define _buildqt 1
9 %if 0%{?_use_qt4}
10 %define buildargs --with-qrencode --with-gui=qt4
11 %else
12 %define buildargs --with-qrencode --with-gui=qt5
13 %endif
14 %endif
16 Name: bitcoin
17 Version: 0.12.0
18 Release: 2%{?dist}
19 Summary: Peer to Peer Cryptographic Currency
21 Group: Applications/System
22 License: MIT
23 URL: https://bitcoin.org/
24 Source0: https://bitcoin.org/bin/bitcoin-core-%{version}/bitcoin-%{version}.tar.gz
25 Source1: http://download.oracle.com/berkeley-db/db-%{bdbv}.NC.tar.gz
27 Source10: https://raw.githubusercontent.com/bitcoin/bitcoin/v%{version}/contrib/debian/examples/bitcoin.conf
29 #man pages
30 Source20: https://raw.githubusercontent.com/bitcoin/bitcoin/v%{version}/doc/man/bitcoind.1
31 Source21: https://raw.githubusercontent.com/bitcoin/bitcoin/v%{version}/doc/man/bitcoin-cli.1
32 Source22: https://raw.githubusercontent.com/bitcoin/bitcoin/v%{version}/doc/man/bitcoin-qt.1
34 #selinux
35 Source30: https://raw.githubusercontent.com/bitcoin/bitcoin/v%{version}/contrib/rpm/bitcoin.te
36 # Source31 - what about bitcoin-tx and bench_bitcoin ???
37 Source31: https://raw.githubusercontent.com/bitcoin/bitcoin/v%{version}/contrib/rpm/bitcoin.fc
38 Source32: https://raw.githubusercontent.com/bitcoin/bitcoin/v%{version}/contrib/rpm/bitcoin.if
40 Source100: https://upload.wikimedia.org/wikipedia/commons/4/46/Bitcoin.svg
42 %if 0%{?_use_libressl:1}
43 BuildRequires: libressl-devel
44 %else
45 BuildRequires: openssl-devel
46 %endif
47 BuildRequires: boost-devel
48 BuildRequires: miniupnpc-devel
49 BuildRequires: autoconf automake libtool
50 BuildRequires: libevent-devel
53 Patch0: bitcoin-0.12.0-libressl.patch
56 %description
57 Bitcoin is a digital cryptographic currency that uses peer-to-peer technology to
58 operate with no central authority or banks; managing transactions and the
59 issuing of bitcoins is carried out collectively by the network.
61 %if %{_buildqt}
62 %package core
63 Summary: Peer to Peer Cryptographic Currency
64 Group: Applications/System
65 Obsoletes: %{name} < %{version}-%{release}
66 Provides: %{name} = %{version}-%{release}
67 %if 0%{?_use_qt4}
68 BuildRequires: qt-devel
69 %else
70 BuildRequires: qt5-qtbase-devel
71 # for /usr/bin/lrelease-qt5
72 BuildRequires: qt5-linguist
73 %endif
74 BuildRequires: protobuf-devel
75 BuildRequires: qrencode-devel
76 BuildRequires: %{_bindir}/desktop-file-validate
77 # for icon generation from SVG
78 BuildRequires: %{_bindir}/inkscape
79 BuildRequires: %{_bindir}/convert
81 %description core
82 Bitcoin is a digital cryptographic currency that uses peer-to-peer technology to
83 operate with no central authority or banks; managing transactions and the
84 issuing of bitcoins is carried out collectively by the network.
86 This package contains the Qt based graphical client and node. If you are looking
87 to run a Bitcoin wallet, this is probably the package you want.
88 %endif
91 %package libs
92 Summary: Bitcoin shared libraries
93 Group: System Environment/Libraries
95 %description libs
96 This package provides the bitcoinconsensus shared libraries. These libraries
97 may be used by third party software to provide consensus verification
98 functionality.
100 Unless you know need this package, you probably do not.
102 %package devel
103 Summary: Development files for bitcoin
104 Group: Development/Libraries
105 Requires: %{name}-libs = %{version}-%{release}
107 %description devel
108 This package contains the header files and static library for the
109 bitcoinconsensus shared library. If you are developing or compiling software
110 that wants to link against that library, then you need this package installed.
112 Most people do not need this package installed.
114 %package server
115 Summary: The bitcoin daemon
116 Group: System Environment/Daemons
117 Requires: bitcoin-utils = %{version}-%{release}
118 Requires: selinux-policy policycoreutils-python
119 Requires(pre): shadow-utils
120 Requires(post): %{_sbindir}/semodule %{_sbindir}/restorecon %{_sbindir}/fixfiles %{_sbindir}/sestatus
121 Requires(postun): %{_sbindir}/semodule %{_sbindir}/restorecon %{_sbindir}/fixfiles %{_sbindir}/sestatus
122 BuildRequires: systemd
123 BuildRequires: checkpolicy
124 BuildRequires: %{_datadir}/selinux/devel/Makefile
126 %description server
127 This package provides a stand-alone bitcoin-core daemon. For most users, this
128 package is only needed if they need a full-node without the graphical client.
130 Some third party wallet software will want this package to provide the actual
131 bitcoin-core node they use to connect to the network.
133 If you use the graphical bitcoin-core client then you almost certainly do not
134 need this package.
136 %package utils
137 Summary: Bitcoin utilities
138 Group: Applications/System
140 %description utils
141 This package provides several command line utilities for interacting with a
142 bitcoin-core daemon.
144 The bitcoin-cli utility allows you to communicate and control a bitcoin daemon
145 over RPC, the bitcoin-tx utility allows you to create a custom transaction, and
146 the bench_bitcoin utility can be used to perform some benchmarks.
148 This package contains utilities needed by the bitcoin-server package.
151 %prep
152 %setup -q
153 %patch0 -p1 -b .libressl
154 cp -p %{SOURCE10} ./bitcoin.conf.example
155 tar -zxf %{SOURCE1}
156 cp -p db-%{bdbv}.NC/LICENSE ./db-%{bdbv}.NC-LICENSE
157 mkdir db4 SELinux
158 cp -p %{SOURCE30} %{SOURCE31} %{SOURCE32} SELinux/
161 %build
162 CWD=`pwd`
163 cd db-%{bdbv}.NC/build_unix/
164 ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=${CWD}/db4
165 make install
166 cd ../..
168 ./autogen.sh
169 %configure LDFLAGS="-L${CWD}/db4/lib/" CPPFLAGS="-I${CWD}/db4/include/" --with-miniupnpc --enable-glibc-back-compat %{buildargs}
170 make %{?_smp_mflags}
172 pushd SELinux
173 for selinuxvariant in %{selinux_variants}; do
174 make NAME=${selinuxvariant} -f %{_datadir}/selinux/devel/Makefile
175 mv bitcoin.pp bitcoin.pp.${selinuxvariant}
176 make NAME=${selinuxvariant} -f %{_datadir}/selinux/devel/Makefile clean
177 done
178 popd
181 %install
182 make install DESTDIR=%{buildroot}
184 mkdir -p -m755 %{buildroot}%{_sbindir}
185 mv %{buildroot}%{_bindir}/bitcoind %{buildroot}%{_sbindir}/bitcoind
187 # systemd stuff
188 mkdir -p %{buildroot}%{_tmpfilesdir}
189 cat <<EOF > %{buildroot}%{_tmpfilesdir}/bitcoin.conf
190 d /run/bitcoind 0750 bitcoin bitcoin -
192 touch -a -m -t 201504280000 %{buildroot}%{_tmpfilesdir}/bitcoin.conf
194 mkdir -p %{buildroot}%{_sysconfdir}/sysconfig
195 cat <<EOF > %{buildroot}%{_sysconfdir}/sysconfig/bitcoin
196 # Provide options to the bitcoin daemon here, for example
197 # OPTIONS="-testnet -disable-wallet"
199 OPTIONS=""
201 # System service defaults.
202 # Don't change these unless you know what you're doing.
203 CONFIG_FILE="%{_sysconfdir}/bitcoin/bitcoin.conf"
204 DATA_DIR="%{_localstatedir}/lib/bitcoin"
205 PID_FILE="/run/bitcoind/bitcoind.pid"
207 touch -a -m -t 201504280000 %{buildroot}%{_sysconfdir}/sysconfig/bitcoin
209 mkdir -p %{buildroot}%{_unitdir}
210 cat <<EOF > %{buildroot}%{_unitdir}/bitcoin.service
211 [Unit]
212 Description=Bitcoin daemon
213 After=syslog.target network.target
215 [Service]
216 Type=forking
217 ExecStart=%{_sbindir}/bitcoind -daemon -conf=\${CONFIG_FILE} -datadir=\${DATA_DIR} -pid=\${PID_FILE} \$OPTIONS
218 EnvironmentFile=%{_sysconfdir}/sysconfig/bitcoin
219 User=bitcoin
220 Group=bitcoin
222 Restart=on-failure
223 PrivateTmp=true
224 TimeoutStopSec=120
225 TimeoutStartSec=60
226 StartLimitInterval=240
227 StartLimitBurst=5
229 [Install]
230 WantedBy=multi-user.target
232 touch -a -m -t 201504280000 %{buildroot}%{_unitdir}/bitcoin.service
233 #end systemd stuff
235 mkdir %{buildroot}%{_sysconfdir}/bitcoin
236 mkdir -p %{buildroot}%{_localstatedir}/lib/bitcoin
238 #SELinux
239 for selinuxvariant in %{selinux_variants}; do
240 install -d %{buildroot}%{_datadir}/selinux/${selinuxvariant}
241 install -p -m 644 SELinux/bitcoin.pp.${selinuxvariant} %{buildroot}%{_datadir}/selinux/${selinuxvariant}/bitcoin.pp
242 done
244 %if %{_buildqt}
245 # qt icons
246 install -D -p share/pixmaps/bitcoin.ico %{buildroot}%{_datadir}/pixmaps/bitcoin.ico
247 install -p share/pixmaps/nsis-header.bmp %{buildroot}%{_datadir}/pixmaps/
248 install -p share/pixmaps/nsis-wizard.bmp %{buildroot}%{_datadir}/pixmaps/
249 install -p %{SOURCE100} %{buildroot}%{_datadir}/pixmaps/bitcoin.svg
250 %{_bindir}/inkscape %{SOURCE100} --export-png=%{buildroot}%{_datadir}/pixmaps/bitcoin16.png -w16 -h16
251 %{_bindir}/inkscape %{SOURCE100} --export-png=%{buildroot}%{_datadir}/pixmaps/bitcoin32.png -w32 -h32
252 %{_bindir}/inkscape %{SOURCE100} --export-png=%{buildroot}%{_datadir}/pixmaps/bitcoin64.png -w64 -h64
253 %{_bindir}/inkscape %{SOURCE100} --export-png=%{buildroot}%{_datadir}/pixmaps/bitcoin128.png -w128 -h128
254 %{_bindir}/inkscape %{SOURCE100} --export-png=%{buildroot}%{_datadir}/pixmaps/bitcoin256.png -w256 -h256
255 %{_bindir}/convert -resize 16x16 %{buildroot}%{_datadir}/pixmaps/bitcoin256.png %{buildroot}%{_datadir}/pixmaps/bitcoin16.xpm
256 %{_bindir}/convert -resize 32x32 %{buildroot}%{_datadir}/pixmaps/bitcoin256.png %{buildroot}%{_datadir}/pixmaps/bitcoin32.xpm
257 %{_bindir}/convert -resize 64x64 %{buildroot}%{_datadir}/pixmaps/bitcoin256.png %{buildroot}%{_datadir}/pixmaps/bitcoin64.xpm
258 %{_bindir}/convert -resize 128x128 %{buildroot}%{_datadir}/pixmaps/bitcoin256.png %{buildroot}%{_datadir}/pixmaps/bitcoin128.xpm
259 %{_bindir}/convert %{buildroot}%{_datadir}/pixmaps/bitcoin256.png %{buildroot}%{_datadir}/pixmaps/bitcoin256.xpm
260 touch %{buildroot}%{_datadir}/pixmaps/*.png -r %{SOURCE100}
261 touch %{buildroot}%{_datadir}/pixmaps/*.xpm -r %{SOURCE100}
263 # Desktop File - change the touch timestamp if modifying
264 mkdir -p %{buildroot}%{_datadir}/applications
265 cat <<EOF > %{buildroot}%{_datadir}/applications/bitcoin-core.desktop
266 [Desktop Entry]
267 Encoding=UTF-8
268 Name=Bitcoin
269 Comment=Bitcoin P2P Cryptocurrency
270 Comment[fr]=Bitcoin, monnaie virtuelle cryptographique pair à pair
271 Comment[tr]=Bitcoin, eşten eşe kriptografik sanal para birimi
272 Exec=bitcoin-qt %u
273 Terminal=false
274 Type=Application
275 Icon=bitcoin128
276 MimeType=x-scheme-handler/bitcoin;
277 Categories=Office;Finance;
279 # change touch date when modifying desktop
280 touch -a -m -t 201511100546 %{buildroot}%{_datadir}/applications/bitcoin-core.desktop
281 %{_bindir}/desktop-file-validate %{buildroot}%{_datadir}/applications/bitcoin-core.desktop
283 # KDE protocol - change the touch timestamp if modifying
284 mkdir -p %{buildroot}%{_datadir}/kde4/services
285 cat <<EOF > %{buildroot}%{_datadir}/kde4/services/bitcoin-core.protocol
286 [Protocol]
287 exec=bitcoin-qt '%u'
288 protocol=bitcoin
289 input=none
290 output=none
291 helper=true
292 listing=
293 reading=false
294 writing=false
295 makedir=false
296 deleting=false
298 # change touch date when modifying protocol
299 touch -a -m -t 201511100546 %{buildroot}%{_datadir}/kde4/services/bitcoin-core.protocol
300 %endif
302 # man pages
303 install -D -p %{SOURCE20} %{buildroot}%{_mandir}/man1/bitcoind.1
304 install -p %{SOURCE21} %{buildroot}%{_mandir}/man1/bitcoin-cli.1
305 %if %{_buildqt}
306 install -p %{SOURCE22} %{buildroot}%{_mandir}/man1/bitcoin-qt.1
307 %endif
309 # nuke these, we do extensive testing of binaries in %%check before packaging
310 rm -f %{buildroot}%{_bindir}/test_*
312 %check
313 make check
314 srcdir=src test/bitcoin-util-test.py
315 test/functional/test_runner.py --extended
317 %post libs -p /sbin/ldconfig
319 %postun libs -p /sbin/ldconfig
321 %pre server
322 getent group bitcoin >/dev/null || groupadd -r bitcoin
323 getent passwd bitcoin >/dev/null ||
324 useradd -r -g bitcoin -d /var/lib/bitcoin -s /sbin/nologin \
325 -c "Bitcoin wallet server" bitcoin
326 exit 0
328 %post server
329 %systemd_post bitcoin.service
330 # SELinux
331 if [ `%{_sbindir}/sestatus |grep -c "disabled"` -eq 0 ]; then
332 for selinuxvariant in %{selinux_variants}; do
333 %{_sbindir}/semodule -s ${selinuxvariant} -i %{_datadir}/selinux/${selinuxvariant}/bitcoin.pp &> /dev/null || :
334 done
335 %{_sbindir}/semanage port -a -t bitcoin_port_t -p tcp 8332
336 %{_sbindir}/semanage port -a -t bitcoin_port_t -p tcp 8333
337 %{_sbindir}/semanage port -a -t bitcoin_port_t -p tcp 18332
338 %{_sbindir}/semanage port -a -t bitcoin_port_t -p tcp 18333
339 %{_sbindir}/semanage port -a -t bitcoin_port_t -p tcp 18443
340 %{_sbindir}/semanage port -a -t bitcoin_port_t -p tcp 18444
341 %{_sbindir}/fixfiles -R bitcoin-server restore &> /dev/null || :
342 %{_sbindir}/restorecon -R %{_localstatedir}/lib/bitcoin || :
345 %posttrans server
346 %{_bindir}/systemd-tmpfiles --create
348 %preun server
349 %systemd_preun bitcoin.service
351 %postun server
352 %systemd_postun bitcoin.service
353 # SELinux
354 if [ $1 -eq 0 ]; then
355 if [ `%{_sbindir}/sestatus |grep -c "disabled"` -eq 0 ]; then
356 %{_sbindir}/semanage port -d -p tcp 8332
357 %{_sbindir}/semanage port -d -p tcp 8333
358 %{_sbindir}/semanage port -d -p tcp 18332
359 %{_sbindir}/semanage port -d -p tcp 18333
360 %{_sbindir}/semanage port -d -p tcp 18443
361 %{_sbindir}/semanage port -d -p tcp 18444
362 for selinuxvariant in %{selinux_variants}; do
363 %{_sbindir}/semodule -s ${selinuxvariant} -r bitcoin &> /dev/null || :
364 done
365 %{_sbindir}/fixfiles -R bitcoin-server restore &> /dev/null || :
366 [ -d %{_localstatedir}/lib/bitcoin ] && \
367 %{_sbindir}/restorecon -R %{_localstatedir}/lib/bitcoin &> /dev/null || :
371 %clean
372 rm -rf %{buildroot}
374 %if %{_buildqt}
375 %files core
376 %defattr(-,root,root,-)
377 %license COPYING db-%{bdbv}.NC-LICENSE
378 %doc COPYING bitcoin.conf.example doc/README.md doc/bips.md doc/files.md doc/multiwallet-qt.md doc/reduce-traffic.md doc/release-notes.md doc/tor.md
379 %attr(0755,root,root) %{_bindir}/bitcoin-qt
380 %attr(0644,root,root) %{_datadir}/applications/bitcoin-core.desktop
381 %attr(0644,root,root) %{_datadir}/kde4/services/bitcoin-core.protocol
382 %attr(0644,root,root) %{_datadir}/pixmaps/*.ico
383 %attr(0644,root,root) %{_datadir}/pixmaps/*.bmp
384 %attr(0644,root,root) %{_datadir}/pixmaps/*.svg
385 %attr(0644,root,root) %{_datadir}/pixmaps/*.png
386 %attr(0644,root,root) %{_datadir}/pixmaps/*.xpm
387 %attr(0644,root,root) %{_mandir}/man1/bitcoin-qt.1*
388 %endif
390 %files libs
391 %defattr(-,root,root,-)
392 %license COPYING
393 %doc COPYING doc/README.md doc/shared-libraries.md
394 %{_libdir}/lib*.so.*
396 %files devel
397 %defattr(-,root,root,-)
398 %license COPYING
399 %doc COPYING doc/README.md doc/developer-notes.md doc/shared-libraries.md
400 %attr(0644,root,root) %{_includedir}/*.h
401 %{_libdir}/*.so
402 %{_libdir}/*.a
403 %{_libdir}/*.la
404 %attr(0644,root,root) %{_libdir}/pkgconfig/*.pc
406 %files server
407 %defattr(-,root,root,-)
408 %license COPYING db-%{bdbv}.NC-LICENSE
409 %doc COPYING bitcoin.conf.example doc/README.md doc/REST-interface.md doc/bips.md doc/dnsseed-policy.md doc/files.md doc/reduce-traffic.md doc/release-notes.md doc/tor.md
410 %attr(0755,root,root) %{_sbindir}/bitcoind
411 %attr(0644,root,root) %{_tmpfilesdir}/bitcoin.conf
412 %attr(0644,root,root) %{_unitdir}/bitcoin.service
413 %dir %attr(0750,bitcoin,bitcoin) %{_sysconfdir}/bitcoin
414 %dir %attr(0750,bitcoin,bitcoin) %{_localstatedir}/lib/bitcoin
415 %config(noreplace) %attr(0600,root,root) %{_sysconfdir}/sysconfig/bitcoin
416 %attr(0644,root,root) %{_datadir}/selinux/*/*.pp
417 %attr(0644,root,root) %{_mandir}/man1/bitcoind.1*
419 %files utils
420 %defattr(-,root,root,-)
421 %license COPYING
422 %doc COPYING bitcoin.conf.example doc/README.md
423 %attr(0755,root,root) %{_bindir}/bitcoin-cli
424 %attr(0755,root,root) %{_bindir}/bitcoin-tx
425 %attr(0755,root,root) %{_bindir}/bench_bitcoin
426 %attr(0644,root,root) %{_mandir}/man1/bitcoin-cli.1*
430 %changelog
431 * Fri Feb 26 2016 Alice Wonder <buildmaster@librelamp.com> - 0.12.0-2
432 - Rename Qt package from bitcoin to bitcoin-core
433 - Make building of the Qt package optional
434 - When building the Qt package, default to Qt5 but allow building
435 - against Qt4
436 - Only run SELinux stuff in post scripts if it is not set to disabled
438 * Wed Feb 24 2016 Alice Wonder <buildmaster@librelamp.com> - 0.12.0-1
439 - Initial spec file for 0.12.0 release
441 # This spec file is written from scratch but a lot of the packaging decisions are directly
442 # based upon the 0.11.2 package spec file from https://www.ringingliberty.com/bitcoin/