Logging changes so I can delete packages

This commit is contained in:
Ryan Hughes committed 2025-08-28 01:12:27 +03:00
1 parent 1789f3b05d
commit 62ccd644bd
2 files changed
+140 -111

No files matched your search

+56 -73
View File
@@ -4,12 +4,9 @@
set -e set -e
# Colors for output # Source common functions
RED='\033[0;31m' SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
GREEN='\033[0;32m' source "$SCRIPT_DIR/../lib/common.sh"
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Repository paths # Repository paths
REPO_DIR="/home/ryan/Dev/omarchy-repo" REPO_DIR="/home/ryan/Dev/omarchy-repo"
@@ -19,60 +16,30 @@ BUILD_DIR="$REPO_DIR/build"
# Create directories if they don't exist # Create directories if they don't exist
mkdir -p "$ARCH_DIR" "$BUILD_DIR" mkdir -p "$ARCH_DIR" "$BUILD_DIR"
# Function to print colored messages
print_msg() {
local color=$1
local msg=$2
echo -e "${color}${msg}${NC}"
}
# Function to build Docker image # Function to build Docker image
build_docker_image() { build_docker_image() {
print_msg "$BLUE" "==> Building Docker image..." print_info "Building Docker image..."
# Check if Dockerfile exists # Check if Dockerfile exists
if [[ ! -f "$BUILD_DIR/Dockerfile" ]]; then if [[ ! -f "$BUILD_DIR/Dockerfile" ]]; then
print_msg "$RED" "Error: Dockerfile not found at $BUILD_DIR/Dockerfile" print_error "Dockerfile not found at $BUILD_DIR/Dockerfile"
exit 1 exit 1
fi fi
# Prepare package list for Docker build
if [[ -n "$ONLY_PACKAGES" ]]; then
print_msg "$YELLOW" " -> Filtering packages: $ONLY_PACKAGES"
# Create temporary filtered list
> "$BUILD_DIR/packages"
# Check each package against the main list
for pkg in $ONLY_PACKAGES; do
# Check if in package list (handle options like skip-pgp)
if [[ -f "$REPO_DIR/packages" ]]; then
grep "^$pkg\( \|$\)" "$REPO_DIR/packages" >> "$BUILD_DIR/packages" && {
print_msg "$GREEN" " -> $pkg"
} || {
print_msg "$YELLOW" " -> $pkg (not found in package list)"
}
fi
done
else
# Copy full packages list to build directory
cp "$REPO_DIR/packages" "$BUILD_DIR/packages"
fi
# Build image # Build image
cd "$BUILD_DIR" cd "$BUILD_DIR"
docker build -t omarchy-builder . || { docker build -t omarchy-builder . || {
print_msg "$RED" "Failed to build Docker image" print_error "Failed to build Docker image"
exit 1 exit 1
} }
print_msg "$GREEN" " -> Docker image built successfully!" print_success "Docker image built successfully!"
} }
# Function to run build in Docker # Function to run build in Docker
run_docker_build() { run_docker_build() {
print_msg "$BLUE" "==> Running package build in Docker..." print_info "Running package build in Docker..."
# Create src directory if it doesn't exist # Create src directory if it doesn't exist
mkdir -p "$REPO_DIR/src" mkdir -p "$REPO_DIR/src"
@@ -80,60 +47,66 @@ run_docker_build() {
# Build docker run command with options # Build docker run command with options
DOCKER_ENV="" DOCKER_ENV=""
if [[ "$SKIP_PGP" == true ]]; then if [[ "$SKIP_PGP" == true ]]; then
print_msg "$YELLOW" " -> Skipping PGP signature verification" print_warning "Skipping PGP signature verification"
DOCKER_ENV="$DOCKER_ENV -e SKIP_PGP=true" DOCKER_ENV="$DOCKER_ENV -e SKIP_PGP=true"
fi fi
if [[ "$FORCE_REBUILD" == true ]]; then if [[ "$FORCE_REBUILD" == true ]]; then
print_msg "$YELLOW" " -> Forcing rebuild of all packages" print_warning "Forcing rebuild of all packages"
DOCKER_ENV="$DOCKER_ENV -e FORCE_REBUILD=true" DOCKER_ENV="$DOCKER_ENV -e FORCE_REBUILD=true"
fi fi
if [[ -n "$ONLY_PACKAGES" ]]; then
print_warning "Filtering packages: $ONLY_PACKAGES"
DOCKER_ENV="$DOCKER_ENV -e ONLY_PACKAGES='$ONLY_PACKAGES'"
fi
docker run --rm \ docker run --rm \
$DOCKER_ENV \ $DOCKER_ENV \
-v "$ARCH_DIR:/output" \ -v "$ARCH_DIR:/output" \
-v "$ARCH_DIR:/var/cache/pacman/pkg" \ -v "$ARCH_DIR:/var/cache/pacman/pkg" \
-v "$REPO_DIR/src:/src" \ -v "$REPO_DIR/src:/src" \
omarchy-builder || { -v "$BUILD_DIR:/build:ro" \
print_msg "$RED" "Docker build failed" omarchy-builder
exit 1
}
print_msg "$GREEN" " -> Package build complete!" # Check exit code but don't fail immediately
BUILD_EXIT_CODE=$?
if [[ $BUILD_EXIT_CODE -ne 0 ]]; then
print_warning "Some packages failed (see summary above)"
return $BUILD_EXIT_CODE
fi
print_success "Package build complete!"
} }
# Function to clean Docker resources # Function to clean Docker resources
clean_docker() { clean_docker() {
print_msg "$BLUE" "==> Cleaning Docker resources..." print_info "Cleaning Docker resources..."
# Remove image # Remove image
docker rmi omarchy-builder 2>/dev/null || true docker rmi omarchy-builder 2>/dev/null || true
# Clean temporary packages file from build directory # Nothing to clean for packages anymore
rm -f "$BUILD_DIR/packages"
print_msg "$GREEN" " -> Cleanup complete!" print_success "Cleanup complete!"
} }
# Main execution # Main execution
main() { main() {
print_msg "$BLUE" "================================" print_header "Omarchy Repository Docker Builder"
print_msg "$BLUE" "Omarchy Repository Docker Builder"
print_msg "$BLUE" "================================"
# Check for Docker # Check for Docker
if ! command -v docker &> /dev/null; then if ! command -v docker &> /dev/null; then
print_msg "$RED" "Error: Docker is not installed" print_error "Docker is not installed"
print_msg "$YELLOW" "Please install Docker first:" print_warning "Please install Docker first:"
print_msg "$YELLOW" " sudo pacman -S docker" echo " sudo pacman -S docker"
print_msg "$YELLOW" " sudo systemctl start docker" echo " sudo systemctl start docker"
print_msg "$YELLOW" " sudo usermod -aG docker $USER" echo " sudo usermod -aG docker $USER"
exit 1 exit 1
fi fi
# Check if Docker daemon is running # Check if Docker daemon is running
if ! docker info &> /dev/null; then if ! docker info &> /dev/null; then
print_msg "$RED" "Error: Docker daemon is not running" print_error "Docker daemon is not running"
print_msg "$YELLOW" "Start Docker with: sudo systemctl start docker" print_warning "Start Docker with: sudo systemctl start docker"
exit 1 exit 1
fi fi
@@ -183,15 +156,14 @@ main() {
echo " $0 --skip-pgp # Build without PGP checks" echo " $0 --skip-pgp # Build without PGP checks"
echo "" echo ""
echo "This script builds all packages listed in:" echo "This script builds all packages listed in:"
echo " - packages.official (downloaded from Arch repos)" echo " - build/packages/*.packages files"
echo " - packages.aur (built from AUR)"
echo "" echo ""
echo "All builds happen inside a Docker container." echo "All builds happen inside a Docker container."
echo "No packages are installed on your host system." echo "No packages are installed on your host system."
exit 0 exit 0
;; ;;
*) *)
print_msg "$RED" "Unknown option: $1" print_error "Unknown option: $1"
exit 1 exit 1
;; ;;
esac esac
@@ -204,26 +176,37 @@ main() {
# Build packages # Build packages
build_docker_image build_docker_image
run_docker_build run_docker_build
BUILD_RESULT=$?
# Clean up unless keeping image # Clean up unless keeping image
if [[ "$KEEP_IMAGE" != true ]]; then if [[ "$KEEP_IMAGE" != true ]]; then
clean_docker clean_docker
else else
print_msg "$YELLOW" "Docker image kept: omarchy-builder" print_warning "Docker image kept: omarchy-builder"
print_msg "$YELLOW" "Remove with: docker rmi omarchy-builder" print_warning "Remove with: docker rmi omarchy-builder"
fi fi
# Show results # Show results
print_msg "$BLUE" "\n==> Build Summary:" echo ""
print_info "Final Summary:"
local count=$(ls -1 "$ARCH_DIR"/*.pkg.tar.* 2>/dev/null | wc -l) local count=$(ls -1 "$ARCH_DIR"/*.pkg.tar.* 2>/dev/null | wc -l)
if [[ $count -gt 0 ]]; then if [[ $count -gt 0 ]]; then
print_msg "$GREEN" " -> Built/downloaded $count package(s)" print_step "Total packages in repository: $count"
print_msg "$GREEN" " -> Packages are in: $ARCH_DIR" print_step "Packages are in: $ARCH_DIR"
print_msg "$YELLOW" "\nNext step: Run ./scripts/update-repo.sh" if [[ $BUILD_RESULT -eq 0 ]]; then
print_success "All requested packages processed successfully"
else
print_warning "Some packages failed (check output above)"
fi
echo ""
print_warning "Next step: Run ./scripts/update-repo.sh"
else else
print_msg "$YELLOW" " -> No packages were built" print_warning "No packages in repository"
print_msg "$YELLOW" " -> Check your package lists" print_warning "Check your package lists"
fi fi
# Exit with the build result code
exit $BUILD_RESULT
fi fi
} }
+84 -38
View File
@@ -1,50 +1,48 @@
#!/bin/bash #!/bin/bash
# Main build script that runs inside Docker container # Main build script that runs inside Docker container
set -e # Don't use set -e so we can handle errors gracefully
echo "==> Setting up local repository..." # Import GPG keys
# Create a temporary repo directory for build dependencies /build/import-gpg-keys.sh
mkdir -p /tmp/build-repo
# Add local repo to pacman.conf so AUR packages can find their dependencies # Sync pacman database
sudo tee -a /etc/pacman.conf > /dev/null << EOF
[omarchy-build]
SigLevel = Optional TrustAll
Server = file:///tmp/build-repo
EOF
# Create initial empty database
repo-add /tmp/build-repo/omarchy-build.db.tar.gz 2>/dev/null || true
# Sync pacman to recognize the new repo
sudo pacman -Sy sudo pacman -Sy
echo "==> Processing package list..." echo "==> Processing package lists..."
FAILED_PACKAGES="" FAILED_PACKAGES=""
PROCESSED_PACKAGES="" PROCESSED_PACKAGES=""
# Merge and deduplicate all *.packages files from /build/packages
cat /build/packages/*.packages 2>/dev/null | \
grep -v '^#' | grep -v '^$' | \
awk '!seen[$1]++ {print}' > /tmp/packages.merged
# If ONLY_PACKAGES is set, filter the merged list
if [[ -n "$ONLY_PACKAGES" ]]; then
echo "==> Filtering packages: $ONLY_PACKAGES"
> /tmp/packages.filtered
for pkg in $ONLY_PACKAGES; do
grep "^$pkg\( \|$\)" /tmp/packages.merged >> /tmp/packages.filtered || echo " -> Warning: $pkg not found in package lists"
done
mv /tmp/packages.filtered /tmp/packages.merged
fi
# Separate packages into official and AUR # Separate packages into official and AUR
> /tmp/packages.official > /tmp/packages.official
> /tmp/packages.aur > /tmp/packages.aur
if [[ -f /home/builder/packages ]]; then while IFS= read -r line || [ -n "$line" ]; do
while IFS= read -r line || [ -n "$line" ]; do # Parse package name and options
[[ "$line" =~ ^#.*$ ]] && continue package=$(echo "$line" | awk '{print $1}')
[[ -z "$line" ]] && continue options=$(echo "$line" | awk '{$1=""; print $0}' | xargs)
# Parse package name and options # Check if it's in official repos
package=$(echo "$line" | awk '{print $1}') if pacman -Si "$package" &>/dev/null; then
options=$(echo "$line" | awk '{$1=""; print $0}' | xargs) echo "$package" >> /tmp/packages.official
else
# Check if it's in official repos echo "$line" >> /tmp/packages.aur # Keep options for AUR packages
if pacman -Si "$package" &>/dev/null; then fi
echo "$package" >> /tmp/packages.official done < /tmp/packages.merged
else
echo "$line" >> /tmp/packages.aur # Keep options for AUR packages
fi
done < /home/builder/packages
fi
# Show package counts # Show package counts
echo "==> Package breakdown:" echo "==> Package breakdown:"
@@ -60,25 +58,73 @@ if [[ -s /tmp/packages.aur ]]; then
fi fi
echo "==> Downloading official packages..." echo "==> Downloading official packages..."
OFFICIAL_FAILED=""
if [[ -s /tmp/packages.official ]]; then if [[ -s /tmp/packages.official ]]; then
while IFS= read -r package || [ -n "$package" ]; do while IFS= read -r package || [ -n "$package" ]; do
echo " -> Downloading $package..." echo " -> Downloading $package..."
# Download package without installing (will use default cache which is now /output) # Download package without installing (will use default cache which is now /output)
sudo pacman -Sw --noconfirm "$package" || { if ! sudo pacman -Sw --noconfirm "$package" 2>/dev/null; then
# Fallback to direct download # Fallback to direct download
url=$(pacman -Sp "$package" 2>/dev/null) url=$(pacman -Sp "$package" 2>/dev/null)
if [[ -n "$url" ]]; then if [[ -n "$url" ]]; then
wget -q -P /output "$url" || echo " -> Failed: $package" if ! wget -q -P /output "$url"; then
echo " -> Failed to download $package"
OFFICIAL_FAILED="$OFFICIAL_FAILED $package"
fi
else
echo " -> Failed to download $package"
OFFICIAL_FAILED="$OFFICIAL_FAILED $package"
fi fi
} fi
done < /tmp/packages.official done < /tmp/packages.official
fi fi
# Source the AUR build functions # Source the AUR build functions
source /home/builder/build-aur.sh source /build/build-aur.sh
# Build AUR packages # Build AUR packages
build_aur_packages build_aur_packages
echo "==> Build complete!" echo ""
echo "==> Build Summary:"
# Count successes
TOTAL_OFFICIAL=$(wc -l < /tmp/packages.official 2>/dev/null || echo 0)
TOTAL_AUR=$(wc -l < /tmp/packages.aur 2>/dev/null || echo 0)
# Report official packages
if [[ -n "$OFFICIAL_FAILED" ]]; then
OFFICIAL_FAILED_COUNT=$(echo $OFFICIAL_FAILED | wc -w)
OFFICIAL_SUCCESS=$((TOTAL_OFFICIAL - OFFICIAL_FAILED_COUNT))
echo " Official packages: $OFFICIAL_SUCCESS/$TOTAL_OFFICIAL succeeded"
echo " Failed official packages:"
for pkg in $OFFICIAL_FAILED; do
echo " - $pkg"
done
else
echo " Official packages: $TOTAL_OFFICIAL/$TOTAL_OFFICIAL succeeded"
fi
# Report AUR packages (FAILED_PACKAGES comes from build-aur.sh)
if [[ -n "$FAILED_PACKAGES" ]]; then
AUR_FAILED_COUNT=$(echo $FAILED_PACKAGES | wc -w)
AUR_SUCCESS=$((TOTAL_AUR - AUR_FAILED_COUNT))
echo " AUR packages: $AUR_SUCCESS/$TOTAL_AUR succeeded"
echo " Failed AUR packages:"
for pkg in $FAILED_PACKAGES; do
echo " - $pkg"
done
else
echo " AUR packages: $TOTAL_AUR/$TOTAL_AUR succeeded"
fi
# Exit with error if any packages failed
if [[ -n "$OFFICIAL_FAILED" ]] || [[ -n "$FAILED_PACKAGES" ]]; then
echo ""
echo "==> Some packages failed to build/download"
exit 1
else
echo ""
echo "==> All packages processed successfully!"
fi