#!/bin/bash set -e echo "=== apt-ostree Clean Ubuntu Setup ===" echo "Setting up daemon and D-Bus on fresh Ubuntu system..." # Step 1: Install dependencies echo "1. Installing system dependencies..." sudo apt update sudo apt install -y \ build-essential \ pkg-config \ libssl-dev \ libdbus-1-dev \ libsystemd-dev \ libostree-dev \ libapt-pkg-dev \ bubblewrap \ libseccomp-dev \ libcap-dev \ libacl1-dev \ libattr1-dev \ libfuse3-dev \ libgirepository1.0-dev \ libglib2.0-dev \ libgpgme-dev \ liblzma-dev \ libzstd-dev \ libcurl4-openssl-dev \ libjson-c-dev \ libyaml-dev \ git \ curl \ wget # Step 2: Build the project echo "2. Building apt-ostree..." cargo build --release if [ ! -f "target/release/apt-ostree" ] || [ ! -f "target/release/apt-ostreed" ]; then echo "❌ Build failed! Missing binaries." exit 1 fi echo "✅ Build successful!" # Step 3: Create necessary directories echo "3. Creating system directories..." sudo mkdir -p /usr/libexec sudo mkdir -p /etc/apt-ostree sudo mkdir -p /var/lib/apt-ostree sudo mkdir -p /var/log/apt-ostree # Step 4: Install binaries echo "4. Installing binaries..." sudo cp target/release/apt-ostree /usr/bin/ sudo cp target/release/apt-ostreed /usr/libexec/ sudo chmod +x /usr/bin/apt-ostree sudo chmod +x /usr/libexec/apt-ostreed # Step 5: Install D-Bus configuration echo "5. Installing D-Bus configuration..." sudo cp src/daemon/org.aptostree.dev.conf /etc/dbus-1/system.d/ sudo cp src/daemon/org.aptostree.dev.service /usr/share/dbus-1/system-services/ sudo chmod 644 /etc/dbus-1/system.d/org.aptostree.dev.conf sudo chmod 644 /usr/share/dbus-1/system-services/org.aptostree.dev.service # Step 6: Install systemd service echo "6. Installing systemd service..." sudo cp src/daemon/apt-ostreed.service /etc/systemd/system/ sudo chmod 644 /etc/systemd/system/apt-ostreed.service # Step 7: Reload system services echo "7. Reloading system services..." sudo systemctl daemon-reload sudo systemctl reload dbus # Step 8: Test daemon binary echo "8. Testing daemon binary..." if /usr/libexec/apt-ostreed --help > /dev/null 2>&1; then echo "✅ Daemon binary works" else echo "❌ Daemon binary test failed" exit 1 fi # Step 9: Test CLI binary echo "9. Testing CLI binary..." if /usr/bin/apt-ostree --help > /dev/null 2>&1; then echo "✅ CLI binary works" else echo "❌ CLI binary test failed" exit 1 fi # Step 10: Start daemon echo "10. Starting daemon..." sudo systemctl start apt-ostreed.service sleep 3 # Step 11: Check daemon status echo "11. Checking daemon status..." if systemctl is-active --quiet apt-ostreed.service; then echo "✅ Daemon is running!" else echo "❌ Daemon failed to start" sudo systemctl status apt-ostreed.service sudo journalctl -u apt-ostreed.service --no-pager -n 10 exit 1 fi # Step 12: Test D-Bus communication echo "12. Testing D-Bus communication..." sleep 2 if apt-ostree daemon-ping; then echo "✅ D-Bus communication successful!" else echo "❌ D-Bus communication failed" echo "Checking D-Bus status..." busctl list | grep apt || echo "No apt services found" exit 1 fi # Step 13: Enable daemon to start on boot echo "13. Enabling daemon to start on boot..." sudo systemctl enable apt-ostreed.service echo "" echo "🎉 Setup complete! apt-ostree daemon is now working." echo "" echo "Test commands:" echo " apt-ostree daemon-ping" echo " apt-ostree status" echo " sudo systemctl status apt-ostreed.service"