#!/bin/bash # NIP Release Build Script set -e echo "๐Ÿš€ Building NIP v0.1.0 for Release" echo "======================================" echo "" # Check if Nim is available if ! command -v nim &> /dev/null; then echo "โŒ Error: Nim compiler not found" echo " Please install Nim: https://nim-lang.org/install.html" exit 1 fi # Show Nim version echo "๐Ÿ“‹ Nim version: $(nim --version | head -1)" echo "" # Clean previous builds echo "๐Ÿงน Cleaning previous builds..." rm -f nip nip_release echo "" # Build optimized release binary echo "๐Ÿ”จ Building optimized release binary..." nim c \ --opt:speed \ --define:release \ --define:danger \ --passC:-flto \ --passL:-flto \ --passL:-s \ --hints:off \ --warnings:off \ --out:nip_release \ nip.nim if [ ! -f "nip_release" ]; then echo "โŒ Build failed!" exit 1 fi # Show binary info echo "" echo "โœ… Build successful!" echo "" echo "๐Ÿ“Š Binary Information:" ls -lh nip_release echo "" # Test the binary echo "๐Ÿงช Testing binary..." if ./nip_release --version > /dev/null 2>&1; then echo "โœ… Binary test passed" else echo "โš ๏ธ Binary test failed (but this is expected without root)" fi echo "" # Create release directory RELEASE_DIR="nip-v0.1.0-$(uname -s)-$(uname -m)" echo "๐Ÿ“ฆ Creating release package: $RELEASE_DIR" mkdir -p "$RELEASE_DIR" # Copy files to release directory cp nip_release "$RELEASE_DIR/nip" cp README.md "$RELEASE_DIR/" 2>/dev/null || echo "# NIP v0.1.0" > "$RELEASE_DIR/README.md" # Create installation script cat > "$RELEASE_DIR/install.sh" << 'EOF' #!/bin/bash # NIP Installation Script set -e echo "๐ŸŒฑ Installing NIP v0.1.0" echo "============================" echo "" # Check if running as root if [ "$EUID" -ne 0 ]; then echo "โš ๏ธ This installer requires root privileges" echo " Please run: sudo ./install.sh" exit 1 fi # Install binary echo "๐Ÿ“ฆ Installing NIP binary..." cp nip /usr/local/bin/nip chmod +x /usr/local/bin/nip echo " Installed to: /usr/local/bin/nip" echo "" # Create directories echo "๐Ÿ“ Creating directories..." mkdir -p /Programs mkdir -p /System/Links/{Executables,Libraries,Headers,Shared} mkdir -p /var/nip/{cache,db} mkdir -p /etc/nip echo " Created system directories" echo "" # Setup system integration echo "๐Ÿ”ง Setting up system integration..." if /usr/local/bin/nip setup; then echo " System integration complete" else echo " System integration partially complete" fi echo "" echo "โœ… NIP installation complete!" echo "" echo "๐ŸŽ‰ You can now use NIP:" echo " nip --help # Show help" echo " nip config init # Initialize user config" echo " nip graft nix:hello # Graft a package" echo " nip status # Show system status" echo "" echo "๐Ÿ“š For more information:" echo " https://git.maiwald.work/Nexus/NexusToolKit" EOF chmod +x "$RELEASE_DIR/install.sh" # Create uninstall script cat > "$RELEASE_DIR/uninstall.sh" << 'EOF' #!/bin/bash # NIP Uninstallation Script set -e echo "๐Ÿ—‘๏ธ Uninstalling NIP" echo "======================" echo "" # Check if running as root if [ "$EUID" -ne 0 ]; then echo "โš ๏ธ This uninstaller requires root privileges" echo " Please run: sudo ./uninstall.sh" exit 1 fi # Remove binary echo "๐Ÿ“ฆ Removing NIP binary..." rm -f /usr/local/bin/nip echo " Removed: /usr/local/bin/nip" echo "" # Ask about data removal echo "โ“ Remove NIP data directories? [y/N]" read -r response if [[ "$response" =~ ^[Yy]$ ]]; then echo "๐Ÿ—‘๏ธ Removing data directories..." rm -rf /Programs rm -rf /System/Links rm -rf /var/nip rm -rf /etc/nip rm -f /etc/profile.d/nip.sh rm -f /etc/ld.so.conf.d/nip.conf echo " Removed all NIP data" else echo " Kept NIP data directories" fi echo "" echo "โœ… NIP uninstallation complete!" EOF chmod +x "$RELEASE_DIR/uninstall.sh" # Create tarball echo "๐Ÿ“ฆ Creating release tarball..." tar -czf "$RELEASE_DIR.tar.gz" "$RELEASE_DIR" echo " Created: $RELEASE_DIR.tar.gz" echo "" echo "๐ŸŽ‰ Release build complete!" echo "" echo "๐Ÿ“‹ Release artifacts:" echo " Binary: nip_release" echo " Package: $RELEASE_DIR/" echo " Tarball: $RELEASE_DIR.tar.gz" echo "" echo "๐Ÿš€ Ready for distribution!"