-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
10,370 additions
and
399 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
#!/bin/bash | ||
# | ||
# Linux Build Script for HathiTrust Package Automation | ||
# | ||
# Creates a standalone executable using PyInstaller that can be distributed | ||
# to Linux users without requiring Python installation. | ||
# | ||
# Usage: | ||
# bash build_scripts/build_linux.sh | ||
# | ||
# Requirements: | ||
# - PyInstaller 6.0+ | ||
# - All application dependencies installed | ||
|
||
set -e # Exit on error | ||
|
||
# Colors for output | ||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
YELLOW='\033[1;33m' | ||
BLUE='\033[0;34m' | ||
NC='\033[0m' # No Color | ||
|
||
# Helper functions | ||
print_header() { | ||
echo "" | ||
echo "======================================================================" | ||
echo " $1" | ||
echo "======================================================================" | ||
echo "" | ||
} | ||
|
||
print_step() { | ||
echo -e "${BLUE}→${NC} $1" | ||
} | ||
|
||
print_success() { | ||
echo -e "${GREEN}✓${NC} $1" | ||
} | ||
|
||
print_error() { | ||
echo -e "${RED}✗${NC} $1" | ||
} | ||
|
||
print_warning() { | ||
echo -e "${YELLOW}⚠${NC} $1" | ||
} | ||
|
||
# Record start time | ||
START_TIME=$(date +%s) | ||
|
||
print_header "HathiTrust Automation - Linux Build Script" | ||
|
||
# Get project root (script is in build_scripts/) | ||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" | ||
|
||
print_step "Project root: $PROJECT_ROOT" | ||
|
||
# Check for PyInstaller | ||
print_step "Checking for PyInstaller..." | ||
|
||
# Try venv first, then system | ||
if [ -f "$PROJECT_ROOT/bin/pyinstaller" ]; then | ||
PYINSTALLER="$PROJECT_ROOT/bin/pyinstaller" | ||
PYINSTALLER_VERSION=$($PYINSTALLER --version) | ||
print_success "PyInstaller found in venv: version $PYINSTALLER_VERSION" | ||
elif command -v pyinstaller &> /dev/null; then | ||
PYINSTALLER="pyinstaller" | ||
PYINSTALLER_VERSION=$(pyinstaller --version) | ||
print_success "PyInstaller found in PATH: version $PYINSTALLER_VERSION" | ||
else | ||
print_error "PyInstaller not found!" | ||
echo "" | ||
echo "Install PyInstaller with:" | ||
echo " pip install pyinstaller" | ||
echo "" | ||
echo "Or install build requirements:" | ||
echo " pip install -r build_scripts/requirements_build.txt" | ||
exit 1 | ||
fi | ||
|
||
# Check for spec file | ||
SPEC_FILE="$PROJECT_ROOT/deployment/pyinstaller/hathitrust.spec" | ||
print_step "Checking spec file..." | ||
|
||
if [ ! -f "$SPEC_FILE" ]; then | ||
print_error "Spec file not found: $SPEC_FILE" | ||
exit 1 | ||
fi | ||
|
||
print_success "Spec file found: $(basename $SPEC_FILE)" | ||
|
||
# Clean previous build | ||
DIST_DIR="$PROJECT_ROOT/dist" | ||
BUILD_DIR="$PROJECT_ROOT/build" | ||
|
||
print_step "Cleaning previous build..." | ||
|
||
if [ -d "$DIST_DIR" ]; then | ||
echo " Removing: $DIST_DIR" | ||
rm -rf "$DIST_DIR" | ||
fi | ||
|
||
if [ -d "$BUILD_DIR" ]; then | ||
echo " Removing: $BUILD_DIR" | ||
rm -rf "$BUILD_DIR" | ||
fi | ||
|
||
print_success "Previous build cleaned" | ||
|
||
# Run PyInstaller | ||
print_header "Building Executable" | ||
echo "This may take 5-10 minutes..." | ||
echo "Progress will be shown below:" | ||
echo "" | ||
|
||
cd "$PROJECT_ROOT" | ||
$PYINSTALLER --clean --noconfirm "$SPEC_FILE" | ||
|
||
BUILD_EXIT_CODE=$? | ||
|
||
if [ $BUILD_EXIT_CODE -ne 0 ]; then | ||
print_error "Build failed with exit code $BUILD_EXIT_CODE" | ||
exit $BUILD_EXIT_CODE | ||
fi | ||
|
||
# Verify build output | ||
print_header "Build Complete - Verifying Output" | ||
|
||
EXE_DIR="$DIST_DIR/HathiTrust-Automation" | ||
if [ ! -d "$EXE_DIR" ]; then | ||
print_error "Distribution directory not found: $EXE_DIR" | ||
exit 1 | ||
fi | ||
|
||
print_success "Distribution directory: $EXE_DIR" | ||
|
||
# Check for executable | ||
EXE_FILE="$EXE_DIR/HathiTrust-Automation" | ||
if [ ! -f "$EXE_FILE" ]; then | ||
print_error "Executable not found: $EXE_FILE" | ||
exit 1 | ||
fi | ||
|
||
# Make executable | ||
chmod +x "$EXE_FILE" | ||
|
||
# Calculate statistics | ||
EXE_SIZE_MB=$(du -sm "$EXE_FILE" | cut -f1) | ||
TOTAL_SIZE_MB=$(du -sm "$EXE_DIR" | cut -f1) | ||
FILE_COUNT=$(find "$EXE_DIR" -type f | wc -l) | ||
|
||
END_TIME=$(date +%s) | ||
ELAPSED=$((END_TIME - START_TIME)) | ||
MINUTES=$((ELAPSED / 60)) | ||
SECONDS=$((ELAPSED % 60)) | ||
|
||
# Print results | ||
print_header "Build Statistics" | ||
echo " Executable: $(basename $EXE_FILE)" | ||
echo " Executable Size: ${EXE_SIZE_MB} MB" | ||
echo " Total Size: ${TOTAL_SIZE_MB} MB" | ||
echo " File Count: ${FILE_COUNT} files" | ||
echo " Build Time: ${MINUTES}m ${SECONDS}s" | ||
echo "" | ||
|
||
# Verify critical files | ||
print_step "Verifying bundled files..." | ||
|
||
CRITICAL_FILES=( | ||
"templates/phase_one.json" | ||
"templates/epson_scanner.json" | ||
"templates/default.json" | ||
"gui/resources/styles.qss" | ||
) | ||
|
||
ALL_PRESENT=true | ||
for REL_PATH in "${CRITICAL_FILES[@]}"; do | ||
FULL_PATH="$EXE_DIR/$REL_PATH" | ||
if [ -f "$FULL_PATH" ]; then | ||
print_success "$REL_PATH" | ||
else | ||
print_warning "$REL_PATH - NOT FOUND" | ||
ALL_PRESENT=false | ||
fi | ||
done | ||
|
||
if [ "$ALL_PRESENT" = false ]; then | ||
echo "" | ||
print_warning "Some data files are missing - application may not work correctly" | ||
fi | ||
|
||
# Success message | ||
print_header "✓ BUILD SUCCESSFUL!" | ||
echo " Executable Location: $EXE_FILE" | ||
echo " Distribution Folder: $EXE_DIR" | ||
echo "" | ||
echo "Next Steps:" | ||
echo " 1. Test the executable on this machine" | ||
echo " 2. Test on a clean Linux VM (no Python installed)" | ||
echo " 3. Verify all features work correctly" | ||
echo "" | ||
echo "To run the executable:" | ||
echo " cd $EXE_DIR" | ||
echo " ./HathiTrust-Automation" | ||
echo "======================================================================" | ||
|
||
exit 0 |
Oops, something went wrong.