Files
mines/rin/miner/build-windows-smart.sh

117 lines
5.0 KiB
Bash

#!/bin/bash
#
# Smart Windows Docker Build Script for RinHash Miner
# Automatically detects curl availability and builds with/without NO_CURL flag accordingly
#
echo "=== Smart Windows Docker Build Script ==="
echo "Automatically detecting curl availability for optimal build..."
echo ""
# Check if Docker is available
if ! command -v docker &> /dev/null; then
echo "❌ Error: Docker is not installed or not in PATH"
echo "Please install Docker Desktop and try again."
pause
exit 1
fi
# Check if cpuminer-opt-rin exists in the expected location
if [ -f "/home/db/Downloads/rinhash/cpuminer-opt-rin/algo/rinhash/rinhash.c" ]; then
CPMINER_PATH="/home/db/Downloads/rinhash/cpuminer-opt-rin"
echo "📁 Found cpuminer-opt-rin at: $CPMINER_PATH"
elif [ -f "cpuminer-opt-rin/algo/rinhash/rinhash.c" ]; then
CPMINER_PATH="$(pwd)/cpuminer-opt-rin"
echo "📁 Found cpuminer-opt-rin at: $CPMINER_PATH"
else
echo "❌ Error: cpuminer-opt-rin directory not found"
echo "Expected locations:"
echo " - /home/db/Downloads/rinhash/cpuminer-opt-rin"
echo " - $(pwd)/cpuminer-opt-rin"
exit 1
fi
echo "🐳 Using Docker container: cpuminer-windows-builder"
echo ""
# First, try to build with original curl implementation (WITHOUT NO_CURL flag)
echo "🔍 Attempting to build with original curl implementation (recommended)..."
docker run --rm \
-v "$CPMINER_PATH:/work" \
-v "$CPMINER_PATH/build/win:/output" \
cpuminer-windows-builder \
bash -c "cd /work && make clean && rm -rf Makefile Makefile.in configure config.* && ./autogen.sh && ./configure --host=x86_64-w64-mingw32 --with-curl=/usr/x86_64-w64-mingw32 CFLAGS='-O3 -march=x86-64 -DCURL_STATICLIB' LDFLAGS='-L/usr/x86_64-w64-mingw32/lib' LIBS='-lcurl -lbcrypt -ladvapi32 -lcrypt32 -lz -lws2_32 -pthread' && make -j4 && cp cpuminer.exe /output/cpuminer-curl.exe"
CURL_BUILD_RESULT=$?
if [ $CURL_BUILD_RESULT -eq 0 ]; then
echo ""
echo "✅ SUCCESS: Built with original curl implementation!"
echo "📦 Checking output file..."
if [ -f "$CPMINER_PATH/build/win/cpuminer-curl.exe" ]; then
FILE_SIZE=$(stat -c%s "$CPMINER_PATH/build/win/cpuminer-curl.exe" 2>/dev/null || stat -f%z "$CPMINER_PATH/build/win/cpuminer-curl.exe" 2>/dev/null)
echo "📦 Original curl executable ready: $CPMINER_PATH/build/win/cpuminer-curl.exe (${FILE_SIZE} bytes)"
# Copy as main executable
cp "$CPMINER_PATH/build/win/cpuminer-curl.exe" "$CPMINER_PATH/build/win/cpuminer.exe"
echo "📦 Also available as: $CPMINER_PATH/build/win/cpuminer.exe"
echo ""
echo "🎉 BUILD COMPLETE - Using original curl implementation!"
echo "💡 This provides the best networking performance and full stratum features."
echo ""
echo "🚀 Ready for shipping to Windows systems!"
echo "💡 Mining command example:"
echo " cpuminer.exe -a rinhash -o stratum+tcp://pool.example.com:3333 -u wallet -p x -t 4"
exit 0
fi
fi
echo ""
echo "⚠️ Original curl build failed (exit code: $CURL_BUILD_RESULT)"
echo "🔄 Falling back to NO_CURL direct socket implementation..."
# Fallback: Build with NO_CURL flag
docker run --rm \
-v "$CPMINER_PATH:/work" \
-v "$CPMINER_PATH/build/win:/output" \
cpuminer-windows-builder \
bash -c "cd /work && make clean && rm -rf Makefile Makefile.in configure config.* && ./autogen.sh && ./configure --host=x86_64-w64-mingw32 CFLAGS='-O3 -march=x86-64 -DNO_CURL' LDFLAGS='-static' && make -j4 && cp cpuminer.exe /output/cpuminer-nocurl.exe"
NOCURL_BUILD_RESULT=$?
if [ $NOCURL_BUILD_RESULT -eq 0 ]; then
echo ""
echo "✅ SUCCESS: Built with NO_CURL fallback implementation!"
echo "📦 Checking output file..."
if [ -f "$CPMINER_PATH/build/win/cpuminer-nocurl.exe" ]; then
FILE_SIZE=$(stat -c%s "$CPMINER_PATH/build/win/cpuminer-nocurl.exe" 2>/dev/null || stat -f%z "$CPMINER_PATH/build/win/cpuminer-nocurl.exe" 2>/dev/null)
echo "📦 Fallback executable ready: $CPMINER_PATH/build/win/cpuminer-nocurl.exe (${FILE_SIZE} bytes)"
# Copy as main executable
cp "$CPMINER_PATH/build/win/cpuminer-nocurl.exe" "$CPMINER_PATH/build/win/cpuminer.exe"
echo "📦 Also available as: $CPMINER_PATH/build/win/cpuminer.exe"
echo ""
echo "⚠️ USING FALLBACK: Direct socket implementation (no curl)"
echo "💡 This works but may have limited networking features."
echo ""
echo "🚀 Ready for shipping to Windows systems!"
echo "💡 Mining command example:"
echo " cpuminer.exe -a rinhash -o stratum+tcp://pool.example.com:3333 -u wallet -p x -t 4"
exit 0
fi
fi
echo ""
echo "❌ FAILED: Both curl and NO_CURL builds failed!"
echo "🔍 Troubleshooting:"
echo " - Check Docker container has required libraries"
echo " - Verify cpuminer source files are intact"
echo " - Check Docker container logs for specific errors"
echo ""
echo "📋 Build exit codes:"
echo " - Original curl build: $CURL_BUILD_RESULT"
echo " - NO_CURL fallback: $NOCURL_BUILD_RESULT"
exit 1