package-enhanced-chunking-beta.sh
1 #!/bin/bash 2 3 # Script to package the Enhanced Adaptive Chunking Beta 4 # This script will: 5 # 1. Create a standalone binary for the Enhanced Adaptive Chunking Beta 6 # 2. Package the binary and documentation into a distributable package 7 # 3. Create installation scripts for different platforms 8 # 9 # Note: This is a small homebuild project with limited distribution 10 # for beta testing primarily by the development team and a small 11 # group of friends. 12 13 set -e 14 15 echo "Enhanced Adaptive Chunking Beta Packager" 16 echo "========================================" 17 18 # Create package directory 19 PACKAGE_DIR="packages/enhanced-chunking-beta-$(date +%Y%m%d)" 20 mkdir -p "$PACKAGE_DIR" 21 mkdir -p "$PACKAGE_DIR/bin" 22 mkdir -p "$PACKAGE_DIR/docs" 23 mkdir -p "$PACKAGE_DIR/scripts" 24 25 # Build the binary 26 echo "Building binary..." 27 go build -o "$PACKAGE_DIR/bin/enhanced-chunking-beta" cmd/keepsync-cli/simplified-chunking-demo/main.go 28 echo " ✓ Binary built successfully" 29 30 # Copy documentation 31 echo "Copying documentation..." 32 cp docs/enhanced-adaptive-chunking-guide.md "$PACKAGE_DIR/docs/" 33 cp docs/enhanced-chunking-implementation-report.md "$PACKAGE_DIR/docs/" 34 echo " ✓ Documentation copied successfully" 35 36 # Create README 37 echo "Creating README..." 38 cat > "$PACKAGE_DIR/README.md" << 'EOF' 39 # Enhanced Adaptive Chunking Beta 40 41 This package contains the beta version of the Enhanced Adaptive Chunking System for KeepSync. 42 43 ## Features 44 45 - **Adaptive Chunk Sizing**: Automatically adjusts chunk sizes based on file characteristics 46 - **Buffer Pooling**: Reuses memory buffers to reduce memory allocation overhead 47 - **Comprehensive Metrics**: Collects detailed performance metrics for analysis 48 - **High Performance**: Achieves throughput of 600+ MB/s on typical hardware 49 50 ## Installation 51 52 ### Linux/macOS 53 54 ```bash 55 ./scripts/install.sh 56 ``` 57 58 ### Windows 59 60 ```batch 61 scripts\install.bat 62 ``` 63 64 ## Usage 65 66 ```bash 67 enhanced-chunking-beta --mode chunk --input <input-file> --output <output-file> [--verbose] 68 ``` 69 70 ### Modes 71 72 - **chunk**: Chunk a file into multiple chunks 73 - **benchmark**: Run benchmarks with various file sizes 74 - **test**: Test different configuration options 75 76 ### Examples 77 78 ```bash 79 # Chunk a file 80 enhanced-chunking-beta --mode chunk --input large-file.dat --output chunked-file.dat --verbose 81 82 # Run benchmarks 83 enhanced-chunking-beta --mode benchmark --test-file-size 50 --benchmark-iterations 5 84 85 # Test different options 86 enhanced-chunking-beta --mode test 87 ``` 88 89 ## Documentation 90 91 For more detailed information, please refer to the documentation in the `docs` directory: 92 93 - [Enhanced Adaptive Chunking Guide](docs/enhanced-adaptive-chunking-guide.md) 94 - [Implementation Report](docs/enhanced-chunking-implementation-report.md) 95 96 ## Feedback 97 98 This is a beta version of the Enhanced Adaptive Chunking System. Your feedback is valuable to us. Please report any issues or suggestions to the KeepSync team. 99 EOF 100 echo " ✓ README created successfully" 101 102 # Create installation script for Linux/macOS 103 echo "Creating installation script for Linux/macOS..." 104 cat > "$PACKAGE_DIR/scripts/install.sh" << 'EOF' 105 #!/bin/bash 106 107 # Installation script for Enhanced Adaptive Chunking Beta 108 # This script will install the Enhanced Adaptive Chunking Beta to the specified directory 109 110 set -e 111 112 # Default installation directory 113 INSTALL_DIR="$HOME/.local/bin" 114 115 # Parse command-line arguments 116 while [[ $# -gt 0 ]]; do 117 key="$1" 118 case $key in 119 --install-dir) 120 INSTALL_DIR="$2" 121 shift 122 shift 123 ;; 124 *) 125 echo "Unknown option: $key" 126 exit 1 127 ;; 128 esac 129 done 130 131 # Create installation directory if it doesn't exist 132 mkdir -p "$INSTALL_DIR" 133 134 # Copy binary to installation directory 135 echo "Installing Enhanced Adaptive Chunking Beta to $INSTALL_DIR..." 136 cp bin/enhanced-chunking-beta "$INSTALL_DIR/" 137 chmod +x "$INSTALL_DIR/enhanced-chunking-beta" 138 139 # Check if installation directory is in PATH 140 if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then 141 echo "Warning: Installation directory is not in PATH" 142 echo "Add the following line to your shell profile:" 143 echo " export PATH=\"\$PATH:$INSTALL_DIR\"" 144 fi 145 146 echo "Installation completed successfully!" 147 echo "You can now run the Enhanced Adaptive Chunking Beta using the command:" 148 echo " enhanced-chunking-beta" 149 EOF 150 chmod +x "$PACKAGE_DIR/scripts/install.sh" 151 echo " ✓ Installation script for Linux/macOS created successfully" 152 153 # Create installation script for Windows 154 echo "Creating installation script for Windows..." 155 cat > "$PACKAGE_DIR/scripts/install.bat" << 'EOF' 156 @echo off 157 REM Installation script for Enhanced Adaptive Chunking Beta 158 REM This script will install the Enhanced Adaptive Chunking Beta to the specified directory 159 160 REM Default installation directory 161 set INSTALL_DIR=%USERPROFILE%\bin 162 163 REM Parse command-line arguments 164 :parse_args 165 if "%~1"=="" goto :done_args 166 if "%~1"=="--install-dir" ( 167 set INSTALL_DIR=%~2 168 shift 169 shift 170 goto :parse_args 171 ) 172 echo Unknown option: %~1 173 exit /b 1 174 :done_args 175 176 REM Create installation directory if it doesn't exist 177 if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%" 178 179 REM Copy binary to installation directory 180 echo Installing Enhanced Adaptive Chunking Beta to %INSTALL_DIR%... 181 copy bin\enhanced-chunking-beta.exe "%INSTALL_DIR%\" 182 183 REM Check if installation directory is in PATH 184 set PATH_FOUND=0 185 for %%i in ("%PATH:;=" "%") do ( 186 if /i "%%~i"=="%INSTALL_DIR%" set PATH_FOUND=1 187 ) 188 if %PATH_FOUND%==0 ( 189 echo Warning: Installation directory is not in PATH 190 echo Add the following directory to your PATH: 191 echo %INSTALL_DIR% 192 ) 193 194 echo Installation completed successfully! 195 echo You can now run the Enhanced Adaptive Chunking Beta using the command: 196 echo enhanced-chunking-beta 197 EOF 198 echo " ✓ Installation script for Windows created successfully" 199 200 # Create package archive 201 echo "Creating package archive..." 202 tar -czf "$PACKAGE_DIR.tar.gz" -C "$(dirname "$PACKAGE_DIR")" "$(basename "$PACKAGE_DIR")" 203 echo " ✓ Package archive created successfully" 204 205 echo "Package created successfully!" 206 echo "Package is available at: $PACKAGE_DIR.tar.gz"