b40c58f886
* Add triangles-cli: JSON-RPC client (port bitcoin-cli pattern)
Triangles never had a CLI client (bitcoin-cli analog). This adds
triangles-cli as a third build target alongside trianglesd and
triangles-qt.
- src/triangles-cli.cpp: self-contained JSON-RPC 1.0 client.
Reads triangles.conf for credentials, supports -rpcuser/-rpcpassword
/-rpcconnect/-rpcport/-testnet/-datadir/-conf flags. Implements
-getinfo (synthesized summary from getnetworkinfo/getblockchaininfo
/getwalletinfo) and raw method dispatch. JSON via json_spirit compat
shim (json_compat.h), HTTP via boost::asio, base64 auth inline.
No util.cpp / wallet.cpp / net.cpp / triangles_common link dep —
keeps the binary small (~600 KB Linux, ~1.5 MB Windows).
- CMake: new option(BUILD_CLI ON) + add_executable(triangles-cli)
in src/CMakeLists.txt. Status line added.
- CI: BUILD_CLI=ON added to build-windows-daemon and build-linux-daemon
jobs. triangles-cli.exe bundled into windows-daemon artifact
alongside trianglesd.exe. triangles-cli added to linux-daemon .deb
package (with launcher in /usr/bin).
- Default ON; set BUILD_CLI=OFF to skip.
Closes the open 'triangles-cli.exe missing from Windows build'
follow-up (the binary wasn't missing — it never existed).
Patterned after Bitcoin Core bitcoin-cli and Dash Core dash-cli.
* Fix macOS build: drop Boost::system/find_package component, use std::filesystem
Homebrew's boost formula doesn't ship the boost_system CMake config file,
so find_package(Boost REQUIRED COMPONENTS system) failed on macOS.
- Replace boost::filesystem with std::filesystem (C++17, no Boost dep)
- Drop 'filesystem' from find_package — only headers needed (asio + system)
- Link libboost_system explicitly per-platform by library name, resolved
via the platform's default search path (Homebrew toolchain on macOS,
system libs on Linux, MSYS2 on Windows)
CI will rerun automatically on PR push.
* Fix macOS build: add Boost::boost target for headers, link boost_system
The previous fix dropped the find_package component but also killed the
boost include path. Now use the modern Boost::boost header-only target
(available in Boost 1.83+) which sets up include directories without
requiring a per-component config file.
Link libboost_system explicitly by name on all platforms — the linker
finds it via the platform's default search path:
- Linux: /usr/lib (libboost_system.so)
- macOS Homebrew: /opt/homebrew/lib (libboost_system.dylib)
- Windows MSYS2: mingw64/bin (libboost_system-mt-X-XX.dll)
* Drop Boost entirely from triangles-cli: use raw sockets for HTTP
Third time's the charm. After two CI failures chasing boost::asio / libboost_system
linking issues across platforms (Homebrew missing config on macOS, MSYS2 versioned
names on Windows, CMake targets that don't quite work everywhere), rip the whole
Boost dependency out of the CLI and use raw POSIX/Winsock sockets.
- triangles-cli.cpp: replaced boost::asio with raw socket() / connect() / send()
/ recv() / getaddrinfo(). Cross-platform: #ifdef _WIN32 for Winsock + WSAStartup
/ WSACleanup, else POSIX. ~100 lines of clean portable socket code.
- src/CMakeLists.txt: dropped find_package(Boost) entirely. Only links
json_compat (header-only) + ws2_32 on Windows. No boost libs to find.
Should be the last fix needed for this PR.
* Fix Windows packaging step: simplify bash { } | sort -u | while pattern
The previous step used a bash group command piped through sort -u and a
while loop. Under MSYS2 bash + 'set -e -o pipefail' (GitHub Actions
default), this triggered a non-zero exit even when the loop body
succeeded, causing the Windows daemon job to fail at the packaging step
(the actual link of both trianglesd.exe and triangles-cli.exe succeeded).
Replaced the { } | sort -u | while pattern with a temp-file-based dedup:
- ldd both binaries, append to /tmp/cli-dlls.txt (or cli-libs.txt on Linux)
- sort -u the temp file
- pipe the result into the while loop (simpler pipeline, no group)
Also applied the same simplification to the Linux .deb packaging for
consistency, even though the Linux build was passing.
* Simplify DLL packaging: plain for loop, no pipe-into-while
The previous attempts used 'ldd | sort -u | while read; do ... done' patterns
that exit 1 under MSYS2 bash + 'set -e -o pipefail' even when the script
ran successfully. Replaced with a plain 'for bin in ...; do ldd > list.txt;
while read; do cp; done < list.txt; done' pattern that has no pipelines
other than the standard redirection, and uses IFS= read -r for safe line
iteration.
Also moved temp files from /tmp to the working directory (./dll-list.txt)
to avoid any MSYS2 /tmp path-translation edge cases.
* diagnostic: add tracing to Windows packaging step
* Add package-windows-daemon.sh + package-linux-daemon.sh scripts
Move the Windows daemon packaging step and the Linux .deb build into
committed shell scripts under scripts/ci/. This bypasses GitHub Actions'
inline-run-block quirks (silent exit 1 under msys2 + set -e -o pipefail
with multi-line scripts) and makes the packaging logic debuggable locally.
* Switch to script-file packaging for Windows + Linux daemon jobs
Replace inline multi-line run: blocks with invocations of the
scripts/ci/package-*.sh scripts. This sidesteps the GitHub Actions
msys2 + 'set -e -o pipefail' issue that caused silent exit 1 on the
Windows daemon packaging step. The scripts are also debuggable locally.
---------
Co-authored-by: Krystie <krystie@sami>
143 lines
4.5 KiB
Bash
Executable File
143 lines
4.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# scripts/ci/package-linux-daemon.sh
|
|
#
|
|
# Linux packaging step for the triangles daemon + CLI .deb.
|
|
# Called from .github/workflows/build-all.yml build-linux-daemon step.
|
|
#
|
|
# Builds a self-contained .deb with trianglesd, triangles-cli, bundled libs,
|
|
# Tor, systemd service, and CLI launchers. Designed to be reproducible and
|
|
# debuggable outside the CI environment.
|
|
#
|
|
# Usage: bash scripts/ci/package-linux-daemon.sh <version>
|
|
|
|
set -euo pipefail
|
|
|
|
VERSION="${1:-0.0.0}"
|
|
PKG="cryptographic-triangles-daemon_${VERSION}_amd64"
|
|
TOR_VERSION="${TOR_VERSION:-15.0.9}"
|
|
|
|
echo ">>> Building .deb for triangles ${VERSION}"
|
|
|
|
# Stage directories
|
|
rm -rf "${PKG}"
|
|
mkdir -p "${PKG}/DEBIAN"
|
|
mkdir -p "${PKG}/usr/lib/cryptographic-triangles/lib"
|
|
mkdir -p "${PKG}/usr/lib/cryptographic-triangles/tor"
|
|
mkdir -p "${PKG}/usr/bin"
|
|
mkdir -p "${PKG}/etc/systemd/system"
|
|
|
|
# Download + extract Tor
|
|
TOR_TARBALL="tor-expert-bundle-linux-x86_64-${TOR_VERSION}.tar.gz"
|
|
if [ ! -f "${TOR_TARBALL}" ]; then
|
|
echo ">>> Downloading Tor ${TOR_VERSION}..."
|
|
curl -sL "https://archive.torproject.org/tor-package-archive/torbrowser/${TOR_VERSION}/${TOR_TARBALL}" -o "${TOR_TARBALL}"
|
|
fi
|
|
mkdir -p tor-extract
|
|
tar -xzf "${TOR_TARBALL}" -C tor-extract
|
|
|
|
# Copy binaries
|
|
cp "build/bin/trianglesd" "${PKG}/usr/lib/cryptographic-triangles/"
|
|
cp "build/bin/triangles-cli" "${PKG}/usr/lib/cryptographic-triangles/"
|
|
|
|
# Copy Tor
|
|
cp "tor-extract/tor/tor" "${PKG}/usr/lib/cryptographic-triangles/tor/"
|
|
chmod +x "${PKG}/usr/lib/cryptographic-triangles/tor/tor"
|
|
if [ -d "tor-extract/data" ]; then
|
|
cp -r "tor-extract/data" "${PKG}/usr/lib/cryptographic-triangles/tor/data"
|
|
fi
|
|
|
|
# Bundle shared library dependencies (skip glibc/kernel — always present)
|
|
echo ">>> Bundling shared library dependencies..."
|
|
ALL_LIBS="$(mktemp)"
|
|
trap 'rm -f "${ALL_LIBS}"' EXIT
|
|
|
|
for bin in trianglesd triangles-cli; do
|
|
ldd "build/bin/${bin}" 2>/dev/null \
|
|
| grep '=> /' \
|
|
| awk '{print $3}' \
|
|
>> "${ALL_LIBS}" || true
|
|
done
|
|
|
|
if [ -s "${ALL_LIBS}" ]; then
|
|
sort -u "${ALL_LIBS}" | while IFS= read -r lib; do
|
|
if [ -z "${lib}" ]; then continue; fi
|
|
case "${lib}" in
|
|
/lib/x86_64-linux-gnu/libc.so*|/lib/x86_64-linux-gnu/libm.so*|/lib/x86_64-linux-gnu/libpthread.so*|/lib/x86_64-linux-gnu/libdl.so*|/lib/x86_64-linux-gnu/librt.so*|/lib/x86_64-linux-gnu/ld-linux*|/lib64/ld-linux*)
|
|
;; # Skip glibc core
|
|
*)
|
|
cp -L "${lib}" "${PKG}/usr/lib/cryptographic-triangles/lib/" 2>/dev/null || true
|
|
;;
|
|
esac
|
|
done
|
|
fi
|
|
|
|
echo ">>> Bundled libs:"
|
|
ls -la "${PKG}/usr/lib/cryptographic-triangles/lib/" | tail -n +2 | wc -l
|
|
|
|
# Launchers (set LD_LIBRARY_PATH for bundled libs)
|
|
cat > "${PKG}/usr/bin/trianglesd" << 'LAUNCHER'
|
|
#!/bin/bash
|
|
INSTALL_DIR=/usr/lib/cryptographic-triangles
|
|
export LD_LIBRARY_PATH="${INSTALL_DIR}/lib:${LD_LIBRARY_PATH}"
|
|
exec "${INSTALL_DIR}/trianglesd" "$@"
|
|
LAUNCHER
|
|
chmod +x "${PKG}/usr/bin/trianglesd"
|
|
|
|
cat > "${PKG}/usr/bin/triangles-cli" << 'LAUNCHER'
|
|
#!/bin/bash
|
|
INSTALL_DIR=/usr/lib/cryptographic-triangles
|
|
export LD_LIBRARY_PATH="${INSTALL_DIR}/lib:${LD_LIBRARY_PATH}"
|
|
exec "${INSTALL_DIR}/triangles-cli" "$@"
|
|
LAUNCHER
|
|
chmod +x "${PKG}/usr/bin/triangles-cli"
|
|
|
|
# systemd unit
|
|
cat > "${PKG}/etc/systemd/system/trianglesd.service" << 'SVC'
|
|
[Unit]
|
|
Description=Cryptographic Triangles Daemon
|
|
After=network-online.target
|
|
Wants=network-online.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
Environment=LD_LIBRARY_PATH=/usr/lib/cryptographic-triangles/lib
|
|
ExecStart=/usr/lib/cryptographic-triangles/trianglesd
|
|
Restart=on-failure
|
|
RestartSec=10
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
SVC
|
|
|
|
# DEBIAN/control
|
|
cat > "${PKG}/DEBIAN/control" << CTRL
|
|
Package: cryptographic-triangles-daemon
|
|
Version: ${VERSION}
|
|
Architecture: amd64
|
|
Maintainer: Cryptographic Triangles <dev@cryptographic-triangles.org>
|
|
Description: Cryptographic Triangles daemon + CLI with integrated Tor
|
|
Fully self-contained headless node + JSON-RPC client with all libraries,
|
|
Tor, and systemd service. No external dependencies required.
|
|
Section: finance
|
|
Priority: optional
|
|
CTRL
|
|
|
|
# DEBIAN/postinst
|
|
cat > "${PKG}/DEBIAN/postinst" << 'POST'
|
|
#!/bin/bash
|
|
systemctl daemon-reload
|
|
echo ""
|
|
echo "Cryptographic Triangles daemon + CLI installed."
|
|
echo " Start daemon: sudo systemctl start trianglesd"
|
|
echo " On boot: sudo systemctl enable trianglesd"
|
|
echo " Use CLI: triangles-cli getinfo"
|
|
echo ""
|
|
POST
|
|
chmod +x "${PKG}/DEBIAN/postinst"
|
|
|
|
# Build the .deb
|
|
dpkg-deb --build "${PKG}"
|
|
echo ">>> Built: ${PKG}.deb"
|
|
ls -la "${PKG}.deb"
|
|
exit 0
|