Sari la conținut

Agnostic OS Installer - Usage Guide

Overview

The Agnostic OS Installer enables declarative software installation across Windows, Linux, and macOS using YAML/TOML configuration files. The installer is distributed as a single executable file that runs on any supported platform without external dependencies.

Quick Start

Download and Run

# Download the installer for your platform
# Linux: agnostic-installer-linux
# Windows: agnostic-installer-windows.exe
# macOS: agnostic-installer-macos

# Make executable (Linux/macOS)
chmod +x agnostic-installer-linux

# Run installer with configuration
./agnostic-installer-linux install myapp.yml

Basic Installation Flow

  1. Get the installer: Download the appropriate executable for your platform
  2. Create configuration: Write a YAML/TOML manifest file
  3. Validate: Check configuration for errors
  4. Install: Run the installer with your configuration
  5. Verify: Check that installation succeeded

CLI Commands

Core Commands

# Install a package
agnostic-installer install <config-file> [options]

# Uninstall a package
agnostic-installer uninstall <package-name> [options]

# Validate configuration file
agnostic-installer validate <config-file>

# List installed packages
agnostic-installer list

# Show package status
agnostic-installer status <package-name>

Command Options

Global Options

  • --help, -h: Show help information
  • --version, -v: Show version information
  • --verbose, -V: Enable verbose logging
  • --quiet, -q: Suppress output except errors
  • --log-file FILE: Write logs to file

Install Command Options

  • --dry-run: Simulate installation without making changes
  • --force: Force installation, override conflicts
  • --skip-dependencies: Skip automatic dependency installation
  • --platform PLATFORM: Override auto-detected platform (linux/windows/macos)
  • --working-dir DIR: Set working directory for relative paths
  • --config-override KEY=VALUE: Override configuration values

Uninstall Command Options

  • --purge: Remove all package data and configuration
  • --force: Force uninstallation, ignore dependencies
  • --keep-data: Preserve data files during uninstall

Configuration Files

Basic Package Configuration

# myapp.yml
package:
  name: "myapp"
  version: "1.0.0"
  description: "My cross-platform application"

files:
  - src: "bin/myapp"
    dest: "/usr/local/bin/myapp"
    permissions: "755"

  - src: "config/app.conf"
    dest: "/etc/myapp/config.conf"
    permissions: "644"

environment:
  MYAPP_HOME: "/usr/local/lib/myapp"
  PATH: "${PATH}:/usr/local/bin"

Advanced Configuration with Services

# complex-app.yml
package:
  name: "complex-app"
  version: "2.1.0"
  description: "Complex application with services and dependencies"

dependencies:
  - "database>=1.0.0"
  - "web-server"

platforms:
  linux:
    prerequisites:
      - "curl"
      - "unzip"
  windows:
    prerequisites:
      - "powershell"
      - "nssm"  # Non-Sucking Service Manager

files:
  - src: "bin/app.exe"
    dest: "C:/Program Files/MyApp/app.exe"
    platform: "windows"
  - src: "bin/app"
    dest: "/opt/myapp/bin/app"
    permissions: "755"
    platform: "linux"

services:
  - name: "myapp-service"
    exec: "/opt/myapp/bin/app --daemon"
    start: "auto"
    user: "myapp-user"
    platform_overrides:
      linux:
        type: "systemd"
        after: "network.target"
      windows:
        type: "winservice"
        display_name: "My Application Service"
        description: "MyApp background service"

shortcuts:
  - name: "My Application"
    target: "C:/Program Files/MyApp/app.exe"
    icon: "icon.ico"
    platform: "windows"
    desktop: true
    start_menu: true

registry:
  - path: "HKLM\\SOFTWARE\\MyApp"
    values:
      InstallPath: "C:/Program Files/MyApp"
      Version: "2.1.0"
    platform: "windows"

Configuration Schema Reference

Package Section

package:
  name: string (required)        # Package identifier
  version: string (required)     # Semver version string
  description: string (required) # Human-readable description
  maintainer: string             # Package maintainer
  homepage: string               # Project homepage URL

Dependencies Section

dependencies:
  - "package-name>=1.0.0"
  - "other-package@^2.0.0"
  - "local-package"  # From local repository

Files Section

files:
  - src: "relative/path/to/source"
    dest: "/absolute/destination/path"
    permissions: "755"           # Octal permissions (Linux/macOS)
    owner: "user:group"          # Ownership (Linux/macOS)
    backup: true                 # Create backup of existing file
    template: true               # Process as template
    platform: "linux|windows|macos"  # Platform-specific

Services Section

services:
  - name: "service-name"
    exec: "/path/to/executable --args"
    start: "auto|manual|disabled"
    user: "username"             # Service user
    group: "groupname"           # Service group
    description: "Service description"
    dependencies: ["other-service"]
    restart: "always|on-failure|no"
    platform_overrides:
      linux:
        type: "systemd"
        after: "network.target"
      windows:
        type: "winservice"
        display_name: "Display Name"

Environment Section

environment:
  VARIABLE_NAME: "value"
  PATH: "${PATH}:/new/path"     # Variable expansion
  HOME_DIR: "${HOME}/myapp"     # Environment variable references

Registry Section (Windows only)

registry:
  - path: "HKLM\\SOFTWARE\\Company\\App"
    values:
      InstallPath: "C:/Program Files/App"
      Version: "1.0.0"
    type: "string|dword|qword|binary|multi-string"

Platform-Specific Usage

Linux Installation

# Install with systemd service
./agnostic-installer-linux install myapp.yml --verbose

# Check service status after installation
sudo systemctl status myapp-service

# View service logs
sudo journalctl -u myapp-service -f

Windows Installation

# Run as Administrator
.\agnostic-installer-windows.exe install myapp.yml --verbose

# Check service status
Get-Service -Name "myapp-service"

# View Windows Event Logs
Get-EventLog -LogName "Application" -Source "MyApp" -Newest 10

macOS Installation (Future)

# Install with launchctl service
./agnostic-installer-macos install myapp.yml --verbose

# Check service status
launchctl list | grep myapp

Advanced Usage

Template Processing

Configuration files support variable substitution:

files:
  - src: "config.template"
    dest: "/etc/myapp/config.conf"
    template: true
    vars:
      INSTALL_PATH: "${MYAPP_HOME}"
      USER_NAME: "${USER}"

environment:
  MYAPP_HOME: "/opt/myapp"
  CONFIG_FILE: "/etc/myapp/config.conf"

Template variables are expanded using: - ${VARIABLE} for environment variables - ${VAR_NAME} for user-defined variables - Platform-specific path expansion - Cross-platform path variables (see below)

Cross-Platform Path Variables

The installer provides standardized variables that automatically resolve to appropriate paths on each platform:

Variabile Cross-Platform Disponibile

Variabilă Windows Linux macOS
${PROGRAM_FILES} C:/Program Files/ /usr/local/ /Applications/
${PROGRAM_FILES_X86} C:/Program Files (x86)/ /usr/local/ /Applications/
${OPT} C:/Program Files/ /opt/ /opt/
${BIN} C:/Program Files/ /usr/local/bin/ /usr/local/bin/
${CONFIG} HKLM\SOFTWARE\ (Registry) /etc/ ~/Library/Preferences/
${DATA} %APPDATA% (Roaming) /var/lib/ ~/Library/Application Support/
${LOG} %LOCALAPPDATA% /var/log/ ~/Library/Logs/
${TEMP} %TEMP% /tmp/ /tmp/
${USER_HOME} C:/Users/username/ /home/username/ /Users/username/

Usage Examples

# Cross-platform installation paths
files:
  - src: "bin/myapp.exe"
    dest: "${PROGRAM_FILES}/MyApp/myapp.exe"
    platform: "windows"
  - src: "bin/myapp"
    dest: "${OPT}/myapp/bin/myapp"
    permissions: "755"
    platform: "linux"

environment:
  MYAPP_HOME: "${OPT}/myapp"
  MYAPP_DATA: "${DATA}/myapp"
  MYAPP_CONFIG: "${CONFIG}/myapp"

services:
  - name: "myapp-service"
    platform_overrides:
      linux:
        exec: "${OPT}/myapp/bin/myapp --daemon"
      windows:
        exec: "${PROGRAM_FILES}/MyApp/myapp.exe --service"

This approach ensures configurations work identically across all supported platforms without hardcoding OS-specific paths.

Platform-Specific Overrides (Optional)

All configuration sections support platform_overrides for when you need OS-specific behavior:

Optional Platform Overrides

# services cu exec comun + override-uri optionale doar când e necesar
services:
  - name: "myapp-service"
    exec: "${OPT}/myapp/bin/app --daemon"  # Funcționează pe TOATE OS-urile
    start: "auto"
    user: "myapp-user"

    # platform_overrides - OPTIONALE! Folosește doar când ai nevoie de diferențe
    platform_overrides:
      windows:
        exec: "${PROGRAM_FILES}/MyApp/app.exe --windows-service"  # Doar când trebuie să fie DIFERIT
        display_name: "My Application"
      linux:
        after: "network.target"  # Detalii specifice Linux

# shortcuts - per platformă în lista separată
shortcuts:
  - platform: "windows"  # Explicit platform-specific
    name: "My Application"
    target: "${PROGRAM_FILES}/MyApp/app.exe"
  - platform: "linux"
    name: "My Application"
    target: "${OPT}/myapp/bin/app"
    desktop: true

# registry - apare doar pentru platforme care îl suportă
# Opțional - apare doar când e definit pentru platforma respectivă

Când să folosești platform_overrides?

✅ Folosește platform_overrides când: - Executabilul trebuie să fie radical diferit per OS - Parametrii de comandă sunt foarte diferiți per OS - Ai nevoie de setări specifice OS-ului (ex: registry entries) - Logica variază fundamental între OS-uri

❌ NU folosi platform_overrides când: - Executabilul rulează identic pe toate OS-urile (folosește variabile agnostice) - Parametrii sunt aceiași sau asemănători per OS - Poți abstractiza cu ${VARIABLE} standarde

Configurații Portabile Maxime

# EXEMPLE ideale - NU folosesc platform_overrides deloc!
package:
  name: "cross-platform-app"
  version: "1.0.0"

dependencies:
  - "python_3.9"

files:
  - src: "bin/app.py"
    dest: "${OPT}/app/bin/app.py"
    permissions: "755"  # Funcționează pe Unix/Windows

services:
  - name: "app-service"
    exec: "${OPT}/app/bin/app.py --daemon"
    start: "auto"

environment:
  APP_HOME: "${OPT}/app"
  APP_DATA: "${DATA}/app"
  APP_CONFIG: "${CONFIG}/app"

# Rezultat: Aceeași configurație rulează identic pe Linux/Windows/macOS!

Custom Package Repositories

repositories:
  - name: "private-repo"
    url: "https://repo.company.com/packages"
    auth:
      type: "basic"
      username: "${REPO_USER}"
      password: "${<PASSWORD>}"

dependencies:
  - "company-package@private-repo>=1.0.0"

Pre/Post Install Hooks

hooks:
  pre_install:
    - command: "systemctl stop conflicting-service"
      platform: "linux"
  post_install:
    - command: "myapp --init-db"
      cwd: "/opt/myapp"
  pre_uninstall:
    - command: "myapp --cleanup"

Troubleshooting

Common Issues

Installation Fails with Permission Errors

  • Linux/macOS: Run with sudo
  • Windows: Run as Administrator
  • Solution: Check file permissions and ownership in configuration

Configuration Validation Errors

# Validate configuration before installation
agnostic-installer validate myapp.yml

# Get detailed schema information
agnostic-installer validate --schema myapp.yml

Service Installation Fails

  • Linux: Ensure systemd is available and user has permissions
  • Windows: Ensure pywin32 dependencies are met
  • Check: Use --dry-run to see what would be installed

Dependency Resolution Issues

# Check dependency status
agnostic-installer status --dependencies myapp

# Install dependencies separately
agnostic-installer install --only-dependencies myapp.yml

Debug Mode

Enable detailed logging for troubleshooting:

# Verbose installation with log file
agnostic-installer install myapp.yml \
  --verbose \
  --log-file install.log \
  --debug

# View detailed logs
cat install.log

Recovery and Rollback

# Rollback failed installation
agnostic-installer rollback myapp

# Force reinstall
agnostic-installer install myapp.yml --force --clean

# Emergency uninstall
agnostic-installer uninstall myapp --purge --force

Configuration Examples

Configuration Approaches: Hardcoded vs Agnostic

❌ BAD EXAMPLE: Configuration with hardcoded paths (problematic)

# This configuration has problems - not cross-platform!
package:
  name: "myapp"
  version: "1.0.0"
  description: "My cross-platform application"

# Dependencies - din registry.yml
dependencies:
  - python_3.9

# Platform-specific prerequisites
platforms:
  linux:
    prerequisites:
      - "curl"
      - "unzip"
  windows:
    prerequisites:
      - "powershell"

# FILES: PROBLEMĂ - căile sunt hardcodate, nu agnostic ❌
files:
  - src: "bin/app.exe"
    dest: "C:/Program Files/MyApp/app.exe"  # Windows hardcoded
    platform: "windows"
  - src: "bin/app"
    dest: "/opt/myapp/bin/app"  # Linux hardcoded
    permissions: "755"
    platform: "linux"

# SERVICES: PROBLEMĂ - exec nu e clar cum să fie per OS ❌
services:
  - name: "myapp-service"
    platform_overrides:
      linux:
        exec: "/opt/myapp/bin/app --daemon"  # Linux hardcoded
        type: "systemd"
      windows:
        exec: "C:/Program Files/MyApp/app.exe --service"  # Windows hardcoded
        type: "winservice"

# ENVIRONMENT: PROBLEMĂ - variabile hardcodate ❌
environment:
  MYAPP_HOME: "/opt/myapp"  # Linux hardcoded
  PATH: "${PATH}:/opt/myapp/bin"  # Linux hardcoded

# SHORTCUTS: PROBLEMĂ - specific unui OS ❌
shortcuts:
  - name: "My Application"
    target: "C:/Program Files/MyApp/app.exe"  # Windows hardcoded
    platform: "windows"
    desktop: true
    start_menu: true

# REGISTRY: PROBLEMĂ - apare fără platform specific, e Windows-only ❌
registry:
  - path: "HKLM\\SOFTWARE\\MyApp"
    values:
      InstallPath: "C:/Program Files/MyApp"
      Version: "1.0.0"
    platform: "windows"

✅ GOOD EXAMPLE: Agnostic configuration with variables

# This configuration works everywhere with no platform-specific code!
package:
  name: "myapp"
  version: "1.0.0"
  description: "My cross-platform application"

# Dependencies - din registry.yml
dependencies:
  - python_3.9

# Platform-specific prerequisites
platforms:
  linux:
    prerequisites:
      - "curl"
      - "unzip"
  windows:
    prerequisites:
      - "powershell"

# FILES: Agnostic paths using variables ✅
files:
  - src: "bin/app.exe"
    dest: "${PROGRAM_FILES}/MyApp/app.exe"  # Se înlocuiește cu C:/Program Files/ pe Windows
    platform: "windows"
  - src: "bin/app"
    dest: "${OPT}/myapp/bin/app"  # Se înlocuiește cu /opt/myapp/bin/ pe Linux
    permissions: "755"
    platform: "linux"

# SERVICES: EXEC per platform în platform_overrides ✅
services:
  - name: "myapp-service"
    platform_overrides:
      linux:
        exec: "${OPT}/myapp/bin/app --daemon"  # Calea agnostică pentru Linux
        after: "network.target"
        type: "systemd"
      windows:
        exec: "${PROGRAM_FILES}/MyApp/app.exe --service"  # Calea agnostică pentru Windows
        display_name: "My Application Service"
        description: "MyApp background service"

# ENVIRONMENT: VARIABILE STANDARD per OS ✅
environment:
  MYAPP_HOME: "${OPT}/myapp"  # ${OPT} = /opt pe Linux, ${PROGRAM_FILES}/MyApp pe Windows
  PATH: "${PATH}:${BIN}"  # ${BIN} = directorul executabile standard al OS-ului
  MYAPP_DATA: "${DATA}/myapp"  # ${DATA} = /var/lib pe Linux, %APPDATA% pe Windows

# SHORTCUTS: ORGANIZAT per platform ✅
shortcuts:
  - platform: "windows"
    name: "My Application"
    target: "${PROGRAM_FILES}/MyApp/app.exe"
    icon: "icon.ico"
    desktop: true
    start_menu: true
  - platform: "linux"
    name: "My Application"
    target: "${OPT}/myapp/bin/app"
    icon: "icon.png"
    desktop: true

# REGISTRY: MUTAT în platform_overrides - apare doar pentru Windows ✅
platforms:
  windows:
    registry:
      - path: "HKLM\\SOFTWARE\\MyApp"
        values:
          InstallPath: "${PROGRAM_FILES}/MyApp"  # Variabilă agnostică
          Version: "1.0.0"

Complete Example: Web Application Deployment

# webapp-install.yml
package:
  name: "my-webapp"
  version: "1.2.0"
  description: "Cross-platform web application"

dependencies:
  - "nginx>=1.20.0"
  - "postgresql>=13.0"

platforms:
  linux:
    prerequisites:
      - "curl"
      - "build-essential"

files:
  # Application files
  - src: "webapp.jar"
    dest: "/opt/mywebapp/app.jar"
    permissions: "644"

  # Config templates
  - src: "nginx.conf.template"
    dest: "/etc/nginx/sites-available/mywebapp.conf"
    template: true
    vars:
      APP_PORT: "8080"
      APP_HOST: "localhost"

  - src: "application.properties.template"
    dest: "/opt/mywebapp/application.properties"
    template: true

services:
  - name: "mywebapp"
    exec: "java -jar /opt/mywebapp/app.jar"
    start: "auto"
    user: "webapp-user"
    environment:
      SPRING_PROFILES_ACTIVE: "production"

  - name: "nginx-mywebapp"
    exec: "/usr/sbin/nginx -c /etc/nginx/sites-available/mywebapp.conf"
    start: "auto"
    dependencies: ["network.target", "mywebapp"]

environment:
  MYWEBAPP_HOME: "/opt/mywebapp"
  JAVA_OPTS: "-Xmx1g -Xms512m"

hooks:
  post_install:
    - command: "nginx -t && systemctl reload nginx"
      platform: "linux"
      ignore_errors: false

Install with:

sudo ./agnostic-installer-linux install webapp-install.yml --verbose

Testing and Validation

Running Tests

Before production deployment, validate your installation:

# Run the test suite
python3 tests/test_functional.py

# Test specific configuration
agnostic-installer validate myapp.yml --verbose

# Dry-run installation
agnostic-installer install myapp.yml --dry-run

Test Coverage

The installer includes comprehensive tests for: - Functional Tests: End-to-end installation scenarios - Unit Tests: Individual component validation - Integration Tests: Component interaction testing - Cross-platform Compatibility: Linux/Windows/macOS support

For detailed testing information, see /docs/testing.md.

Security Considerations

  • Always validate configuration files before installation
  • Use HTTPS for remote dependencies and templates
  • Avoid storing credentials in configuration files
  • Review file permissions and ownership carefully
  • Consider using privilege separation for services

Support and Resources

  • Configuration Schema Reference: agnostic-installer validate --help
  • Platform-specific Examples: /docs/examples/
  • Issue Reporting: GitHub Issues
  • Community Support: GitHub Discussions