1423 lines
47 KiB
Bash
1423 lines
47 KiB
Bash
#!/bin/bash
|
|
# Main execution and command dispatch for Particle-OS apt-layer Tool
|
|
|
|
# Show version information
|
|
show_version() {
|
|
cat << 'EOF'
|
|
apt-layer:
|
|
Version: '2025.1'
|
|
Git: Particle-OS apt-layer Tool
|
|
Compiled: 2025-01-27 23:55 UTC
|
|
Features:
|
|
- composefs
|
|
- container
|
|
- live-overlay
|
|
- rpm-ostree-compat
|
|
- atomic-transactions
|
|
- dpkg-direct-install
|
|
EOF
|
|
}
|
|
|
|
# Show concise usage information
|
|
show_usage() {
|
|
cat << 'EOF'
|
|
Usage:
|
|
apt-layer [OPTION…] COMMAND
|
|
|
|
Builtin Commands:
|
|
install Overlay additional packages
|
|
upgrade Perform a system upgrade
|
|
rebase Switch to a different base
|
|
rollback Revert to the previously booted deployment
|
|
status Get the version of the booted system
|
|
kargs Query or modify kernel arguments
|
|
cleanup Clear cached/pending data
|
|
cancel Cancel an active transaction
|
|
initramfs Enable or disable local initramfs regeneration
|
|
usroverlay Apply a transient overlayfs to /usr
|
|
|
|
Layer Management:
|
|
--container Create layer using container isolation
|
|
--dpkg-install Install packages using direct dpkg
|
|
--live-install Install packages on live system
|
|
--live-overlay Manage live system overlayfs
|
|
--live-commit Commit live overlay changes
|
|
--live-rollback Rollback live overlay changes
|
|
|
|
|
|
|
|
Image Management:
|
|
--list List available images
|
|
--info Show image information
|
|
--remove Remove image
|
|
--oci-export Export as OCI image
|
|
--oci-import Import OCI image
|
|
|
|
System Management:
|
|
--init Initialize apt-layer system
|
|
--reinit Reinitialize apt-layer system (force recreation)
|
|
--rm-init Remove apt-layer system (cleanup)
|
|
--reset Reset apt-layer system
|
|
--status Show apt-layer system status
|
|
--help-full Show detailed help
|
|
--examples Show usage examples
|
|
|
|
Help Options:
|
|
-h, --help Show help options
|
|
|
|
Application Options:
|
|
--version Print version information and exit
|
|
-q, --quiet Avoid printing most informational messages
|
|
|
|
Examples:
|
|
apt-layer ubuntu-base/24.04 gaming/24.04 steam wine
|
|
apt-layer --container ubuntu-base/24.04 dev/24.04 vscode git
|
|
apt-layer --live-install firefox
|
|
apt-layer install steam wine
|
|
apt-layer status
|
|
EOF
|
|
}
|
|
|
|
# Show full detailed usage information
|
|
show_full_usage() {
|
|
cat << 'EOF'
|
|
apt-layer Tool - Enhanced with Container Support and LIVE SYSTEM LAYERING
|
|
Like rpm-ostree + Vanilla OS Apx for Ubuntu/Debian, now ComposeFS-based
|
|
|
|
BASIC LAYER CREATION:
|
|
apt-layer base-image new-image [packages...]
|
|
# Add a new layer to an existing ComposeFS image (build or user)
|
|
|
|
apt-layer --container base-image new-image [packages...]
|
|
# Create layer using container isolation (like Apx)
|
|
|
|
apt-layer --dpkg-install packages
|
|
# Install packages using direct dpkg (faster, more controlled)
|
|
|
|
apt-layer --container-dpkg base-image new-image [packages...]
|
|
# Create layer using container isolation with dpkg (optimized)
|
|
|
|
LIVE SYSTEM LAYERING:
|
|
apt-layer --live-install packages
|
|
# Install packages on live system with overlayfs (like rpm-ostree install)
|
|
|
|
apt-layer --live-dpkg packages
|
|
# Install packages on live system using dpkg (optimized)
|
|
|
|
apt-layer --live-overlay action [options]
|
|
# Manage live system overlayfs
|
|
# Actions: start, stop, status, commit, rollback
|
|
|
|
apt-layer --live-commit [message]
|
|
# Commit current live overlay changes as new ComposeFS layer
|
|
|
|
apt-layer --live-rollback
|
|
# Rollback live overlay changes
|
|
|
|
rpm-ostree COMPATIBILITY:
|
|
apt-layer install packages
|
|
# Install packages (rpm-ostree install compatibility)
|
|
|
|
apt-layer upgrade
|
|
# Upgrade system (rpm-ostree upgrade compatibility)
|
|
|
|
apt-layer rebase new-base
|
|
# Rebase to new base (rpm-ostree rebase compatibility)
|
|
|
|
apt-layer rollback [commit]
|
|
# Rollback to previous deployment (rpm-ostree rollback compatibility)
|
|
|
|
apt-layer status
|
|
# Show deployment status (rpm-ostree status compatibility)
|
|
|
|
apt-layer diff [from] [to]
|
|
# Show package differences (rpm-ostree diff compatibility)
|
|
|
|
apt-layer db list
|
|
# List deployments (rpm-ostree db list compatibility)
|
|
|
|
apt-layer db diff [from] [to]
|
|
# Show detailed differences (rpm-ostree db diff compatibility)
|
|
|
|
apt-layer cleanup [--purge]
|
|
# Clean up old deployments (rpm-ostree cleanup compatibility)
|
|
|
|
apt-layer cancel
|
|
# Cancel pending deployment (rpm-ostree cancel compatibility)
|
|
|
|
apt-layer initramfs action
|
|
# Manage initramfs (rpm-ostree initramfs compatibility)
|
|
|
|
apt-layer kargs action [args...]
|
|
# Manage kernel arguments (rpm-ostree kargs compatibility)
|
|
|
|
apt-layer bootloader action [options]
|
|
# Manage bootloader entries and configuration
|
|
|
|
apt-layer usroverlay action
|
|
# Manage /usr overlay (rpm-ostree usroverlay compatibility)
|
|
|
|
apt-layer composefs action [args...]
|
|
# Manage ComposeFS (rpm-ostree composefs compatibility)
|
|
|
|
IMAGE MANAGEMENT:
|
|
apt-layer --list
|
|
# List all available ComposeFS images/layers
|
|
|
|
apt-layer --info image
|
|
# Show information about a specific ComposeFS image/layer
|
|
|
|
apt-layer --remove image
|
|
# Remove an image/layer
|
|
|
|
apt-layer --oci-export image placeholder
|
|
# Export ComposeFS image as OCI image
|
|
|
|
apt-layer --oci-import placeholder placeholder
|
|
# Import OCI image as ComposeFS image
|
|
|
|
apt-layer --oci-status
|
|
# Show OCI integration system status
|
|
|
|
SYSTEM MANAGEMENT:
|
|
apt-layer --init
|
|
# Initialize apt-layer system
|
|
|
|
apt-layer --reset
|
|
# Reset apt-layer system
|
|
|
|
EXAMPLES:
|
|
apt-layer ubuntu-base/24.04 gaming/24.04 steam wine
|
|
apt-layer --container ubuntu-base/24.04 dev/24.04 vscode git
|
|
apt-layer --dpkg-install curl wget
|
|
apt-layer --live-install firefox
|
|
apt-layer install steam wine
|
|
apt-layer status
|
|
EOF
|
|
}
|
|
|
|
# Show category-specific help
|
|
show_layer_help() {
|
|
cat << 'EOF'
|
|
Layer Management Commands
|
|
|
|
BASIC LAYER CREATION:
|
|
apt-layer base-image new-image [packages...]
|
|
# Create new layer from base image with packages
|
|
|
|
apt-layer --container base-image new-image [packages...]
|
|
# Create layer using container isolation (like Apx)
|
|
|
|
apt-layer --dpkg-install packages
|
|
# Install packages using direct dpkg (faster, more controlled)
|
|
|
|
apt-layer --container-dpkg base-image new-image [packages...]
|
|
# Create layer using container isolation with dpkg (optimized)
|
|
|
|
apt-layer --advanced-install packages
|
|
# Install packages with security checks and dependency resolution
|
|
|
|
apt-layer --advanced-remove packages
|
|
# Remove packages with dependency checking and safety validation
|
|
|
|
apt-layer --advanced-update packages
|
|
# Update packages with rollback capability and backup creation
|
|
|
|
Examples:
|
|
apt-layer ubuntu-base/24.04 gaming/24.04 steam wine
|
|
apt-layer --container ubuntu-base/24.04 dev/24.04 vscode git
|
|
apt-layer --dpkg-install curl wget
|
|
apt-layer --advanced-install firefox
|
|
EOF
|
|
}
|
|
|
|
show_live_help() {
|
|
cat << 'EOF'
|
|
Live System Management Commands
|
|
|
|
LIVE INSTALLATION:
|
|
apt-layer --live-install packages
|
|
# Install packages on live system with overlayfs (like rpm-ostree install)
|
|
# Uses apt-get (requires network access)
|
|
# ⚠️ For WSL/offline/atomic overlays, use --live-dpkg instead
|
|
|
|
apt-layer --live-dpkg packages
|
|
# Install packages on live system using dpkg (optimized for overlays, offline, WSL)
|
|
# Usage: apt-layer --live-dpkg /path/to/*.deb
|
|
|
|
LIVE OVERLAY MANAGEMENT:
|
|
apt-layer --live-overlay action [options]
|
|
# Manage live system overlayfs
|
|
# Actions: start, stop, status, commit, rollback
|
|
|
|
apt-layer --live-commit [message]
|
|
# Commit current live overlay changes as new ComposeFS layer
|
|
|
|
apt-layer --live-rollback
|
|
# Rollback live overlay changes
|
|
|
|
Examples:
|
|
apt-layer --live-install firefox
|
|
apt-layer --live-dpkg ~/apt-cache/*.deb
|
|
apt-layer --live-overlay start
|
|
apt-layer --live-overlay commit "Add development tools"
|
|
apt-layer --live-rollback
|
|
EOF
|
|
}
|
|
|
|
show_rpm_ostree_help() {
|
|
cat << 'EOF'
|
|
rpm-ostree Compatibility Commands
|
|
|
|
BASIC COMMANDS:
|
|
apt-layer install packages
|
|
# Install packages (rpm-ostree install compatibility)
|
|
|
|
apt-layer upgrade
|
|
# Upgrade system (rpm-ostree upgrade compatibility)
|
|
|
|
apt-layer rebase new-base
|
|
# Rebase to new base (rpm-ostree rebase compatibility)
|
|
|
|
apt-layer rollback [commit]
|
|
# Rollback to previous deployment (rpm-ostree rollback compatibility)
|
|
|
|
apt-layer status
|
|
# Show deployment status (rpm-ostree status compatibility)
|
|
|
|
apt-layer diff [from] [to]
|
|
# Show package differences (rpm-ostree diff compatibility)
|
|
|
|
DATABASE COMMANDS:
|
|
apt-layer db list
|
|
# List deployments (rpm-ostree db list compatibility)
|
|
|
|
apt-layer db diff [from] [to]
|
|
# Show detailed differences (rpm-ostree db diff compatibility)
|
|
|
|
SYSTEM COMMANDS:
|
|
apt-layer cleanup [--purge]
|
|
# Clean up old deployments (rpm-ostree cleanup compatibility)
|
|
|
|
apt-layer cancel
|
|
# Cancel pending deployment (rpm-ostree cancel compatibility)
|
|
|
|
apt-layer initramfs action
|
|
# Manage initramfs (rpm-ostree initramfs compatibility)
|
|
|
|
apt-layer kargs action [args...]
|
|
# Manage kernel arguments (rpm-ostree kargs compatibility)
|
|
|
|
apt-layer bootloader action [options]
|
|
# Manage bootloader entries and configuration
|
|
|
|
apt-layer usroverlay action
|
|
# Manage /usr overlay (rpm-ostree usroverlay compatibility)
|
|
|
|
apt-layer composefs action [args...]
|
|
# Manage ComposeFS (rpm-ostree composefs compatibility)
|
|
|
|
Examples:
|
|
apt-layer install steam wine
|
|
apt-layer status
|
|
apt-layer upgrade
|
|
apt-layer kargs add "console=ttyS0"
|
|
apt-layer rollback
|
|
EOF
|
|
}
|
|
|
|
# Show image management help
|
|
show_image_help() {
|
|
cat << 'EOF'
|
|
IMAGE MANAGEMENT COMMANDS:
|
|
|
|
IMAGE OPERATIONS:
|
|
apt-layer --list
|
|
# List all available ComposeFS images/layers
|
|
|
|
apt-layer --info image
|
|
# Show information about a specific ComposeFS image/layer
|
|
|
|
apt-layer --remove image
|
|
# Remove an image/layer
|
|
|
|
OCI INTEGRATION:
|
|
apt-layer --oci-export image placeholder
|
|
# Export ComposeFS image as OCI image
|
|
|
|
apt-layer --oci-import placeholder placeholder
|
|
# Import OCI image as ComposeFS image
|
|
|
|
apt-layer --oci-status
|
|
# Show OCI integration system status
|
|
|
|
EXAMPLES:
|
|
apt-layer --list
|
|
apt-layer --info particle-os/base/24.04
|
|
apt-layer --remove old-layer
|
|
apt-layer --oci-export my-image oci:my-registry/my-image:latest
|
|
EOF
|
|
}
|
|
|
|
show_security_help() {
|
|
cat << 'EOF'
|
|
Security & Signing Commands
|
|
|
|
LAYER SIGNING & VERIFICATION:
|
|
apt-layer --generate-key key-name type
|
|
# Generate signing key pair (sigstore, gpg)
|
|
|
|
apt-layer --sign-layer layer-path key-name
|
|
# Sign layer with specified key
|
|
|
|
apt-layer --verify-layer layer-path
|
|
# Verify layer signature
|
|
|
|
apt-layer --revoke-layer layer-path [reason]
|
|
# Revoke layer (mark as untrusted)
|
|
|
|
apt-layer --list-keys
|
|
# List all signing keys
|
|
|
|
apt-layer --list-signatures
|
|
# List all layer signatures
|
|
|
|
apt-layer --layer-status layer-path
|
|
# Show layer signing status
|
|
|
|
SECURITY SCANNING:
|
|
apt-layer --scan-package package-name [version] [scan-level]
|
|
# Scan package for vulnerabilities (standard, thorough, quick)
|
|
|
|
apt-layer --scan-layer layer-path [scan-level]
|
|
# Scan layer for vulnerabilities
|
|
|
|
apt-layer --generate-security-report type [format] [scan-level]
|
|
# Generate security report (package, layer, system)
|
|
|
|
apt-layer --security-status
|
|
# Show security scanning system status
|
|
|
|
apt-layer --update-cve-database
|
|
# Update CVE database from NVD
|
|
|
|
apt-layer --cleanup-security-reports [days]
|
|
# Clean up old security reports (default: 90 days)
|
|
|
|
Examples:
|
|
apt-layer --generate-key my-key sigstore
|
|
apt-layer --sign-layer layer.squashfs my-key
|
|
apt-layer --verify-layer layer.squashfs
|
|
apt-layer --scan-package firefox
|
|
apt-layer --security-status
|
|
EOF
|
|
}
|
|
|
|
show_audit_help() {
|
|
cat << 'EOF'
|
|
Audit & Compliance Commands
|
|
|
|
AUDIT LOGGING:
|
|
apt-layer --query-audit format [filters...]
|
|
# Query audit logs with filters (json, csv, table)
|
|
|
|
apt-layer --export-audit format [output-file] [filters...]
|
|
# Export audit logs to file (json, csv, html)
|
|
|
|
apt-layer --list-audit-reports
|
|
# List all audit reports
|
|
|
|
apt-layer --audit-status
|
|
# Show audit system status
|
|
|
|
apt-layer --cleanup-audit-logs [days]
|
|
# Clean up old audit logs (default: 90 days)
|
|
|
|
COMPLIANCE REPORTING:
|
|
apt-layer --generate-compliance-report framework [period] [format]
|
|
# Generate compliance report (sox, pci-dss)
|
|
|
|
Examples:
|
|
apt-layer --query-audit json --user=admin --since=2024-01-01
|
|
apt-layer --export-audit csv --output=audit-export.csv
|
|
apt-layer --generate-compliance-report sox monthly html
|
|
apt-layer --audit-status
|
|
EOF
|
|
}
|
|
|
|
show_admin_help() {
|
|
cat << 'EOF'
|
|
Admin Utilities Commands
|
|
|
|
SYSTEM HEALTH:
|
|
apt-layer admin health
|
|
# System health check and diagnostics
|
|
|
|
apt-layer admin perf
|
|
# Performance analytics and resource usage
|
|
|
|
MAINTENANCE:
|
|
apt-layer admin cleanup
|
|
# Maintenance cleanup
|
|
|
|
apt-layer admin backup
|
|
# Backup configs and layers
|
|
|
|
apt-layer admin restore
|
|
# Restore from backup
|
|
|
|
USER MANAGEMENT:
|
|
apt-layer --add-user username role
|
|
# Add user to package management system with specified role
|
|
|
|
apt-layer --remove-user username
|
|
# Remove user from package management system
|
|
|
|
apt-layer --list-users
|
|
# List all package management users and roles
|
|
|
|
PACKAGE MANAGEMENT:
|
|
apt-layer --package-info package
|
|
# Get detailed information about a package
|
|
|
|
apt-layer --package-status
|
|
# Show advanced package management system status
|
|
|
|
apt-layer --list-backups
|
|
# List all package backups
|
|
|
|
apt-layer --cleanup-backups [days]
|
|
# Clean up backups older than specified days (default: 30)
|
|
|
|
Examples:
|
|
apt-layer admin health
|
|
apt-layer admin perf
|
|
apt-layer --add-user john package_manager
|
|
apt-layer --list-users
|
|
apt-layer --package-status
|
|
EOF
|
|
}
|
|
|
|
show_enterprise_help() {
|
|
cat << 'EOF'
|
|
Enterprise Features Commands
|
|
|
|
MULTI-TENANT MANAGEMENT:
|
|
apt-layer tenant action [options]
|
|
# Multi-tenant management
|
|
# Actions: init, create, delete, list, info, quota, backup, restore, health
|
|
|
|
COMPLIANCE FRAMEWORKS:
|
|
apt-layer compliance action [options]
|
|
# Compliance framework management
|
|
# Actions: init, enable, disable, list, scan, report
|
|
|
|
ENTERPRISE INTEGRATION:
|
|
apt-layer enterprise action [options]
|
|
# Enterprise integration
|
|
# Actions: init, enable, disable, list, test, hook, send
|
|
|
|
MONITORING & ALERTING:
|
|
apt-layer monitoring action [options]
|
|
# Monitoring and alerting
|
|
# Actions: init, check, policy, history, report
|
|
|
|
Examples:
|
|
apt-layer tenant create my-org
|
|
apt-layer compliance enable SOX
|
|
apt-layer enterprise enable SIEM siem-config.json
|
|
apt-layer monitoring check
|
|
EOF
|
|
}
|
|
|
|
show_cloud_help() {
|
|
cat << 'EOF'
|
|
Cloud Integration Commands
|
|
|
|
CLOUD PROVIDERS:
|
|
apt-layer cloud action [options]
|
|
# Cloud provider integration (AWS, Azure, GCP)
|
|
# Actions: init, aws, azure, gcp, deploy, status, list-deployments, cleanup
|
|
|
|
KUBERNETES:
|
|
apt-layer kubernetes action [options]
|
|
# Kubernetes integration (EKS, AKS, GKE, OpenShift)
|
|
# Actions: init, eks, aks, gke, openshift, deploy, helm, monitoring, security, cleanup
|
|
|
|
CONTAINER ORCHESTRATION:
|
|
apt-layer orchestration action [options]
|
|
# Container orchestration
|
|
# Actions: init, multi-cluster, service-mesh, gitops, deployments, status, cleanup
|
|
|
|
MULTI-CLOUD:
|
|
apt-layer multicloud action [options]
|
|
# Multi-cloud deployment
|
|
# Actions: init, add-profile, list-profiles, deploy, migrate, status, policy
|
|
|
|
CLOUD SECURITY:
|
|
apt-layer cloud-security action [options]
|
|
# Cloud-native security
|
|
# Actions: init, scan, policy, list-scans, list-policies, cleanup, status
|
|
|
|
Examples:
|
|
apt-layer cloud aws init
|
|
apt-layer cloud deploy particle-os/gaming/24.04 aws ecr
|
|
apt-layer kubernetes eks create-cluster my-cluster us-west-2
|
|
apt-layer orchestration gitops init https://github.com/my-org/gitops-repo
|
|
apt-layer cloud-security scan particle-os/gaming/24.04 aws comprehensive
|
|
EOF
|
|
}
|
|
|
|
# Show examples
|
|
show_examples() {
|
|
cat << 'EOF'
|
|
Particle-OS apt-layer Tool - Examples
|
|
|
|
BASIC LAYER CREATION:
|
|
# Create gaming layer from base Ubuntu image
|
|
apt-layer particle-os/base/24.04 particle-os/gaming/24.04 steam wine
|
|
|
|
# Create development layer with container isolation
|
|
apt-layer --container particle-os/base/24.04 particle-os/dev/24.04 vscode git
|
|
|
|
# Direct dpkg installation (faster)
|
|
apt-layer --dpkg-install curl wget
|
|
|
|
# Deep dpkg analysis and metadata extraction
|
|
apt-layer dpkg-analyze extract <deb-file> <extract-dir>
|
|
apt-layer dpkg-analyze analyze <deb-file> [analysis-dir]
|
|
apt-layer dpkg-analyze validate <deb-file> [validation-mode]
|
|
apt-layer dpkg-analyze install <deb-file> <target-dir> [preserve-metadata]
|
|
|
|
# Basic ComposeFS Integration (Phase 2.2)
|
|
apt-layer composefs create <source-dir> <layer-path> [layer-name]
|
|
apt-layer composefs atomic-create <source-dir> <layer-path> [layer-name] [preserve-metadata] [conflict-resolution]
|
|
apt-layer composefs mount <layer-path> <mount-point>
|
|
apt-layer composefs unmount <mount-point>
|
|
apt-layer composefs compose <base-layer> <overlay-layer> <output-layer> [conflict-resolution]
|
|
apt-layer composefs validate <layer-path>
|
|
apt-layer composefs test <layer-path> [test-mount-point]
|
|
apt-layer composefs rollback <current-layer> <backup-layer>
|
|
apt-layer composefs status
|
|
|
|
LIVE SYSTEM MANAGEMENT:
|
|
# Install packages on running system
|
|
apt-layer --live-install firefox
|
|
|
|
# Start live overlay for temporary changes
|
|
apt-layer --live-overlay start
|
|
|
|
# Commit overlay changes as new layer
|
|
apt-layer --live-overlay commit "Add development tools"
|
|
|
|
# Rollback overlay changes
|
|
apt-layer --live-rollback
|
|
|
|
rpm-ostree COMPATIBILITY:
|
|
# Install packages (rpm-ostree style)
|
|
apt-layer install steam wine
|
|
|
|
# Check system status
|
|
apt-layer status
|
|
|
|
# Upgrade system
|
|
apt-layer upgrade
|
|
|
|
# Add kernel argument
|
|
apt-layer kargs add "console=ttyS0"
|
|
|
|
ENHANCED OSTREE WORKFLOW:
|
|
# Rebase to new base image
|
|
apt-layer ostree rebase oci://ubuntu:24.04
|
|
|
|
# Layer packages on current deployment
|
|
apt-layer ostree layer vim git build-essential
|
|
|
|
# Override package with custom version
|
|
apt-layer ostree override linux-image-generic /path/to/custom-kernel.deb
|
|
|
|
# Deploy specific deployment
|
|
apt-layer ostree deploy my-deployment-20250128-143022
|
|
|
|
# Build from declarative configuration
|
|
apt-layer ostree compose tree apt-layer-compose.yaml
|
|
|
|
# Layer with metadata preservation
|
|
apt-layer ostree layer-metadata package-name true keep-latest
|
|
|
|
# Layer with multi-arch support
|
|
apt-layer ostree layer-multiarch libc6 amd64 same
|
|
|
|
# Layer with script validation
|
|
apt-layer ostree layer-scripts package-name strict
|
|
|
|
# Show deployment history
|
|
apt-layer ostree log
|
|
|
|
# Show differences between deployments
|
|
apt-layer ostree diff deployment1 deployment2
|
|
|
|
# Rollback to previous deployment
|
|
apt-layer ostree rollback
|
|
|
|
# Show current status
|
|
apt-layer ostree status
|
|
|
|
IMAGE MANAGEMENT:
|
|
# List available images
|
|
apt-layer --list
|
|
|
|
# Show image details
|
|
apt-layer --info particle-os/gaming/24.04
|
|
|
|
# Export as OCI image
|
|
apt-layer --oci-export particle-os/gaming/24.04 particle-os/gaming:latest
|
|
EOF
|
|
}
|
|
|
|
# HARDWARE DETECTION & AUTO-CONFIGURATION:
|
|
# apt-layer --detect-hardware # Detect hardware and auto-configure
|
|
# apt-layer --show-hardware-info # Show detailed hardware information
|
|
# apt-layer --auto-configure-modules # Auto-configure kernel modules
|
|
# apt-layer --install-enabled-modules # Install all enabled modules
|
|
|
|
# KERNEL PATCHING (Ubuntu-specific):
|
|
# apt-layer --list-patches # List available kernel patches
|
|
# apt-layer --list-enabled-patches # List enabled kernel patches
|
|
# apt-layer --enable-patch patch-name # Enable specific kernel patch
|
|
# apt-layer --disable-patch patch-name # Disable specific kernel patch
|
|
# apt-layer --apply-patch [patch-name] # Apply specific or all enabled patches
|
|
# apt-layer --update-kernel-args # Update kernel arguments for patches
|
|
|
|
# Initialize Particle-OS system
|
|
initialize_particle_system() {
|
|
log_info "Initializing Particle-OS system..." "apt-layer"
|
|
|
|
# Check if running as root
|
|
check_root
|
|
|
|
# Create configuration file
|
|
if [[ ! -f "/usr/local/etc/particle-config.sh" ]]; then
|
|
log_info "Creating configuration file..." "apt-layer"
|
|
mkdir -p "/usr/local/etc"
|
|
|
|
cat > "/usr/local/etc/particle-config.sh" << 'EOF'
|
|
#!/bin/bash
|
|
# Particle-OS Configuration File
|
|
# This file contains the main configuration for Particle-OS
|
|
|
|
# Workspace and directory configuration
|
|
PARTICLE_WORKSPACE="/var/lib/particle-os"
|
|
PARTICLE_CONFIG_DIR="/usr/local/etc/particle-os"
|
|
PARTICLE_LOG_DIR="/var/log/particle-os"
|
|
PARTICLE_CACHE_DIR="/var/cache/particle-os"
|
|
|
|
# Build and temporary directories
|
|
PARTICLE_BUILD_DIR="$PARTICLE_WORKSPACE/build"
|
|
PARTICLE_TEMP_DIR="$PARTICLE_WORKSPACE/temp"
|
|
PARTICLE_LAYERS_DIR="$PARTICLE_WORKSPACE/layers"
|
|
|
|
# ComposeFS configuration
|
|
PARTICLE_COMPOSEFS_DIR="$PARTICLE_WORKSPACE/composefs"
|
|
PARTICLE_COMPOSEFS_SCRIPT="/usr/local/bin/composefs-alternative.sh"
|
|
|
|
# Container configuration
|
|
# Container runtime will be detected dynamically
|
|
PARTICLE_CONTAINER_RUNTIME=""
|
|
PARTICLE_CONTAINER_WORKSPACE="$PARTICLE_WORKSPACE/containers"
|
|
|
|
# Live overlay configuration
|
|
PARTICLE_LIVE_OVERLAY_DIR="$PARTICLE_WORKSPACE/live-overlay"
|
|
|
|
# Transaction configuration
|
|
PARTICLE_TRANSACTION_STATE="$PARTICLE_WORKSPACE/transaction-state"
|
|
PARTICLE_TRANSACTION_LOG="$PARTICLE_LOG_DIR/transaction.log"
|
|
|
|
# Logging configuration
|
|
PARTICLE_LOG_LEVEL="info"
|
|
PARTICLE_LOG_COLOR="true"
|
|
|
|
# Security configuration
|
|
PARTICLE_SECURITY_ENABLED="true"
|
|
PARTICLE_SECURITY_SCAN_LEVEL="standard"
|
|
|
|
# Audit configuration
|
|
PARTICLE_AUDIT_ENABLED="true"
|
|
PARTICLE_AUDIT_RETENTION_DAYS="90"
|
|
|
|
# OCI configuration
|
|
PARTICLE_OCI_ENABLED="true"
|
|
PARTICLE_OCI_WORKSPACE="$PARTICLE_WORKSPACE/oci"
|
|
|
|
# Export variables for use in scripts
|
|
export PARTICLE_WORKSPACE
|
|
export PARTICLE_CONFIG_DIR
|
|
export PARTICLE_LOG_DIR
|
|
export PARTICLE_CACHE_DIR
|
|
export PARTICLE_BUILD_DIR
|
|
export PARTICLE_TEMP_DIR
|
|
export PARTICLE_LAYERS_DIR
|
|
export PARTICLE_COMPOSEFS_DIR
|
|
export PARTICLE_COMPOSEFS_SCRIPT
|
|
export PARTICLE_CONTAINER_RUNTIME
|
|
export PARTICLE_CONTAINER_WORKSPACE
|
|
export PARTICLE_LIVE_OVERLAY_DIR
|
|
export PARTICLE_TRANSACTION_STATE
|
|
export PARTICLE_TRANSACTION_LOG
|
|
export PARTICLE_LOG_LEVEL
|
|
export PARTICLE_LOG_COLOR
|
|
export PARTICLE_SECURITY_ENABLED
|
|
export PARTICLE_SECURITY_SCAN_LEVEL
|
|
export PARTICLE_AUDIT_ENABLED
|
|
export PARTICLE_AUDIT_RETENTION_DAYS
|
|
export PARTICLE_OCI_ENABLED
|
|
export PARTICLE_OCI_WORKSPACE
|
|
EOF
|
|
|
|
chmod 644 "/usr/local/etc/particle-config.sh"
|
|
log_success "Configuration file created: /usr/local/etc/particle-config.sh" "apt-layer"
|
|
fi
|
|
|
|
# Create workspace directory
|
|
if [[ ! -d "$WORKSPACE" ]]; then
|
|
log_info "Creating workspace directory..." "apt-layer"
|
|
mkdir -p "$WORKSPACE"
|
|
log_success "Workspace directory created: $WORKSPACE" "apt-layer"
|
|
fi
|
|
|
|
# Create log directory
|
|
if [[ ! -d "/var/log/particle-os" ]]; then
|
|
log_info "Creating log directory..." "apt-layer"
|
|
mkdir -p "/var/log/particle-os"
|
|
log_success "Log directory created: /var/log/particle-os" "apt-layer"
|
|
fi
|
|
|
|
# Create cache directory
|
|
if [[ ! -d "/var/cache/particle-os" ]]; then
|
|
log_info "Creating cache directory..." "apt-layer"
|
|
mkdir -p "/var/cache/particle-os"
|
|
log_success "Cache directory created: /var/cache/particle-os" "apt-layer"
|
|
fi
|
|
|
|
# Initialize workspace subdirectories
|
|
init_workspace
|
|
|
|
log_success "Particle-OS system initialization completed successfully!" "apt-layer"
|
|
echo ""
|
|
echo "System is now ready for use. You can run:"
|
|
echo " apt-layer --help"
|
|
echo " apt-layer status"
|
|
echo " apt-layer --list"
|
|
}
|
|
|
|
# Main execution
|
|
main() {
|
|
# Initialize deployment database
|
|
init_deployment_db
|
|
|
|
# Check for incomplete transactions first
|
|
check_incomplete_transactions
|
|
|
|
# Check if system needs initialization (skip for help and initialization commands)
|
|
if [[ "${1:-}" != "--init" && "${1:-}" != "--reinit" && "${1:-}" != "--rm-init" && "${1:-}" != "--reset" && "${1:-}" != "--status" && "${1:-}" != "--help" && "${1:-}" != "-h" && "${1:-}" != "--help-full" && "${1:-}" != "--examples" && "${1:-}" != "--version" ]]; then
|
|
check_initialization_needed
|
|
fi
|
|
|
|
# Parse command line arguments first (before dependency checks)
|
|
case "${1:-}" in
|
|
--init)
|
|
# Initialize apt-layer system
|
|
initialize_apt_layer_system
|
|
exit 0
|
|
;;
|
|
--reinit)
|
|
# Reinitialize apt-layer system (force recreation)
|
|
if command -v reinitialize_apt_layer_system >/dev/null 2>&1; then
|
|
reinitialize_apt_layer_system
|
|
else
|
|
log_error "Reinit function not available" "apt-layer"
|
|
exit 1
|
|
fi
|
|
exit 0
|
|
;;
|
|
--rm-init)
|
|
# Remove apt-layer system (cleanup)
|
|
if command -v remove_apt_layer_system >/dev/null 2>&1; then
|
|
remove_apt_layer_system
|
|
else
|
|
log_error "Remove init function not available" "apt-layer"
|
|
exit 1
|
|
fi
|
|
exit 0
|
|
;;
|
|
--status)
|
|
# Show apt-layer system status
|
|
if command -v show_apt_layer_system_status >/dev/null 2>&1; then
|
|
show_apt_layer_system_status
|
|
else
|
|
log_error "Status function not available" "apt-layer"
|
|
exit 1
|
|
fi
|
|
exit 0
|
|
;;
|
|
--reset)
|
|
# Reset apt-layer system
|
|
reset_apt_layer_system
|
|
exit 0
|
|
;;
|
|
--help|-h)
|
|
show_usage
|
|
exit 0
|
|
;;
|
|
--help-full)
|
|
show_full_usage
|
|
exit 0
|
|
;;
|
|
--examples)
|
|
show_examples
|
|
exit 0
|
|
;;
|
|
--version)
|
|
show_version
|
|
exit 0
|
|
;;
|
|
layer)
|
|
if [[ "${2:-}" == "--help" || "${2:-}" == "-h" ]]; then
|
|
show_layer_help
|
|
exit 0
|
|
fi
|
|
;;
|
|
live)
|
|
if [[ "${2:-}" == "--help" || "${2:-}" == "-h" ]]; then
|
|
show_live_help
|
|
exit 0
|
|
fi
|
|
;;
|
|
rpm-ostree)
|
|
if [[ "${2:-}" == "--help" || "${2:-}" == "-h" ]]; then
|
|
show_rpm_ostree_help
|
|
exit 0
|
|
fi
|
|
;;
|
|
image)
|
|
if [[ "${2:-}" == "--help" || "${2:-}" == "-h" ]]; then
|
|
show_image_help
|
|
exit 0
|
|
fi
|
|
;;
|
|
security)
|
|
if [[ "${2:-}" == "--help" || "${2:-}" == "-h" ]]; then
|
|
show_security_help
|
|
exit 0
|
|
fi
|
|
;;
|
|
audit)
|
|
if [[ "${2:-}" == "--help" || "${2:-}" == "-h" ]]; then
|
|
show_audit_help
|
|
exit 0
|
|
fi
|
|
;;
|
|
admin)
|
|
if [[ "${2:-}" == "--help" || "${2:-}" == "-h" ]]; then
|
|
show_admin_help
|
|
exit 0
|
|
fi
|
|
;;
|
|
enterprise)
|
|
if [[ "${2:-}" == "--help" || "${2:-}" == "-h" ]]; then
|
|
show_enterprise_help
|
|
exit 0
|
|
fi
|
|
;;
|
|
cloud)
|
|
if [[ "${2:-}" == "--help" || "${2:-}" == "-h" ]]; then
|
|
show_cloud_help
|
|
exit 0
|
|
fi
|
|
;;
|
|
kubernetes)
|
|
if [[ "${2:-}" == "--help" || "${2:-}" == "-h" ]]; then
|
|
show_cloud_help
|
|
exit 0
|
|
fi
|
|
;;
|
|
dpkg-analyze)
|
|
# Deep dpkg analysis and metadata extraction
|
|
local subcommand="${2:-}"
|
|
case "$subcommand" in
|
|
extract)
|
|
local deb_file="${3:-}"
|
|
local extract_dir="${4:-}"
|
|
if [[ -z "$deb_file" ]] || [[ -z "$extract_dir" ]]; then
|
|
log_error "Debian package and extract directory required" "apt-layer"
|
|
log_info "Usage: apt-layer dpkg-analyze extract <deb-file> <extract-dir>" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
shift 2
|
|
extract_dpkg_metadata "$deb_file" "$extract_dir"
|
|
;;
|
|
analyze)
|
|
local deb_file="${3:-}"
|
|
local analysis_dir="${4:-}"
|
|
if [[ -z "$deb_file" ]]; then
|
|
log_error "Debian package required" "apt-layer"
|
|
log_info "Usage: apt-layer dpkg-analyze analyze <deb-file> [analysis-dir]" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
if [[ -z "$analysis_dir" ]]; then
|
|
analysis_dir=$(mktemp -d)
|
|
fi
|
|
shift 2
|
|
analyze_package_comprehensive "$deb_file" "$analysis_dir"
|
|
;;
|
|
validate)
|
|
local deb_file="${3:-}"
|
|
local validation_mode="${4:-warn}"
|
|
if [[ -z "$deb_file" ]]; then
|
|
log_error "Debian package required" "apt-layer"
|
|
log_info "Usage: apt-layer dpkg-analyze validate <deb-file> [validation-mode]" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
shift 2
|
|
validate_package_for_apt_layer "$deb_file" "$validation_mode"
|
|
;;
|
|
install)
|
|
local deb_file="${3:-}"
|
|
local target_dir="${4:-}"
|
|
local preserve_metadata="${5:-true}"
|
|
if [[ -z "$deb_file" ]] || [[ -z "$target_dir" ]]; then
|
|
log_error "Debian package and target directory required" "apt-layer"
|
|
log_info "Usage: apt-layer dpkg-analyze install <deb-file> <target-dir> [preserve-metadata]" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
shift 2
|
|
dpkg_direct_install_with_metadata "$deb_file" "$target_dir" "$preserve_metadata"
|
|
;;
|
|
*)
|
|
log_error "Invalid dpkg-analyze subcommand: $subcommand" "apt-layer"
|
|
log_info "Valid subcommands: extract, analyze, validate, install" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
exit 0
|
|
;;
|
|
composefs)
|
|
# Basic ComposeFS Integration (Phase 2.2)
|
|
local subcommand="${2:-}"
|
|
case "$subcommand" in
|
|
create)
|
|
local source_dir="${3:-}"
|
|
local layer_path="${4:-}"
|
|
local layer_name="${5:-}"
|
|
if [[ -z "$source_dir" ]] || [[ -z "$layer_path" ]]; then
|
|
log_error "Source directory and layer path required" "apt-layer"
|
|
log_info "Usage: apt-layer composefs create <source-dir> <layer-path> [layer-name]" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
shift 2
|
|
create_composefs_layer "$source_dir" "$layer_path" "$layer_name"
|
|
;;
|
|
atomic-create)
|
|
local source_dir="${3:-}"
|
|
local layer_path="${4:-}"
|
|
local layer_name="${5:-}"
|
|
local preserve_metadata="${6:-true}"
|
|
local conflict_resolution="${7:-keep-latest}"
|
|
if [[ -z "$source_dir" ]] || [[ -z "$layer_path" ]]; then
|
|
log_error "Source directory and layer path required" "apt-layer"
|
|
log_info "Usage: apt-layer composefs atomic-create <source-dir> <layer-path> [layer-name] [preserve-metadata] [conflict-resolution]" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
shift 2
|
|
atomic_create_composefs_layer "$source_dir" "$layer_path" "$layer_name" "$preserve_metadata" "$conflict_resolution"
|
|
;;
|
|
mount)
|
|
local layer_path="${3:-}"
|
|
local mount_point="${4:-}"
|
|
if [[ -z "$layer_path" ]] || [[ -z "$mount_point" ]]; then
|
|
log_error "Layer path and mount point required" "apt-layer"
|
|
log_info "Usage: apt-layer composefs mount <layer-path> <mount-point>" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
shift 2
|
|
mount_composefs_layer "$layer_path" "$mount_point"
|
|
;;
|
|
unmount)
|
|
local mount_point="${3:-}"
|
|
if [[ -z "$mount_point" ]]; then
|
|
log_error "Mount point required" "apt-layer"
|
|
log_info "Usage: apt-layer composefs unmount <mount-point>" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
shift 2
|
|
unmount_composefs_layer "$mount_point"
|
|
;;
|
|
compose)
|
|
local base_layer="${3:-}"
|
|
local overlay_layer="${4:-}"
|
|
local output_layer="${5:-}"
|
|
local conflict_resolution="${6:-keep-latest}"
|
|
if [[ -z "$base_layer" ]] || [[ -z "$overlay_layer" ]] || [[ -z "$output_layer" ]]; then
|
|
log_error "Base layer, overlay layer, and output layer required" "apt-layer"
|
|
log_info "Usage: apt-layer composefs compose <base-layer> <overlay-layer> <output-layer> [conflict-resolution]" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
shift 2
|
|
compose_composefs_layers "$base_layer" "$overlay_layer" "$output_layer" "$conflict_resolution"
|
|
;;
|
|
validate)
|
|
local layer_path="${3:-}"
|
|
if [[ -z "$layer_path" ]]; then
|
|
log_error "Layer path required" "apt-layer"
|
|
log_info "Usage: apt-layer composefs validate <layer-path>" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
shift 2
|
|
validate_layer_integrity "$layer_path"
|
|
;;
|
|
test)
|
|
local layer_path="${3:-}"
|
|
local test_mount_point="${4:-}"
|
|
if [[ -z "$layer_path" ]]; then
|
|
log_error "Layer path required" "apt-layer"
|
|
log_info "Usage: apt-layer composefs test <layer-path> [test-mount-point]" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
if [[ -z "$test_mount_point" ]]; then
|
|
test_mount_point=$(mktemp -d)
|
|
fi
|
|
shift 2
|
|
test_composefs_layer "$layer_path" "$test_mount_point"
|
|
;;
|
|
rollback)
|
|
local current_layer="${3:-}"
|
|
local backup_layer="${4:-}"
|
|
if [[ -z "$current_layer" ]] || [[ -z "$backup_layer" ]]; then
|
|
log_error "Current layer and backup layer required" "apt-layer"
|
|
log_info "Usage: apt-layer composefs rollback <current-layer> <backup-layer>" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
shift 2
|
|
rollback_composefs_layer "$current_layer" "$backup_layer"
|
|
;;
|
|
status)
|
|
shift 2
|
|
composefs_status
|
|
;;
|
|
*)
|
|
log_error "Invalid composefs subcommand: $subcommand" "apt-layer"
|
|
log_info "Valid subcommands: create, atomic-create, mount, unmount, compose, validate, test, rollback, status" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
exit 0
|
|
;;
|
|
--list)
|
|
list_branches
|
|
exit 0
|
|
;;
|
|
--info)
|
|
if [ -z "${2:-}" ]; then
|
|
log_error "Image name required for --info" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
show_branch_info "$2"
|
|
exit 0
|
|
;;
|
|
--remove)
|
|
if [ -z "${2:-}" ]; then
|
|
log_error "Image name required for --remove" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
remove_image "$2"
|
|
exit 0
|
|
;;
|
|
--oci-status)
|
|
# Show OCI integration system status
|
|
oci_status
|
|
exit 0
|
|
;;
|
|
--live-overlay)
|
|
# Live overlay management
|
|
require_root "live overlay management"
|
|
if [ -z "${2:-}" ]; then
|
|
log_error "Action required for --live-overlay" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
|
|
local action="$2"
|
|
shift 2
|
|
local options=("$@")
|
|
|
|
manage_live_overlay "$action" "${options[@]}"
|
|
;;
|
|
--live-install)
|
|
# Live system installation
|
|
require_root "live system installation"
|
|
if [ $# -lt 2 ]; then
|
|
log_error "No packages specified for --live-install" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
|
|
shift
|
|
local packages=("$@")
|
|
|
|
live_install "${packages[@]}"
|
|
;;
|
|
--live-dpkg)
|
|
# Live system dpkg installation (offline/overlay optimized)
|
|
require_root "live system dpkg installation"
|
|
if [ $# -lt 2 ]; then
|
|
log_error "No .deb files specified for --live-dpkg" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
|
|
shift
|
|
local deb_files=("$@")
|
|
|
|
live_dpkg_install "${deb_files[@]}"
|
|
;;
|
|
--live-commit)
|
|
# Commit live overlay changes
|
|
require_root "live overlay commit"
|
|
local message="${2:-Live overlay changes}"
|
|
commit_live_overlay "$message"
|
|
;;
|
|
--live-rollback)
|
|
# Rollback live overlay changes
|
|
require_root "live overlay rollback"
|
|
rollback_live_overlay
|
|
;;
|
|
orchestration)
|
|
# Container orchestration
|
|
if [ -z "${2:-}" ]; then
|
|
log_error "Action required for orchestration" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
local action="$2"
|
|
shift 2
|
|
local args=("$@")
|
|
|
|
handle_orchestration_command "$action" "${args[@]}"
|
|
exit 0
|
|
;;
|
|
multicloud)
|
|
# Multi-cloud deployment
|
|
if [ -z "${2:-}" ]; then
|
|
log_error "Action required for multicloud" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
local action="$2"
|
|
shift 2
|
|
local args=("$@")
|
|
|
|
handle_multicloud_command "$action" "${args[@]}"
|
|
exit 0
|
|
;;
|
|
cloud-security)
|
|
# Cloud-native security
|
|
if [ -z "${2:-}" ]; then
|
|
log_error "Action required for cloud-security" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
local action="$2"
|
|
shift 2
|
|
local args=("$@")
|
|
|
|
handle_cloud_security_command "$action" "${args[@]}"
|
|
exit 0
|
|
;;
|
|
ostree)
|
|
# OSTree atomic package management interface
|
|
local subcommand="${2:-}"
|
|
case "$subcommand" in
|
|
rebase)
|
|
local new_base="${3:-}"
|
|
local deployment_name="${4:-current}"
|
|
if [[ -z "$new_base" ]]; then
|
|
log_error "Base image required for rebase" "apt-layer"
|
|
log_info "Usage: apt-layer ostree rebase <base-image> [deployment-name]" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
shift 2
|
|
ostree_rebase "$new_base" "$deployment_name"
|
|
;;
|
|
layer)
|
|
shift 2
|
|
if [[ $# -eq 0 ]]; then
|
|
log_error "Packages required for layering" "apt-layer"
|
|
log_info "Usage: apt-layer ostree layer <package1> [package2] ..." "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
ostree_layer "$@"
|
|
;;
|
|
override)
|
|
local package_name="${3:-}"
|
|
local override_path="${4:-}"
|
|
if [[ -z "$package_name" ]] || [[ -z "$override_path" ]]; then
|
|
log_error "Package name and override path required" "apt-layer"
|
|
log_info "Usage: apt-layer ostree override <package> <path-to-deb>" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
shift 2
|
|
ostree_override "$package_name" "$override_path"
|
|
;;
|
|
deploy)
|
|
local deployment_name="${3:-}"
|
|
if [[ -z "$deployment_name" ]]; then
|
|
log_error "Deployment name required" "apt-layer"
|
|
log_info "Usage: apt-layer ostree deploy <deployment-name>" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
shift 2
|
|
ostree_deploy "$deployment_name"
|
|
;;
|
|
compose)
|
|
local compose_action="${3:-}"
|
|
shift 3
|
|
case "$compose_action" in
|
|
tree)
|
|
local config_file="${1:-}"
|
|
if [[ -z "$config_file" ]]; then
|
|
log_error "Configuration file required" "apt-layer"
|
|
log_info "Usage: apt-layer ostree compose tree <config-file>" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
ostree_compose_tree "$config_file"
|
|
;;
|
|
install)
|
|
ostree_compose_install "$@"
|
|
;;
|
|
remove)
|
|
ostree_compose_remove "$@"
|
|
;;
|
|
update)
|
|
ostree_compose_update "$@"
|
|
;;
|
|
*)
|
|
log_error "Invalid compose action: $compose_action" "apt-layer"
|
|
log_info "Valid actions: tree, install, remove, update" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
;;
|
|
layer-metadata)
|
|
local package="${3:-}"
|
|
local preserve_metadata="${4:-true}"
|
|
local resolve_conflicts="${5:-keep-latest}"
|
|
if [[ -z "$package" ]]; then
|
|
log_error "Package required for metadata-aware layering" "apt-layer"
|
|
log_info "Usage: apt-layer ostree layer-metadata <package> [preserve-metadata] [resolve-conflicts]" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
shift 2
|
|
ostree_layer_with_metadata "$package" "$preserve_metadata" "$resolve_conflicts"
|
|
;;
|
|
layer-multiarch)
|
|
local package="${3:-}"
|
|
local arch="${4:-amd64}"
|
|
local multiarch_type="${5:-same}"
|
|
if [[ -z "$package" ]]; then
|
|
log_error "Package required for multi-arch layering" "apt-layer"
|
|
log_info "Usage: apt-layer ostree layer-multiarch <package> [arch] [multiarch-type]" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
shift 2
|
|
ostree_layer_multiarch "$package" "$arch" "$multiarch_type"
|
|
;;
|
|
layer-scripts)
|
|
local package="${3:-}"
|
|
local script_context="${4:-offline}"
|
|
if [[ -z "$package" ]]; then
|
|
log_error "Package required for script-aware layering" "apt-layer"
|
|
log_info "Usage: apt-layer ostree layer-scripts <package> [script-context]" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
shift 2
|
|
ostree_layer_with_script_validation "$package" "$script_context"
|
|
;;
|
|
log)
|
|
shift 2
|
|
ostree_log "$@"
|
|
;;
|
|
diff)
|
|
shift 2
|
|
ostree_diff "$@"
|
|
;;
|
|
rollback)
|
|
shift 2
|
|
ostree_rollback "$@"
|
|
;;
|
|
status)
|
|
shift 2
|
|
ostree_status "$@"
|
|
;;
|
|
*)
|
|
log_error "Invalid ostree subcommand: $subcommand" "apt-layer"
|
|
log_info "Valid subcommands: rebase, layer, override, deploy, compose, layer-metadata, layer-multiarch, layer-scripts, log, diff, rollback, status" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
exit 0
|
|
;;
|
|
*)
|
|
# Check for empty argument
|
|
if [ -z "${1:-}" ]; then
|
|
log_error "No command specified" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
|
|
# Regular layer creation (legacy mode)
|
|
if [ $# -lt 2 ]; then
|
|
log_error "Insufficient arguments for layer creation" "apt-layer"
|
|
show_usage
|
|
exit 1
|
|
fi
|
|
|
|
local base_image="$1"
|
|
local new_image="$2"
|
|
shift 2
|
|
local packages=("$@")
|
|
|
|
create_layer "$base_image" "$new_image" "${packages[@]}"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
# Run main function
|
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
main "$@"
|
|
fi
|