feat: improve CI/CD package naming and build script functionality
- Replace hardcoded version with dynamic extraction from debian/changelog - Use portable sed/awk commands instead of grep -oP for better compatibility - Implement robust fallback system for version extraction - Add install/remove arguments to build-debian-trixie.sh - Fix timestamp fallback to use readable format (YYYYMMDDHHMMSS) - Truncate commit hashes to 16 characters for better readability - Ensure YAML syntax validity for CI/CD workflow
This commit is contained in:
parent
cc4d989b82
commit
bf2b5104f1
2 changed files with 223 additions and 7 deletions
|
|
@ -2,9 +2,31 @@
|
|||
|
||||
# Build apt-ostree for Debian Trixie/Forky
|
||||
# This script ensures compatibility with libapt-pkg7.0
|
||||
# Usage: ./build-debian-trixie.sh [install|remove]
|
||||
# - No arguments: Build only
|
||||
# - "install" argument: Build, remove existing installation, then install new
|
||||
# - "remove" argument: Remove existing apt-ostree installation from system
|
||||
|
||||
set -e
|
||||
|
||||
# Parse command line arguments
|
||||
INSTALL_AFTER_BUILD=false
|
||||
REMOVE_ONLY=false
|
||||
if [[ "$1" == "install" ]]; then
|
||||
INSTALL_AFTER_BUILD=true
|
||||
print_status "Install mode enabled - will remove existing installation, build, then install new"
|
||||
elif [[ "$1" == "remove" ]]; then
|
||||
REMOVE_ONLY=true
|
||||
print_status "Remove mode enabled - will only remove existing apt-ostree installation"
|
||||
elif [[ "$1" != "" ]]; then
|
||||
print_error "Invalid argument: $1"
|
||||
print_error "Usage: $0 [install|remove]"
|
||||
print_error " - No arguments: Build only"
|
||||
print_error " - 'install': Build, remove existing installation, then install new"
|
||||
print_error " - 'remove': Remove existing apt-ostree installation from system"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Colors for output
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
|
|
@ -24,6 +46,10 @@ print_error() {
|
|||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
print_header() {
|
||||
echo ""
|
||||
echo -e "${BLUE}================================${NC}"
|
||||
|
|
@ -33,12 +59,69 @@ print_header() {
|
|||
|
||||
print_header "Building apt-ostree for Debian Trixie/Forky"
|
||||
|
||||
# Show usage information
|
||||
if [[ "$REMOVE_ONLY" == "true" ]]; then
|
||||
print_status "Mode: REMOVE ONLY (will not build or install)"
|
||||
elif [[ "$INSTALL_AFTER_BUILD" == "true" ]]; then
|
||||
print_status "Mode: BUILD + REMOVE + INSTALL (will replace system installation)"
|
||||
else
|
||||
print_status "Mode: BUILD ONLY (package will not be installed)"
|
||||
fi
|
||||
|
||||
# Check if we're in the right directory
|
||||
if [ ! -f "Cargo.toml" ]; then
|
||||
print_error "Cargo.toml not found. Please run this script from the project root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Remove mode: Only remove existing installation
|
||||
if [[ "$REMOVE_ONLY" == "true" ]]; then
|
||||
print_header "Removing existing apt-ostree installation"
|
||||
|
||||
# Check if apt-ostree is currently installed
|
||||
if command -v apt-ostree >/dev/null 2>&1; then
|
||||
print_status "Found existing apt-ostree installation, removing..."
|
||||
|
||||
# Remove existing binaries
|
||||
if [ -f "/usr/local/bin/apt-ostree" ]; then
|
||||
sudo rm -f /usr/local/bin/apt-ostree
|
||||
print_status "Removed /usr/local/bin/apt-ostree"
|
||||
fi
|
||||
|
||||
if [ -f "/usr/local/bin/apt-ostreed" ]; then
|
||||
sudo rm -f /usr/local/bin/apt-ostreed
|
||||
print_status "Removed /usr/local/bin/apt-ostreed"
|
||||
fi
|
||||
|
||||
# Remove existing configuration
|
||||
if [ -d "/etc/apt-ostreed" ]; then
|
||||
sudo rm -rf /etc/apt-ostreed
|
||||
print_status "Removed /etc/apt-ostreed configuration"
|
||||
fi
|
||||
|
||||
# Remove existing systemd service
|
||||
if [ -f "/etc/systemd/system/apt-ostreed.service" ]; then
|
||||
sudo systemctl stop apt-ostreed.service 2>/dev/null || true
|
||||
sudo systemctl disable apt-ostreed.service 2>/dev/null || true
|
||||
sudo rm -f /etc/systemd/system/apt-ostreed.service
|
||||
print_status "Removed apt-ostreed systemd service"
|
||||
fi
|
||||
|
||||
# Remove symlinks
|
||||
if [ -L "/etc/systemd/system/multi-user.target.wants/apt-ostreed.service" ]; then
|
||||
sudo rm -f /etc/systemd/system/multi-user.target.wants/apt-ostreed.service
|
||||
print_status "Removed systemd symlink"
|
||||
fi
|
||||
|
||||
print_success "Existing apt-ostree installation removed successfully!"
|
||||
else
|
||||
print_status "No existing apt-ostree installation found"
|
||||
fi
|
||||
|
||||
# Exit after removal
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check if debian directory exists
|
||||
if [ ! -d "debian" ]; then
|
||||
print_error "debian/ directory not found. Please ensure Debian packaging files are present."
|
||||
|
|
@ -167,3 +250,93 @@ fi
|
|||
print_success "Build and test completed successfully!"
|
||||
print_status "Package ready for Debian Trixie/Forky:"
|
||||
ls -la ../apt-ostree_*.deb
|
||||
|
||||
# Install mode: Replace system installation
|
||||
if [[ "$INSTALL_AFTER_BUILD" == "true" ]]; then
|
||||
print_header "Installing new build to system"
|
||||
|
||||
# First remove existing installation
|
||||
print_status "Removing existing apt-ostree installation..."
|
||||
|
||||
# Remove existing binaries
|
||||
if [ -f "/usr/local/bin/apt-ostree" ]; then
|
||||
sudo rm -f /usr/local/bin/apt-ostree
|
||||
print_status "Removed /usr/local/bin/apt-ostree"
|
||||
fi
|
||||
|
||||
if [ -f "/usr/local/bin/apt-ostreed" ]; then
|
||||
sudo rm -f /usr/local/bin/apt-ostreed
|
||||
print_status "Removed /usr/local/bin/apt-ostreed"
|
||||
fi
|
||||
|
||||
# Remove existing configuration
|
||||
if [ -d "/etc/apt-ostreed" ]; then
|
||||
sudo rm -rf /etc/apt-ostreed
|
||||
print_status "Removed /etc/apt-ostreed configuration"
|
||||
fi
|
||||
|
||||
# Remove existing systemd service
|
||||
if [ -f "/etc/systemd/system/apt-ostreed.service" ]; then
|
||||
sudo systemctl stop apt-ostreed.service 2>/dev/null || true
|
||||
sudo systemctl disable apt-ostreed.service 2>/dev/null || true
|
||||
sudo rm -f /etc/systemd/system/apt-ostreed.service
|
||||
print_status "Removed apt-ostreed systemd service"
|
||||
fi
|
||||
|
||||
# Remove symlinks
|
||||
if [ -L "/etc/systemd/system/multi-user.target.wants/apt-ostreed.service" ]; then
|
||||
sudo rm -f /etc/systemd/system/multi-user.target.wants/apt-ostreed.service
|
||||
print_status "Removed systemd symlink"
|
||||
fi
|
||||
|
||||
print_status "Existing installation removed, proceeding with new installation..."
|
||||
|
||||
# Install the new package
|
||||
print_status "Installing new package..."
|
||||
if sudo dpkg -i ../apt-ostree_*.deb; then
|
||||
print_success "Package installed successfully!"
|
||||
|
||||
# Verify installation
|
||||
print_status "Verifying installation..."
|
||||
if command -v apt-ostree >/dev/null 2>&1; then
|
||||
print_success "apt-ostree command available"
|
||||
apt-ostree --version
|
||||
else
|
||||
print_error "apt-ostree command not found after installation"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if daemon is available
|
||||
if command -v apt-ostreed >/dev/null 2>&1; then
|
||||
print_success "apt-ostreed daemon available"
|
||||
else
|
||||
print_warning "apt-ostreed daemon not found (may be normal for some builds)"
|
||||
fi
|
||||
|
||||
# Reload systemd and enable service if daemon exists
|
||||
if command -v apt-ostreed >/dev/null 2>&1; then
|
||||
print_status "Setting up systemd service..."
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
# Check if service file was created by the package
|
||||
if [ -f "/etc/systemd/system/apt-ostreed.service" ]; then
|
||||
sudo systemctl enable apt-ostreed.service
|
||||
print_success "apt-ostreed service enabled"
|
||||
else
|
||||
print_warning "No systemd service file found - manual setup may be required"
|
||||
fi
|
||||
fi
|
||||
|
||||
print_success "System installation completed successfully!"
|
||||
print_status "New apt-ostree is now active on the system"
|
||||
|
||||
else
|
||||
print_error "Package installation failed!"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
print_status "Install mode not enabled - package built but not installed"
|
||||
print_status "To install, run: $0 install"
|
||||
print_status "To remove existing installation only, run: $0 remove"
|
||||
print_status "To test existing .deb file: $0 remove && sudo dpkg -i ../apt-ostree_*.deb"
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue