Sari la conținut

Agnostic OS Installer Architecture

Overview

The Agnostic OS Installer is a cross-platform, configuration-driven package installation system built in Python. It enables declarative software installation across Windows, Linux, and macOS through YAML/TOML configuration files, managing dependencies, services, files, and system-level configurations with zero user interaction.

Core Modules

1. Configuration Engine (core/engine_cli.py)

  • Purpose: Interprets YAML/TOML installation manifests
  • Technology: PyYAML for parsing
  • Features:
  • Declarative package definitions
  • Dependency resolution
  • Platform-specific overrides
  • Configuration validation with error handling
  • Variable expansion and templating support

2. Platform Detection (core/platform_detect.py)

  • Purpose: Automatically detect target operating system and architecture
  • Features:
  • Cross-platform OS detection (Linux/Windows/macOS)
  • Hardware architecture identification
  • Platform-specific variable resolution
  • Configuration transformation for target platform

3. File Management (core/files_handle.py)

  • Purpose: Cross-platform file operations and permissions
  • Features:
  • File copying with permission preservation
  • Platform-specific permission handling
  • Template processing with variable substitution
  • Backup creation for existing files
  • File ownership management (Unix-like systems)

4. Service Management (core/services_manage.py)

  • Purpose: System service installation and management
  • Features:
  • systemd service creation (Linux)
  • Windows Service Manager integration (future)
  • launchd service support (macOS - future)
  • Service dependency management
  • Automatic service startup configuration
  • Cross-platform service uninstallation

5. Dependency Resolution (core/dependency_resolve.py)

  • Purpose: Resolve and install package dependencies
  • Features:
  • Registry-based package management
  • Platform-specific package commands
  • Dependency graph resolution
  • Version constraint checking

6. Package Registry (core/registry.py)

  • Purpose: Local package database management
  • Features:
  • Package command mappings by platform
  • Registry data loading from YAML
  • Platform-specific command execution
  • Package availability verification

7. Environment & System Integration

  • Purpose: System-level configuration management
  • Features:
  • Environment variable management
  • Windows registry operations (future)
  • Desktop shortcut creation (future)
  • System PATH updates

8. CLI Interface (core/engine_cli.py)

  • Purpose: Command-line interface for all operations
  • Commands:
  • install: Package installation with dry-run support
  • uninstall: Package removal
  • build: Cross-platform package creation
  • list: Installed package listing
  • status: Service/package status checking
  • Global options: verbose logging, force mode, configuration overrides

3. Platform Adapters

  • Windows Adapter: pywin32 for services, registry, shortcuts
  • Linux Adapter: systemd service management, file permissions
  • macOS Adapter: launchctl service management (future)

4. CLI Interface

  • Purpose: Primary user interface
  • Features:
  • Package installation/uninstallation
  • Configuration validation
  • Dependency checking
  • Dry-run mode
  • Verbose logging

5. Build System

  • Host Platform: Linux-based cross-compilation
  • Technologies:
  • Briefcase: Standalone executable with embedded Python
  • Nuitka: Native compilation (performance optimization)
  • Outputs: Single-file executables per platform

Architecture Flow

graph TD
    A[YAML Config] --> B[Configuration Engine]
    B --> C[Dependency Resolver]
    C --> D{Platform Check}
    D --> E[Linux Adapter: systemd]
    D --> F[Windows Adapter: pywin32]
    D --> H[Mac Adapter: launchctl]
    E --> I[File Operations]
    F --> I
    H --> I
    I --> J[Service Installation]
    J --> K[System Integration]

Technology Stack

Component Technology Purpose
Core Engine Python 3.9+ Cross-platform runtime
Configuration YAML/TOML Declarative manifests
Windows Integration pywin32 OS-specific operations
Linux Integration systemd API Service management
Packaging Briefcase Self-contained executables
Compilation Nuitka Performance optimization
Testing unittest/subprocess Quality assurance with integration testing
CLI Framework argparse Command-line interface

Configuration Schema

Package Manifest Structure

# agnostic-installer.yml
package:
  name: "my-application"
  version: "1.0.0"
  description: "Cross-platform software installer"

dependencies:
  - package1>=1.0.0
  - package2

platforms:
  linux:
    prerequisites:
      - curl
      - unzip
    services: [...]
  windows:
    prerequisites:
      - powershell
      - nsis
    services: [...]
  macos:
    prerequisites: [...]
    services: [...]

files:
  - src: "bin/app"
    dest: "/opt/myapp/bin/app"
    permissions: "755"
  - src: "config/app.conf"
    dest: "/etc/myapp/app.conf"

services:
  - name: "myapp-service"
    exec: "/opt/myapp/bin/app --daemon"
    start: "auto"
    user: "myapp-user"
    platform_overrides:
      linux:
        type: "systemd"
      windows:
        type: "winservice"

environment:
  MYAPP_HOME: "/opt/myapp"
  PATH: "${PATH}:/opt/myapp/bin"

shortcuts:
  - name: "MyApp"
    target: "/opt/myapp/bin/app"
    icon: "icon.ico"
    platform: "windows"

registry:
  - path: "HKLM\\SOFTWARE\\MyApp"
    values:
      InstallPath: "/opt/myapp"
    platform: "windows"

Cross-Platform Implementation

Windows Implementation

  • Services: Windows Service Manager via pywin32
  • Registry: winreg module for system integration
  • Shortcuts: Windows shell links (.lnk files)
  • Permissions: Windows ACL management

Linux Implementation

  • Services: systemd unit files generation
  • Permissions: chmod/chown for file ownership
  • System Integration: Environment variables, PATH updates
  • Packaging: rpm/deb package generation (optional)

macOS Implementation (Future)

  • Services: launchctl plist files
  • Permissions: macOS permission systems
  • Integration: macOS app bundles, environment variables

Build and Distribution

Development Environment

  • Host: Linux (Ubuntu/Debian preferred)
  • Python: 3.9+ with virtual environments
  • Dependencies: pywin32 (Windows), pyyaml, briefcase

Build Process

# Cross-platform build workflow
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

# Build for target platforms
briefcase build --target linux
briefcase build --target windows
briefcase build --target macos

Distribution Artifacts

  • installer-linux: Standalone Linux executable
  • installer-windows.exe: Windows executable
  • installer-macos: macOS app bundle

Security and Reliability

Security Measures

  • Permission Management: Least privilege principle
  • Validation: Configuration schema validation
  • Integrity: File checksum validation
  • Rollback: Installation failure recovery

Error Handling

  • Platform Detection: Autodetect target OS
  • Dependency Resolution: Cycle detection, version conflicts
  • Graceful Degradation: Fallback mechanisms for missing features
  • Logging: Comprehensive audit trails

Extensibility

Plugin Architecture

  • Package Types: Support for custom installer types
  • Platform Extensions: Easy addition of new OS support
  • Integration Hooks: Pre/post-install callbacks
  • Custom Actions: Extensible installation steps

Future Enhancements

  • Standalone Packages: Self-contained package bundles
  • GUI Interface: Optional graphical installer
  • Cloud Integration: Remote package repository
  • Container Support: Docker/Kubernetes deployment