#!/bin/bash # apt-ostree Compatibility Validator # Tests CLI compatibility with rpm-ostree set -e echo "๐Ÿ” Validating apt-ostree compatibility with rpm-ostree..." echo "==================================================" # Check if both commands are available if ! command -v rpm-ostree &> /dev/null; then echo "โŒ rpm-ostree not found. Install it first for comparison." exit 1 fi if ! command -v apt-ostree &> /dev/null; then echo "โŒ apt-ostree not found. Build it first with 'cargo build --release'" exit 1 fi echo "โœ… Both commands available" # Test command structure echo "" echo "๐Ÿ“‹ Testing command structure..." # Get command lists rpm_ostree_commands=$(rpm-ostree --help 2>/dev/null | grep -E "^ [a-z-]+" | awk '{print $1}' | sort) apt_ostree_commands=$(apt-ostree --help 2>/dev/null | grep -E "^ [a-z-]+" | awk '{print $1}' | sort) echo "rpm-ostree commands: $(echo "$rpm_ostree_commands" | wc -l)" echo "apt-ostree commands: $(echo "$apt_ostree_commands" | wc -l)" # Find missing commands missing_commands=$(comm -23 <(echo "$rpm_ostree_commands") <(echo "$apt_ostree_commands")) extra_commands=$(comm -13 <(echo "$rpm_ostree_commands") <(echo "$apt_ostree_commands")) if [ -n "$missing_commands" ]; then echo "โŒ Missing commands:" echo "$missing_commands" | sed 's/^/ - /' else echo "โœ… All rpm-ostree commands are available" fi if [ -n "$extra_commands" ]; then echo "โ„น๏ธ Extra commands:" echo "$extra_commands" | sed 's/^/ + /' fi # Test help command compatibility echo "" echo "๐Ÿ“– Testing help command compatibility..." # Compare help output structure rpm_help_lines=$(rpm-ostree --help 2>/dev/null | wc -l) apt_help_lines=$(apt-ostree --help 2>/dev/null | wc -l) echo "rpm-ostree help lines: $rpm_help_lines" echo "apt-ostree help lines: $apt_help_lines" # Test basic command execution echo "" echo "๐Ÿงช Testing basic command execution..." # Test status command echo "Testing 'status' command..." if apt-ostree status &>/dev/null; then echo "โœ… Status command works" else echo "โŒ Status command failed" fi # Test help command echo "Testing '--help' flag..." if apt-ostree --help &>/dev/null; then echo "โœ… Help flag works" else echo "โŒ Help flag failed" fi # Test version command echo "Testing '--version' flag..." if apt-ostree --version &>/dev/null; then echo "โœ… Version flag works" else echo "โŒ Version flag failed" fi # Test invalid command handling echo "" echo "โš ๏ธ Testing error handling..." # Test invalid command echo "Testing invalid command..." if apt-ostree invalid-command &>/dev/null; then echo "โŒ Invalid command should have failed" else echo "โœ… Invalid command properly rejected" fi # Test invalid flag echo "Testing invalid flag..." if apt-ostree --invalid-flag &>/dev/null; then echo "โŒ Invalid flag should have failed" else echo "โœ… Invalid flag properly rejected" fi echo "" echo "๐ŸŽฏ Compatibility validation complete!" echo "" echo "Summary:" echo "- Commands available: $(echo "$apt_ostree_commands" | wc -l)/$(echo "$rpm_ostree_commands" | wc -l)" echo "- Missing: $(echo "$missing_commands" | wc -l)" echo "- Extra: $(echo "$extra_commands" | wc -l)" if [ -z "$missing_commands" ]; then echo "๐ŸŽ‰ 100% command compatibility achieved!" else echo "โš ๏ธ Some commands still need implementation" fi