dependency script for compilations

Post Reply
wroomwroom
Posts: 48
Joined: Wed Jul 31, 2024 5:59 pm

dependency script for compilations

Post by wroomwroom »

UBUNTU 24 Compiler Dependencies (doesn't seem to succeed with compiling)
I like to work in evergui/evergui24:latest (everpanel deployable, ubuntu24, shows up on your browser with https and gptcp1 port. Password is default)

Of course, this is done on a disposable instance, so there's probably security risks of doing this on your personal computer. Only do it in a virtual machine that u don't care about :)

Code: Select all

#!/usr/bin/env bash
set -Eeuo pipefail

# ============================================================
# Sashimono development environment setup
# Ubuntu / Debian
#
# Installs:
#   - C/C++ build tools
#   - CMake / Git
#   - Boost / libsodium / OpenSSL / SQLite / zlib
#   - Clang / LLD
#   - WABT: wasm2wat, wat2wasm, wasm-objdump
#   - Node.js / npm
#   - @vercel/ncc
#   - CLI11 2.4.2
#   - jsoncons 1.4.1
#   - moodycamel concurrentqueue
#   - moodycamel readerwriterqueue
#   - plog 1.1.5
#   - wasienv / wasmcc
#   - RichardAH/hook-cleaner-c
#
# Does NOT clone/build Sashimono.
#
# Run as your NORMAL user:
#   bash ./sashimono-dev-deps-fixed.sh
#
# Do NOT run the whole script with sudo.
# ============================================================

if [[ "${EUID}" -eq 0 ]]; then
    echo "ERROR: Run this as your normal development user, not root."
    exit 1
fi

TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT

echo "=========================================="
echo "1. Installing system dependencies"
echo "=========================================="

sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
    build-essential \
    cmake \
    git \
    curl \
    wget \
    ca-certificates \
    pkg-config \
    python3 \
    python3-pip \
    python3-venv \
    libsodium-dev \
    libssl-dev \
    libsqlite3-dev \
    libboost-all-dev \
    zlib1g-dev \
    jq \
    wabt \
    clang \
    lld

echo
echo "=========================================="
echo "2. Setting up local PATH"
echo "=========================================="

mkdir -p "$HOME/.local/bin"

LOCAL_PATH_LINE='export PATH="$HOME/.local/bin:$PATH"'
grep -Fqx "$LOCAL_PATH_LINE" "$HOME/.bashrc" 2>/dev/null || \
    echo "$LOCAL_PATH_LINE" >> "$HOME/.bashrc"

export PATH="$HOME/.local/bin:$PATH"

echo
echo "=========================================="
echo "3. Installing CLI11 2.4.2"
echo "=========================================="

git clone --depth 1 --branch v2.4.2 \
    https://github.com/CLIUtils/CLI11.git \
    "$TMP_DIR/CLI11"

cmake -S "$TMP_DIR/CLI11" -B "$TMP_DIR/CLI11/build" \
    -DCLI11_BUILD_EXAMPLES=OFF \
    -DCLI11_BUILD_TESTS=OFF

cmake --build "$TMP_DIR/CLI11/build" --parallel "$(nproc)"
sudo cmake --install "$TMP_DIR/CLI11/build"

echo
echo "=========================================="
echo "4. Installing jsoncons 1.4.1"
echo "=========================================="

git clone --depth 1 --branch v1.4.1 \
    https://github.com/danielaparker/jsoncons.git \
    "$TMP_DIR/jsoncons"

sudo rm -rf \
    /usr/local/include/jsoncons \
    /usr/local/include/jsoncons_ext

sudo cp -a "$TMP_DIR/jsoncons/include/jsoncons" /usr/local/include/

if [[ -d "$TMP_DIR/jsoncons/include/jsoncons_ext" ]]; then
    sudo cp -a "$TMP_DIR/jsoncons/include/jsoncons_ext" /usr/local/include/
fi

echo
echo "=========================================="
echo "5. Installing moodycamel queues"
echo "=========================================="

git clone --depth 1 \
    https://github.com/cameron314/concurrentqueue.git \
    "$TMP_DIR/concurrentqueue"

sudo install -m 0644 \
    "$TMP_DIR/concurrentqueue/concurrentqueue.h" \
    "$TMP_DIR/concurrentqueue/blockingconcurrentqueue.h" \
    "$TMP_DIR/concurrentqueue/lightweightsemaphore.h" \
    /usr/local/include/

git clone --depth 1 \
    https://github.com/cameron314/readerwriterqueue.git \
    "$TMP_DIR/readerwriterqueue"

sudo mkdir -p /usr/local/include/readerwriterqueue

sudo install -m 0644 \
    "$TMP_DIR/readerwriterqueue/readerwriterqueue.h" \
    "$TMP_DIR/readerwriterqueue/atomicops.h" \
    "$TMP_DIR/readerwriterqueue/readerwritercircularbuffer.h" \
    /usr/local/include/readerwriterqueue/

echo
echo "=========================================="
echo "6. Installing plog 1.1.5"
echo "=========================================="

git clone --depth 1 --branch 1.1.5 \
    https://github.com/SergiusTheBest/plog.git \
    "$TMP_DIR/plog"

sudo rm -rf /usr/local/include/plog
sudo cp -a "$TMP_DIR/plog/include/plog" /usr/local/include/

echo
echo "=========================================="
echo "7. Ensuring Node.js, npm and @vercel/ncc"
echo "=========================================="

# Do NOT install "nodejs npm" together in the main apt command.
# NodeSource's nodejs package already includes npm and conflicts with the
# separate Ubuntu npm package. This logic works with either packaging style.

if ! command -v node >/dev/null 2>&1; then
    echo "Node.js not found. Installing nodejs..."
    sudo apt-get install -y nodejs
fi

if ! command -v npm >/dev/null 2>&1; then
    echo "npm not found after installing/detecting Node.js."
    echo "Installing the separate npm package (needed by Ubuntu's split packaging)..."
    sudo apt-get install -y npm
fi

echo "node: $(node --version)"
echo "npm:  $(npm --version)"

if ! command -v ncc >/dev/null 2>&1; then
    echo "Installing @vercel/ncc globally..."
    sudo npm install -g @vercel/ncc
fi

hash -r

command -v ncc >/dev/null 2>&1 || {
    echo "ERROR: @vercel/ncc installation completed but 'ncc' is not on PATH."
    exit 1
}

echo "ncc:  $(ncc --version)"

echo
echo "=========================================="
echo "8. Installing wasienv / wasmcc"
echo "=========================================="

# Remove failed/partial wasienv setup from previous attempts.
rm -rf "$HOME/.wasienv"

mkdir -p "$HOME/.wasienv/bin"

# Isolate the Python package in its own venv.
python3 -m venv "$HOME/.wasienv/venv"

"$HOME/.wasienv/venv/bin/python" -m pip install --upgrade pip setuptools wheel
"$HOME/.wasienv/venv/bin/python" -m pip install wasienv

# The Python package installs ALL console wrappers in venv/bin.
# Put that directory on PATH. This is the key fix for wasmcc.
cat > "$HOME/.wasienv/wasienv.sh" <<'EOF'
export WASIENV_DIR="$HOME/.wasienv"
export PATH="$WASIENV_DIR/venv/bin:$WASIENV_DIR/bin:$HOME/.local/bin:$PATH"
EOF

. "$HOME/.wasienv/wasienv.sh"

WASIENV_BASHRC_LINE='. "$HOME/.wasienv/wasienv.sh"'
grep -Fqx "$WASIENV_BASHRC_LINE" "$HOME/.bashrc" 2>/dev/null || {
    echo >> "$HOME/.bashrc"
    echo '# wasienv / wasmcc' >> "$HOME/.bashrc"
    echo "$WASIENV_BASHRC_LINE" >> "$HOME/.bashrc"
}

echo
echo "wasienv executable:"
command -v wasienv

echo
echo "wasmcc wrapper before SDK install:"
command -v wasmcc

echo
echo "Installing WASI SDK..."
wasienv install-sdk unstable

echo
echo "Selecting default WASI SDK..."
wasienv default-sdk unstable

# Refresh shell command cache/PATH.
. "$HOME/.wasienv/wasienv.sh"
hash -r

echo
echo "=========================================="
echo "9. Building RichardAH Hook Cleaner"
echo "=========================================="

if [[ ! -d "$HOME/hook-cleaner-c/.git" ]]; then
    git clone \
        https://github.com/RichardAH/hook-cleaner-c.git \
        "$HOME/hook-cleaner-c"
else
    echo "hook-cleaner-c already exists; updating."
    git -C "$HOME/hook-cleaner-c" pull --ff-only
fi

make -C "$HOME/hook-cleaner-c" clean 2>/dev/null || true
make -C "$HOME/hook-cleaner-c"

install -m 0755 \
    "$HOME/hook-cleaner-c/hook-cleaner" \
    "$HOME/.local/bin/hook-cleaner"

echo
echo "=========================================="
echo "10. Verification"
echo "=========================================="

echo "--- gcc ---"
gcc --version | head -1

echo "--- g++ ---"
g++ --version | head -1

echo "--- cmake ---"
cmake --version | head -1

echo "--- clang ---"
clang --version | head -1

echo "--- node ---"
node --version

echo "--- npm ---"
npm --version

echo "--- ncc ---"
command -v ncc
ncc --version

echo "--- WABT ---"
command -v wasm2wat
command -v wat2wasm
command -v wasm-objdump

echo "--- wasienv ---"
command -v wasienv

echo "--- wasmcc ---"
command -v wasmcc

echo "--- wasicc ---"
command -v wasicc

echo "--- hook-cleaner ---"
command -v hook-cleaner

echo
echo "--- C++ headers ---"
for header in \
    /usr/local/include/CLI/CLI.hpp \
    /usr/local/include/jsoncons/json.hpp \
    /usr/local/include/concurrentqueue.h \
    /usr/local/include/blockingconcurrentqueue.h \
    /usr/local/include/lightweightsemaphore.h \
    /usr/local/include/readerwriterqueue/readerwriterqueue.h \
    /usr/local/include/plog/Log.h
do
    [[ -f "$header" ]] || {
        echo "ERROR: missing $header"
        exit 1
    }
    echo "OK: $header"
done

echo
echo "=========================================="
echo "DEVELOPMENT ENVIRONMENT READY"
echo "=========================================="
echo
echo "wasienv:      $(command -v wasienv)"
echo "wasmcc:       $(command -v wasmcc)"
echo "wasicc:       $(command -v wasicc)"
echo "hook-cleaner: $(command -v hook-cleaner)"
echo "ncc:          $(command -v ncc)"
echo "wasm2wat:     $(command -v wasm2wat)"
echo
echo "Open a new shell, or run:"
echo
echo "    . ~/.bashrc"
echo
echo "Done."



Working Today
UBUNTU 20 Compiler Dependencies

Compile in VNC enviorement, I use image everbackup/markz:latest--gptcp1--36525 and VNC Viewer for this.

Code: Select all

#!/usr/bin/env bash
set -Eeuo pipefail

# ============================================================
# Sashimono v1.0.0 development environment
# Ubuntu 20.04 reproduction environment
#
# IMPORTANT:
#   Run as your NORMAL user.
#   Do NOT run the whole script with sudo.
#
# Purpose:
#   Reproduce the historical Ubuntu-20/GCC-9 build environment
#   as closely as practical.
#
# Sashimono v1.0.0's own dev-setup.sh used:
#   CMake                 3.16.0-rc3
#   jsoncons              0.153.3
#   plog                  1.1.5
#   readerwriterqueue     1.0.3
#   concurrentqueue       1.0.2
#   CLI11                 2.0.0
#   Node.js               20.x
# ============================================================

die() {
    echo
    echo "============================================================"
    echo "ERROR: $*"
    echo "============================================================"
    exit 1
}

if [[ "${EUID}" -eq 0 ]]; then
    die "Run this as your normal development user, not root."
fi

if [[ ! -r /etc/os-release ]]; then
    die "Cannot determine operating system."
fi

. /etc/os-release

if [[ "${ID:-}" != "ubuntu" || "${VERSION_ID:-}" != "20.04" ]]; then
    die "This script is intended for Ubuntu 20.04. Detected: ${PRETTY_NAME:-unknown}"
fi

TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT

echo "============================================================"
echo " Sashimono Ubuntu 20.04 development environment"
echo "============================================================"
echo "OS: ${PRETTY_NAME}"

echo
echo "============================================================"
echo "1. Installing Ubuntu packages"
echo "============================================================"

sudo apt-get update

sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
    build-essential \
    git \
    wget \
    curl \
    ca-certificates \
    gnupg \
    pkg-config \
    python3 \
    python3-pip \
    python3-venv \
    libssl-dev \
    libsodium-dev \
    sqlite3 \
    libsqlite3-dev \
    libboost-stacktrace-dev \
    fuse3 \
    jq \
    bind9-host \
    clang \
    lld \
    wabt \
    binaryen

echo
echo "============================================================"
echo "2. Checking GCC"
echo "============================================================"

gcc --version | head -1
g++ --version | head -1

if ! gcc --version | head -1 | grep -q '9\.4\.0'; then
    echo
    echo "WARNING:"
    echo "Known-good sagent reports GCC 9.4.0."
    echo "This machine is using:"
    gcc --version | head -1
    echo
    echo "The build may work, but an exact binary match is less likely."
fi

echo
echo "============================================================"
echo "3. Installing CMake 3.16.0-rc3"
echo "============================================================"

CMAKE_NAME="cmake-3.16.0-rc3-Linux-x86_64"

cd "$TMP_DIR"

wget -q --show-progress \
    "https://github.com/Kitware/CMake/releases/download/v3.16.0-rc3/${CMAKE_NAME}.tar.gz"

tar -xzf "${CMAKE_NAME}.tar.gz"

sudo cp -a "${CMAKE_NAME}/bin/." /usr/local/bin/
sudo cp -a "${CMAKE_NAME}/share/." /usr/local/share/

hash -r

echo "cmake: $(cmake --version | head -1)"

echo
echo "============================================================"
echo "4. Installing jsoncons 0.153.3"
echo "============================================================"

cd "$TMP_DIR"

wget -q --show-progress \
    "https://github.com/danielaparker/jsoncons/archive/v0.153.3.tar.gz" \
    -O jsoncons-0.153.3.tar.gz

tar -xzf jsoncons-0.153.3.tar.gz

sudo rm -rf \
    /usr/local/include/jsoncons \
    /usr/local/include/jsoncons_ext

sudo cp -a \
    "$TMP_DIR/jsoncons-0.153.3/include/jsoncons" \
    /usr/local/include/

sudo mkdir -p /usr/local/include/jsoncons_ext

if [[ -d "$TMP_DIR/jsoncons-0.153.3/include/jsoncons_ext/bson" ]]; then
    sudo cp -a \
        "$TMP_DIR/jsoncons-0.153.3/include/jsoncons_ext/bson" \
        /usr/local/include/jsoncons_ext/
fi

echo
echo "============================================================"
echo "5. Installing plog 1.1.5"
echo "============================================================"

cd "$TMP_DIR"

wget -q --show-progress \
    "https://github.com/SergiusTheBest/plog/archive/1.1.5.tar.gz" \
    -O plog-1.1.5.tar.gz

tar -xzf plog-1.1.5.tar.gz

sudo rm -rf /usr/local/include/plog
sudo cp -a \
    "$TMP_DIR/plog-1.1.5/include/plog" \
    /usr/local/include/

echo
echo "============================================================"
echo "6. Installing readerwriterqueue 1.0.3"
echo "============================================================"

cd "$TMP_DIR"

wget -q --show-progress \
    "https://github.com/cameron314/readerwriterqueue/archive/v1.0.3.tar.gz" \
    -O readerwriterqueue-1.0.3.tar.gz

tar -xzf readerwriterqueue-1.0.3.tar.gz

cmake \
    -S "$TMP_DIR/readerwriterqueue-1.0.3" \
    -B "$TMP_DIR/readerwriterqueue-1.0.3/build"

cmake --build \
    "$TMP_DIR/readerwriterqueue-1.0.3/build" \
    --parallel "$(nproc)"

sudo cmake --install \
    "$TMP_DIR/readerwriterqueue-1.0.3/build"

echo
echo "============================================================"
echo "7. Installing concurrentqueue 1.0.2"
echo "============================================================"

cd "$TMP_DIR"

wget -q --show-progress \
    "https://github.com/cameron314/concurrentqueue/archive/1.0.2.tar.gz" \
    -O concurrentqueue-1.0.2.tar.gz

tar -xzf concurrentqueue-1.0.2.tar.gz

sudo install -m 0644 \
    "$TMP_DIR/concurrentqueue-1.0.2/concurrentqueue.h" \
    /usr/local/include/concurrentqueue.h

echo
echo "============================================================"
echo "8. Installing CLI11 2.0.0"
echo "============================================================"

cd "$TMP_DIR"

wget -q --show-progress \
    "https://github.com/CLIUtils/CLI11/archive/refs/tags/v2.0.0.tar.gz" \
    -O CLI11-2.0.0.tar.gz

tar -xzf CLI11-2.0.0.tar.gz

cmake \
    -S "$TMP_DIR/CLI11-2.0.0" \
    -B "$TMP_DIR/CLI11-2.0.0/build" \
    -DCLI11_BUILD_EXAMPLES=OFF \
    -DCLI11_BUILD_TESTS=OFF

cmake --build \
    "$TMP_DIR/CLI11-2.0.0/build" \
    --parallel "$(nproc)"

sudo cmake --install \
    "$TMP_DIR/CLI11-2.0.0/build"

echo
echo "============================================================"
echo "9. Installing Node.js 20"
echo "============================================================"

sudo mkdir -p /etc/apt/keyrings

curl -fsSL \
    https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key |
    gpg --dearmor |
    sudo tee /etc/apt/keyrings/nodesource.gpg >/dev/null

echo \
    "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" |
    sudo tee /etc/apt/sources.list.d/nodesource.list >/dev/null

sudo apt-get update
sudo apt-get install -y nodejs

echo "node: $(node --version)"
echo "npm:  $(npm --version)"

echo
echo "============================================================"
echo "10. Installing @vercel/ncc"
echo "============================================================"

if ! command -v ncc >/dev/null 2>&1; then
    sudo npm install -g @vercel/ncc
fi

hash -r

command -v ncc >/dev/null || die "ncc is not available."

echo "ncc: $(ncc --version)"

echo
echo "============================================================"
echo "11. Local PATH"
echo "============================================================"

mkdir -p "$HOME/.local/bin"

LOCAL_PATH_LINE='export PATH="$HOME/.local/bin:$PATH"'

grep -Fqx "$LOCAL_PATH_LINE" "$HOME/.bashrc" 2>/dev/null || \
    echo "$LOCAL_PATH_LINE" >> "$HOME/.bashrc"

export PATH="$HOME/.local/bin:$PATH"

echo
echo "============================================================"
echo "12. Optional wasienv / wasmcc tooling"
echo "============================================================"

# This tooling is kept because your Ubuntu-24 environment contained it.
# It is not used to select the compiler for sagent itself.

rm -rf "$HOME/.wasienv"

mkdir -p "$HOME/.wasienv/bin"

python3 -m venv "$HOME/.wasienv/venv"

"$HOME/.wasienv/venv/bin/python" \
    -m pip install --upgrade pip setuptools wheel

"$HOME/.wasienv/venv/bin/python" \
    -m pip install wasienv

cat > "$HOME/.wasienv/wasienv.sh" <<'EOF'
export WASIENV_DIR="$HOME/.wasienv"
export PATH="$WASIENV_DIR/venv/bin:$WASIENV_DIR/bin:$HOME/.local/bin:$PATH"
EOF

. "$HOME/.wasienv/wasienv.sh"

WASIENV_BASHRC_LINE='. "$HOME/.wasienv/wasienv.sh"'

grep -Fqx "$WASIENV_BASHRC_LINE" "$HOME/.bashrc" 2>/dev/null || {
    echo >> "$HOME/.bashrc"
    echo '# wasienv / wasmcc' >> "$HOME/.bashrc"
    echo "$WASIENV_BASHRC_LINE" >> "$HOME/.bashrc"
}

if command -v wasienv >/dev/null 2>&1; then
    echo "wasienv: $(command -v wasienv)"

    # This is intentionally not involved in the sagent C++ compiler.
    wasienv install-sdk unstable
    wasienv default-sdk unstable

    . "$HOME/.wasienv/wasienv.sh"
    hash -r
fi

echo
echo "============================================================"
echo "13. Hook Cleaner"
echo "============================================================"

if [[ ! -d "$HOME/hook-cleaner-c/.git" ]]; then
    git clone \
        https://github.com/RichardAH/hook-cleaner-c.git \
        "$HOME/hook-cleaner-c"
else
    git -C "$HOME/hook-cleaner-c" pull --ff-only
fi

make -C "$HOME/hook-cleaner-c" clean 2>/dev/null || true
make -C "$HOME/hook-cleaner-c"

install -m 0755 \
    "$HOME/hook-cleaner-c/hook-cleaner" \
    "$HOME/.local/bin/hook-cleaner"

echo
echo "============================================================"
echo "14. Verification"
echo "============================================================"

echo "--- OS ---"
cat /etc/os-release | grep -E '^(PRETTY_NAME|VERSION_ID)='

echo
echo "--- GCC ---"
gcc --version | head -1
g++ --version | head -1

echo
echo "--- GLIBC ---"
ldd --version | head -1

echo
echo "--- CMake ---"
cmake --version | head -1

echo
echo "--- Node ---"
node --version
npm --version

echo
echo "--- NCC ---"
ncc --version

echo
echo "--- Headers ---"

for header in \
    /usr/local/include/CLI/CLI.hpp \
    /usr/local/include/jsoncons/json.hpp \
    /usr/local/include/concurrentqueue.h \
    /usr/local/include/readerwriterqueue/readerwriterqueue.h \
    /usr/local/include/plog/Log.h
do
    [[ -f "$header" ]] || die "Missing header: $header"
    echo "OK: $header"
done

echo
echo "--- WASM tools ---"

for cmd in wasm2wat wat2wasm wasm-objdump clang ld.lld; do
    if command -v "$cmd" >/dev/null 2>&1; then
        echo "$cmd: $(command -v "$cmd")"
    fi
done

echo
echo "--- Extra tools ---"

for cmd in wasienv wasmcc wasicc hook-cleaner; do
    if command -v "$cmd" >/dev/null 2>&1; then
        echo "$cmd: $(command -v "$cmd")"
    fi
done

echo
echo "============================================================"
echo " UBUNTU 20.04 DEVELOPMENT ENVIRONMENT READY"
echo "============================================================"
echo
echo "Open a new shell or run:"
echo
echo "    . ~/.bashrc"
echo
Last edited by wroomwroom on Wed Aug 19, 2026 2:24 am, edited 18 times in total.
wroomwroom
Posts: 48
Joined: Wed Jul 31, 2024 5:59 pm

Re: dependency script for compilations

Post by wroomwroom »

UBUNTU 24 Build scripts (seem to fail compiling)

This fetches sashimono 1.0.0 and builds it for the first time.

Code: Select all

#!/usr/bin/env bash
set -Eeuo pipefail

# ============================================================
# Sashimono Ubuntu-24 / sagent v1.0.0
# INITIAL BUILD SCRIPT
#
# Run the dependency installer FIRST.
#
# This follows the project's documented build flow:
#   git submodule update --init --recursive
#   cmake .
#   make
#
# Notes:
#   - Fresh-clones the official ubuntu-24 branch
#   - Uses an in-source CMake build
#   - Does NOT modify tracked source files
#   - Does NOT patch PATH_MAX
#   - Does NOT manually relink sagent
#   - Keeps known GCC warnings non-fatal
#   - Does NOT deploy anything
#
# Expected output:
#   ~/sashimono-ubuntu24/build/sagent
# ============================================================

REPO="https://github.com/EvernodeXRPL/sashimono.git"
BRANCH="ubuntu-24"
EXPECTED_VERSION="1.0.0"

SRC="$HOME/sashimono-ubuntu24"
LOG="$SRC/sashimono-build.log"

CXX_FLAGS="-Wno-error=format-overflow -Wno-error=format-truncation -Wno-error=stringop-overflow -Wno-error=array-bounds"

die() {
    echo
    echo "============================================================"
    echo "ERROR: $*"
    echo "============================================================"
    exit 1
}

if [[ "$EUID" -eq 0 ]]; then
    die "Run this as your normal development user, not root."
fi

echo "============================================================"
echo " Sashimono Ubuntu-24 initial build"
echo "============================================================"
echo "Repo:    $REPO"
echo "Branch:  $BRANCH"
echo "Version: $EXPECTED_VERSION"

echo
echo "[1/7] Checking required tools..."

for cmd in git cmake make gcc g++ python3 node npm ncc tee; do
    command -v "$cmd" >/dev/null 2>&1 || \
        die "Missing '$cmd'. Run the dependency installer first."
done

echo
echo "[2/7] Removing previous source tree..."
rm -rf "$SRC"

echo
echo "[3/7] Cloning fresh ubuntu-24 source..."

git clone \
    --branch "$BRANCH" \
    --single-branch \
    "$REPO" \
    "$SRC"

cd "$SRC"

echo
echo "[4/7] Initializing submodules..."

git submodule update --init --recursive

echo
echo "Branch: $(git branch --show-current)"
echo "Commit: $(git rev-parse HEAD)"

if ! git diff --quiet; then
    git diff
    die "Fresh source tree already contains tracked modifications."
fi

echo
echo "[5/7] Configuring in-source CMake build..."

cmake . \
    -DCMAKE_CXX_FLAGS="$CXX_FLAGS"

if ! git diff --quiet; then
    git diff
    die "CMake modified tracked source files."
fi

echo
echo "[6/7] Building with make..."

set +e
make -j"$(nproc)" 2>&1 | tee "$LOG"
RC=${PIPESTATUS[0]}
set -e

if [[ "$RC" -ne 0 ]]; then
    die "make failed with exit code $RC. See: $LOG"
fi

echo
echo "[7/7] Verifying generated sagent..."

SAGENT="$SRC/build/sagent"

[[ -x "$SAGENT" ]] || die "Expected binary not found: $SAGENT"

VERSION="$("$SAGENT" version 2>/dev/null | tr -d '\r\n')"

[[ "$VERSION" == "$EXPECTED_VERSION" ]] || \
    die "Expected sagent $EXPECTED_VERSION, got '$VERSION'"

echo
echo "============================================================"
echo "BUILD SUCCESS"
echo "============================================================"
echo "Version: $VERSION"
echo "Binary:"
echo "  $SAGENT"
echo
echo "Tracked git diff:"
git diff
echo
echo "Nothing was deployed."
echo
echo "Build log:"
echo "  $LOG"


rebuild script

Code: Select all

#!/usr/bin/env bash
set -Eeuo pipefail

# ============================================================
# Sashimono Ubuntu-24 / sagent v1.0.0
# REBUILD SCRIPT
#
# Use this AFTER editing source files.
#
# This follows the same in-source build setup as the initial build:
#   cmake .
#   make
#
# It:
#   - does NOT clone
#   - does NOT reset source changes
#   - does NOT modify tracked source files
#   - does NOT manually relink sagent
#   - does NOT deploy anything
#
# Expected binary:
#   ~/sashimono-ubuntu24/build/sagent
# ============================================================

EXPECTED_VERSION="1.0.0"

SRC="${1:-$HOME/sashimono-ubuntu24}"
LOG="$SRC/sashimono-rebuild.log"

CXX_FLAGS="-Wno-error=format-overflow -Wno-error=format-truncation -Wno-error=stringop-overflow -Wno-error=array-bounds"

die() {
    echo
    echo "============================================================"
    echo "ERROR: $*"
    echo "============================================================"
    exit 1
}

if [[ "$EUID" -eq 0 ]]; then
    die "Run this as your normal development user, not root."
fi

[[ -d "$SRC/.git" ]] || die "Source tree not found: $SRC"
[[ -f "$SRC/CMakeLists.txt" ]] || die "Missing $SRC/CMakeLists.txt"

for cmd in cmake make gcc g++ node npm ncc tee; do
    command -v "$cmd" >/dev/null 2>&1 || \
        die "Missing '$cmd'. Run the dependency installer first."
done

cd "$SRC"

echo "============================================================"
echo " Sashimono incremental rebuild"
echo "============================================================"

echo
echo "Current source changes:"
git status --short

echo
echo "[1/3] Re-running in-source CMake configuration..."

cmake . \
    -DCMAKE_CXX_FLAGS="$CXX_FLAGS"

echo
echo "[2/3] Rebuilding..."

set +e
make -j"$(nproc)" 2>&1 | tee "$LOG"
RC=${PIPESTATUS[0]}
set -e

if [[ "$RC" -ne 0 ]]; then
    die "make failed with exit code $RC. See: $LOG"
fi

echo
echo "[3/3] Verifying sagent..."

SAGENT="$SRC/build/sagent"

[[ -x "$SAGENT" ]] || die "Expected binary not found: $SAGENT"

VERSION="$("$SAGENT" version 2>/dev/null | tr -d '\r\n')"

[[ "$VERSION" == "$EXPECTED_VERSION" ]] || \
    die "Expected sagent $EXPECTED_VERSION, got '$VERSION'"

echo
echo "============================================================"
echo "REBUILD SUCCESS"
echo "============================================================"
echo "Version: $VERSION"
echo "Binary:"
echo "  $SAGENT"
echo
echo "Current git diff:"
git diff
echo
echo "Nothing was deployed."
echo
echo "Rebuild log:"
echo "  $LOG"


Working Today
UBUNTU 20 BUILD SCRIPTS

Initial Build

Code: Select all

#!/usr/bin/env bash
set -Eeuo pipefail

# ============================================================
# Sashimono / sagent v1.0.0
# Ubuntu 20.04 / GCC 9 reproduction build
#
# Expected output:
#   ~/sashimono-v1.0.0-ubuntu20/build/sagent
# ============================================================

REPO="https://github.com/EvernodeXRPL/sashimono.git"
REF="v1.0.0"

EXPECTED_VERSION="1.0.0"
EXPECTED_COMMIT="321c98ba7e1ddad36c2c3df32a16cf546f1c3fb7"

SRC="$HOME/sashimono-v1.0.0-ubuntu20"
LOG="$SRC/sashimono-build.log"

# Optional:
# Copy the known-good sagent to ~/sagent before building.
KNOWN_GOOD="${KNOWN_GOOD:-$HOME/sagent}"

die() {
    echo
    echo "============================================================"
    echo "ERROR: $*"
    echo "============================================================"
    exit 1
}

if [[ "$EUID" -eq 0 ]]; then
    die "Run this as your normal development user, not root."
fi

. /etc/os-release

[[ "${ID:-}" == "ubuntu" ]] || \
    die "Ubuntu required."

[[ "${VERSION_ID:-}" == "20.04" ]] || \
    die "Ubuntu 20.04 required. Detected: ${PRETTY_NAME:-unknown}"

echo "============================================================"
echo " Sashimono v1.0.0 Ubuntu-20 reproduction build"
echo "============================================================"

echo "OS:"
echo "  $PRETTY_NAME"

echo
echo "Compiler:"
gcc --version | head -1
g++ --version | head -1

echo
echo "glibc:"
ldd --version | head -1

if ! gcc --version | head -1 | grep -q '9\.4\.0'; then
    echo
    echo "WARNING: known-good binary was built with GCC 9.4.0."
fi

echo
echo "[1/8] Checking required tools..."

for cmd in \
    git \
    cmake \
    make \
    gcc \
    g++ \
    python3 \
    node \
    npm \
    tee \
    readelf \
    sha256sum \
    file
do
    command -v "$cmd" >/dev/null 2>&1 || \
        die "Missing '$cmd'. Run the Ubuntu-20 dependency installer first."
done

echo
echo "[2/8] Removing previous source tree..."

rm -rf "$SRC"

echo
echo "[3/8] Cloning v1.0.0..."

git clone \
    --branch "$REF" \
    --single-branch \
    "$REPO" \
    "$SRC"

cd "$SRC"

ACTUAL_COMMIT="$(git rev-parse HEAD)"

echo
echo "Reference: $REF"
echo "Commit:    $ACTUAL_COMMIT"

[[ "$ACTUAL_COMMIT" == "$EXPECTED_COMMIT" ]] || {
    echo
    echo "WARNING:"
    echo "Expected commit:"
    echo "  $EXPECTED_COMMIT"
    echo
    echo "Actual commit:"
    echo "  $ACTUAL_COMMIT"
    echo
    echo "Stopping rather than building an unexpected source revision."
    exit 1
}

echo
echo "[4/8] Initializing pinned submodules..."

git submodule update --init --recursive

echo
echo "Submodules:"
git submodule status --recursive

if ! git diff --quiet; then
    git diff
    die "Fresh source tree contains tracked modifications."
fi

echo
echo "[5/8] Installing repository libblake3.so..."

if [[ -f "$SRC/dependencies/libblake3.so" ]]; then
    sudo install -m 0644 \
        "$SRC/dependencies/libblake3.so" \
        /usr/local/lib/libblake3.so

    sudo ldconfig
else
    echo "WARNING: dependencies/libblake3.so not found."
fi

echo
echo "[6/8] Configuring exactly through normal CMake flow..."

# IMPORTANT:
# Do NOT add the GCC-13 warning suppression flags used by Ubuntu 24.
#
# Project CMakeLists.txt supplies its own Release configuration,
# -Wall, -Werror, etc.

cmake .

if ! git diff --quiet; then
    git diff
    die "CMake modified tracked source files."
fi

echo
echo "CMake compiler:"
grep -E '^CMAKE_CXX_COMPILER:' CMakeCache.txt || true

echo
echo "CMake flags:"
grep -E '^CMAKE_(C|CXX)_FLAGS' CMakeCache.txt || true

echo
echo "[7/8] Building..."

set +e
make -j"$(nproc)" 2>&1 | tee "$LOG"
RC=${PIPESTATUS[0]}
set -e

if [[ "$RC" -ne 0 ]]; then
    die "make failed with exit code $RC. See: $LOG"
fi

echo
echo "[8/8] Verifying generated sagent..."

SAGENT="$SRC/build/sagent"

[[ -x "$SAGENT" ]] || \
    die "Expected binary not found: $SAGENT"

VERSION="$("$SAGENT" version 2>/dev/null | tr -d '\r\n')"

[[ "$VERSION" == "$EXPECTED_VERSION" ]] || \
    die "Expected sagent $EXPECTED_VERSION, got '$VERSION'"

echo
echo "============================================================"
echo " BUILD SUCCESS"
echo "============================================================"

echo
echo "Version:"
echo "  $VERSION"

echo
echo "Binary:"
echo "  $SAGENT"

echo
echo "File:"
file "$SAGENT"

echo
echo "SHA-256:"
sha256sum "$SAGENT"

echo
echo "Compiler embedded in .comment:"
readelf -p .comment "$SAGENT" 2>/dev/null || true

echo
echo "GNU Build ID:"
readelf -n "$SAGENT" 2>/dev/null | \
    grep -A1 -B1 'Build ID' || true

echo
echo "Dynamic dependencies:"
ldd "$SAGENT" || true

echo
echo "Git:"
echo "  ref:    $REF"
echo "  commit: $(git rev-parse HEAD)"

echo
echo "Submodules:"
git submodule status --recursive

echo
echo "Tracked source changes:"
git status --short

echo
echo "Build log:"
echo "  $LOG"

if [[ -f "$KNOWN_GOOD" ]]; then
    echo
    echo "============================================================"
    echo " COMPARING AGAINST KNOWN-GOOD"
    echo "============================================================"

    echo
    echo "Built:"
    sha256sum "$SAGENT"

    echo
    echo "Known-good:"
    sha256sum "$KNOWN_GOOD"

    echo
    echo "Built compiler:"
    readelf -p .comment "$SAGENT" 2>/dev/null || true

    echo
    echo "Known-good compiler:"
    readelf -p .comment "$KNOWN_GOOD" 2>/dev/null || true

    echo
    echo "Built Build-ID:"
    readelf -n "$SAGENT" 2>/dev/null | grep 'Build ID' || true

    echo
    echo "Known-good Build-ID:"
    readelf -n "$KNOWN_GOOD" 2>/dev/null | grep 'Build ID' || true

    echo
    if cmp -s "$SAGENT" "$KNOWN_GOOD"; then
        echo "EXACT BYTE-FOR-BYTE MATCH"
    else
        echo "NOT byte-for-byte identical yet."
    fi
else
    echo
    echo "Known-good binary not present at:"
    echo "  $KNOWN_GOOD"
    echo
    echo "Copy it there if you want automatic comparison."
fi

echo
echo "Nothing was deployed."

Rebuild

Code: Select all

#!/usr/bin/env bash
set -Eeuo pipefail

# ============================================================
# Sashimono / sagent v1.0.0
# Ubuntu 20.04 incremental rebuild
#
# Use AFTER editing source.
#
# Default source:
#   ~/sashimono-v1.0.0-ubuntu20
# ============================================================

EXPECTED_VERSION="1.0.0"

SRC="${1:-$HOME/sashimono-v1.0.0-ubuntu20}"
LOG="$SRC/sashimono-rebuild.log"

KNOWN_GOOD="${KNOWN_GOOD:-$HOME/sagent}"

die() {
    echo
    echo "============================================================"
    echo "ERROR: $*"
    echo "============================================================"
    exit 1
}

if [[ "$EUID" -eq 0 ]]; then
    die "Run this as your normal development user, not root."
fi

. /etc/os-release

[[ "${ID:-}" == "ubuntu" ]] || \
    die "Ubuntu required."

[[ "${VERSION_ID:-}" == "20.04" ]] || \
    die "Ubuntu 20.04 required. Detected: ${PRETTY_NAME:-unknown}"

[[ -d "$SRC/.git" ]] || \
    die "Source tree not found: $SRC"

[[ -f "$SRC/CMakeLists.txt" ]] || \
    die "Missing: $SRC/CMakeLists.txt"

for cmd in \
    cmake \
    make \
    gcc \
    g++ \
    node \
    npm \
    tee \
    sha256sum \
    readelf \
    file
do
    command -v "$cmd" >/dev/null 2>&1 || \
        die "Missing '$cmd'."
done

cd "$SRC"

echo "============================================================"
echo " Sashimono Ubuntu-20 incremental rebuild"
echo "============================================================"

echo
echo "OS:"
echo "  $PRETTY_NAME"

echo
echo "Compiler:"
gcc --version | head -1
g++ --version | head -1

echo
echo "Commit:"
git rev-parse HEAD

echo
echo "Current source changes:"
git status --short

echo
echo "[1/3] Re-running CMake..."

# No GCC-13 warning workarounds.
cmake .

echo
echo "[2/3] Rebuilding..."

set +e
make -j"$(nproc)" 2>&1 | tee "$LOG"
RC=${PIPESTATUS[0]}
set -e

if [[ "$RC" -ne 0 ]]; then
    die "make failed with exit code $RC. See: $LOG"
fi

echo
echo "[3/3] Verifying sagent..."

SAGENT="$SRC/build/sagent"

[[ -x "$SAGENT" ]] || \
    die "Expected binary not found: $SAGENT"

VERSION="$("$SAGENT" version 2>/dev/null | tr -d '\r\n')"

[[ "$VERSION" == "$EXPECTED_VERSION" ]] || \
    die "Expected sagent $EXPECTED_VERSION, got '$VERSION'"

echo
echo "============================================================"
echo " REBUILD SUCCESS"
echo "============================================================"

echo
echo "Version:"
echo "  $VERSION"

echo
echo "Binary:"
echo "  $SAGENT"

echo
echo "SHA-256:"
sha256sum "$SAGENT"

echo
echo "Compiler:"
readelf -p .comment "$SAGENT" 2>/dev/null || true

echo
echo "Build ID:"
readelf -n "$SAGENT" 2>/dev/null | \
    grep 'Build ID' || true

echo
echo "Current git diff:"
git diff

echo
echo "Current git status:"
git status --short

if [[ -f "$KNOWN_GOOD" ]]; then
    echo
    echo "Known-good:"
    sha256sum "$KNOWN_GOOD"

    if cmp -s "$SAGENT" "$KNOWN_GOOD"; then
        echo
        echo "EXACT BYTE-FOR-BYTE MATCH"
    else
        echo
        echo "Binary differs from known-good."
    fi
fi

echo
echo "Nothing was deployed."

echo
echo "Rebuild log:"
echo "  $LOG"
Last edited by wroomwroom on Wed Aug 19, 2026 2:24 am, edited 31 times in total.
wroomwroom
Posts: 48
Joined: Wed Jul 31, 2024 5:59 pm

Re: dependency script for compilations

Post by wroomwroom »

Remember permissions after switch
sudo chown root:root /usr/bin/sashimono/sagent
sudo chmod 755 /usr/bin/sashimono/sagent
Post Reply