Repository navigation
Expand file tree
/
Copy pathinstallcore29.sh
More file actions
132 lines (121 loc) · 5.61 KB
/
Copy pathinstallcore29.sh
File metadata and controls
132 lines (121 loc) · 5.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env bash
# installcore29.sh — offline installer for BCA-Core29 (Bitcoin Atom on Core 29.3)
# Target: freshly installed Ubuntu 22.04 Server (jammy), no network required.
# The project folder is self-contained: all .debs, the BDB 4.8 sources and
# this script travel together. Run as root from the project root:
# sudo ./installcore29.sh [--no-tests] [--no-docker] [-j N]
set -euo pipefail
RUN_TESTS=1
USE_DOCKER=1
JOBS="$(nproc)"
for arg in "$@"; do
case "$arg" in
--no-tests) RUN_TESTS=0 ;;
--no-docker) USE_DOCKER=0 ;;
-j*) JOBS="${arg#-j}" ;;
esac
done
log() { echo "[installcore29] $*"; }
die() { echo "[installcore29] ERROR: $*" >&2; exit 1; }
[ "$(id -u)" = "0" ] || die "run as root (sudo ./installcore29.sh)"
export DEBIAN_FRONTEND=noninteractive
if [ -f /etc/os-release ]; then
# shellcheck disable=SC1091
. /etc/os-release
[ "${VERSION_CODENAME:-}" = "jammy" ] || log "WARNING: expected Ubuntu 22.04 (jammy), found '${PRETTY_NAME:-unknown}' — continuing anyway"
fi
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PKG_DIR="$PROJECT_DIR/offline/packages"
DB4_DIR="$PROJECT_DIR/offline/db4"
[ -d "$PKG_DIR" ] || die "offline/packages/ missing — the project folder is incomplete"
[ -f "$DB4_DIR/db-4.8.30.NC.tar.gz" ] || die "offline/db4 tarball missing"
# ------------------------------------------------------------ preflight ----
AVAILABLE_KB="$(df / | awk 'NR==2 {print $4}')"
REQUIRED_KB=10485760 # 10 GB
if [ "$AVAILABLE_KB" -lt "$REQUIRED_KB" ]; then
die "not enough disk space: ${AVAILABLE_KB}KB available, need ${REQUIRED_KB}KB (~10GB)"
fi
# ---------------------------------------------------------------- repos ---
log "wiring local package repository"
echo "deb [trusted=yes] file://$PKG_DIR ./" > /etc/apt/sources.list.d/atom-offline.list
apt-get update -o Acquire::AllowInsecureRepositories=true
log "pre-caching all debs to avoid local-repo path resolution"
cp -f "$PKG_DIR"/*.deb /var/cache/apt/archives/ 2>/dev/null || true
log "regenerating Packages index with correct paths"
(cd "$PKG_DIR" && dpkg-scanpackages --multiversion . /dev/null 2>/dev/null | sed "s|Filename: \./|Filename: $PKG_DIR/|g" > Packages && gzip -f Packages)
apt-get update -o Acquire::AllowInsecureRepositories=true
log "installing build dependencies (offline)"
DEPS="build-essential cmake pkgconf python3 ccache curl wget git
libevent-dev libboost-dev libsqlite3-dev
qtbase5-dev qttools5-dev qttools5-dev-tools
libqrencode-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev"
# shellcheck disable=SC2086
apt-get install -y --no-download $DEPS || {
log "apt failed — falling back to dpkg + apt-get -f"
dpkg -i /var/cache/apt/archives/*.deb 2>/dev/null || true
apt-get install -f -y || die "dependency install failed even with dpkg fallback"
}
# --------------------------------------------------------------- docker ---
if [ "$USE_DOCKER" = "1" ]; then
if command -v docker >/dev/null 2>&1; then
log "docker already installed: $(docker --version | head -1)"
else
log "installing docker (offline)"
apt-get install -y --no-download docker.io || die "docker install failed"
fi
if ! docker info >/dev/null 2>&1; then
log "starting docker daemon"
if command -v systemctl >/dev/null 2>&1; then
systemctl start docker 2>/dev/null || dockerd >/var/log/dockerd.log 2>&1 &
elif command -v service >/dev/null 2>&1; then
service docker start 2>/dev/null || dockerd >/var/log/dockerd.log 2>&1 &
else
dockerd >/var/log/dockerd.log 2>&1 &
fi
for i in $(seq 1 30); do docker info >/dev/null 2>&1 && break; sleep 2; done
docker info >/dev/null 2>&1 || die "docker daemon did not start"
fi
log "docker ready: $(docker --version | head -1)"
fi
# ------------------------------------------------------------ bdb 4.8 ----
if [ ! -f /opt/db4/lib/libdb_cxx-4.8.a ]; then
log "building Berkeley DB 4.8 (vendored sources)"
rm -rf /tmp/db4src && mkdir -p /tmp/db4src && cd /tmp/db4src
echo "12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef db-4.8.30.NC.tar.gz" > sha256sums
cp "$DB4_DIR/db-4.8.30.NC.tar.gz" "$DB4_DIR/clang.patch" .
sha256sum -c sha256sums || die "BDB tarball checksum mismatch"
tar xzf db-4.8.30.NC.tar.gz
cd db-4.8.30.NC
patch -p2 < ../clang.patch
cd build_unix
../dist/configure --enable-cxx --disable-shared --disable-replication \
--with-pic --prefix=/opt/db4 > /tmp/db4-configure.log 2>&1
make -j"$JOBS" > /tmp/db4-build.log 2>&1
make install > /tmp/db4-install.log 2>&1
cd / && rm -rf /tmp/db4src
log "BDB 4.8 installed to /opt/db4"
else
log "BDB 4.8 already present at /opt/db4"
fi
# ---------------------------------------------------------------- build ---
log "configuring BCA-Core29"
cd "$PROJECT_DIR"
cmake -B build -DCMAKE_PREFIX_PATH=/opt/db4 -DWITH_BDB=ON -DBUILD_GUI=ON \
-DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo > /tmp/atom-cmake.log 2>&1
log "compiling (-j$JOBS, this takes a while)"
cmake --build build -j"$JOBS" --target bitcoind bitcoin-cli bitcoin-wallet \
bitcoin-tx bitcoin-qt test_bitcoin > /tmp/atom-build.log 2>&1
log "build finished"
if [ "$RUN_TESTS" = "1" ]; then
log "running unit test suite"
./build/bin/test_bitcoin > /tmp/atom-unittests.log 2>&1
log "unit tests passed"
else
log "tests skipped (--no-tests)"
fi
mkdir -p releaseBIN
cp -f build/bin/bitcoind build/bin/bitcoin-cli build/bin/bitcoin-wallet \
build/bin/bitcoin-tx build/bin/bitcoin-qt releaseBIN/
log "binaries in $PROJECT_DIR/releaseBIN:"
ls -la releaseBIN/
log "install complete"