117 lines
3.1 KiB
Bash
Executable file
117 lines
3.1 KiB
Bash
Executable file
#!/bin/bash
|
|
# Build verification and dependency check script
|
|
|
|
set -e
|
|
|
|
echo "=== Strawberry Security Scanner - Build Verification ==="
|
|
echo
|
|
|
|
# Color codes
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Track status
|
|
MISSING_DEPS=()
|
|
OPTIONAL_DEPS=()
|
|
|
|
check_command() {
|
|
if command -v "$1" &> /dev/null; then
|
|
echo -e "${GREEN}✓${NC} $1 found: $(which $1)"
|
|
return 0
|
|
else
|
|
echo -e "${RED}✗${NC} $1 not found"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
check_pkg_config() {
|
|
if pkg-config --exists "$1" 2>/dev/null; then
|
|
version=$(pkg-config --modversion "$1" 2>/dev/null || echo "unknown")
|
|
echo -e "${GREEN}✓${NC} $1 found (version: $version)"
|
|
return 0
|
|
else
|
|
echo -e "${RED}✗${NC} $1 not found"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
check_optional() {
|
|
if pkg-config --exists "$1" 2>/dev/null; then
|
|
version=$(pkg-config --modversion "$1" 2>/dev/null || echo "unknown")
|
|
echo -e "${GREEN}✓${NC} $1 found (version: $version)"
|
|
return 0
|
|
else
|
|
echo -e "${YELLOW}⚠${NC} $1 not found (optional)"
|
|
OPTIONAL_DEPS+=("$1")
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
check_header() {
|
|
if [ -f "$1" ]; then
|
|
echo -e "${GREEN}✓${NC} Header found: $1"
|
|
return 0
|
|
else
|
|
echo -e "${YELLOW}⚠${NC} Header not found: $1 (optional)"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
echo "Checking required tools..."
|
|
check_command meson || MISSING_DEPS+=("meson")
|
|
check_command ninja || MISSING_DEPS+=("ninja-build")
|
|
check_command g++ || check_command clang++ || MISSING_DEPS+=("g++ or clang++")
|
|
|
|
echo
|
|
echo "Checking required libraries..."
|
|
check_pkg_config openssl || MISSING_DEPS+=("libssl-dev")
|
|
if pkg-config --exists threads 2>/dev/null; then
|
|
check_pkg_config threads
|
|
else
|
|
echo -e "${GREEN}✓${NC} threads provided by toolchain/standard library"
|
|
fi
|
|
|
|
echo
|
|
echo "Checking optional dependencies..."
|
|
check_optional libbpf || true
|
|
check_optional yara || check_optional libyara || true
|
|
|
|
echo
|
|
echo "Checking bundled headers..."
|
|
check_header "include/tinyfsm.hpp" || \
|
|
echo -e "${YELLOW}⚠${NC} local tinyfsm shim is missing"
|
|
|
|
echo
|
|
echo "======================================"
|
|
|
|
if [ ${#MISSING_DEPS[@]} -eq 0 ]; then
|
|
echo -e "${GREEN}All required dependencies are installed!${NC}"
|
|
echo
|
|
echo "Optional dependencies missing: ${#OPTIONAL_DEPS[@]}"
|
|
if [ ${#OPTIONAL_DEPS[@]} -gt 0 ]; then
|
|
echo " The project will build without: ${OPTIONAL_DEPS[*]}"
|
|
echo " Some features may not be fully functional."
|
|
fi
|
|
echo
|
|
echo "You can now build the project:"
|
|
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
|
|
echo " meson setup builddir"
|
|
echo " meson compile -C builddir"
|
|
exit 0
|
|
else
|
|
echo -e "${RED}Missing required dependencies!${NC}"
|
|
echo
|
|
echo "To install on Ubuntu/Debian:"
|
|
echo " sudo apt-get update"
|
|
echo -n " sudo apt-get install -y"
|
|
for dep in "${MISSING_DEPS[@]}"; do
|
|
echo -n " $dep"
|
|
done
|
|
echo
|
|
echo
|
|
echo "For optional dependencies (recommended):"
|
|
echo " sudo apt-get install -y libbpf-dev libyara-dev"
|
|
exit 1
|
|
fi
|