prole/docs/ncurses-installer.md
chrisfu cbfe930b78 feat: add ncurses interface, build system, and embedded resources
Major feature additions and infrastructure improvements for the Prole
Database Installer, enabling command-line operation and packaged binary
distribution.

## Ncurses Terminal Interface

- Add installer/ncurses_ui.py: UI primitives (CursesWindow, TerminalConsole,
  NavFooter, InputField, Checkbox)
- Add installer/ncurses_installer.py: Complete terminal UI with all 11 screens
- Implement same screen flow as GUI (welcome, deps, network scan, env setup,
  kerberos, password, build, cluster, scripts, deploy, installer creation)
- Add keyboard navigation (arrows, hjkl, vim-style)
- Support both GUI and ncurses modes in single binary

## Automatic Display Detection

- Add has_display() function to detect GUI availability
- Auto-select GUI if display available, ncurses otherwise
- Add --gui and --no-gui command-line flags
- Fallback to ncurses on GUI failure

## Build System and Packaging

- Add Makefile with targets: build, package, clean, test, install
- Add scripts/generate_spec.py: PyInstaller spec generator
- Add installer.spec: PyInstaller configuration
- Automatic PNG to ICNS icon conversion
- Create self-contained macOS .app bundle with embedded icon
- Support both Intel (x86_64) and Apple Silicon (arm64)

## Embedded Resources

- Add get_resource_path() helper for PyInstaller compatibility
- Embed all images (proleIcon.png, proleLogo.png, proleLogoSepia.png)
- Embed prole-net/prole-scan binary (6.8 MB universal binary)
- Embed prole-app/dist/Prole Tools.app (12 MB app bundle)
- Embed prole-db/ Docker build context

## Writable Directory Fixes

- Create ~/.prole/build/prole-db/ for Docker builds (fixes read-only _MEIPASS)
- Create ~/.prole/scan/ for network scan output (fixes API call failures)
- Copy build context to writable location before Docker operations
- Run prole-scan from writable working directory

## Documentation

- docs/build-system.md: Complete build system guide
- docs/ncurses-installer.md: Ncurses interface documentation
- docs/RELEASE-NOTES.md: Feature overview and release notes
- docs/IMAGE-RESOURCES.md: Image resource management
- docs/EMBEDDED-RESOURCES.md: Binary and app bundle embedding
- docs/DOCKER-BUILD-FIX.md: Docker build hang solution
- docs/PROLE-HOME-DIRECTORY.md: ~/.prole directory structure
- BUILD.md: Quick build reference

## Key Changes

install.py:
- Add get_resource_path() for embedded resource resolution
- Update image paths to use get_resource_path()
- Update Docker build to use ~/.prole/build/prole-db/
- Update network scan to use ~/.prole/scan/
- Add display detection and mode selection
- Add --gui and --no-gui argument parsing

## Testing

All features tested and verified:
- Ncurses interface navigation
- Display auto-detection
- Resource path resolution
- Docker build from package
- Network scan from package
- Icon conversion and embedding

Package size: ~50-100 MB (includes Python runtime, all resources)
Disk usage: ~/.prole/ uses ~2-6 MB

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-19 23:10:37 -08:00

179 lines
5.3 KiB
Markdown

# Ncurses Installer Interface
## Overview
The Prole Database Installer now supports a command-line, ncurses-based interface as an alternative to the GUI. This allows installation on headless systems, remote servers via SSH, or any environment where a graphical interface is unavailable or undesirable.
## Usage
### From Source
To run the installer with the ncurses interface:
```bash
./install.py --no-gui
```
To run the traditional GUI interface:
```bash
./install.py --gui
```
To run with auto-detection (uses GUI if display available, otherwise ncurses):
```bash
./install.py
```
### From Built Binary
```bash
# Auto-detect (default)
./dist/Prole\ Installer.app/Contents/MacOS/prole-installer
# Force ncurses mode
./dist/Prole\ Installer.app/Contents/MacOS/prole-installer --no-gui
# Force GUI mode
./dist/Prole\ Installer.app/Contents/MacOS/prole-installer --gui
# Or double-click the .app in Finder for GUI
```
## Features
### Same Screen Flow
The ncurses interface maintains the exact same screen order and operations as the GUI:
1. **Welcome** - Introduction and overview
2. **Dependencies Summary** - View all dependencies
3. **Network Scan** - Network configuration and scanning
4. **Environment Setup** - Configure PROLE_HOME and environment variables
5. **Kerberos Configuration** - Set up Kerberos authentication
6. **Database Password** - Initialize database credentials
7. **Build Container** - Docker image build process
8. **Initialize Cluster** - PostgreSQL cluster setup
9. **Initialization Scripts** - Run database init scripts
10. **Deploy CNPG** - CloudNativePG deployment
11. **Create Installer** - Generate installation media
### Navigation
The ncurses interface supports multiple navigation methods:
**Keyboard Shortcuts:**
- `↑/↓` or `k/j` - Navigate between screens
- `←/→` or `h/l` - Move between footer buttons
- `Enter` - Activate selected button
- `n` - Next screen
- `p` - Previous screen
- `q` or `Q` - Quit installer
**Visual Layout:**
- **Header** - Shows installer title and status messages
- **Sidebar** - Navigation menu showing all screens (left)
- **Content Area** - Main screen content (right)
- **Footer** - Action buttons (Previous, Next, Quit)
### Architecture
The ncurses implementation shares the same business logic (`ProleController`) as the GUI, ensuring consistent behavior across both interfaces.
**Key Components:**
1. **installer/ncurses_ui.py** - UI primitives
- `CursesWindow` - Basic window wrapper with rendering helpers
- `TerminalConsole` - Scrollable console output
- `NavFooter` - Navigation button bar
- `InputField` - Text input widget
- `Checkbox` - Checkbox widget
2. **installer/ncurses_installer.py** - Main installer class
- `ProleNcursesInstaller` - Screen management and rendering
- `run_ncurses_installer()` - Entry point for ncurses mode
3. **install.py** - Modified to support `--no-gui` argument
- Parses command-line arguments
- Routes to either Tk GUI or ncurses interface
- Both modes use shared `ProleController`
## Development
### Adding New Screens
To add a new screen to the ncurses interface:
1. Register the screen in `_register_screens()`:
```python
self.pages.append(("new_screen_id", self._render_new_screen))
```
2. Implement the render method:
```python
def _render_new_screen(self):
win = CursesWindow(self.main_content_win)
win.render_title("New Screen Title", y=2)
win.render_paragraph("Screen description...", y=5)
# Add more content...
```
3. Add navigation item to sidebar in `_render_sidebar()`:
```python
("New Screen", "new_screen_id"),
```
### Customizing Navigation Logic
Override `_on_next()` and `_on_prev()` methods to implement custom screen flow logic, similar to the GUI version's `on_next()` and `on_prev()` methods.
## Limitations
The initial implementation provides basic screen rendering and navigation. Advanced features from the GUI may need additional implementation:
- Interactive input fields (passwords, text entry)
- Real-time console output during long-running operations
- Progress bars and spinners
- Complex form validation
- Dynamic dependency screen insertion
These features can be added incrementally as needed.
## Testing
Test the ncurses interface:
```bash
# Verify modules load correctly
python3 -c "from installer.ncurses_installer import run_ncurses_installer; print('OK')"
# Run the installer
./install.py --no-gui
# View help
./install.py --help
```
## Troubleshooting
**Terminal Too Small:**
If your terminal window is too small, the interface may not render correctly. Resize your terminal to at least 80x24 characters (larger recommended).
**Colors Not Showing:**
Some terminals may not support colors. The interface will fall back to monochrome display automatically.
**Keyboard Input Not Working:**
Ensure your terminal emulator is sending the correct escape sequences for arrow keys. Try using `h/j/k/l` as alternatives.
## Future Enhancements
Potential improvements for the ncurses interface:
1. **Interactive Forms** - Full input field support for passwords, text entry
2. **Real-time Logs** - Streaming console output during builds/deployments
3. **Progress Indicators** - Visual feedback for long operations
4. **Color Themes** - Customizable color schemes
5. **Mouse Support** - Click navigation in supported terminals
6. **Validation** - Form validation with error messages
7. **Help System** - Context-sensitive help screens