### A Note on Recent Challenges
I want to take a moment to address a recent issue. Due to a mistake on my part with WalletBuilders.com, there was a typo in the hardcoded node, which caused some complications. I’ve since corrected the code and uploaded the revised version to our GitHub repository. I apologize for any inconvenience this may have caused and appreciate your understanding as we work to resolve these issues.
I'm working on a shell script that will automate the entire process of building the project for Linux users particularly Ubuntu and have the following so far...
#!/bin/bash
# Script: compile_cannacoin_smoke.sh
# Purpose: Fully automates cloning, patching, and compilation of the cannacoin-smoke project on Ubuntu 24.04,
# placing it in the home directory (~), using Boost 1.81.0 without NumPy support.
# Includes RPATH configuration, system checks, and cleanup for a true turnkey experience.
# Date: March 31, 2025
# Usage: Save this script locally (e.g., as compile_cannacoin_smoke.sh), make it executable (chmod +x compile_cannacoin_smoke.sh),
# and run it (./compile_cannacoin_smoke.sh) from any directory. Requires sudo privileges.
# Notes: - Assumes Ubuntu 24.04 on x86_64 architecture.
# - Requires ~5-10 GB of free disk space.
# - Internet connection is needed to download Boost and clone the repository.
# Exit on any error
set -e
# Colors for user feedback
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
# Function to display error messages and exit
error_exit() {
echo -e "${RED}Error: $1${NC}" >&2
exit 1
}
# Define key variables
REPO_URL="https://github.com/cannacoin-official/cannacoin-smoke.git"
REPO_DIR="$HOME/cannacoin-smoke"
BOOST_VERSION="1_81_0"
BOOST_DIR="$REPO_DIR/boost_${BOOST_VERSION}"
BOOST_INSTALL_DIR="$BOOST_DIR/install"
BOOST_TAR="boost_${BOOST_VERSION}.tar.gz"
BOOST_URL="https://archives.boost.io/release/1.81.0/source/${BOOST_TAR}"
BOOST_FALLBACK_URL="https://sourceforge.net/projects/boost/files/boost/1.81.0/${BOOST_TAR}/download"
BOOST_EXPECTED_SIZE=140221178 # Size in bytes
BOOST_SHA256="205666dea9f6a7cfed87c7a6dfbeb52a2c1b9de55712c9c1a87735d7181452b6"
MAX_ATTEMPTS=5
RETRY_DELAY=10 # seconds
LOG_FILE="$REPO_DIR/build.log"
MIN_DISK_SPACE=10000000 # 10 GB in KB
# Function to check system requirements
check_requirements() {
echo "Checking system requirements..."
# Check Ubuntu version
if ! lsb_release -d | grep -q "Ubuntu 24.04"; then
error_exit "This script is designed for Ubuntu 24.04. Your system is $(lsb_release -d)."
fi
# Check architecture
if [ "$(uname -m)" != "x86_64" ]; then
error_exit "This script is designed for x86_64 architecture. Your system is $(uname -m)."
fi
# Check disk space
AVAILABLE_SPACE=$(df -k "$HOME" | tail -1 | awk '{print $4}')
if [ "$AVAILABLE_SPACE" -lt "$MIN_DISK_SPACE" ]; then
error_exit "Insufficient disk space. Need at least 10 GB free, but only $(($AVAILABLE_SPACE / 1024)) MB available in $HOME."
fi
# Check internet connectivity
if ! ping -c 1 google.com > /dev/null 2>&1; then
error_exit "No internet connection detected. Please connect to the internet and try again."
fi
}
# Function to install a package if missing
install_if_missing() {
if ! command -v "$1" &> /dev/null; then
echo "Installing $1..."
sudo apt install -y "$2" || error_exit "Failed to install $1."
fi
}
# Function to download Boost with retries
download_boost() {
local url="$1"
local attempt=1
while [ $attempt -le $MAX_ATTEMPTS ]; do
echo "Attempt $attempt of $MAX_ATTEMPTS: Downloading Boost 1.81.0 from $url..."
if curl -L -o "$BOOST_TAR" "$url"; then
FILE_SIZE=$(stat -c%s "$BOOST_TAR" 2>/dev/null || stat --format=%s "$BOOST_TAR")
if [ "$FILE_SIZE" -eq "$BOOST_EXPECTED_SIZE" ]; then
DOWNLOADED_SHA256=$(sha256sum "$BOOST_TAR" | cut -d' ' -f1)
if [ "$DOWNLOADED_SHA256" = "$BOOST_SHA256" ]; then
return 0
else
echo "Checksum mismatch. Expected: $BOOST_SHA256, Got: $DOWNLOADED_SHA256."
fi
else
echo "Size mismatch. Expected: $BOOST_EXPECTED_SIZE, Got: $FILE_SIZE."
fi
fi
attempt=$((attempt + 1))
if [ $attempt -le $MAX_ATTEMPTS ]; then
echo "Retrying in $RETRY_DELAY seconds..."
sleep $RETRY_DELAY
fi
done
return 1
}
# Step 1: Check system requirements
check_requirements
# Step 2: Ensure basic tools are installed
echo "Ensuring basic tools are installed..."
install_if_missing "git" "git"
install_if_missing "curl" "curl"
install_if_missing "tar" "tar"
install_if_missing "sudo" "sudo"
install_if_missing "sha256sum" "coreutils"
install_if_missing "lsb_release" "lsb-release"
# Step 3: Install system dependencies for the project and Boost build
echo "Installing system dependencies..."
DEPENDENCIES="build-essential libssl-dev libevent-dev libqrencode-dev libzmq3-dev libprotobuf-dev \
protobuf-compiler libminiupnpc-dev libdb5.3++-dev qtbase5-dev qttools5-dev-tools libqt5dbus5t64 \
pkg-config g++ libicu-dev libbz2-dev liblzma-dev zlib1g-dev autoconf automake libtool"
sudo apt update || error_exit "Failed to update package list. Check internet connection."
sudo apt install -y $DEPENDENCIES || error_exit "Failed to install dependencies. On non-Ubuntu systems, install equivalents manually (see $REPO_URL)."
# Step 4: Handle repository cloning with retries
echo "Cloning cannacoin-smoke repository into $REPO_DIR..."
attempt=1
while [ $attempt -le $MAX_ATTEMPTS ]; do
if git clone "$REPO_URL" "$REPO_DIR"; then
break
else
echo "Attempt $attempt of $MAX_ATTEMPTS: Failed to clone repository. Retrying in $RETRY_DELAY seconds..."
sleep $RETRY_DELAY
attempt=$((attempt + 1))
fi
done
[ $attempt -gt $MAX_ATTEMPTS ] && error_exit "Failed to clone repository after $MAX_ATTEMPTS attempts."
# Change to the repository directory
cd "$REPO_DIR" || error_exit "Failed to change to $REPO_DIR."
# Step 5: Check if Boost 1.81.0 is already present and installed
if [ ! -d "$BOOST_INSTALL_DIR/lib" ] || [ ! -f "$BOOST_INSTALL_DIR/lib/libboost_system.a" ]; then
echo "Boost 1.81.0 not found or not installed correctly. Downloading and building it now..."
# Download Boost with retries
if [ ! -f "$BOOST_TAR" ] || [ "$(stat -c%s "$BOOST_TAR" 2>/dev/null || stat --format=%s "$BOOST_TAR")" -ne "$BOOST_EXPECTED_SIZE" ]; then
download_boost "$BOOST_URL" || {
echo "Primary URL failed, trying fallback..."
download_boost "$BOOST_FALLBACK_URL" || error_exit "Failed to download Boost 1.81.0 from both URLs after $MAX_ATTEMPTS attempts."
}
fi
# Extract Boost
echo "Extracting $BOOST_TAR..."
tar -xzf "$BOOST_TAR" || error_exit "Failed to extract Boost 1.81.0."
# Build and install Boost without NumPy
cd "$BOOST_DIR"
echo "Bootstrapping Boost..."
./bootstrap.sh > "$LOG_FILE" 2>&1 || error_exit "Boost bootstrap failed. Check $LOG_FILE for details."
echo "Building Boost 1.81.0 without NumPy support (this may take up to 10 minutes)..."
./b2 --without-python -j$(nproc) >> "$LOG_FILE" 2>&1 || error_exit "Failed to build Boost 1.81.0. Check $LOG_FILE for details."
echo "Installing Boost to $BOOST_INSTALL_DIR..."
./b2 install --prefix="$BOOST_INSTALL_DIR" >> "$LOG_FILE" 2>&1 || error_exit "Failed to install Boost 1.81.0. Check $LOG_FILE for details."
cd ..
echo -e "${GREEN}Boost 1.81.0 built and installed successfully.${NC}"
else
echo "Boost 1.81.0 already present and installed in $BOOST_INSTALL_DIR."
fi
# Step 6: Patch qt/transactiondesc.cpp and qt/paymentserver.cpp to fix compilation errors
echo "Patching source files to fix compilation errors..."
# Patch qt/transactiondesc.cpp: Replace Q_FOREACH with range-based for loop
sed -i 's/Q_FOREACH (const PAIRTYPE(std::string, std::string)& r, wtx.vOrderForm)/for (const auto\& r : wtx.vOrderForm)/g' src/qt/transactiondesc.cpp
echo "Replaced Q_FOREACH with range-based for loop in src/qt/transactiondesc.cpp."
# Patch qt/paymentserver.cpp: Add #include <array> if not present
if ! grep -q "#include <array>" src/qt/paymentserver.cpp; then
sed -i '2i#include <array>' src/qt/paymentserver.cpp
echo "Added #include <array> to src/qt/paymentserver.cpp."
else
echo "#include <array> already present in src/qt/paymentserver.cpp."
fi
# Patch qt/paymentserver.cpp: Replace Q_FOREACH with range-based for loop
sed -i 's/Q_FOREACH(const PAIRTYPE(CScript, CAmount)& sendingTo, sendingTos)/for (const auto\& sendingTo : sendingTos)/g' src/qt/paymentserver.cpp
echo "Replaced Q_FOREACH with range-based for loop in src/qt/paymentserver.cpp."
# Step 7: Clean previous build artifacts
echo "Cleaning previous build artifacts..."
make clean || true # Ignore errors if no previous build exists
# Step 8: Run autogen.sh
echo "Running autogen.sh..."
./autogen.sh > "$LOG_FILE" 2>&1 || error_exit "autogen.sh failed. Check $LOG_FILE for details."
# Step 9: Configure with Boost 1.81.0, explicit paths, and RPATH for runtime library location
echo "Configuring build with Boost 1.81.0 and setting RPATH..."
./configure --with-boost="$BOOST_INSTALL_DIR" \
LDFLAGS="-L$BOOST_INSTALL_DIR/lib -Wl,-rpath,$BOOST_INSTALL_DIR/lib" \
CPPFLAGS="-I$BOOST_INSTALL_DIR/include" > "$LOG_FILE" 2>&1 || error_exit "configure failed. Check $LOG_FILE for details."
# Step 10: Compile the project with parallel jobs and detailed logging
echo "Compiling cannacoin-smoke (this may take up to 15 minutes)..."
make -j$(nproc) >> "$LOG_FILE" 2>&1 || error_exit "make failed. Check $LOG_FILE for detailed errors."
# Step 11: Verify the binaries exist and are executable
echo "Verifying compiled binaries..."
for binary in "$REPO_DIR/src/smoked" "$REPO_DIR/src/qt/smoke-qt" "$REPO_DIR/src/smoke-cli"; do
if [ ! -f "$binary" ]; then
error_exit "Binary $binary not found after compilation."
fi
chmod +x "$binary" || error_exit "Failed to make $binary executable."
done
# Step 12: Test the GUI binary (smoke-qt) to ensure it runs
echo "Testing smoke-qt binary..."
if ! "$REPO_DIR/src/qt/smoke-qt" --version > /dev/null 2>&1; then
echo -e "${RED}Warning: smoke-qt failed to run. It may require a graphical environment (X11).${NC}"
echo "If you're on a server without a GUI, use smoked or smoke-cli instead."
fi
# Step 13: Clean up temporary files to save space
echo "Cleaning up temporary files..."
[ -d "$BOOST_DIR" ] && rm -rf "$BOOST_DIR"
[ -f "$BOOST_TAR" ] && rm -f "$BOOST_TAR"
echo "Cleanup completed."
# Step 14: Success message with instructions
echo -e "${GREEN}Compilation completed successfully!${NC}"
echo "The compiled binaries are located in $REPO_DIR/src/."
echo "To run the daemon (smoked), use this command from anywhere:"
echo " $REPO_DIR/src/smoked"
echo "To run the GUI (smoke-qt), use (requires a graphical environment):"
echo " $REPO_DIR/src/qt/smoke-qt"
echo "To use the CLI (smoke-cli), for example to check the status, run:"
echo " $REPO_DIR/src/smoke-cli getinfo"
echo "Optional: Run 'cd $REPO_DIR && sudo make install' to install system-wide."
echo "For more information, visit: https://cannacoin.org"
i made that with the help of grok and it suggests that there are some patches necessary to a couple different source files.
can anyone complete this with good portable results?
Best regards,
deusopus
here is the file ez-linux-setup.sh