247 lines
No EOL
8.7 KiB
Bash
Executable file
247 lines
No EOL
8.7 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Wrapper script for Ubuntu Noble ostree backport
|
|
# This script calls the main backport script with noble as the target
|
|
# Options: --podman, --vm, --help
|
|
|
|
set -e
|
|
|
|
# Default values
|
|
USE_PODMAN=false
|
|
USE_VM=false
|
|
VM_NAME="ostree-noble-test"
|
|
CONTAINER_NAME="ostree-noble-backport"
|
|
|
|
# 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 show usage
|
|
show_usage() {
|
|
echo -e "${BLUE}=== Ubuntu Noble (24.04 LTS) ostree Backport ===${NC}"
|
|
echo ""
|
|
echo "Usage: $0 [OPTIONS]"
|
|
echo ""
|
|
echo "Options:"
|
|
echo " --podman Run in Podman container (recommended for testing)"
|
|
echo " --vm Run in virsh VM (requires KVM/libvirt)"
|
|
echo " --help Show this help message"
|
|
echo ""
|
|
echo "Examples:"
|
|
echo " $0 # Run directly on host (not recommended)"
|
|
echo " $0 --podman # Run in isolated Podman container"
|
|
echo " $0 --vm # Run in isolated VM"
|
|
echo ""
|
|
echo "Safety:"
|
|
echo " - Podman containers are isolated and safe"
|
|
echo " - VMs provide full isolation but require more resources"
|
|
echo " - Direct host execution may affect your system"
|
|
}
|
|
|
|
# Function to check if command exists
|
|
command_exists() {
|
|
command -v "$1" >/dev/null 2>&1
|
|
}
|
|
|
|
# Function to create and run Podman container
|
|
run_in_podman() {
|
|
echo -e "${BLUE}=== Setting up Podman container for Ubuntu Noble backport ===${NC}"
|
|
|
|
if ! command_exists podman; then
|
|
echo -e "${RED}Error: Podman is not installed. Please install podman first.${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Creating Ubuntu Noble container..."
|
|
|
|
# Create container with necessary privileges
|
|
podman run --rm -it \
|
|
--name "$CONTAINER_NAME" \
|
|
--privileged \
|
|
--security-opt label=disable \
|
|
-v "$(pwd):/workspace:Z" \
|
|
-w /workspace \
|
|
ubuntu:24.04 \
|
|
bash -c "
|
|
echo '=== Setting up container environment ==='
|
|
apt update -y
|
|
apt install -y git curl wget sudo
|
|
git clone https://git.raines.xyz/robojerk/libostree-dev.git /tmp/libostree-dev
|
|
cp -r /tmp/libostree-dev/* /workspace/
|
|
cp -r /tmp/libostree-dev/.* /workspace/ 2>/dev/null || true
|
|
chmod +x /workspace/*.sh
|
|
echo '=== Container ready, running backport ==='
|
|
cd /workspace
|
|
# Create a non-root user for running the script
|
|
useradd -m -s /bin/bash backport-user
|
|
# Don't change ownership of host files - only workspace content
|
|
chown -R backport-user:backport-user /workspace/*.sh
|
|
chown -R backport-user:backport-user /workspace/ostree-backport.sh
|
|
echo 'backport-user ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
|
# Create build directory inside container
|
|
mkdir -p /home/backport-user/build
|
|
chown -R backport-user:backport-user /home/backport-user
|
|
su - backport-user -c 'cd /workspace && BACKPORT_DIR=/home/backport-user/build/ostree-backport-noble ./ostree-backport.sh noble'
|
|
# Copy built packages to host builds directory
|
|
echo '=== Copying built packages to host builds/ directory ==='
|
|
mkdir -p /workspace/builds
|
|
cp -r /home/backport-user/build/ostree-backport-noble/*.deb /workspace/builds/ 2>/dev/null || echo 'No .deb files found'
|
|
cp -r /home/backport-user/build/ostree-backport-noble/*.dsc /workspace/builds/ 2>/dev/null || echo 'No .dsc files found'
|
|
cp -r /home/backport-user/build/ostree-backport-noble/*.tar.* /workspace/builds/ 2>/dev/null || echo 'No source tarballs found'
|
|
echo '=== Build complete. Check builds/ directory for packages ==='
|
|
"
|
|
}
|
|
|
|
# Function to create and run VM
|
|
run_in_vm() {
|
|
echo -e "${BLUE}=== Setting up VM for Ubuntu Noble backport ===${NC}"
|
|
|
|
if ! command_exists virsh; then
|
|
echo -e "${RED}Error: virsh is not installed. Please install libvirt-clients first.${NC}"
|
|
echo "On Bazzite, try: ujust install libvirt-clients"
|
|
exit 1
|
|
fi
|
|
|
|
# Check for virt-install (may not be available on immutable distros)
|
|
if ! command_exists virt-install; then
|
|
echo -e "${YELLOW}Warning: virt-install not found. This is common on immutable distros like Bazzite.${NC}"
|
|
echo ""
|
|
echo "Alternative VM creation methods:"
|
|
echo "1. Use virt-manager (Flatpak) - GUI interface"
|
|
echo "2. Use virt-install via toolbox/distrobox"
|
|
echo "3. Use Podman containers instead (recommended)"
|
|
echo ""
|
|
echo "For virt-manager (Flatpak):"
|
|
echo " flatpak run org.virt_manager.virt-manager"
|
|
echo ""
|
|
echo "For toolbox/distrobox with virt-install:"
|
|
echo " toolbox create --distro fedora"
|
|
echo " toolbox enter"
|
|
echo " sudo dnf install virt-install"
|
|
echo ""
|
|
echo "For Podman container (recommended):"
|
|
echo " $0 --podman"
|
|
echo ""
|
|
read -p "Would you like to try Podman container instead? (Y/n): " -n 1 -r
|
|
echo
|
|
if [[ ! $REPLY =~ ^[Nn]$ ]]; then
|
|
echo "Switching to Podman container..."
|
|
run_in_podman
|
|
return
|
|
else
|
|
echo "Continuing with VM setup..."
|
|
fi
|
|
fi
|
|
|
|
echo "Creating Ubuntu Noble VM..."
|
|
|
|
# Check if VM already exists
|
|
if virsh list --all --name | grep -q "$VM_NAME"; then
|
|
echo -e "${YELLOW}VM $VM_NAME already exists. Starting it...${NC}"
|
|
virsh start "$VM_NAME"
|
|
virsh console "$VM_NAME"
|
|
else
|
|
echo "Creating new VM: $VM_NAME"
|
|
|
|
# Try to create VM with virt-install if available
|
|
if command_exists virt-install; then
|
|
# Create VM with Ubuntu Noble
|
|
virt-install \
|
|
--name "$VM_NAME" \
|
|
--memory 4096 \
|
|
--vcpus 2 \
|
|
--disk size=20 \
|
|
--network default \
|
|
--os-variant ubuntu24.04 \
|
|
--location http://archive.ubuntu.com/ubuntu/dists/noble/main/installer-amd64/ \
|
|
--extra-args "console=ttyS0,115200n8 serial" \
|
|
--graphics none \
|
|
--noautoconsole
|
|
else
|
|
echo -e "${YELLOW}virt-install not available. Please create VM manually:${NC}"
|
|
echo ""
|
|
echo "1. Open virt-manager (Flatpak):"
|
|
echo " flatpak run org.virt_manager.virt-manager"
|
|
echo ""
|
|
echo "2. Create new VM with these settings:"
|
|
echo " - Name: $VM_NAME"
|
|
echo " - Memory: 4096 MB"
|
|
echo " - CPUs: 2"
|
|
echo " - Disk: 20 GB"
|
|
echo " - OS: Ubuntu 24.04 (Noble Numbat)"
|
|
echo " - Network: Default"
|
|
echo ""
|
|
echo "3. Once VM is created and running, connect to it and run:"
|
|
echo " git clone https://git.raines.xyz/robojerk/libostree-dev.git"
|
|
echo " cd libostree-dev"
|
|
echo " ./backport-noble.sh"
|
|
echo ""
|
|
echo "Alternatively, use Podman container:"
|
|
echo " $0 --podman"
|
|
return
|
|
fi
|
|
|
|
echo -e "${GREEN}VM created successfully. You can connect to it with:${NC}"
|
|
echo "virsh console $VM_NAME"
|
|
echo ""
|
|
echo "Once connected, run:"
|
|
echo "git clone https://git.raines.xyz/robojerk/libostree-dev.git"
|
|
echo "cd libostree-dev"
|
|
echo "./backport-noble.sh"
|
|
fi
|
|
}
|
|
|
|
# Parse command line arguments
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
--podman)
|
|
USE_PODMAN=true
|
|
shift
|
|
;;
|
|
--vm)
|
|
USE_VM=true
|
|
shift
|
|
;;
|
|
--help|-h)
|
|
show_usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo -e "${RED}Error: Unknown option $1${NC}"
|
|
show_usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Check for conflicting options
|
|
if [ "$USE_PODMAN" = true ] && [ "$USE_VM" = true ]; then
|
|
echo -e "${RED}Error: Cannot use both --podman and --vm options${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
# Main execution logic
|
|
if [ "$USE_PODMAN" = true ]; then
|
|
run_in_podman
|
|
elif [ "$USE_VM" = true ]; then
|
|
run_in_vm
|
|
else
|
|
echo -e "${YELLOW}=== Ubuntu Noble (24.04 LTS) ostree Backport ===${NC}"
|
|
echo "Source: Ubuntu Questing"
|
|
echo "Target: Ubuntu Noble"
|
|
echo ""
|
|
echo -e "${YELLOW}Warning: Running directly on host. Consider using --podman or --vm for safety.${NC}"
|
|
echo ""
|
|
read -p "Continue anyway? (y/N): " -n 1 -r
|
|
echo
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
echo "Aborted. Use --podman or --vm for safe testing."
|
|
exit 0
|
|
fi
|
|
|
|
# Call the main backport script with noble as the target
|
|
./ostree-backport.sh noble
|
|
fi |