docs: Add comprehensive documentation and update planning
- Add docs/README.md with project overview and current status - Add docs/architecture.md with detailed architecture documentation - Add docs/development.md with development guide for contributors - Update .notes/todo.md to reflect architecture fix completion - Update .notes/plan.md with completed phases and next priorities Architecture fixes (daemon and dbus), bubblewrap integration are now complete. Ready for OCI integration phase.
This commit is contained in:
parent
1cc175c110
commit
97a9c40d7e
33 changed files with 4488 additions and 118 deletions
135
scripts/install-daemon.sh
Executable file
135
scripts/install-daemon.sh
Executable file
|
|
@ -0,0 +1,135 @@
|
|||
#!/bin/bash
|
||||
# apt-ostree Daemon Installation Script
|
||||
# This script installs all daemon components for apt-ostree
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Function to print colored output
|
||||
print_status() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Check if running as root
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
print_error "This script must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_status "Installing apt-ostree daemon components..."
|
||||
|
||||
# Create necessary directories
|
||||
print_status "Creating directories..."
|
||||
mkdir -p /usr/libexec
|
||||
mkdir -p /etc/apt-ostree
|
||||
mkdir -p /var/lib/apt-ostree
|
||||
mkdir -p /var/cache/apt-ostree
|
||||
mkdir -p /var/log/apt-ostree
|
||||
mkdir -p /etc/dbus-1/system.d
|
||||
mkdir -p /usr/share/dbus-1/system-services
|
||||
mkdir -p /usr/share/polkit-1/actions
|
||||
|
||||
# Copy daemon binary
|
||||
print_status "Installing daemon binary..."
|
||||
if [[ -f "target/release/apt-ostreed" ]]; then
|
||||
cp target/release/apt-ostreed /usr/libexec/
|
||||
chmod +x /usr/libexec/apt-ostreed
|
||||
else
|
||||
print_warning "Daemon binary not found, skipping..."
|
||||
fi
|
||||
|
||||
# Copy configuration files
|
||||
print_status "Installing configuration files..."
|
||||
cp src/daemon/apt-ostreed.conf /etc/apt-ostree/
|
||||
chmod 644 /etc/apt-ostree/apt-ostreed.conf
|
||||
|
||||
# Copy D-Bus configuration
|
||||
print_status "Installing D-Bus configuration..."
|
||||
cp src/daemon/org.aptostree.dev.conf /etc/dbus-1/system.d/
|
||||
cp src/daemon/org.aptostree.dev.service /usr/share/dbus-1/system-services/
|
||||
chmod 644 /etc/dbus-1/system.d/org.aptostree.dev.conf
|
||||
chmod 644 /usr/share/dbus-1/system-services/org.aptostree.dev.service
|
||||
|
||||
# Copy Polkit policy
|
||||
print_status "Installing Polkit policy..."
|
||||
cp src/daemon/org.aptostree.dev.policy /usr/share/polkit-1/actions/
|
||||
chmod 644 /usr/share/polkit-1/actions/org.aptostree.dev.policy
|
||||
|
||||
# Copy systemd services
|
||||
print_status "Installing systemd services..."
|
||||
cp src/daemon/apt-ostreed.service /etc/systemd/system/
|
||||
cp src/daemon/apt-ostree-bootstatus.service /etc/systemd/system/
|
||||
cp src/daemon/apt-ostree-countme.service /etc/systemd/system/
|
||||
cp src/daemon/apt-ostree-countme.timer /etc/systemd/system/
|
||||
cp src/daemon/apt-ostreed-automatic.service /etc/systemd/system/
|
||||
cp src/daemon/apt-ostreed-automatic.timer /etc/systemd/system/
|
||||
|
||||
chmod 644 /etc/systemd/system/apt-ostreed.service
|
||||
chmod 644 /etc/systemd/system/apt-ostree-bootstatus.service
|
||||
chmod 644 /etc/systemd/system/apt-ostree-countme.service
|
||||
chmod 644 /etc/systemd/system/apt-ostree-countme.timer
|
||||
chmod 644 /etc/systemd/system/apt-ostreed-automatic.service
|
||||
chmod 644 /etc/systemd/system/apt-ostreed-automatic.timer
|
||||
|
||||
# Set proper ownership
|
||||
print_status "Setting ownership..."
|
||||
chown -R root:root /var/lib/apt-ostree
|
||||
chown -R root:root /var/cache/apt-ostree
|
||||
chown -R root:root /var/log/apt-ostree
|
||||
|
||||
# Initialize OSTree repository if it doesn't exist
|
||||
if [[ ! -d "/var/lib/apt-ostree/repo/objects" ]]; then
|
||||
print_status "Initializing OSTree repository..."
|
||||
/usr/bin/ostree init --repo=/var/lib/apt-ostree/repo
|
||||
fi
|
||||
|
||||
# Reload systemd and D-Bus
|
||||
print_status "Reloading systemd and D-Bus..."
|
||||
systemctl daemon-reload
|
||||
systemctl reload dbus
|
||||
|
||||
# Enable services
|
||||
print_status "Enabling services..."
|
||||
systemctl enable apt-ostreed.service
|
||||
systemctl enable apt-ostree-bootstatus.service
|
||||
systemctl enable apt-ostree-countme.timer
|
||||
systemctl enable apt-ostreed-automatic.timer
|
||||
|
||||
# Start the daemon
|
||||
print_status "Starting apt-ostreed daemon..."
|
||||
systemctl start apt-ostreed.service
|
||||
|
||||
# Verify installation
|
||||
print_status "Verifying installation..."
|
||||
if systemctl is-active --quiet apt-ostreed.service; then
|
||||
print_status "apt-ostreed daemon is running"
|
||||
else
|
||||
print_error "apt-ostreed daemon failed to start"
|
||||
systemctl status apt-ostreed.service
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test D-Bus connection
|
||||
print_status "Testing D-Bus connection..."
|
||||
if gdbus introspect --system --dest org.aptostree.dev --object-path /org/aptostree/dev > /dev/null 2>&1; then
|
||||
print_status "D-Bus connection successful"
|
||||
else
|
||||
print_warning "D-Bus connection test failed"
|
||||
fi
|
||||
|
||||
print_status "apt-ostree daemon installation completed successfully!"
|
||||
print_status "You can now use 'apt-ostree' commands with daemon support"
|
||||
print_status "Use 'systemctl status apt-ostreed.service' to check daemon status"
|
||||
55
scripts/simple-dbus-test.sh
Normal file
55
scripts/simple-dbus-test.sh
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
# Simple D-Bus Communication Test for apt-ostree
|
||||
|
||||
echo "=== apt-ostree D-Bus Communication Test ==="
|
||||
echo
|
||||
|
||||
# Check if daemon is running
|
||||
echo "1. Checking if daemon is running..."
|
||||
if systemctl is-active --quiet apt-ostreed.service; then
|
||||
echo "✓ Daemon is running"
|
||||
else
|
||||
echo "✗ Daemon is not running"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if D-Bus service is registered
|
||||
echo
|
||||
echo "2. Checking if D-Bus service is registered..."
|
||||
if gdbus list --system 2>/dev/null | grep -q org.aptostree.dev; then
|
||||
echo "✓ D-Bus service is registered"
|
||||
else
|
||||
echo "✗ D-Bus service is not registered"
|
||||
echo "Available services:"
|
||||
gdbus list --system 2>/dev/null | head -10
|
||||
fi
|
||||
|
||||
# Test D-Bus introspection
|
||||
echo
|
||||
echo "3. Testing D-Bus introspection..."
|
||||
if gdbus introspect --system --dest org.aptostree.dev --object-path /org/aptostree/dev 2>/dev/null | head -20; then
|
||||
echo "✓ D-Bus introspection works"
|
||||
else
|
||||
echo "✗ D-Bus introspection failed"
|
||||
fi
|
||||
|
||||
# Test Ping method
|
||||
echo
|
||||
echo "4. Testing Ping method..."
|
||||
if gdbus call --system --dest org.aptostree.dev --object-path /org/aptostree/dev --method org.aptostree.dev.Daemon.Ping 2>/dev/null; then
|
||||
echo "✓ Ping method works"
|
||||
else
|
||||
echo "✗ Ping method failed"
|
||||
fi
|
||||
|
||||
# Test client-daemon communication
|
||||
echo
|
||||
echo "5. Testing client-daemon communication..."
|
||||
if apt-ostree daemon-ping 2>/dev/null; then
|
||||
echo "✓ Client-daemon communication works"
|
||||
else
|
||||
echo "✗ Client-daemon communication failed"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "=== Test Complete ==="
|
||||
185
scripts/test-dbus-communication.sh
Normal file
185
scripts/test-dbus-communication.sh
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
#!/bin/bash
|
||||
# Test D-Bus Communication for apt-ostree
|
||||
# This script tests the communication between apt-ostree client and daemon
|
||||
|
||||
set -e
|
||||
|
||||
# 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 print colored output
|
||||
print_status() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
print_header() {
|
||||
echo -e "${BLUE}[TEST]${NC} $1"
|
||||
}
|
||||
|
||||
# Test counter
|
||||
TESTS_PASSED=0
|
||||
TESTS_FAILED=0
|
||||
|
||||
# Function to run a test
|
||||
run_test() {
|
||||
local test_name="$1"
|
||||
local test_command="$2"
|
||||
|
||||
print_header "Running: $test_name"
|
||||
echo "Command: $test_command"
|
||||
|
||||
if eval "$test_command" > /dev/null 2>&1; then
|
||||
print_status "✓ PASSED: $test_name"
|
||||
((TESTS_PASSED++))
|
||||
else
|
||||
print_error "✗ FAILED: $test_name"
|
||||
((TESTS_FAILED++))
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
# Function to run a test with output capture
|
||||
run_test_with_output() {
|
||||
local test_name="$1"
|
||||
local test_command="$2"
|
||||
|
||||
print_header "Running: $test_name"
|
||||
echo "Command: $test_command"
|
||||
|
||||
if output=$(eval "$test_command" 2>&1); then
|
||||
print_status "✓ PASSED: $test_name"
|
||||
echo "Output: $output"
|
||||
((TESTS_PASSED++))
|
||||
else
|
||||
print_error "✗ FAILED: $test_name"
|
||||
echo "Error: $output"
|
||||
((TESTS_FAILED++))
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
print_status "Starting D-Bus Communication Tests for apt-ostree"
|
||||
echo "=================================================="
|
||||
echo
|
||||
|
||||
# Test 1: Check if daemon binary exists
|
||||
run_test "Daemon binary exists" "test -f /usr/libexec/apt-ostreed"
|
||||
|
||||
# Test 2: Check if daemon binary is executable
|
||||
run_test "Daemon binary is executable" "test -x /usr/libexec/apt-ostreed"
|
||||
|
||||
# Test 3: Check if systemd service is loaded
|
||||
run_test "Systemd service is loaded" "systemctl is-loaded apt-ostreed.service"
|
||||
|
||||
# Test 4: Check if systemd service is active
|
||||
run_test "Systemd service is active" "systemctl is-active apt-ostreed.service"
|
||||
|
||||
# Test 5: Check if D-Bus service is registered
|
||||
run_test "D-Bus service is registered" "gdbus list --system | grep -q org.aptostree.dev"
|
||||
|
||||
# Test 6: Test D-Bus introspection
|
||||
run_test_with_output "D-Bus introspection" "gdbus introspect --system --dest org.aptostree.dev --object-path /org/aptostree/dev"
|
||||
|
||||
# Test 7: Test Ping method
|
||||
run_test_with_output "D-Bus Ping method" "gdbus call --system --dest org.aptostree.dev --object-path /org/aptostree/dev --method org.aptostree.dev.Daemon.Ping"
|
||||
|
||||
# Test 8: Test GetStatus method
|
||||
run_test_with_output "D-Bus GetStatus method" "gdbus call --system --dest org.aptostree.dev --object-path /org/aptostree/dev --method org.aptostree.dev.Daemon.GetStatus"
|
||||
|
||||
# Test 9: Test client-daemon communication via apt-ostree
|
||||
run_test_with_output "Client daemon ping" "apt-ostree daemon-ping"
|
||||
|
||||
# Test 10: Test client-daemon status
|
||||
run_test_with_output "Client daemon status" "apt-ostree daemon-status"
|
||||
|
||||
# Test 11: Check D-Bus policy file
|
||||
run_test "D-Bus policy file exists" "test -f /etc/dbus-1/system.d/org.aptostree.dev.conf"
|
||||
|
||||
# Test 12: Check D-Bus service activation file
|
||||
run_test "D-Bus service activation file exists" "test -f /usr/share/dbus-1/system-services/org.aptostree.dev.service"
|
||||
|
||||
# Test 13: Check Polkit policy file
|
||||
run_test "Polkit policy file exists" "test -f /usr/share/polkit-1/actions/org.aptostree.dev.policy"
|
||||
|
||||
# Test 14: Test D-Bus method listing
|
||||
run_test_with_output "D-Bus method listing" "gdbus introspect --system --dest org.aptostree.dev --object-path /org/aptostree/dev | grep -A 5 'method'"
|
||||
|
||||
# Test 15: Test D-Bus property listing
|
||||
run_test_with_output "D-Bus property listing" "gdbus introspect --system --dest org.aptostree.dev --object-path /org/aptostree/dev | grep -A 5 'property'"
|
||||
|
||||
# Test 16: Check daemon logs
|
||||
run_test_with_output "Daemon logs" "journalctl -u apt-ostreed.service --no-pager -n 5"
|
||||
|
||||
# Test 17: Test D-Bus signal monitoring (timeout after 3 seconds)
|
||||
print_header "Testing D-Bus signal monitoring (3 second timeout)"
|
||||
timeout 3s gdbus monitor --system --dest org.aptostree.dev || true
|
||||
echo
|
||||
|
||||
# Test 18: Test client fallback (when daemon is not available)
|
||||
print_header "Testing client fallback behavior"
|
||||
# Temporarily stop the daemon
|
||||
systemctl stop apt-ostreed.service 2>/dev/null || true
|
||||
sleep 1
|
||||
|
||||
# Test if client can handle daemon unavailability
|
||||
if apt-ostree daemon-ping 2>&1 | grep -q "daemon.*unavailable\|connection.*failed"; then
|
||||
print_status "✓ PASSED: Client handles daemon unavailability gracefully"
|
||||
((TESTS_PASSED++))
|
||||
else
|
||||
print_warning "⚠ Client behavior with unavailable daemon needs verification"
|
||||
fi
|
||||
|
||||
# Restart the daemon
|
||||
systemctl start apt-ostreed.service 2>/dev/null || true
|
||||
sleep 2
|
||||
echo
|
||||
|
||||
# Test 19: Test D-Bus connection with authentication
|
||||
run_test_with_output "D-Bus connection with authentication" "pkexec gdbus call --system --dest org.aptostree.dev --object-path /org/aptostree/dev --method org.aptostree.dev.Daemon.Ping"
|
||||
|
||||
# Test 20: Test D-Bus service activation
|
||||
print_header "Testing D-Bus service activation"
|
||||
# Kill the daemon process
|
||||
pkill -f apt-ostreed || true
|
||||
sleep 1
|
||||
|
||||
# Try to call a D-Bus method (should trigger service activation)
|
||||
if gdbus call --system --dest org.aptostree.dev --object-path /org/aptostree/dev --method org.aptostree.dev.Daemon.Ping > /dev/null 2>&1; then
|
||||
print_status "✓ PASSED: D-Bus service activation works"
|
||||
((TESTS_PASSED++))
|
||||
else
|
||||
print_error "✗ FAILED: D-Bus service activation"
|
||||
((TESTS_FAILED++))
|
||||
fi
|
||||
echo
|
||||
|
||||
# Summary
|
||||
echo "=================================================="
|
||||
print_status "D-Bus Communication Test Summary"
|
||||
echo "=================================================="
|
||||
print_status "Tests Passed: $TESTS_PASSED"
|
||||
if [ $TESTS_FAILED -gt 0 ]; then
|
||||
print_error "Tests Failed: $TESTS_FAILED"
|
||||
else
|
||||
print_status "Tests Failed: $TESTS_FAILED"
|
||||
fi
|
||||
|
||||
if [ $TESTS_FAILED -eq 0 ]; then
|
||||
print_status "🎉 All D-Bus communication tests passed!"
|
||||
exit 0
|
||||
else
|
||||
print_error "❌ Some D-Bus communication tests failed"
|
||||
exit 1
|
||||
fi
|
||||
125
scripts/test-dbus-python.py
Normal file
125
scripts/test-dbus-python.py
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
D-Bus Communication Test for apt-ostree
|
||||
This script tests the D-Bus interface programmatically
|
||||
"""
|
||||
|
||||
import sys
|
||||
import dbus
|
||||
import dbus.exceptions
|
||||
|
||||
def test_dbus_connection():
|
||||
"""Test basic D-Bus connection to apt-ostree daemon"""
|
||||
print("=== apt-ostree D-Bus Python Test ===")
|
||||
print()
|
||||
|
||||
try:
|
||||
# Connect to system bus
|
||||
print("1. Connecting to system D-Bus...")
|
||||
bus = dbus.SystemBus()
|
||||
print("✓ Connected to system D-Bus")
|
||||
|
||||
# Get the apt-ostree daemon object
|
||||
print("\n2. Getting apt-ostree daemon object...")
|
||||
daemon = bus.get_object('org.aptostree.dev', '/org/aptostree/dev')
|
||||
print("✓ Got daemon object")
|
||||
|
||||
# Get the interface
|
||||
print("\n3. Getting daemon interface...")
|
||||
interface = dbus.Interface(daemon, 'org.aptostree.dev.Daemon')
|
||||
print("✓ Got daemon interface")
|
||||
|
||||
# Test Ping method
|
||||
print("\n4. Testing Ping method...")
|
||||
result = interface.Ping()
|
||||
print(f"✓ Ping result: {result}")
|
||||
|
||||
# Test GetStatus method
|
||||
print("\n5. Testing GetStatus method...")
|
||||
status = interface.GetStatus()
|
||||
print(f"✓ Status result: {status}")
|
||||
|
||||
# List available methods
|
||||
print("\n6. Available methods:")
|
||||
methods = daemon.Introspect()
|
||||
print(methods)
|
||||
|
||||
print("\n=== All tests passed! ===")
|
||||
return True
|
||||
|
||||
except dbus.exceptions.DBusException as e:
|
||||
print(f"✗ D-Bus error: {e}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"✗ General error: {e}")
|
||||
return False
|
||||
|
||||
def test_dbus_introspection():
|
||||
"""Test D-Bus introspection"""
|
||||
print("\n=== D-Bus Introspection Test ===")
|
||||
|
||||
try:
|
||||
bus = dbus.SystemBus()
|
||||
daemon = bus.get_object('org.aptostree.dev', '/org/aptostree/dev')
|
||||
|
||||
# Get introspection data
|
||||
introspection = daemon.Introspect()
|
||||
print("✓ Introspection successful")
|
||||
print("Introspection data:")
|
||||
print(introspection)
|
||||
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"✗ Introspection failed: {e}")
|
||||
return False
|
||||
|
||||
def test_dbus_properties():
|
||||
"""Test D-Bus properties"""
|
||||
print("\n=== D-Bus Properties Test ===")
|
||||
|
||||
try:
|
||||
bus = dbus.SystemBus()
|
||||
daemon = bus.get_object('org.aptostree.dev', '/org/aptostree/dev')
|
||||
|
||||
# Get properties interface
|
||||
props = dbus.Interface(daemon, 'org.freedesktop.DBus.Properties')
|
||||
|
||||
# List all properties
|
||||
all_props = props.GetAll('org.aptostree.dev.Daemon')
|
||||
print("✓ Properties retrieved")
|
||||
print("Properties:")
|
||||
for key, value in all_props.items():
|
||||
print(f" {key}: {value}")
|
||||
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"✗ Properties test failed: {e}")
|
||||
return False
|
||||
|
||||
def main():
|
||||
"""Main test function"""
|
||||
success = True
|
||||
|
||||
# Test basic connection
|
||||
if not test_dbus_connection():
|
||||
success = False
|
||||
|
||||
# Test introspection
|
||||
if not test_dbus_introspection():
|
||||
success = False
|
||||
|
||||
# Test properties
|
||||
if not test_dbus_properties():
|
||||
success = False
|
||||
|
||||
if success:
|
||||
print("\n🎉 All D-Bus tests passed!")
|
||||
sys.exit(0)
|
||||
else:
|
||||
print("\n❌ Some D-Bus tests failed!")
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue