Skip to content

Commit 476933c

Browse files
committed
Merge pull request #1395 from braydonf/v4
bitcoind address index
2 parents 0c9d44c + 3ce344a commit 476933c

12 files changed

+245
-25
lines changed

Diff for: .gitignore

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ bower_components
1515
report
1616
.DS_Store
1717

18+
build
1819

19-
bitcore.js
20-
bitcore.min.js
21-
bitcore.js.sig
22-
bitcore.min.js.sig
2320
tests.js

Diff for: .travis.yml

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
language: node_js
21
sudo: false
2+
language: node_js
3+
env:
4+
- CXX=g++-4.8 CC=gcc-4.8
5+
addons:
6+
apt:
7+
sources:
8+
- ubuntu-toolchain-r-test
9+
packages:
10+
- g++-4.8
11+
- gcc-4.8
12+
- libzmq3-dev
313
node_js:
4-
- '0.12'
5-
before_install:
6-
- npm install -g bower
7-
- export DISPLAY=:99.0
8-
- sh -e /etc/init.d/xvfb start
14+
- '0.12'
15+
- '4'
916
install:
10-
- bower install
1117
- npm install
12-
after_script:
13-
- gulp coveralls
18+
script:
19+
- npm run test

Diff for: README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Infrastructure to build Bitcoin and blockchain-based applications for the next g
1010

1111
## Getting Started
1212

13-
Before you begin you'll need to have Node.js v0.12 installed. There are several options for installation. One method is to use [nvm](https://github.com/creationix/nvm) to easily switch between different versions, or download directly from [Node.js](https://nodejs.org/).
13+
Before you begin you'll need to have Node.js v4 or v0.12 installed. There are several options for installation. One method is to use [nvm](https://github.com/creationix/nvm) to easily switch between different versions, or download directly from [Node.js](https://nodejs.org/).
1414

1515
```bash
1616
npm install -g bitcore
@@ -79,6 +79,7 @@ You can also use our pre-generated files, provided for each release along with a
7979

8080
To verify signatures, use the following PGP keys:
8181
- @braydonf: https://pgp.mit.edu/pks/lookup?op=get&search=0x9BBF07CAC07A276D
82+
- @kleetus: https://pgp.mit.edu/pks/lookup?op=get&search=0x33195D27EF6BDB7F
8283
- @pnagurny: https://pgp.mit.edu/pks/lookup?op=get&search=0x0909B33F0AA53013
8384

8485
## License

Diff for: package.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "bitcore",
3-
"version": "3.0.0",
3+
"version": "4.0.0",
44
"description": "A platform to build bitcoin and blockchain-based applications.",
55
"author": "BitPay <[email protected]>",
66
"main": "index.js",
77
"scripts": {
8-
"test": "./node_modules/.bin/mocha test/** --recursive"
8+
"test": "./node_modules/.bin/mocha test/** --recursive",
9+
"build-deb": "./scripts/build-deb"
910
},
1011
"bin": {
1112
"bitcore": "./bin/bitcore",
@@ -81,10 +82,10 @@
8182
"request": "browser-request"
8283
},
8384
"dependencies": {
84-
"bitcore-lib": "^0.13.12",
85-
"bitcore-node": "^2.0.0",
86-
"insight-api": "^0.3.2",
87-
"insight-ui": "^0.3.0"
85+
"bitcore-lib": "^0.13.14",
86+
"bitcore-node": "~3.0.0",
87+
"insight-api": "^0.4.0",
88+
"insight-ui": "^0.4.0"
8889
},
8990
"license": "MIT",
9091
"devDependencies": {

Diff for: scripts/build-deb

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/bash
2+
set -e
3+
set -o pipefail
4+
5+
log_title() {
6+
local code="\033["
7+
local color="${code}1;34m"
8+
[ -z "$text" ] && local text="$color$1${code}0m"
9+
echo -e "\n$text"
10+
}
11+
12+
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
13+
14+
package_arch="amd64"
15+
package_version=$(jq -r ".version" "${root_dir}/package.json")
16+
package_maintainer=$(jq -r ".author" "${root_dir}/package.json")
17+
package_description=$(jq -r ".description" "${root_dir}/package.json")
18+
19+
deb_dir="${root_dir}/build/bitcore_${package_version}_${package_arch}"
20+
21+
log_title "Making Debian package:\n"
22+
echo -e " Name: bitcore"
23+
echo -e " Version: ${package_version}"
24+
echo -e " Maintainer: ${package_maintainer}"
25+
echo -e " Description: ${package_description}"
26+
echo -e ""
27+
28+
if [ -e "$deb_dir" ]; then rm -rf "$deb_dir"; fi
29+
30+
escape() {
31+
sed -e 's/[]\/$*.^|[]/\\&/g' -e 's/&/\\&/g' <<< "$@"
32+
}
33+
34+
replace_vars() {
35+
declare -r file="$1"
36+
declare -r target_file="$2"
37+
38+
sed < "$file" \
39+
-e "s/{{ deb_package_version }}/$(escape $package_version)/g" \
40+
-e "s/{{ deb_package_description }}/$(escape $package_description)/g" \
41+
-e "s/{{ deb_package_maintainer }}/$(escape $package_maintainer)/g" \
42+
-e "s/{{ deb_package_arch }}/$(escape $package_arch)/g" \
43+
> "$target_file"
44+
}
45+
46+
log_title "Setting up Debian package:"
47+
mkdir -vp "$deb_dir/DEBIAN" \
48+
"$deb_dir/etc/bitcore" \
49+
"$deb_dir/usr/opt/bitcore" \
50+
"$deb_dir/usr/opt/bitcore/bin" \
51+
"$deb_dir/usr/bin"
52+
53+
mkdir -vp "$deb_dir/etc/init"
54+
mkdir -vp "$deb_dir/etc/systemd/system"
55+
replace_vars "${root_dir}/scripts/debian/control" "$deb_dir/DEBIAN/control"
56+
replace_vars "${root_dir}/scripts/debian/postinst" "$deb_dir/DEBIAN/postinst"
57+
replace_vars "${root_dir}/scripts/debian/prerm" "$deb_dir/DEBIAN/prerm"
58+
replace_vars "${root_dir}/scripts/debian/bitcore.conf" "$deb_dir/etc/init/bitcore.conf"
59+
replace_vars "${root_dir}/scripts/debian/bitcore.service" "$deb_dir/etc/systemd/system/bitcore.service"
60+
replace_vars "${root_dir}/scripts/debian/bitcore-bitcoind.conf" "$deb_dir/etc/init/bitcore-bitcoind.conf"
61+
replace_vars "${root_dir}/scripts/debian/bitcore-bitcoind.service" "$deb_dir/etc/systemd/system/bitcore-bitcoind.service"
62+
chmod -vR 0755 "$deb_dir/DEBIAN/"
63+
64+
log_title "Copying Bitcore"
65+
66+
app_dir="$deb_dir/usr/opt/bitcore"
67+
68+
cp -v "${root_dir}/bin/bitcored" "${app_dir}/bin/bitcored"
69+
cp -v "${root_dir}/bin/bitcore" "${app_dir}/bin/bitcore"
70+
chmod -vR 0755 "${app_dir}/bin/bitcore" "${app_dir}/bin/bitcored"
71+
cp -v "${root_dir}/package.json" "${app_dir}"
72+
cp -v "${root_dir}/README.md" "${app_dir}"
73+
cp -v "${root_dir}/index.js" "${app_dir}"
74+
pushd "${deb_dir}/usr/bin"
75+
ln -vs "../opt/bitcore/bin/bitcore"
76+
ln -vs "../opt/bitcore/bin/bitcored"
77+
ln -vs "../opt/bitcore/node_modules/.bin/bitcoind" "bitcore-bitcoind"
78+
popd
79+
80+
log_title "Installing Bitcore Modules"
81+
pushd "${app_dir}"
82+
VERIFY_BITCOIN_DOWNLOAD=1 npm install --production
83+
echo "Cleanup Node.js addon binaries before packaging:"
84+
find "${app_dir}" -type f -name '*.node' -print -delete
85+
find "${app_dir}" -type f -name '*.o' -print -delete
86+
echo "Cleanup intermediate files:"
87+
rm -v "${deb_dir}/usr/opt/bitcore/node_modules/bitcore-node/bin/bitcoin-0.12.0-linux64.tar.gz"
88+
npm shrinkwrap --dev
89+
popd
90+
91+
log_title "Building Debian package"
92+
dpkg-deb -Z gzip --verbose --build "$deb_dir"
93+
94+
log_title "Signing Debian package"
95+
dpkg-sig --sign builder "${deb_dir}.deb"
96+
97+
echo -e "Success.\n"

Diff for: scripts/debian/bitcore-bitcoind.conf

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
description "Bitcoin Core for Bitcore"
2+
author "BitPay, Inc."
3+
4+
limit nofile 20000 30000
5+
6+
start on runlevel [2345]
7+
stop on runlevel [016]
8+
9+
kill timeout 300
10+
kill signal SIGINT
11+
12+
# user/group for bitcore daemon to run as
13+
setuid bitcore
14+
setgid bitcore
15+
16+
# home dir of the bitcore daemon user
17+
env HOME=/home/bitcore
18+
19+
respawn
20+
respawn limit 5 15
21+
22+
script
23+
exec bitcore-bitcored -datadir=/home/bitcore/.bitcore/data/
24+
end script

Diff for: scripts/debian/bitcore-bitcoind.service

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[Unit]
2+
Description=Bitcoin Core for Bitcore
3+
Requires=network.target
4+
5+
[Service]
6+
Type=simple
7+
WorkingDirectory=/usr/opt/bitcore
8+
ExecStart=/usr/bin/bitcore-bitcoind -datadir=/home/bitcore/.bitcore/data/
9+
ExecReload=/bin/kill -HUP $MAINPID
10+
Restart=on-failure
11+
RestartSec=15
12+
User=bitcore
13+
ExecStartPre=/bin/mkdir -p /run/bitcore
14+
ExecStartPre=/bin/chown bitcore:bitcore /run/bitcore
15+
ExecStartPre=/bin/chmod 755 /run/bitcore
16+
PermissionsStartOnly=true
17+
TimeoutStopSec=300
18+
19+
[Install]
20+
WantedBy=multi-user.target

Diff for: etc/init/bitcored.conf renamed to scripts/debian/bitcore.conf

-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Bitcored Upstart script
2-
31
description "Bitcore Daemon"
42
author "BitPay, Inc."
53

@@ -18,9 +16,6 @@ setgid bitcore
1816
# home dir of the bitcore daemon user
1917
env HOME=/home/bitcore
2018

21-
# path should include the correct version of node
22-
env PATH=/home/bitcore/.nvm/versions/node/v0.12.7/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
23-
2419
respawn
2520
respawn limit 5 15
2621

Diff for: scripts/debian/bitcore.service

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[Unit]
2+
Description={{ deb_package_description }}
3+
Requires=network.target
4+
5+
[Service]
6+
Type=simple
7+
WorkingDirectory=/usr/opt/bitcore
8+
ExecStart=/usr/opt/bitcore/bin/bitcored
9+
ExecReload=/bin/kill -HUP $MAINPID
10+
Restart=on-failure
11+
RestartSec=15
12+
User=bitcore
13+
ExecStartPre=/bin/mkdir -p /run/bitcore
14+
ExecStartPre=/bin/chown bitcore:bitcore /run/bitcore
15+
ExecStartPre=/bin/chmod 755 /run/bitcore
16+
PermissionsStartOnly=true
17+
TimeoutStopSec=300
18+
19+
[Install]
20+
WantedBy=multi-user.target

Diff for: scripts/debian/control

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Package: bitcore
2+
Version: {{ deb_package_version }}
3+
Section: base
4+
Priority: optional
5+
Architecture: {{ deb_package_arch }}
6+
Depends: nodejs, nodejs-legacy, npm, build-essential, libzmq3-dev
7+
Maintainer: {{ deb_package_maintainer }}
8+
Description: {{ deb_package_description }}

Diff for: scripts/debian/postinst

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
set -e
3+
set -o pipefail
4+
5+
# add group
6+
if ! getent group | grep -q "^bitcore:" ; then
7+
echo "Creating system group: bitcore"
8+
groupadd --system bitcore
9+
fi
10+
11+
# add user
12+
if ! getent passwd | grep -q "^bitcore:"; then
13+
echo "Creating bitcore system user"
14+
useradd --gid "bitcore" --system -m bitcore
15+
fi
16+
17+
# build nodejs addons
18+
cd "/usr/opt/bitcore"
19+
SKIP_BITCOIN_DOWNLOAD=1 npm rebuild
20+
21+
# setup data directory
22+
mkdir -p "/home/bitcore/.bitcore/data"
23+
chown -R bitcore:bitcore "/home/bitcore/.bitcore"
24+
25+
# start bitcore
26+
if hash service 2> /dev/null; then
27+
service bitcore start || echo "bitcore could not be registered or started"
28+
elif hash start 2> /dev/null; then
29+
start bitcore || echo "bitcore could not be registered or started"
30+
elif hash systemctl 2> /dev/null; then
31+
{
32+
systemctl enable "bitcore.service" && \
33+
systemctl start "bitcore.service"
34+
} || echo "bitcore could not be registered or started"
35+
else
36+
echo 'Your system does not appear to use upstart or systemd, so bitcore could not be started'
37+
fi

Diff for: scripts/debian/prerm

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -o pipefail
5+
6+
if hash service 2> /dev/null; then
7+
service bitcore stop || echo "bitcore wasn't running!"
8+
elif hash stop 2> /dev/null; then
9+
stop "$service_name" || echo "bitcore wasn't running!"
10+
elif hash systemctl 2> /dev/null; then
11+
systemctl disable "bitcore.service" || echo "bitcore wasn't running!"
12+
else
13+
echo "Your system does not appear to use upstart or systemd, so bitcore could not be stopped"
14+
fi

0 commit comments

Comments
 (0)