Package Registry - External Dependencies¶
Overview¶
The Package Registry feature allows Agnostic OS Installer to automatically install external dependencies (like Python, Git, Node.js, or custom packages) using platform-specific commands. Instead of including installation files in your package, you can reference dependencies that the installer knows how to install.
How It Works¶
Registry File Structure¶
Registry is stored in data/registry.yml and contains mappings of package identifiers to installation commands per platform.
# data/registry.yml
packages:
python_3.9:
description: "Python 3.9 Interpreter"
platforms:
linux:
ubuntu: ">=18.04":
install_command: |
sudo apt update
sudo apt install -y python3.9 python3.9-pip python3.9-venv
uninstall_command: |
sudo apt remove -y python3.9 python3.9-pip python3.9-venv
check_command: "python3.9 --version"
centos: ">=7":
install_command: |
sudo yum install -y python39 python39-pip
check_command: "python3.9 --version"
windows:
version: ">=10":
install_command: |
powershell -Command "
$url = 'https://www.python.org/ftp/python/3.9.13/python-3.9.13-amd64.exe'
$installer = '$env:TEMP\python-installer.exe'
Invoke-WebRequest -Uri $url -OutFile $installer
Start-Process -FilePath $installer -ArgumentList '/quiet InstallAllUsers=1 PrependPath=1' -Wait
Remove-Item $installer
"
check_command: "python --version"
version: "<10":
install_command: "winget install --id Python.Python.3.9 --accept-package-agreements --accept-source-agreements"
macos:
version: ">=12":
install_command: |
/bin/bash -c "
if ! command -v brew &> /dev/null; then
echo 'Please install Homebrew first: /bin/bash -c \"$curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh\"'
exit 1
fi
brew install python@3.9
"
nodejs_lts:
description: "Node.js LTS Runtime"
platforms:
linux:
ubuntu: "*": # Any version
install_command: |
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
check_command: "node --version"
my_custom_package:
description: "My company's internal tool"
external_hook: true # Use custom script from package
platforms:
linux:
ubuntu: "*":
install_command: "${HOOK_DIR}/install-custom-linux.sh --version=${PACKAGE_VERSION}"
windows:
"*": # Any Windows version
install_command: "powershell ${HOOK_DIR}\\install-custom-win.ps1 -Version ${PACKAGE_VERSION}"
Using Registry in Configurations¶
Simple Dependencies¶
# myapp.yml
package:
name: my-app
version: 1.0.0
dependencies:
- python_3.9 # Will check registry.yml and install Python 3.9
- nodejs_lts # Will install Node.js LTS
- my_custom_package # Will run custom hook
files:
# Your application files
- src: "dist/app.js"
dest: "/opt/myapp/app.js"
Platform-Specific Dependencies¶
package:
name: cross-platform-app
version: 1.1.0
dependencies:
- python_3.9[linux] # Only for Linux
- python_3.9[windows] # Only for Windows
- mac_tools[macos] # Only for macOS
Registry Commands¶
Adding Packages to Registry¶
# Add a new package to registry
agnostic-installer registry add python_3.11 --description "Python 3.11"
# Update package commands for a specific platform
agnostic-installer registry update python_3.11 --platform linux --distro ubuntu \
--version ">=20.04" --command "sudo apt install python3.11"
Managing Registry¶
# List all packages in registry
agnostic-installer registry list
# Show details for a package
agnostic-installer registry show python_3.9
# Validate registry file
agnostic-installer registry validate
# Backup registry
agnostic-installer registry backup registry-backup.yml
# Import from backup
agnostic-installer registry import registry-new.yml
Version Matching¶
How Version Constraints Work¶
Version constraints use semantic versioning expressions:
platforms:
linux:
ubuntu: ">=18.04": # Ubuntu 18.04 and newer
ubuntu: ">=20.04,<22": # Ubuntu 20.04 to 21.10
ubuntu: "==20.04": # Exactly Ubuntu 20.04
windows:
version: ">=10": # Windows 10 and newer
version: "<11": # Windows versions below 11
Custom Hooks for Proprietary Packages¶
Hook Directory Structure¶
When external_hook: true is set in registry, Agnostic Installer looks for hook scripts in your package:
my-package.zip/
├── config.yml
├── hooks/
│ ├── install-custom-linux.sh
│ ├── install-custom-win.ps1
│ └── uninstall-custom.sh
└── data/
└── my-software.msi # Your custom installer files
Hook Script Variables¶
Hooks receive environment variables:
${HOOK_DIR}- Path to hooks directory${PACKAGE_NAME}- Package name from registry${PACKAGE_VERSION}- Version specified in config${PLATFORM}- Current platform (linux/windows/macos)${DISTRO}- Linux distribution (ubuntu/centos/etc)${OS_VERSION}- OS version
Example Hook Script (Linux)¶
#!/bin/bash
# hooks/install-custom-linux.sh
set -e
echo "Installing ${PACKAGE_NAME} version ${PACKAGE_VERSION} on ${PLATFORM}"
# Install dependencies first
if [[ "${DISTRO}" == "ubuntu" ]]; then
sudo apt update
sudo apt install -y some-dependency
fi
# Run your custom installer
chmod +x "${HOOK_DIR}/../data/my-software.run"
"${HOOK_DIR}/../data/my-software.run" --version="${PACKAGE_VERSION}" --silent
echo "Installation completed"
Registry Maintenance¶
Frequency of Updates¶
- System packages: Rarely - only when new major versions are released or when new platforms are added
- Custom packages: Whenever your internal packages change installation methods
Best Practices¶
- Test on clean systems: Always test installation commands on fresh systems
- Use idempotent commands: Commands should be safe to run multiple times
- Include validation: Add check_command to verify installation succeeded
- Document changes: Update package descriptions when commands change
- Version pinning: Use exact versions (python_3.9) rather than ranges for predictability
Validation¶
# Validate registry syntax
agnostic-installer registry validate
# Test package installation on current system
agnostic-installer registry test python_3.9 --dry-run
Advanced Features¶
Dynamic Commands with Templates¶
Registry commands can use templates:
packages:
postgresql:
platforms:
linux:
ubuntu: "*":
install_command: |
sudo apt update
sudo apt install -y postgresql-${DB_VERSION}
variables:
DB_VERSION: "13" # Default value
# Override in config
dependencies:
- postgresql[DB_VERSION=15] # Install PostgreSQL 15 instead
Repository Integration (Future)¶
packages:
mycompany-pkg:
repository: "https://artifacts.company.com/api/packages"
credentials:
username: "${ARTIFACTORY_USER}"
password: "${ARTIFACTORY_PASS}"
platforms:
"*":
install_command: |
curl -u "${ARTIFACTORY_USER}:${ARTIF<NAME>}" \
"${REPOSITORY_URL}/${PACKAGE_NAME}/${PACKAGE_VERSION}/download" \
-o package.tar.gz
tar xzf package.tar.gz
./install.sh
Security Considerations¶
- Hook scripts run with installer privileges - review carefully
- Validate download URLs and certificates
- Don't store credentials in registry files directly
- Use environment variables for sensitive data
Troubleshooting¶
Common Issues¶
- Registry not found: Ensure
data/registry.ymlexists in installer directory - Platform not supported: Add platform-specific commands to registry entry
- Hook execution fails: Check hook script permissions and shebang
- Version mismatch: Update registry with new OS version constraints
- Command fails silently: Add
set -eto bash scripts for error detection
Debug Registry Issues¶
```bash
Enable registry debugging¶
agnostic-installer install config.yml --verbose --log-registry
Test registry resolution only¶
agnostic-installer registry resolve python_3.9 --platform linux --distro ubuntu
Dry-run dependency installation¶
agnostic-installer install config.yml --dry-run --resolve-only