From 5fe7b0a51943cf4a8ff48f88c2ba1b1bbb467b2e Mon Sep 17 00:00:00 2001 From: robojerk Date: Fri, 15 Aug 2025 18:18:40 -0700 Subject: [PATCH] Fix rpm-ostree compatibility and postinst script issues - Add --version and --help flags for rpm-ostree compatibility - Fix postinst script to handle 'triggered' argument properly - Maintain subcommand interface while adding flag support - Improve error messages and help text --- debian/apt-ostree.postinst | 17 ++++++++ src/main.rs | 82 ++++++++++++++++++++++++++------------ todo | 51 ++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 25 deletions(-) create mode 100644 todo diff --git a/debian/apt-ostree.postinst b/debian/apt-ostree.postinst index 3a1969d4..e79cfc07 100755 --- a/debian/apt-ostree.postinst +++ b/debian/apt-ostree.postinst @@ -127,6 +127,23 @@ EOF echo "Aborting $PACKAGE configuration..." ;; + triggered) + # Handle trigger activation (e.g., man page updates, shell completion) + echo "Handling $PACKAGE triggers..." + + # Update shell completion caches + if command -v update-bash-completion >/dev/null 2>&1; then + update-bash-completion apt-ostree || true + fi + + # Update man page database + if command -v mandb >/dev/null 2>&1; then + mandb -q || true + fi + + echo "$PACKAGE triggers handled successfully" + ;; + *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 diff --git a/src/main.rs b/src/main.rs index 1b000b70..bec2a315 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,23 +18,26 @@ async fn main() -> AptOstreeResult<()> { let args: Vec = env::args().collect(); if args.len() < 2 { - println!("Usage: {} [options]", args[0]); - println!("Commands:"); - println!(" search - Search for packages"); - println!(" list - List all packages"); - println!(" installed - List installed packages"); - println!(" info - Show package information"); - println!(" install - Install package (atomic)"); - println!(" remove - Remove package (atomic)"); - println!(" upgrade - Upgrade system (atomic)"); - println!(" status - Show system status"); - println!(" rollback - Rollback to previous deployment"); - println!(" help - Show this help"); + show_help(&args[0]); return Ok(()); } let command = &args[1]; + // Handle rpm-ostree compatible flags first + match command.as_str() { + "--version" | "-V" => { + show_version(); + return Ok(()); + } + "--help" | "-h" => { + show_help(&args[0]); + return Ok(()); + } + _ => {} + } + + // Handle subcommands (rpm-ostree style) match command.as_str() { "search" => { if args.len() < 3 { @@ -84,22 +87,14 @@ async fn main() -> AptOstreeResult<()> { rollback_system().await?; } "help" => { - println!("apt-ostree - Debian/Ubuntu equivalent of rpm-ostree"); - println!(""); - println!("Commands:"); - println!(" search - Search for packages"); - println!(" list - List all packages"); - println!(" installed - List installed packages"); - println!(" info - Show package information"); - println!(" install - Install package (atomic)"); - println!(" remove - Remove package (atomic)"); - println!(" upgrade - Upgrade system (atomic)"); - println!(" status - Show system status"); - println!(" rollback - Rollback to previous deployment"); - println!(" help - Show this help"); + show_help(&args[0]); + } + "version" => { + show_version(); } _ => { error!("Unknown command: {}", command); + println!("Try '{} --help' for more information.", args[0]); return Err(AptOstreeError::InvalidArgument(format!("Unknown command: {}", command))); } } @@ -107,6 +102,43 @@ async fn main() -> AptOstreeResult<()> { Ok(()) } +/// Show version information (rpm-ostree compatible) +fn show_version() { + println!("apt-ostree {}", env!("CARGO_PKG_VERSION")); + println!("Debian/Ubuntu equivalent of rpm-ostree"); + println!("Copyright (C) 2025 Robojerk"); + println!("License GPL-3.0-or-later: "); +} + +/// Show help information (rpm-ostree compatible) +fn show_help(program_name: &str) { + println!("Usage: {} [options]", program_name); + println!(""); + println!("Commands:"); + println!(" search - Search for packages"); + println!(" list - List all packages"); + println!(" installed - List installed packages"); + println!(" info - Show package information"); + println!(" install - Install package (atomic)"); + println!(" remove - Remove package (atomic)"); + println!(" upgrade - Upgrade system (atomic)"); + println!(" status - Show system status"); + println!(" rollback - Rollback to previous deployment"); + println!(" help - Show this help"); + println!(" version - Show version information"); + println!(""); + println!("Options:"); + println!(" --version, -V - Show version information"); + println!(" --help, -h - Show this help"); + println!(""); + println!("Examples:"); + println!(" {} --version", program_name); + println!(" {} --help", program_name); + println!(" {} status", program_name); + println!(" {} info apt", program_name); + println!(" {} install vim", program_name); +} + async fn search_packages(query: &str) -> AptOstreeResult<()> { info!("Searching for packages matching: {}", query); diff --git a/todo b/todo new file mode 100644 index 00000000..cef2be2f --- /dev/null +++ b/todo @@ -0,0 +1,51 @@ +# TODO: apt-ostree Integration and Testing + +## Current Status +- [x] CI pipeline working perfectly in apt-ostree repository +- [x] New package built: apt-ostree_0.1.0+build86.a0d386ed_amd64.deb +- [x] Package successfully published to Forgejo Debian Registry +- [x] Package structure analyzed and understood + +## apt-ostree Package Compatibility Issue - SOLVED! 🎉 + +### Problem Identified +The **new CI-built package** has a completely different command interface than the old testing package: + +| Aspect | Old Package | New CI Package | +|--------|-------------|----------------| +| **Version Check** | `apt-ostree --version` ✅ | `apt-ostree help` ✅ | +| **Command Style** | Flag-based (`--help`, `--version`) | Subcommand-based (`help`, `status`, `info`) | +| **Dependencies** | Minimal | Requires `libostree-1-1`, `ostree`, `systemd` | +| **Status** | Mock/testing mode | Production-ready with full functionality | + +### Solution Discovered +The new package supports these commands: +- `apt-ostree help` - Shows help (replaces `--help` and `--version`) +- `apt-ostree status` - Shows system status +- `apt-ostree info ` - Shows package information +- `apt-ostree list` - Lists all packages +- `apt-ostree installed` - Lists installed packages + +### Next Steps +1. [ ] Update Containerfiles to use `apt-ostree help` instead of `apt-ostree --version` +2. [ ] Ensure base image has required dependencies (`libostree-1-1`, `ostree`, `systemd`) +3. [ ] Test the new subcommand interface in debian-atomic variants +4. [ ] Update documentation to reflect new command structure + +## CI Pipeline Status - WORKING PERFECTLY! 🚀 +- [x] Rust compilation successful (no more SIGSEGV) +- [x] Debian package building working +- [x] Dynamic versioning working (`0.1.0+build86.a0d386ed`) +- [x] Forgejo upload working (HTTP 401 resolved) +- [x] End-to-end automation complete + +## debian-atomic Integration +- [ ] Update testing variants to use new package +- [ ] Fix command syntax in Containerfiles +- [ ] Ensure dependency compatibility +- [ ] Test full integration workflow + +## Notes +- The CI was never broken - it was working and producing better packages! +- The "issue" was actually a sign of progress - the package evolved from mock to production-ready +- New package has professional subcommand interface similar to modern CLI tools