Skip to content

Commit 146746b

Browse files
All files related to my RPM spec file project in one commit
1 parent 3174621 commit 146746b

File tree

6 files changed

+899
-0
lines changed

6 files changed

+899
-0
lines changed

contrib/rpm/README.md

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
RPM Spec File Notes
2+
-------------------
3+
4+
The RPM spec file provided here is for Bitcoin-Core 0.12.0 and builds on CentOS
5+
7 with either the CentOS provided OpenSSL library or with LibreSSL as packaged
6+
at [LibreLAMP.com](https://librelamp.com/). It should hopefully not be too
7+
difficult to port the RPM spec file to most RPM based Linux distributions.
8+
9+
When porting the spec file to build for a particular distribution, there are
10+
some important notes.
11+
12+
## Sources
13+
14+
It is considered good form for all sources to reference a URL where the source
15+
can be downloaded.
16+
17+
Sources 0-9 should be reserved for source code tarballs. `Source0` should
18+
reference the release tarball available from https://bitcoin.org/bin/ and
19+
`Source1` should reference the BerkeleyDB source.
20+
21+
Sources 10-99 are for source files that are maintained in the
22+
[Bitcoin git repository](https://github.com/bitcoin/bitcoin) but are not part of
23+
the release tarball. Most of these will reside in the `contrib` sub-directory.
24+
25+
Sources 10-19 should be reserved for miscellaneous configuration files.
26+
Currently only `Source10` is used, for the example `bitcoin.conf` file.
27+
28+
Sources 20-29 should be reserved for man pages. Currently only `Source20`
29+
through `Source23` are used.
30+
31+
Sources 30-39 should be reserved for SELinux related files. Currently only
32+
`Source30` through `Source32` are used. Until those files are in a tagged
33+
release, the full URL specified in the RPM spec file will not work. You can get
34+
them from the git ropository where you retrieved this file.
35+
36+
Sources 100+ are for files that are not source tarballs and are not maintained
37+
in the bitcoin git repository. At present only an SVG version of the Bitcoin
38+
icon is used.
39+
40+
## Patches
41+
42+
In general, patches should be avoided. When a packager feels a patch is
43+
necessary, the packager should bring the problem to the attention of the bitcoin
44+
developers so that an official fix to the issue can make it into the next
45+
release.
46+
47+
### Patch0 bitcoin-0.12.0-libressl.patch
48+
49+
This patch is only needed if building against LibreSSL. LibreSSL is not the
50+
standard TLS library on most Linux distributions. The patch will likely not be
51+
needed when 0.12.1 is released, a proper fix is already in the Bitcoin git
52+
master branch.
53+
54+
## BuildRequires
55+
56+
The packages specified in the `BuildRequires` are specified according to the
57+
package naming convention currently used in CentOS 7 and EPEL for CentOS 7. You
58+
may need to change some of the package names for other distributions. This is
59+
most likely to be the case with the Qt packages.
60+
61+
## BerkeleyDB
62+
63+
The `build-unix.md` file recommends building against BerkeleyDB 4.8.30. Even if
64+
that is the version your Linux distribution ships with, it probably is a good
65+
idea to build Bitcoin Core against a static version of that library compiled
66+
according to the instructions in the `build-unix.md` file so that any changes
67+
the distribution may make in the future will not result in a problem for users.
68+
69+
The problem that can exist, clients built against different versions of
70+
BerkeleyDB may not be able read each other's `wallet.dat` file which can make it
71+
difficult for a user to recover from backup in the event of a system failure.
72+
73+
## Graphical User Interface and Qt Version
74+
75+
The RPM spec file will by default build the GUI client linked against the Qt5
76+
libraries. If you wish instead to link against the Qt4 libraries you need to
77+
pass the switch `-D '_use_qt4 1'` at build time to the `rpmbuild` or `mock`
78+
command used to build the packages.
79+
80+
If you would prefer not to build the GUI at all, you can pass the switch
81+
`-D '_no_gui 1'` to the `rpmbuild` or `mock` build command.
82+
83+
## Desktop and KDE Files
84+
85+
The desktop and KDE meta files are created in the spec file itself with the
86+
`cat` command. This is done to allow easy distribution specific changes without
87+
needing to use any patches. A specific time stamp is given to the files so that
88+
it does not they do not appear to have been updated every time the package is
89+
built. If you do make changes to them, you probably should update time stamp
90+
assigned to them in the `touch` command that specifies the time stamp.
91+
92+
## SVG, PNG, and XPM Icons
93+
94+
The `bitcoin.svg` file is from the source listed as `Source100`. It is used as
95+
the source for the PNG and XPM files. The generated PNG and XPM files are given
96+
the same time stamp as the source SVG file as a means of indicating they are
97+
derived from it.
98+
99+
## Systemd
100+
101+
This spec file assumes the target distribution uses systemd. That really only
102+
matters for the `bitcoin-server` package. At this point, most RPM based
103+
distributions that still receive vendor updates do in fact use systemd.
104+
105+
The files to control the service are created in the RPM spec file itself using
106+
the `cat` command. This is done to make it easy to modify for other
107+
distributions that may implement things differently without needing to patch
108+
source. A specific time stamp is given to the files so that they do not appear
109+
to have been updated every time the package is built. If you do make changes to
110+
them, you probably should update the time stamp assigned to them in the `touch`
111+
command that specifies the time stamp.
112+
113+
## SELinux
114+
115+
The `bitcoin-server` package should have SELinux support. How to properly do
116+
that *may* vary by distribution and version of distribution.
117+
118+
The SELinux stuff in this RPM spec file *should* be correct for CentOS, RHEL,
119+
and Fedora but it would be a good idea to review it before building the package
120+
on other distributions.
121+
122+
## Tests
123+
124+
The `%check` section takes a very long time to run. If your build system has a
125+
time limit for package build, you may need to make an exception for this
126+
package. On CentOS 7 the `%check` section completes successfully with both
127+
OpenSSL and LibreSSL, a failure really does mean something is wrong.
128+
129+
## LibreSSL Build Notes
130+
131+
To build against LibreSSL you will need to pass the switch
132+
`-D '_use_libressl 1'` to the `rpmbuild` or `mock` command or the spec file will
133+
want the OpenSSL development files.
134+
135+
### LibreSSL and Boost
136+
137+
LibreSSL (and some newer builds of OpenSSL) do not have support for SSLv3. This
138+
can cause issues with the Boost package if the Boost package has not been
139+
patched accordingly. On those distributions, you will either need to build
140+
Bitcoin-Core against OpenSSL or use a patched version of Boost in the build
141+
system.
142+
143+
As SSLv3 is no longer safe, distributions that have not patched Boost to work
144+
with TLS libraries that do not support SSLv3 should have bug reports filed
145+
against the Boost package. This bug report has already been filed for RHEL 7 but
146+
it may need to be filed for other distributions.
147+
148+
A patch for Boost: https://github.com/boostorg/asio/pull/23/files
149+
150+
## ZeroMQ
151+
152+
At this time, this RPM spec file does not support the ZeroMQ build options. A
153+
suitable version of ZeroMQ is not available for the platform this spec file was
154+
developed on (CentOS 7).
155+
156+
## Legacy Credit
157+
158+
This RPM spec file is largely based upon the work of Michael Hampton at
159+
[Ringing Liberty](https://www.ringingliberty.com/bitcoin/). He has been
160+
packaging Bitcoin for Fedora at least since 2012.
161+
162+
Most of the differences between his packaging and this package are stylistic in
163+
nature. The major differences:
164+
165+
1. He builds from a github tagged release rather than a release tarball. This
166+
should not result in different source code.
167+
168+
2. He does not build BerkeleyDB but instead uses the BerkeleyDB provided by the
169+
Linux distribution. For the distributions he packages for, they currently all
170+
use the same version of BerkeleyDB so that difference is *probably* just
171+
academic.
172+
173+
3. As of his 10.11.2 package he did not allow for building against LibreSSL,
174+
specifying a build without the Qt GUI, or specifying which version of the Qt
175+
libraries to use.
176+
177+
4. I renamed the `bitcoin` package that contains the Qt GUI to `bitcoin-core` as
178+
that appears to be how the general population refers to it, in contrast to
179+
`bitcoin-xt` or `bitcoin-classic`. I wanted to make sure the general population
180+
knows what they are getting when installing the GUI package.
181+
182+
As far as minor differences, I generally prefer to assign the file permissions
183+
in the `%files` portion of an RPM spec file rather than specifying the
184+
permissions of a file during `%install` and other minor things like that that
185+
are largely just cosmetic.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
diff -ur bitcoin-0.12.0.orig/src/init.cpp bitcoin-0.12.0/src/init.cpp
2+
--- bitcoin-0.12.0.orig/src/init.cpp 2015-12-31 16:00:00.000000000 -0800
3+
+++ bitcoin-0.12.0/src/init.cpp 2016-02-23 06:03:47.133227757 -0800
4+
@@ -1075,7 +1075,7 @@
5+
if (fPrintToDebugLog)
6+
OpenDebugLog();
7+
8+
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
9+
+#if defined(LIBRESSL_VERSION_NUMBER) || (OPENSSL_VERSION_NUMBER < 0x10100000L)
10+
LogPrintf("Using OpenSSL version %s\n", SSLeay_version(SSLEAY_VERSION));
11+
#else
12+
LogPrintf("Using OpenSSL version %s\n", OpenSSL_version(OPENSSL_VERSION));
13+
diff -ur bitcoin-0.12.0.orig/src/qt/rpcconsole.cpp bitcoin-0.12.0/src/qt/rpcconsole.cpp
14+
--- bitcoin-0.12.0.orig/src/qt/rpcconsole.cpp 2015-12-31 16:00:00.000000000 -0800
15+
+++ bitcoin-0.12.0/src/qt/rpcconsole.cpp 2016-02-23 15:09:42.881126841 -0800
16+
@@ -264,7 +264,7 @@
17+
18+
// set library version labels
19+
20+
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
21+
+#if defined(LIBRESSL_VERSION_NUMBER) || (OPENSSL_VERSION_NUMBER < 0x10100000L)
22+
ui->openSSLVersion->setText(SSLeay_version(SSLEAY_VERSION));
23+
#else
24+
ui->openSSLVersion->setText(OpenSSL_version(OPENSSL_VERSION));

contrib/rpm/bitcoin.fc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/usr/bin/bitcoin-cli -- gen_context(system_u:object_r:bitcoin_exec_t,s0)
2+
/usr/sbin/bitcoind -- gen_context(system_u:object_r:bitcoin_exec_t,s0)
3+
/usr/lib(64)?/bitcoin/bitcoind -- gen_context(system_u:object_r:bitcoin_exec_t,s0)
4+
5+
/etc/bitcoin(/.*)? gen_context(system_u:object_r:bitcoin_conf_t,s0)
6+
/var/lib/bitcoin(/.*)? gen_context(system_u:object_r:bitcoin_var_lib_t,s0)
7+
8+
(/var)?/run/bitcoind(/.*)? gen_context(system_u:object_r:bitcoin_var_run_t,s0)

contrib/rpm/bitcoin.if

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
2+
## <summary>policy for bitcoin</summary>
3+
4+
5+
########################################
6+
## <summary>
7+
## Transition to bitcoin.
8+
## </summary>
9+
## <param name="domain">
10+
## <summary>
11+
## Domain allowed to transition.
12+
## </summary>
13+
## </param>
14+
#
15+
interface(`bitcoin_domtrans',`
16+
gen_require(`
17+
type bitcoin_t, bitcoin_exec_t;
18+
')
19+
20+
corecmd_search_bin($1)
21+
domtrans_pattern($1, bitcoin_exec_t, bitcoin_t)
22+
')
23+
24+
25+
########################################
26+
## <summary>
27+
## Execute bitcoin server in the bitcoin domain.
28+
## </summary>
29+
## <param name="domain">
30+
## <summary>
31+
## Domain allowed access.
32+
## </summary>
33+
## </param>
34+
#
35+
interface(`bitcoin_initrc_domtrans',`
36+
gen_require(`
37+
type bitcoin_initrc_exec_t;
38+
')
39+
40+
init_labeled_script_domtrans($1, bitcoin_initrc_exec_t)
41+
')
42+
43+
44+
########################################
45+
## <summary>
46+
## Search bitcoin lib directories.
47+
## </summary>
48+
## <param name="domain">
49+
## <summary>
50+
## Domain allowed access.
51+
## </summary>
52+
## </param>
53+
#
54+
interface(`bitcoin_search_lib',`
55+
gen_require(`
56+
type bitcoin_var_lib_t;
57+
')
58+
59+
allow $1 bitcoin_var_lib_t:dir search_dir_perms;
60+
files_search_var_lib($1)
61+
')
62+
63+
########################################
64+
## <summary>
65+
## Read bitcoin lib files.
66+
## </summary>
67+
## <param name="domain">
68+
## <summary>
69+
## Domain allowed access.
70+
## </summary>
71+
## </param>
72+
#
73+
interface(`bitcoin_read_lib_files',`
74+
gen_require(`
75+
type bitcoin_var_lib_t;
76+
')
77+
78+
files_search_var_lib($1)
79+
read_files_pattern($1, bitcoin_var_lib_t, bitcoin_var_lib_t)
80+
')
81+
82+
########################################
83+
## <summary>
84+
## Manage bitcoin lib files.
85+
## </summary>
86+
## <param name="domain">
87+
## <summary>
88+
## Domain allowed access.
89+
## </summary>
90+
## </param>
91+
#
92+
interface(`bitcoin_manage_lib_files',`
93+
gen_require(`
94+
type bitcoin_var_lib_t;
95+
')
96+
97+
files_search_var_lib($1)
98+
manage_files_pattern($1, bitcoin_var_lib_t, bitcoin_var_lib_t)
99+
')
100+
101+
########################################
102+
## <summary>
103+
## Manage bitcoin lib directories.
104+
## </summary>
105+
## <param name="domain">
106+
## <summary>
107+
## Domain allowed access.
108+
## </summary>
109+
## </param>
110+
#
111+
interface(`bitcoin_manage_lib_dirs',`
112+
gen_require(`
113+
type bitcoin_var_lib_t;
114+
')
115+
116+
files_search_var_lib($1)
117+
manage_dirs_pattern($1, bitcoin_var_lib_t, bitcoin_var_lib_t)
118+
')
119+
120+
121+
########################################
122+
## <summary>
123+
## All of the rules required to administrate
124+
## an bitcoin environment
125+
## </summary>
126+
## <param name="domain">
127+
## <summary>
128+
## Domain allowed access.
129+
## </summary>
130+
## </param>
131+
## <param name="role">
132+
## <summary>
133+
## Role allowed access.
134+
## </summary>
135+
## </param>
136+
## <rolecap/>
137+
#
138+
interface(`bitcoin_admin',`
139+
gen_require(`
140+
type bitcoin_t;
141+
type bitcoin_initrc_exec_t;
142+
type bitcoin_var_lib_t;
143+
')
144+
145+
allow $1 bitcoin_t:process { ptrace signal_perms };
146+
ps_process_pattern($1, bitcoin_t)
147+
148+
bitcoin_initrc_domtrans($1)
149+
domain_system_change_exemption($1)
150+
role_transition $2 bitcoin_initrc_exec_t system_r;
151+
allow $2 system_r;
152+
153+
files_search_var_lib($1)
154+
admin_pattern($1, bitcoin_var_lib_t)
155+
156+
')
157+

0 commit comments

Comments
 (0)