diff --git a/docs/ci-menu.md b/docs/ci-menu.md new file mode 100644 index 00000000..e7e7abd8 --- /dev/null +++ b/docs/ci-menu.md @@ -0,0 +1,361 @@ +# apt-ostree CI/CD Pipeline Menu + +## Overview + +This document outlines the comprehensive CI/CD pipeline for apt-ostree, designed to ensure code quality, build reliability, and comprehensive testing across multiple platforms and scenarios. + +## πŸ—οΈ CI Pipeline Architecture + +### Core Principles +- **Multi-stage testing**: Build β†’ Test β†’ Package β†’ Deploy +- **Cross-platform support**: Debian, Ubuntu, and derivatives +- **Quality gates**: Code style, security, performance, and integration tests +- **Automated packaging**: Debian package generation and publishing +- **Comprehensive validation**: Unit tests, integration tests, and end-to-end scenarios + +## πŸ“‹ CI Jobs Menu + +### 1. **Build & Compilation Jobs** + +#### 1.1 Primary Build +- **Name**: `build` +- **Purpose**: Core Rust compilation and binary generation +- **Platform**: Ubuntu latest (rust:trixie container) +- **Key Features**: + - Rust toolchain validation + - Dependency resolution + - Binary compilation + - Artifact generation + +#### 1.2 Cross-Compilation Builds +- **Name**: `build-cross-*` +- **Purpose**: Multi-architecture support +- **Targets**: amd64, arm64, armhf +- **Features**: + - Architecture-specific toolchains + - Cross-compilation validation + - Platform-specific optimizations + +#### 1.3 Debug Build +- **Name**: `build-debug` +- **Purpose**: Development and debugging support +- **Features**: + - Debug symbols + - Development tooling + - Testing artifacts + +### 2. **Quality Assurance Jobs** + +#### 2.1 Code Style & Linting +- **Name**: `code-quality` +- **Purpose**: Code consistency and style enforcement +- **Tools**: + - `cargo fmt` - Rust formatting + - `cargo clippy` - Linting and best practices + - `yamllint` - YAML validation + - Shell script validation + +#### 2.2 Security Scanning +- **Name**: `security-audit` +- **Purpose**: Vulnerability detection and security validation +- **Tools**: + - `cargo audit` - Rust dependency security + - `cargo deny` - License and security policy + - Dependency vulnerability scanning + +#### 2.3 Static Analysis +- **Name**: `static-analysis` +- **Purpose**: Code quality and potential issue detection +- **Tools**: + - `cargo check` - Compilation validation + - Dead code detection + - Unused import analysis + +### 3. **Testing Jobs** + +#### 3.1 Unit Tests +- **Name**: `unit-tests` +- **Purpose**: Individual component validation +- **Coverage**: + - Core functionality tests + - Error handling validation + - Edge case testing + - Mock data validation + +#### 3.2 Integration Tests +- **Name**: `integration-tests` +- **Purpose**: Component interaction validation +- **Scenarios**: + - APT integration testing + - OSTree operation validation + - Package management workflows + - Configuration handling + +#### 3.3 End-to-End Tests +- **Name**: `e2e-tests` +- **Purpose**: Complete workflow validation +- **Test Cases**: + - Package installation workflows + - System upgrade scenarios + - Rollback operations + - Error recovery paths + +### 4. **Packaging Jobs** + +#### 4.1 Debian Package Generation +- **Name**: `package-debian` +- **Purpose**: Debian package creation and validation +- **Features**: + - Multi-architecture package generation + - Dependency validation + - Package metadata verification + - Lintian quality checks + +#### 4.2 Package Publishing +- **Name**: `publish-packages` +- **Purpose**: Distribution and deployment +- **Targets**: + - Forgejo Debian Registry + - GitHub Releases + - Package repository updates + +### 5. **Integration & Compatibility Jobs** + +#### 5.1 OSTree Integration +- **Name**: `ostree-integration` +- **Purpose**: OSTree system compatibility validation +- **Tests**: + - OSTree repository operations + - Deployment workflows + - Rollback mechanisms + - System integration + +#### 5.2 APT Compatibility +- **Name**: `apt-compatibility` +- **Purpose**: APT system integration validation +- **Validation**: + - Package database operations + - Dependency resolution + - Repository management + - Configuration handling + +#### 5.3 Cross-Platform Testing +- **Name**: `cross-platform` +- **Purpose**: Multi-distribution compatibility +- **Platforms**: + - Debian (stable, testing, unstable) + - Ubuntu (LTS, current, development) + - Derivatives (Pop!_OS, Linux Mint, etc.) + +### 6. **Performance & Reliability Jobs** + +#### 6.1 Performance Testing +- **Name**: `performance` +- **Purpose**: Performance validation and optimization +- **Metrics**: + - Build time optimization + - Runtime performance + - Memory usage analysis + - CPU utilization + +#### 6.2 Reliability Testing +- **Name**: `reliability` +- **Purpose**: Stability and error handling validation +- **Tests**: + - Long-running operation stability + - Error recovery mechanisms + - Resource cleanup validation + - Concurrent operation handling + +### 7. **Documentation & Release Jobs** + +#### 7.1 Documentation Generation +- **Name**: `docs` +- **Purpose**: Documentation validation and generation +- **Content**: + - API documentation + - User guides + - CLI reference + - Development documentation + +#### 7.2 Release Management +- **Name**: `release` +- **Purpose**: Release automation and validation +- **Features**: + - Version bumping + - Changelog generation + - Release notes creation + - Tag management + +## πŸ”§ CI Configuration + +### Environment Variables +```yaml +# Build Configuration +CARGO_TERM_COLOR: always +RUST_BACKTRACE: 1 +DEB_BUILD_OPTIONS: "parallel=$(nproc)" + +# Version Information +BUILD_VERSION: ${{ github.run_number }} +COMMIT_HASH: ${{ github.sha }} +BUILD_NUMBER: ${{ github.run_number }} + +# Package Configuration +PACKAGE_NAME: apt-ostree +PACKAGE_VERSION: 0.1.0 +``` + +### Container Images +- **Primary**: `rust:trixie` (Debian-based Rust environment) +- **Testing**: `debian:trixie-slim` (minimal testing environment) +- **Cross-compilation**: Architecture-specific toolchains + +### Dependencies +```bash +# Core Build Dependencies +rustc, cargo, build-essential +crossbuild-essential-*, gcc-*-linux-gnu + +# Development Tools +lintian, devscripts, debhelper +git, curl, wget + +# Testing Dependencies +podman, docker.io +qemu-user-static, binfmt-support +``` + +## πŸ“Š Testing Strategy + +### Test Categories + +#### 1. **Unit Tests** +- **Scope**: Individual functions and methods +- **Coverage**: Core business logic +- **Tools**: `cargo test` +- **Execution**: Fast, isolated, repeatable + +#### 2. **Integration Tests** +- **Scope**: Component interactions +- **Coverage**: API boundaries and workflows +- **Tools**: Custom test frameworks +- **Execution**: Medium speed, component-level + +#### 3. **System Tests** +- **Scope**: End-to-end workflows +- **Coverage**: Complete user scenarios +- **Tools**: Container-based testing +- **Execution**: Slower, system-level validation + +#### 4. **Compatibility Tests** +- **Scope**: Platform and distribution support +- **Coverage**: Multi-environment validation +- **Tools**: Matrix testing +- **Execution**: Parallel, environment-specific + +### Test Execution Flow + +```mermaid +graph TD + A[Code Commit] --> B[Build Validation] + B --> C[Unit Tests] + C --> D[Integration Tests] + D --> E[System Tests] + E --> F[Package Generation] + F --> G[Quality Checks] + G --> H[Publishing] + H --> I[Deployment Validation] +``` + +## πŸš€ Deployment Pipeline + +### Stages + +#### 1. **Development** +- **Trigger**: Pull requests +- **Purpose**: Pre-merge validation +- **Actions**: Build, test, quality checks + +#### 2. **Staging** +- **Trigger**: Merge to main +- **Purpose**: Pre-release validation +- **Actions**: Full test suite, package generation + +#### 3. **Production** +- **Trigger**: Release tags +- **Purpose**: Production deployment +- **Actions**: Package publishing, distribution + +### Quality Gates + +#### 1. **Build Success** +- All compilation steps must pass +- No critical warnings or errors +- Dependency resolution successful + +#### 2. **Test Coverage** +- Minimum 80% code coverage +- All critical paths tested +- No failing tests + +#### 3. **Quality Standards** +- Lintian checks pass +- Security scans clean +- Performance benchmarks met + +#### 4. **Integration Validation** +- OSTree operations successful +- APT integration working +- Cross-platform compatibility + +## πŸ“ˆ Monitoring & Metrics + +### Key Metrics +- **Build Success Rate**: Target >95% +- **Test Pass Rate**: Target >98% +- **Build Time**: Target <15 minutes +- **Package Quality Score**: Target >9.0 + +### Monitoring Tools +- **CI Dashboard**: Forgejo Actions +- **Test Results**: Automated reporting +- **Performance Metrics**: Build time tracking +- **Quality Metrics**: Lintian scores + +## πŸ”„ Continuous Improvement + +### Feedback Loops +1. **Automated Testing**: Immediate feedback on code changes +2. **Quality Gates**: Prevent regression introduction +3. **Performance Monitoring**: Identify optimization opportunities +4. **User Feedback**: Real-world usage validation + +### Optimization Areas +- **Build Time**: Parallelization and caching +- **Test Coverage**: Comprehensive scenario coverage +- **Quality Standards**: Automated enforcement +- **Deployment Speed**: Streamlined publishing + +## πŸ“š Additional Resources + +### Documentation +- [Development Setup](development-setup.md) +- [Testing Guide](testing-guide.md) +- [Package Management](package-management.md) +- [Troubleshooting](troubleshooting.md) + +### Tools & Scripts +- `ci/build.sh` - Build automation +- `ci/test.sh` - Test execution +- `ci/package.sh` - Package generation +- `ci/deploy.sh` - Deployment automation + +### External References +- [rpm-ostree CI](https://github.com/coreos/rpm-ostree/tree/main/.github/workflows) +- [Debian Packaging](https://www.debian.org/doc/manuals/debmake-doc/) +- [Rust CI Best Practices](https://rust-lang.github.io/rustup/concepts/channels.html) + +--- + +*This CI menu provides a comprehensive overview of the apt-ostree continuous integration and deployment pipeline. For specific implementation details, refer to the individual job configurations and scripts.* diff --git a/docs/cli-manual-mapping.md b/docs/cli-manual-mapping.md new file mode 100644 index 00000000..07c8111a --- /dev/null +++ b/docs/cli-manual-mapping.md @@ -0,0 +1,733 @@ +# apt-ostree CLI Manual Mapping + +## Overview + +This document provides a complete mapping of rpm-ostree CLI commands and options to ensure apt-ostree maintains 100% compatibility. Based on the [rpm-ostree documentation](https://coreos.github.io/rpm-ostree/) and command analysis. + +## 🎯 Core Philosophy + +apt-ostree aims to be a **hybrid image/package system** that combines: +- **OSTree** as the base image format (atomic, versioned, checksummed) +- **APT** package management (Debian/Ubuntu ecosystem) +- **Client-side package layering** and overrides +- **Transactional updates** with atomic rollback capability + +**⚠️ Important**: Most apt-ostree commands require elevated privileges (sudo) as they modify system state, boot configuration, and OSTree deployments. Only read-only operations like `status`, `search`, and help commands can run without privileges. + +## πŸ“‹ Complete CLI Command Reference + +### **Basic Commands** + +#### `apt-ostree` (no arguments) +- **Purpose**: Show usage information +- **Expected Output**: Command list and basic help +- **rpm-ostree Equivalent**: `rpm-ostree` +- **Status**: βœ… Implemented + +#### `apt-ostree --version` +- **Purpose**: Display version information +- **Expected Output**: Version, copyright, license +- **rpm-ostree Equivalent**: `rpm-ostree --version` +- **Status**: βœ… Implemented + +#### `apt-ostree --help` / `apt-ostree -h` +- **Purpose**: Display help information +- **Expected Output**: Full command reference +- **rpm-ostree Equivalent**: `rpm-ostree --help` +- **Status**: βœ… Implemented + +#### `apt-ostree -q` / `apt-ostree --quiet` +- **Purpose**: Reduce output verbosity +- **Expected Output**: Minimal output +- **rpm-ostree Equivalent**: `rpm-ostree -q` +- **Status**: βœ… Implemented + +### **System Status Commands** + +#### `apt-ostree status` +- **Purpose**: Show current system status +- **Expected Output**: Deployment information, boot status +- **rpm-ostree Equivalent**: `rpm-ostree status` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟒 No privileges required (read-only) +- **Options**: + - `--json` - JSON output format + - `--peer` - Force peer-to-peer connection + - `--sysroot=SYSROOT` - Use specific system root + +#### `apt-ostree status --help` +- **Purpose**: Show status command help +- **Expected Output**: Status command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree status --help` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟒 No privileges required (read-only) + +### **Package Management Commands** + +#### `apt-ostree install ` +- **Purpose**: Install package (atomic overlay) +- **Expected Output**: Installation progress and result +- **rpm-ostree Equivalent**: `rpm-ostree install ` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) +- **Options**: + - `--allow-inactive` - Allow inactive packages + - `--apply-live` - Apply changes immediately + - `--cache-only` - Use only cached packages + - `--force-replacefiles` - Force file replacement + - `--idempotent` - Skip if already installed + - `--reboot` - Reboot after installation + - `--dry-run` - Show what would be done + +#### `apt-ostree install --help` +- **Purpose**: Show install command help +- **Expected Output**: Install command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree install --help` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟒 No privileges required (read-only) + +#### `apt-ostree uninstall ` +- **Purpose**: Remove package (atomic overlay) +- **Expected Output**: Removal progress and result +- **rpm-ostree Equivalent**: `rpm-ostree uninstall ` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) +- **Options**: + - `--reboot` - Reboot after removal + - `--dry-run` - Show what would be done + +#### `apt-ostree uninstall --help` +- **Purpose**: Show uninstall command help +- **Expected Output**: Uninstall command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree uninstall --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +### **System Update Commands** + +#### `apt-ostree upgrade` +- **Purpose**: Perform system upgrade (atomic) +- **Expected Output**: Upgrade progress and result +- **rpm-ostree Equivalent**: `rpm-ostree upgrade` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) +- **Options**: + - `--allow-downgrade` - Allow version downgrades + - `--cache-only` - Use only cached packages + - `--check` - Check for available updates + - `--download-only` - Download without installing + - `--reboot` - Reboot after upgrade + - `--dry-run` - Show what would be done + +#### `apt-ostree upgrade --help` +- **Purpose**: Show upgrade command help +- **Expected Output**: Upgrade command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree upgrade --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +#### `apt-ostree rollback` +- **Purpose**: Rollback to previous deployment +- **Expected Output**: Rollback progress and result +- **rpm-ostree Equivalent**: `rpm-ostree rollback` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) +- **Options**: + - `--reboot` - Reboot after rollback + - `--dry-run` - Show what would be done + +#### `apt-ostree rollback --help` +- **Purpose**: Show rollback command help +- **Expected Output**: Rollback command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree rollback --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +### **Package Search Commands** + +#### `apt-ostree search ` +- **Purpose**: Search for available packages +- **Expected Output**: Package list matching query +- **rpm-ostree Equivalent**: `rpm-ostree search ` +- **Status**: βœ… Implemented (basic functionality) +- **Privileges**: 🟒 No privileges required (read-only) +- **Options**: + - `--repo=REPO` - Search specific repository + - `--show-duplicates` - Show duplicate packages + - `--quiet` - Minimal output + +#### `apt-ostree search --help` +- **Purpose**: Show search command help +- **Expected Output**: Search command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree search --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +### **Deployment Commands** + +#### `apt-ostree deploy ` +- **Purpose**: Deploy specific commit +- **Expected Output**: Deployment progress and result +- **rpm-ostree Equivalent**: `rpm-ostree deploy ` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) +- **Options**: + - `--reboot` - Reboot after deployment + - `--dry-run` - Show what would be done + +#### `apt-ostree deploy --help` +- **Purpose**: Show deploy command help +- **Expected Output**: Deploy command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree deploy --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +#### `apt-ostree rebase ` +- **Purpose**: Switch to different tree/branch +- **Expected Output**: Rebase progress and result +- **rpm-ostree Equivalent**: `rpm-ostree rebase ` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) +- **Options**: + - `--reboot` - Reboot after rebase + - `--dry-run` - Show what would be done + +#### `apt-ostree rebase --help` +- **Purpose**: Show rebase command help +- **Expected Output**: Rebase command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree rebase --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +### **Transaction Management Commands** + +#### `apt-ostree cancel` +- **Purpose**: Cancel active transaction +- **Expected Output**: Transaction cancellation result +- **rpm-ostree Equivalent**: `rpm-ostree cancel` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) +- **Options**: + - `--peer` - Force peer-to-peer connection + - `--sysroot=SYSROOT` - Use specific system root + +#### `apt-ostree cancel --help` +- **Purpose**: Show cancel command help +- **Expected Output**: Cancel command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree cancel --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +#### `apt-ostree cleanup` +- **Purpose**: Clear cached/pending data +- **Expected Output**: Cleanup progress and result +- **rpm-ostree Equivalent**: `rpm-ostree cleanup` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) +- **Options**: + - `--base` - Clean base deployments + - `--rollback` - Clean rollback deployments + +#### `apt-ostree cleanup --help` +- **Purpose**: Show cleanup command help +- **Expected Output**: Cleanup command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree cleanup --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +### **Live Update Commands** + +#### `apt-ostree apply-live` +- **Purpose**: Apply pending deployment changes +- **Expected Output**: Live update progress and result +- **rpm-ostree Equivalent**: `rpm-ostree apply-live` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) +- **Options**: + - `--target` - Apply specific target + - `--dry-run` - Show what would be done + +#### `apt-ostree apply-live --help` +- **Purpose**: Show apply-live command help +- **Expected Output**: Apply-live command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree apply-live --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +### **Finalization Commands** + +#### `apt-ostree finalize-deployment` +- **Purpose**: Finalize staged deployment +- **Expected Output**: Finalization result +- **rpm-ostree Equivalent**: `rpm-ostree finalize-deployment` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) +- **Options**: + - `--reboot` - Reboot after finalization + +#### `apt-ostree finalize-deployment --help` +- **Purpose**: Show finalize-deployment command help +- **Expected Output**: Finalize-deployment command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree finalize-deployment --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +### **Configuration Commands** + +#### `apt-ostree reload` +- **Purpose**: Reload configuration +- **Expected Output**: Reload result +- **rpm-ostree Equivalent**: `rpm-ostree reload` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) + +#### `apt-ostree reload --help` +- **Purpose**: Show reload command help +- **Expected Output**: Reload command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree reload --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +#### `apt-ostree reset` +- **Purpose**: Remove all mutations +- **Expected Output**: Reset progress and result +- **rpm-ostree Equivalent**: `rpm-ostree reset` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) +- **Options**: + - `--reboot` - Reboot after reset + - `--dry-run` - Show what would be done + +#### `apt-ostree reset --help` +- **Purpose**: Show reset command help +- **Expected Output**: Reset command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree reset --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +### **Metadata Commands** + +#### `apt-ostree refresh-md` +- **Purpose**: Generate repository metadata +- **Expected Output**: Metadata generation result +- **rpm-ostree Equivalent**: `rpm-ostree refresh-md` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) + +#### `apt-ostree refresh-md --help` +- **Purpose**: Show refresh-md command help +- **Expected Output**: Refresh-md command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree refresh-md --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +### **Subcommand Groups** + +#### `apt-ostree compose` +- **Purpose**: Compose commands +- **Expected Output**: Compose subcommand list +- **rpm-ostree Equivalent**: `rpm-ostree compose` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) +- **Subcommands**: + - `start` - Start compose operation + - `status` - Show compose status + - `cancel` - Cancel compose operation + +#### `apt-ostree compose --help` +- **Purpose**: Show compose command help +- **Expected Output**: Compose command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree compose --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +#### `apt-ostree db` +- **Purpose**: Database commands +- **Expected Output**: Database subcommand list +- **rpm-ostree Equivalent**: `rpm-ostree db` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟒 No privileges required (read-only) +- **Subcommands**: + - `list` - List database contents + - `diff` - Show database differences + +#### `apt-ostree db --help` +- **Purpose**: Show db command help +- **Expected Output**: Db command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree db --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +#### `apt-ostree initramfs` +- **Purpose**: Initramfs commands +- **Expected Output**: Initramfs subcommand list +- **rpm-ostree Equivalent**: `rpm-ostree initramfs` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) +- **Subcommands**: + - `enable` - Enable initramfs regeneration + - `disable` - Disable initramfs regeneration + +#### `apt-ostree initramfs --help` +- **Purpose**: Show initramfs command help +- **Expected Output**: Initramfs command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree initramfs --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +#### `apt-ostree initramfs-etc` +- **Purpose**: Initramfs-etc commands +- **Expected Output**: Initramfs-etc subcommand list +- **rpm-ostree Equivalent**: `rpm-ostree initramfs-etc` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) +- **Subcommands**: + - `add` - Add files to initramfs + - `remove` - Remove files from initramfs + +#### `apt-ostree initramfs-etc --help` +- **Purpose**: Show initramfs-etc command help +- **Expected Output**: Initramfs-etc command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree initramfs-etc --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +#### `apt-ostree kargs` +- **Purpose**: Kernel arguments commands +- **Expected Output**: Kargs subcommand list +- **rpm-ostree Equivalent**: `rpm-ostree kargs` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) +- **Subcommands**: + - `get` - Get kernel arguments + - `set` - Set kernel arguments + - `delete` - Delete kernel arguments + +#### `apt-ostree kargs --help` +- **Purpose**: Show kargs command help +- **Expected Output**: Kargs command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree kargs --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +#### `apt-ostree override` +- **Purpose**: Override commands +- **Expected Output**: Override subcommand list +- **rpm-ostree Equivalent**: `rpm-ostree override` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) +- **Subcommands**: + - `add` - Add package override + - `remove` - Remove package override + - `reset` - Reset all overrides + - `replace` - Replace package with URL + +#### `apt-ostree override --help` +- **Purpose**: Show override command help +- **Expected Output**: Override command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree override --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +#### `apt-ostree usroverlay` +- **Purpose**: USR overlay commands +- **Expected Output**: Usroverlay subcommand list +- **rpm-ostree Equivalent**: `rpm-ostree usroverlay` +- **Status**: πŸ”§ Placeholder (needs implementation) +- **Privileges**: 🟑 Elevated privileges required (sudo) +- **Subcommands**: + - `apply` - Apply transient overlay + - `remove` - Remove transient overlay + +#### `apt-ostree usroverlay --help` +- **Purpose**: Show usroverlay command help +- **Expected Output**: Usroverlay command options and usage +- **rpm-ostree Equivalent**: `rpm-ostree usroverlay --help` +- **Status**: πŸ”§ Placeholder (needs implementation) + +## πŸ”§ Global Options + +### **System Options** +- `--sysroot=SYSROOT` - Use specific system root (default: /) +- `--peer` - Force peer-to-peer connection instead of system message bus + +### **Output Options** +- `--json` - JSON output format +- `--quiet` / `-q` - Reduce output verbosity +- `--verbose` / `-v` - Increase output verbosity + +### **Debug Options** +- `--debug` - Enable debug output +- `--trace` - Enable trace output + +## πŸ” Privilege Requirements + +### **🟒 No Privileges Required (Read-Only)** +- `--version`, `--help`, `-h` - Basic information +- `status` - System status (read-only) +- `search ` - Package search +- `db list` - Database listing +- `db diff` - Database differences + +### **🟑 Elevated Privileges Required (sudo)** +- `install ` - Package installation (modifies system) +- `uninstall ` - Package removal (modifies system) +- `upgrade` - System upgrade (modifies system) +- `rollback` - System rollback (modifies boot configuration) +- `deploy ` - Deploy specific commit (modifies system) +- `rebase ` - Switch tree/branch (modifies system) +- `apply-live` - Apply pending changes (modifies running system) +- `finalize-deployment` - Finalize deployment (modifies system) +- `cancel` - Cancel transaction (modifies system state) +- `cleanup` - Clear cached data (modifies system) +- `reload` - Reload configuration (modifies system) +- `reset` - Remove mutations (modifies system) +- `refresh-md` - Generate metadata (modifies repository data) +- `compose` - Compose operations (modifies system) +- `initramfs` - Initramfs management (modifies boot) +- `initramfs-etc` - Initramfs file management (modifies boot) +- `kargs` - Kernel arguments (modifies boot configuration) +- `override` - Package overrides (modifies system) +- `usroverlay` - USR overlay (modifies filesystem) + +### **πŸ”΄ Root Privileges Required** +- All commands that modify the system state +- Commands that interact with OSTree admin operations +- Commands that modify bootloader configuration +- Commands that create/delete deployments + +## πŸ“– Complete Help System Mapping + +### **πŸ” Main Help Commands** + +#### `apt-ostree --help` / `apt-ostree -h` +- **Purpose**: Show main help and command list +- **Expected Output**: Complete command reference +- **rpm-ostree Equivalent**: `rpm-ostree --help` +- **Status**: βœ… Implemented +- **Privileges**: 🟒 No privileges required + +#### `apt-ostree help` +- **Purpose**: Show main help (subcommand version) +- **Expected Output**: Same as `--help` +- **rpm-ostree Equivalent**: `rpm-ostree help` +- **Status**: βœ… Implemented +- **Privileges**: 🟒 No privileges required + +### **πŸ“š Command-Specific Help** + +#### **System Status Commands** +- `apt-ostree status --help` - Status command options +- `apt-ostree status -h` - Short help for status + +#### **Package Management Commands** +- `apt-ostree install --help` - Install command options +- `apt-ostree install -h` - Short help for install +- `apt-ostree uninstall --help` - Uninstall command options +- `apt-ostree uninstall -h` - Short help for uninstall + +#### **System Update Commands** +- `apt-ostree upgrade --help` - Upgrade command options +- `apt-ostree upgrade -h` - Short help for upgrade +- `apt-ostree rollback --help` - Rollback command options +- `apt-ostree rollback -h` - Short help for rollback + +#### **Package Search Commands** +- `apt-ostree search --help` - Search command options +- `apt-ostree search -h` - Short help for search + +#### **Deployment Commands** +- `apt-ostree deploy --help` - Deploy command options +- `apt-ostree deploy -h` - Short help for deploy +- `apt-ostree rebase --help` - Rebase command options +- `apt-ostree rebase -h` - Short help for rebase + +#### **Transaction Management Commands** +- `apt-ostree cancel --help` - Cancel command options +- `apt-ostree cancel -h` - Short help for cancel +- `apt-ostree cleanup --help` - Cleanup command options +- `apt-ostree cleanup -h` - Short help for cleanup + +#### **Live Update Commands** +- `apt-ostree apply-live --help` - Apply-live command options +- `apt-ostree apply-live -h` - Short help for apply-live + +#### **Finalization Commands** +- `apt-ostree finalize-deployment --help` - Finalize-deployment options +- `apt-ostree finalize-deployment -h` - Short help for finalize-deployment + +#### **Configuration Commands** +- `apt-ostree reload --help` - Reload command options +- `apt-ostree reload -h` - Short help for reload +- `apt-ostree reset --help` - Reset command options +- `apt-ostree reset -h` - Short help for reset + +#### **Metadata Commands** +- `apt-ostree refresh-md --help` - Refresh-md command options +- `apt-ostree refresh-md -h` - Short help for refresh-md + +### **πŸ”§ Subcommand Group Help** + +#### **Compose Commands** +- `apt-ostree compose --help` - Compose subcommand list +- `apt-ostree compose -h` - Short help for compose +- `apt-ostree compose start --help` - Start compose options +- `apt-ostree compose status --help` - Status compose options +- `apt-ostree compose cancel --help` - Cancel compose options + +#### **Database Commands** +- `apt-ostree db --help` - Database subcommand list +- `apt-ostree db -h` - Short help for db +- `apt-ostree db list --help` - List database options +- `apt-ostree db diff --help` - Diff database options + +#### **Initramfs Commands** +- `apt-ostree initramfs --help` - Initramfs subcommand list +- `apt-ostree initramfs -h` - Short help for initramfs +- `apt-ostree initramfs enable --help` - Enable initramfs options +- `apt-ostree initramfs disable --help` - Disable initramfs options + +#### **Initramfs-etc Commands** +- `apt-ostree initramfs-etc --help` - Initramfs-etc subcommand list +- `apt-ostree initramfs-etc -h` - Short help for initramfs-etc +- `apt-ostree initramfs-etc add --help` - Add initramfs-etc options +- `apt-ostree initramfs-etc remove --help` - Remove initramfs-etc options + +#### **Kernel Arguments Commands** +- `apt-ostree kargs --help` - Kargs subcommand list +- `apt-ostree kargs -h` - Short help for kargs +- `apt-ostree kargs get --help` - Get kargs options +- `apt-ostree kargs set --help` - Set kargs options +- `apt-ostree kargs delete --help` - Delete kargs options + +#### **Override Commands** +- `apt-ostree override --help` - Override subcommand list +- `apt-ostree override -h` - Short help for override +- `apt-ostree override add --help` - Add override options +- `apt-ostree override remove --help` - Remove override options +- `apt-ostree override reset --help` - Reset override options +- `apt-ostree override replace --help` - Replace override options + +#### **USR Overlay Commands** +- `apt-ostree usroverlay --help` - Usroverlay subcommand list +- `apt-ostree usroverlay -h` - Short help for usroverlay +- `apt-ostree usroverlay apply --help` - Apply usroverlay options +- `apt-ostree usroverlay remove --help` - Remove usroverlay options + +### **βš™οΈ Option-Specific Help** + +#### **Global Options Help** +- `apt-ostree --sysroot=/ --help` - Help with sysroot option +- `apt-ostree --peer --help` - Help with peer option +- `apt-ostree --version --help` - Help with version option +- `apt-ostree -q --help` - Help with quiet option + +#### **Command-Specific Options Help** +- `apt-ostree status --json --help` - Help with JSON output +- `apt-ostree status --peer --help` - Help with peer connection +- `apt-ostree install --reboot --help` - Help with reboot option +- `apt-ostree install --dry-run --help` - Help with dry-run option +- `apt-ostree upgrade --check --help` - Help with check option +- `apt-ostree rollback --dry-run --help` - Help with dry-run option + +### **πŸ“‹ Help Output Structure** + +#### **Standard Help Format** +``` +Usage: + apt-ostree COMMAND [OPTION…] + +Command description + +Help Options: + -h, --help Show help options + +Application Options: + --sysroot=SYSROOT Use system root SYSROOT (default: /) + --peer Force peer-to-peer connection + --version Print version information and exit + -q, --quiet Avoid printing most informational messages +``` + +#### **Subcommand Help Format** +``` +Usage: + apt-ostree COMMAND SUBCOMMAND [OPTION…] + +Subcommand description + +Help Options: + -h, --help Show help options + +Application Options: + --sysroot=SYSROOT Use system root SYSROOT (default: /) + --peer Force peer-to-peer connection + --version Print version information and exit + -q, --quiet Avoid printing most informational messages +``` + +### **🎯 Help Implementation Status** + +#### **βœ… Help Commands Implemented** +- Main help (`--help`, `-h`, `help`) +- Basic command structure + +#### **πŸ”§ Help Commands to Implement** +- Command-specific help (`command --help`) +- Subcommand help (`command subcommand --help`) +- Option-specific help (`--option --help`) +- Help output formatting +- Help content generation + +#### **πŸ“š Help Content to Create** +- Command descriptions +- Option explanations +- Usage examples +- Error message help +- Troubleshooting tips + +## πŸ“Š Implementation Status + +### **βœ… Fully Implemented** +- Basic command structure +- Version and help flags +- Search functionality (basic) +- Command-line argument parsing + +### **πŸ”§ Placeholder Implemented** +- All major commands have placeholder functions +- Error handling structure in place +- Logging framework ready + +### **❌ Not Yet Implemented** +- OSTree integration +- APT package management +- Transaction handling +- System operations +- Configuration management + +### **πŸ” Privilege Analysis Complete** +- **🟒 Read-Only Commands**: 5 commands (no privileges needed) +- **🟑 Elevated Privileges**: 20+ commands (sudo required) +- **πŸ”΄ Root Privileges**: All system-modifying operations + +### **πŸ“– Help System Mapping Complete** +- **πŸ” Main Help**: 3 commands (`--help`, `-h`, `help`) +- **πŸ“š Command Help**: 25+ commands with `--help` support +- **πŸ”§ Subcommand Help**: 15+ subcommands with help +- **βš™οΈ Option Help**: Global and command-specific options +- **πŸ“‹ Help Formats**: Standard and subcommand formats defined + +## πŸš€ Next Implementation Steps + +### **Phase 1: Core Infrastructure** +1. Implement OSTree manager +2. Implement APT package manager +3. Add transaction handling + +### **Phase 2: Command Implementation** +1. Implement status command +2. Implement install/uninstall commands +3. Implement upgrade/rollback commands + +### **Phase 3: Advanced Features** +1. Implement override system +2. Implement initramfs management +3. Implement kernel argument management + +### **Phase 4: Integration & Testing** +1. End-to-end testing +2. Performance optimization +3. Documentation completion + +## πŸ“š Reference Materials + +- [rpm-ostree Official Documentation](https://coreos.github.io/rpm-ostree/) +- [rpm-ostree GitHub Repository](https://github.com/coreos/rpm-ostree) +- [OSTree Documentation](https://ostreedev.github.io/ostree/) +- [APT Package Management](https://wiki.debian.org/Apt) + +--- + +*This CLI manual mapping ensures apt-ostree maintains 100% compatibility with rpm-ostree while adapting to the Debian/Ubuntu ecosystem.* diff --git a/simple_rpm_ostree_test.sh b/simple_rpm_ostree_test.sh new file mode 100755 index 00000000..179253f7 --- /dev/null +++ b/simple_rpm_ostree_test.sh @@ -0,0 +1,208 @@ +#!/bin/bash + +# Simple rpm-ostree Command Testing Script +# Run this on your rpm-ostree system to capture command outputs + +OUTPUT_FILE="rpm_ostree_output.txt" + +echo "Testing rpm-ostree commands..." > "$OUTPUT_FILE" +echo "Generated on: $(date)" >> "$OUTPUT_FILE" +echo "System: $(uname -a)" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +# Test basic commands +echo "=== BASIC COMMANDS ===" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree (no args) ---" >> "$OUTPUT_FILE" +rpm-ostree >> "$OUTPUT_FILE" 2>&1 || echo "Command failed (expected)" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree --version ---" >> "$OUTPUT_FILE" +rpm-ostree --version >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree --help ---" >> "$OUTPUT_FILE" +rpm-ostree --help >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +# Test main commands +echo "=== MAIN COMMANDS ===" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree status ---" >> "$OUTPUT_FILE" +rpm-ostree status >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree cancel ---" >> "$OUTPUT_FILE" +rpm-ostree cancel >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree cleanup ---" >> "$OUTPUT_FILE" +rpm-ostree cleanup >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree reload ---" >> "$OUTPUT_FILE" +rpm-ostree reload >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree reset ---" >> "$OUTPUT_FILE" +rpm-ostree reset >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree rollback ---" >> "$OUTPUT_FILE" +rpm-ostree rollback >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree upgrade ---" >> "$OUTPUT_FILE" +rpm-ostree upgrade >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree finalize-deployment ---" >> "$OUTPUT_FILE" +rpm-ostree finalize-deployment >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +# Test commands that require arguments +echo "=== COMMANDS WITH ARGUMENTS ===" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree search apt ---" >> "$OUTPUT_FILE" +rpm-ostree search apt >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree install vim ---" >> "$OUTPUT_FILE" +rpm-ostree install vim >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree uninstall vim ---" >> "$OUTPUT_FILE" +rpm-ostree uninstall vim >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree deploy test-commit ---" >> "$OUTPUT_FILE" +rpm-ostree deploy test-commit >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree rebase test-target ---" >> "$OUTPUT_FILE" +rpm-ostree rebase test-target >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree apply-live ---" >> "$OUTPUT_FILE" +rpm-ostree apply-live >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +# Test subcommand groups +echo "=== SUBCOMMAND GROUPS ===" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree compose ---" >> "$OUTPUT_FILE" +rpm-ostree compose >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree db ---" >> "$OUTPUT_FILE" +rpm-ostree db >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree initramfs ---" >> "$OUTPUT_FILE" +rpm-ostree initramfs >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree initramfs-etc ---" >> "$OUTPUT_FILE" +rpm-ostree initramfs-etc >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree kargs ---" >> "$OUTPUT_FILE" +rpm-ostree kargs >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree override ---" >> "$OUTPUT_FILE" +rpm-ostree override >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree usroverlay ---" >> "$OUTPUT_FILE" +rpm-ostree usroverlay >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +# Test specific subcommands +echo "=== SPECIFIC SUBCOMMANDS ===" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree db list ---" >> "$OUTPUT_FILE" +rpm-ostree db list >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree db diff ---" >> "$OUTPUT_FILE" +rpm-ostree db diff >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree kargs get ---" >> "$OUTPUT_FILE" +rpm-ostree kargs get >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree kargs set test=value ---" >> "$OUTPUT_FILE" +rpm-ostree kargs set test=value >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree override add test-package ---" >> "$OUTPUT_FILE" +rpm-ostree override add test-package >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree override remove test-package ---" >> "$OUTPUT_FILE" +rpm-ostree override remove test-package >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree override reset ---" >> "$OUTPUT_FILE" +rpm-ostree override reset >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +# Test error conditions +echo "=== ERROR CONDITIONS ===" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree install (no package) ---" >> "$OUTPUT_FILE" +rpm-ostree install >> "$OUTPUT_FILE" 2>&1 || echo "Command failed (expected)" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree search (no query) ---" >> "$OUTPUT_FILE" +rpm-ostree search >> "$OUTPUT_FILE" 2>&1 || echo "Command failed (expected)" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree deploy (no commit) ---" >> "$OUTPUT_FILE" +rpm-ostree deploy >> "$OUTPUT_FILE" 2>&1 || echo "Command failed (expected)" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree rebase (no target) ---" >> "$OUTPUT_FILE" +rpm-ostree rebase >> "$OUTPUT_FILE" 2>&1 || echo "Command failed (expected)" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +# Test with options +echo "=== COMMANDS WITH OPTIONS ===" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree status --sysroot=/ ---" >> "$OUTPUT_FILE" +rpm-ostree status --sysroot=/ >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree status --peer ---" >> "$OUTPUT_FILE" +rpm-ostree status --peer >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree status -q ---" >> "$OUTPUT_FILE" +rpm-ostree status -q >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +# Test help for specific commands +echo "=== HELP FOR SPECIFIC COMMANDS ===" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree cancel --help ---" >> "$OUTPUT_FILE" +rpm-ostree cancel --help >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree install --help ---" >> "$OUTPUT_FILE" +rpm-ostree install --help >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree search --help ---" >> "$OUTPUT_FILE" +rpm-ostree search --help >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "--- rpm-ostree status --help ---" >> "$OUTPUT_FILE" +rpm-ostree status --help >> "$OUTPUT_FILE" 2>&1 || echo "Command failed" >> "$OUTPUT_FILE" +echo "" >> "$OUTPUT_FILE" + +echo "=== TESTING COMPLETED ===" >> "$OUTPUT_FILE" +echo "Results saved to: $OUTPUT_FILE" + +echo "βœ… Testing completed! Results saved to: $OUTPUT_FILE" diff --git a/src/main.rs b/src/main.rs index f3da0a04..3eb263fe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,95 +46,178 @@ async fn main() -> AptOstreeResult<()> { // Handle subcommands (exact rpm-ostree compatibility) match command.as_str() { "apply-live" => { - apply_live().await?; + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_apply_live_help(&args[0]); + } else { + apply_live().await?; + } } "cancel" => { - cancel_transaction().await?; + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_cancel_help(&args[0]); + } else { + cancel_transaction().await?; + } } "cleanup" => { - cleanup().await?; + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_cleanup_help(&args[0]); + } else { + cleanup().await?; + } } "compose" => { - compose_commands(&args[2..]).await?; + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_compose_help(&args[0]); + } else { + compose_commands(&args[2..]).await?; + } } "db" => { - db_commands(&args[2..]).await?; + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_db_help(&args[0]); + } else { + db_commands(&args[2..]).await?; + } } "deploy" => { - if args.len() < 3 { + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_deploy_help(&args[0]); + } else if args.len() < 3 { error!("No target commit specified"); return Err(AptOstreeError::InvalidArgument("No target commit specified".to_string())); + } else { + let commit = &args[2]; + deploy_commit(commit).await?; } - let commit = &args[2]; - deploy_commit(commit).await?; } "finalize-deployment" => { - finalize_deployment().await?; + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_finalize_deployment_help(&args[0]); + } else { + finalize_deployment().await?; + } } "initramfs" => { - initramfs_commands(&args[2..]).await?; + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_initramfs_help(&args[0]); + } else { + initramfs_commands(&args[2..]).await?; + } } "initramfs-etc" => { - initramfs_etc_commands(&args[2..]).await?; + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_initramfs_etc_help(&args[0]); + } else { + initramfs_etc_commands(&args[2..]).await?; + } } "install" => { - if args.len() < 3 { + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_install_help(&args[0]); + } else if args.len() < 3 { error!("No package specified"); return Err(AptOstreeError::InvalidArgument("No package specified".to_string())); + } else { + let package_name = &args[2]; + install_package(package_name).await?; } - let package_name = &args[2]; - install_package(package_name).await?; } "kargs" => { - kargs_commands(&args[2..]).await?; + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_kargs_help(&args[0]); + } else { + kargs_commands(&args[2..]).await?; + } } "override" => { - override_commands(&args[2..]).await?; + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_override_help(&args[0]); + } else { + override_commands(&args[2..]).await?; + } } "rebase" => { - if args.len() < 3 { + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_rebase_help(&args[0]); + } else if args.len() < 3 { error!("No target specified"); return Err(AptOstreeError::InvalidArgument("No target specified".to_string())); + } else { + let target = &args[2]; + rebase_to_target(target).await?; } - let target = &args[2]; - rebase_to_target(target).await?; } "refresh-md" => { - refresh_metadata().await?; + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_refresh_md_help(&args[0]); + } else { + refresh_metadata().await?; + } } "reload" => { - reload_configuration().await?; + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_reload_help(&args[0]); + } else { + reload_configuration().await?; + } } "reset" => { - reset_mutations().await?; + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_reset_help(&args[0]); + } else { + reset_mutations().await?; + } } "rollback" => { - rollback_system().await?; + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_rollback_help(&args[0]); + } else { + rollback_system().await?; + } } "search" => { - if args.len() < 3 { + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_search_help(&args[0]); + } else if args.len() < 3 { error!("No query specified"); return Err(AptOstreeError::InvalidArgument("No query specified".to_string())); + } else { + let query = &args[2]; + search_packages(query).await?; } - let query = &args[2]; - search_packages(query).await?; } "status" => { - show_system_status().await?; + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_status_help(&args[0]); + } else { + show_system_status().await?; + } } "uninstall" => { - if args.len() < 3 { + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_uninstall_help(&args[0]); + } else if args.len() < 3 { error!("No package specified"); return Err(AptOstreeError::InvalidArgument("No package specified".to_string())); + } else { + let package_name = &args[2]; + uninstall_package(package_name).await?; } - let package_name = &args[2]; - uninstall_package(package_name).await?; } "upgrade" => { - upgrade_system().await?; + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_upgrade_help(&args[0]); + } else { + upgrade_system().await?; + } } "usroverlay" => { - usroverlay_commands(&args[2..]).await?; + if args.len() > 2 && (args[2] == "--help" || args[2] == "-h") { + show_usroverlay_help(&args[0]); + } else { + usroverlay_commands(&args[2..]).await?; + } } "help" => { show_help(&args[0]); @@ -452,3 +535,383 @@ async fn rollback_system() -> AptOstreeResult<()> { println!("rollback: Not yet implemented"); Ok(()) } + +// Help functions for each command (rpm-ostree compatible) + +fn show_apply_live_help(program_name: &str) { + println!("Usage:"); + println!(" {} apply-live [OPTION…]", program_name); + println!(""); + println!("Apply pending deployment changes to booted deployment"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); +} + +fn show_cancel_help(program_name: &str) { + println!("Usage:"); + println!(" {} cancel [OPTION…]", program_name); + println!(""); + println!("Cancel an active transaction"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); +} + +fn show_cleanup_help(program_name: &str) { + println!("Usage:"); + println!(" {} cleanup [OPTION…]", program_name); + println!(""); + println!("Clear cached/pending data"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); +} + +fn show_compose_help(program_name: &str) { + println!("Usage:"); + println!(" {} compose [OPTION…] COMMAND", program_name); + println!(""); + println!("Commands to compose a tree"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); +} + +fn show_db_help(program_name: &str) { + println!("Usage:"); + println!(" {} db [OPTION…] COMMAND", program_name); + println!(""); + println!("Commands to query the APT database"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); +} + +fn show_deploy_help(program_name: &str) { + println!("Usage:"); + println!(" {} deploy [OPTION…] COMMIT", program_name); + println!(""); + println!("Deploy a specific commit"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); + println!(" --reboot Reboot after deployment"); + println!(" --dry-run Show what would be done"); +} + +fn show_finalize_deployment_help(program_name: &str) { + println!("Usage:"); + println!(" {} finalize-deployment [OPTION…]", program_name); + println!(""); + println!("Unset the finalization locking state of the staged deployment and reboot"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); + println!(" --reboot Reboot after finalization"); +} + +fn show_initramfs_help(program_name: &str) { + println!("Usage:"); + println!(" {} initramfs [OPTION…] COMMAND", program_name); + println!(""); + println!("Enable or disable local initramfs regeneration"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); +} + +fn show_initramfs_etc_help(program_name: &str) { + println!("Usage:"); + println!(" {} initramfs-etc [OPTION…] COMMAND", program_name); + println!(""); + println!("Add files to the initramfs"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); +} + +fn show_install_help(program_name: &str) { + println!("Usage:"); + println!(" {} install [OPTION…] PACKAGE", program_name); + println!(""); + println!("Overlay additional packages"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); + println!(" --allow-inactive Allow inactive packages"); + println!(" --apply-live Apply changes immediately"); + println!(" --cache-only Use only cached packages"); + println!(" --force-replacefiles Force file replacement"); + println!(" --idempotent Skip if already installed"); + println!(" --reboot Reboot after installation"); + println!(" --dry-run Show what would be done"); +} + +fn show_kargs_help(program_name: &str) { + println!("Usage:"); + println!(" {} kargs [OPTION…] COMMAND", program_name); + println!(""); + println!("Query or modify kernel arguments"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); +} + +fn show_override_help(program_name: &str) { + println!("Usage:"); + println!(" {} override [OPTION…] COMMAND", program_name); + println!(""); + println!("Manage base package overrides"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); +} + +fn show_rebase_help(program_name: &str) { + println!("Usage:"); + println!(" {} rebase [OPTION…] TARGET", program_name); + println!(""); + println!("Switch to a different tree"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); + println!(" --reboot Reboot after rebase"); + println!(" --dry-run Show what would be done"); +} + +fn show_refresh_md_help(program_name: &str) { + println!("Usage:"); + println!(" {} refresh-md [OPTION…]", program_name); + println!(""); + println!("Generate apt repo metadata"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); +} + +fn show_reload_help(program_name: &str) { + println!("Usage:"); + println!(" {} reload [OPTION…]", program_name); + println!(""); + println!("Reload configuration"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); +} + +fn show_reset_help(program_name: &str) { + println!("Usage:"); + println!(" {} reset [OPTION…]", program_name); + println!(""); + println!("Remove all mutations"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); + println!(" --reboot Reboot after reset"); + println!(" --dry-run Show what would be done"); +} + +fn show_rollback_help(program_name: &str) { + println!("Usage:"); + println!(" {} rollback [OPTION…]", program_name); + println!(""); + println!("Revert to the previously booted tree"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); + println!(" --reboot Reboot after rollback"); + println!(" --dry-run Show what would be done"); +} + +fn show_search_help(program_name: &str) { + println!("Usage:"); + println!(" {} search [OPTION…] QUERY", program_name); + println!(""); + println!("Search for packages"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); + println!(" --repo=REPO Search specific repository"); + println!(" --show-duplicates Show duplicate packages"); +} + +fn show_status_help(program_name: &str) { + println!("Usage:"); + println!(" {} status [OPTION…]", program_name); + println!(""); + println!("Get the version of the booted system"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); + println!(" --json JSON output format"); +} + +fn show_uninstall_help(program_name: &str) { + println!("Usage:"); + println!(" {} uninstall [OPTION…] PACKAGE", program_name); + println!(""); + println!("Remove overlayed additional packages"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); + println!(" --reboot Reboot after removal"); + println!(" --dry-run Show what would be done"); +} + +fn show_upgrade_help(program_name: &str) { + println!("Usage:"); + println!(" {} upgrade [OPTION…]", program_name); + println!(""); + println!("Perform a system upgrade"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); + println!(" --allow-downgrade Allow version downgrades"); + println!(" --cache-only Use only cached packages"); + println!(" --check Check for available updates"); + println!(" --download-only Download without installing"); + println!(" --reboot Reboot after upgrade"); + println!(" --dry-run Show what would be done"); +} + +fn show_usroverlay_help(program_name: &str) { + println!("Usage:"); + println!(" {} usroverlay [OPTION…] COMMAND", program_name); + println!(""); + println!("Apply a transient overlayfs to /usr"); + println!(""); + println!("Help Options:"); + println!(" -h, --help Show help options"); + println!(""); + println!("Application Options:"); + println!(" --sysroot=SYSROOT Use system root SYSROOT (default: /)"); + println!(" --peer Force peer-to-peer connection"); + println!(" --version Print version information and exit"); + println!(" -q, --quiet Avoid printing most informational messages"); +} diff --git a/test_rpm_ostree_commands.sh b/test_rpm_ostree_commands.sh new file mode 100755 index 00000000..72966503 --- /dev/null +++ b/test_rpm_ostree_commands.sh @@ -0,0 +1,243 @@ +#!/bin/bash + +# rpm-ostree Command Testing Script +# This script tests all rpm-ostree commands and captures their output +# for comparison with apt-ostree implementation + +set -e + +# Output file +OUTPUT_FILE="rpm_ostree_commands_output.txt" +LOG_FILE="rpm_ostree_test.log" + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Function to log messages +log() { + echo -e "${BLUE}[$(date '+%Y-%m-%d %H:%M:%S')]${NC} $1" | tee -a "$LOG_FILE" +} + +# Function to test a command +test_command() { + local cmd="$1" + local description="$2" + local args="$3" + + log "Testing: $cmd $args - $description" + echo "=== $cmd $args - $description ===" >> "$OUTPUT_FILE" + echo "" >> "$OUTPUT_FILE" + + # Test without sudo + log " Testing without sudo..." + echo "--- Without sudo ---" >> "$OUTPUT_FILE" + if timeout 30s bash -c "$cmd $args" >> "$OUTPUT_FILE" 2>&1; then + echo -e "${GREEN} βœ“ Success without sudo${NC}" + else + echo -e "${YELLOW} ⚠ Failed without sudo (expected for some commands)${NC}" + fi + echo "" >> "$OUTPUT_FILE" + + # Test with sudo + log " Testing with sudo..." + echo "--- With sudo ---" >> "$OUTPUT_FILE" + if timeout 30s sudo bash -c "$cmd $args" >> "$OUTPUT_FILE" 2>&1; then + echo -e "${GREEN} βœ“ Success with sudo${NC}" + else + echo -e "${YELLOW} ⚠ Failed with sudo (expected for some commands)${NC}" + fi + echo "" >> "$OUTPUT_FILE" + + # Test --help + log " Testing --help..." + echo "--- --help output ---" >> "$OUTPUT_FILE" + if timeout 30s bash -c "$cmd --help" >> "$OUTPUT_FILE" 2>&1; then + echo -e "${GREEN} βœ“ --help successful${NC}" + else + echo -e "${RED} βœ— --help failed${NC}" + fi + echo "" >> "$OUTPUT_FILE" + + echo "==========================================" >> "$OUTPUT_FILE" + echo "" >> "$OUTPUT_FILE" + + log "Completed testing: $cmd" + echo "" +} + +# Function to test commands with arguments +test_command_with_args() { + local cmd="$1" + local description="$2" + local args="$3" + + log "Testing: $cmd $args - $description" + echo "=== $cmd $args - $description ===" >> "$OUTPUT_FILE" + echo "" >> "$OUTPUT_FILE" + + # Test without sudo + log " Testing without sudo..." + echo "--- Without sudo ---" >> "$OUTPUT_FILE" + if timeout 30s bash -c "$cmd $args" >> "$OUTPUT_FILE" 2>&1; then + echo -e "${GREEN} βœ“ Success without sudo${NC}" + else + echo -e "${YELLOW} ⚠ Failed without sudo (expected for some commands)${NC}" + fi + echo "" >> "$OUTPUT_FILE" + + # Test with sudo + log " Testing with sudo..." + echo "--- With sudo ---" >> "$OUTPUT_FILE" + if timeout 30s sudo bash -c "$cmd $args" >> "$OUTPUT_FILE" 2>&1; then + echo -e "${GREEN} βœ“ Success with sudo${NC}" + else + echo -e "${YELLOW} ⚠ Failed with sudo (expected for some commands)${NC}" + fi + echo "" >> "$OUTPUT_FILE" + + echo "==========================================" >> "$OUTPUT_FILE" + echo "" >> "$OUTPUT_FILE" + + log "Completed testing: $cmd $args" + echo "" +} + +# Main script +main() { + log "Starting rpm-ostree command testing..." + log "Output will be saved to: $OUTPUT_FILE" + log "Log will be saved to: $LOG_FILE" + + # Clear output file + > "$OUTPUT_FILE" + > "$LOG_FILE" + + # Header + echo "rpm-ostree Command Testing Results" >> "$OUTPUT_FILE" + echo "Generated on: $(date)" >> "$OUTPUT_FILE" + echo "System: $(uname -a)" >> "$OUTPUT_FILE" + echo "rpm-ostree version: $(rpm-ostree --version 2>/dev/null || echo 'Unknown')" >> "$OUTPUT_FILE" + echo "" >> "$OUTPUT_FILE" + echo "==========================================" >> "$OUTPUT_FILE" + echo "" >> "$OUTPUT_FILE" + + # Test basic commands (no arguments) + log "Testing basic commands..." + + test_command "rpm-ostree" "No arguments (should show usage)" + test_command "rpm-ostree --version" "Version information" + test_command "rpm-ostree --help" "Help information" + test_command "rpm-ostree -h" "Short help" + test_command "rpm-ostree -q" "Quiet mode" + test_command "rpm-ostree --quiet" "Quiet mode long" + + # Test commands that don't require arguments + log "Testing commands without required arguments..." + + test_command "rpm-ostree status" "System status" + test_command "rpm-ostree cancel" "Cancel transaction" + test_command "rpm-ostree cleanup" "Cleanup" + test_command "rpm-ostree reload" "Reload configuration" + test_command "rpm-ostree reset" "Reset mutations" + test_command "rpm-ostree rollback" "Rollback system" + test_command "rpm-ostree upgrade" "Upgrade system" + test_command "rpm-ostree finalize-deployment" "Finalize deployment" + + # Test commands that require arguments + log "Testing commands that require arguments..." + + test_command_with_args "rpm-ostree search" "Search packages" "apt" + test_command_with_args "rpm-ostree install" "Install package" "vim" + test_command_with_args "rpm-ostree uninstall" "Uninstall package" "vim" + test_command_with_args "rpm-ostree deploy" "Deploy commit" "test-commit" + test_command_with_args "rpm-ostree rebase" "Rebase to target" "test-target" + test_command_with_args "rpm-ostree apply-live" "Apply live changes" "" + + # Test subcommand groups + log "Testing subcommand groups..." + + test_command "rpm-ostree compose" "Compose commands" + test_command "rpm-ostree db" "Database commands" + test_command "rpm-ostree initramfs" "Initramfs commands" + test_command "rpm-ostree initramfs-etc" "Initramfs-etc commands" + test_command "rpm-ostree kargs" "Kernel args commands" + test_command "rpm-ostree override" "Override commands" + test_command "rpm-ostree usroverlay" "USR overlay commands" + + # Test specific subcommands + log "Testing specific subcommands..." + + test_command_with_args "rpm-ostree db list" "Database list" "" + test_command_with_args "rpm-ostree db diff" "Database diff" "" + test_command_with_args "rpm-ostree kargs get" "Get kernel args" "" + test_command_with_args "rpm-ostree kargs set" "Set kernel args" "test=value" + test_command_with_args "rpm-ostree override add" "Add override" "test-package" + test_command_with_args "rpm-ostree override remove" "Remove override" "test-package" + test_command_with_args "rpm-ostree override reset" "Reset overrides" "" + + # Test compose subcommands + log "Testing compose subcommands..." + + test_command "rpm-ostree compose start" "Start compose" + test_command "rpm-ostree compose status" "Compose status" + test_command "rpm-ostree compose cancel" "Cancel compose" + + # Test initramfs subcommands + log "Testing initramfs subcommands..." + + test_command "rpm-ostree initramfs enable" "Enable initramfs" + test_command "rpm-ostree initramfs disable" "Disable initramfs" + test_command "rpm-ostree initramfs-etc add" "Add initramfs-etc" + test_command "rpm-ostree initramfs-etc remove" "Remove initramfs-etc" + + # Test usroverlay subcommands + log "Testing usroverlay subcommands..." + + test_command "rpm-ostree usroverlay apply" "Apply usroverlay" + test_command "rpm-ostree usroverlay remove" "Remove usroverlay" + + # Test refresh-md + log "Testing refresh-md..." + + test_command "rpm-ostree refresh-md" "Refresh metadata" + + # Test with sysroot option + log "Testing with sysroot option..." + + test_command_with_args "rpm-ostree status" "Status with sysroot" "--sysroot=/" + test_command_with_args "rpm-ostree status" "Status with peer" "--peer" + + # Test error conditions + log "Testing error conditions..." + + test_command_with_args "rpm-ostree install" "Install without package (should fail)" "" + test_command_with_args "rpm-ostree search" "Search without query (should fail)" "" + test_command_with_args "rpm-ostree deploy" "Deploy without commit (should fail)" "" + test_command_with_args "rpm-ostree rebase" "Rebase without target (should fail)" "" + + # Test invalid commands + log "Testing invalid commands..." + + test_command "rpm-ostree invalid-command" "Invalid command (should fail)" + test_command "rpm-ostree --invalid-flag" "Invalid flag (should fail)" + + # Footer + echo "==========================================" >> "$OUTPUT_FILE" + echo "Testing completed on: $(date)" >> "$OUTPUT_FILE" + echo "Total commands tested: $(grep -c "===" "$OUTPUT_FILE")" >> "$OUTPUT_FILE" + + log "Testing completed!" + log "Results saved to: $OUTPUT_FILE" + log "Log saved to: $LOG_FILE" + + echo -e "${GREEN}βœ… All tests completed successfully!${NC}" + echo -e "${BLUE}πŸ“„ Results: $OUTPUT_FILE${NC}" + echo -e "${BLUE}πŸ“ Log: $LOG_FILE${NC}" +} + +# Run main function +main "$@"