upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/build-linux.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build-linux.sh')
-rw-r--r--build-linux.sh71
1 files changed, 71 insertions, 0 deletions
diff --git a/build-linux.sh b/build-linux.sh
new file mode 100644
index 0000000..bb11e82
--- /dev/null
+++ b/build-linux.sh
@@ -0,0 +1,71 @@
1#!/usr/bin/env bash
2# Bitflash headless node/miner -- one-shot Linux build (Debian/Ubuntu).
3# Builds the dependencies (libsecp256k1 with schnorrsig, RandomX) and then the
4# node itself. Run from the project root (the directory that contains src/):
5#
6# bash build-linux.sh
7#
8# Result: src/bitflash-node . Run it with: ./src/bitflash-node -gen
9
10set -e
11ROOT="$(cd "$(dirname "$0")" && pwd)"
12cd "$ROOT"
13
14# Use sudo only when not already root (a root login often has no sudo installed).
15SUDO=""
16if [ "$(id -u)" -ne 0 ]; then SUDO="sudo"; fi
17
18echo "==> installing system packages"
19if command -v apt-get >/dev/null 2>&1; then
20 $SUDO apt-get update
21 $SUDO apt-get install -y build-essential cmake git pkg-config autoconf libtool \
22 libssl-dev libdb5.3++-dev libsodium-dev nlohmann-json3-dev libboost-dev
23else
24 echo "!! non-apt system: install manually -> g++ cmake git autoconf libtool"
25 echo " libssl-dev libdb++-dev libsodium-dev nlohmann-json (headers)"
26fi
27
28# ---- libsecp256k1 (Schnorr/BIP340 + extrakeys), static, installed to /usr/local
29if [ ! -f /usr/local/lib/libsecp256k1.a ]; then
30 echo "==> building libsecp256k1"
31 rm -rf "$ROOT/secp256k1-build"
32 git clone --depth 1 https://github.com/bitcoin-core/secp256k1 "$ROOT/secp256k1-build"
33 cd "$ROOT/secp256k1-build"
34 ./autogen.sh
35 ./configure --enable-module-schnorrsig --enable-module-extrakeys \
36 --disable-shared --with-pic --disable-benchmark --disable-tests
37 make -j"$(nproc)"
38 $SUDO make install
39 $SUDO ldconfig
40 cd "$ROOT"
41else
42 echo "==> libsecp256k1 already installed, skipping"
43fi
44
45# ---- RandomX (memory-hard CPU PoW), static lib
46if [ ! -f "$HOME/RandomX/build/librandomx.a" ]; then
47 echo "==> building RandomX"
48 rm -rf "$HOME/RandomX"
49 git clone --depth 1 https://github.com/tevador/RandomX "$HOME/RandomX"
50 mkdir -p "$HOME/RandomX/build"
51 cd "$HOME/RandomX/build"
52 cmake .. -DCMAKE_BUILD_TYPE=Release
53 make -j"$(nproc)" randomx
54 cd "$ROOT"
55else
56 echo "==> RandomX already built, skipping"
57fi
58
59# ---- the node
60echo "==> building bitflash-node"
61cd "$ROOT/src"
62make -f makefile.linux RANDOMX_DIR="$HOME/RandomX" -j"$(nproc)"
63
64echo
65echo "==================================================================="
66echo " DONE. Binary: $ROOT/src/bitflash-node"
67echo
68echo " Mine: ./src/bitflash-node -gen"
69echo " Custom data dir: ./src/bitflash-node -gen -datadir=\$HOME/.bitflash"
70echo " Run as a service: see linux-node.service note in the README"
71echo "==================================================================="