Lots of cleanup
This commit is contained in:
@@ -5,7 +5,7 @@ set -e
|
||||
|
||||
# Source common functions
|
||||
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
||||
source "$BUILD_ROOT/lib/common.sh"
|
||||
source "$BUILD_ROOT/lib/message-helpers.sh"
|
||||
|
||||
# Prepare build directories
|
||||
ARCH_DIR="$BUILD_ROOT/x86_64"
|
||||
|
||||
+202
-214
@@ -4,242 +4,230 @@
|
||||
|
||||
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
|
||||
# Source common functions
|
||||
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
||||
source "$BUILD_ROOT/lib/message-helpers.sh"
|
||||
|
||||
# Repository configuration
|
||||
REPO_DIR="/home/ryan/Dev/omarchy-repo"
|
||||
ARCH_DIR="$REPO_DIR/x86_64"
|
||||
ARCH_DIR="$BUILD_ROOT/x86_64"
|
||||
KEEP_VERSIONS=2
|
||||
|
||||
# Function to print colored messages
|
||||
print_msg() {
|
||||
local color=$1
|
||||
local msg=$2
|
||||
echo -e "${color}${msg}${NC}"
|
||||
}
|
||||
|
||||
# Function to clean old packages
|
||||
clean_packages() {
|
||||
local keep=$1
|
||||
local dry_run=$2
|
||||
|
||||
print_msg "$BLUE" "==> Cleaning old packages (keeping $keep versions)..."
|
||||
|
||||
cd "$ARCH_DIR"
|
||||
|
||||
# Group packages by name
|
||||
declare -A packages
|
||||
|
||||
for pkg in *.pkg.tar.*; do
|
||||
[[ -f "$pkg" ]] || continue
|
||||
|
||||
# Skip signature files
|
||||
[[ "$pkg" == *.sig ]] && continue
|
||||
|
||||
# Extract package name (remove version and architecture)
|
||||
# Format: name-version-release-arch.pkg.tar.*
|
||||
local pkgname=$(echo "$pkg" | sed -E 's/-[0-9]+.*-(any|x86_64|i686)\.pkg\.tar\..*//')
|
||||
|
||||
# Add to array
|
||||
if [[ -n "${packages[$pkgname]}" ]]; then
|
||||
packages[$pkgname]="${packages[$pkgname]} $pkg"
|
||||
else
|
||||
packages[$pkgname]="$pkg"
|
||||
fi
|
||||
done
|
||||
|
||||
# Process each package group
|
||||
local total_removed=0
|
||||
local space_freed=0
|
||||
|
||||
for pkgname in "${!packages[@]}"; do
|
||||
# Convert string to array and sort by modification time (newest first)
|
||||
IFS=' ' read -ra pkg_files <<< "${packages[$pkgname]}"
|
||||
|
||||
# Sort by modification time
|
||||
local sorted_files=($(ls -t "${pkg_files[@]}" 2>/dev/null))
|
||||
local count=${#sorted_files[@]}
|
||||
|
||||
if [[ $count -gt $keep ]]; then
|
||||
print_msg "$GREEN" " -> Processing $pkgname ($count versions found)"
|
||||
|
||||
# Remove old versions
|
||||
for ((i=$keep; i<$count; i++)); do
|
||||
local file="${sorted_files[$i]}"
|
||||
local size=$(stat -c%s "$file" 2>/dev/null || echo 0)
|
||||
space_freed=$((space_freed + size))
|
||||
|
||||
if [[ "$dry_run" == true ]]; then
|
||||
print_msg "$YELLOW" " Would remove: $file ($(numfmt --to=iec-i --suffix=B $size))"
|
||||
else
|
||||
print_msg "$RED" " Removing: $file ($(numfmt --to=iec-i --suffix=B $size))"
|
||||
rm -f "$file"
|
||||
rm -f "${file}.sig" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
total_removed=$((total_removed + 1))
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
# Summary
|
||||
if [[ $total_removed -gt 0 ]]; then
|
||||
if [[ "$dry_run" == true ]]; then
|
||||
print_msg "$BLUE" "\n -> Would remove $total_removed old package(s)"
|
||||
print_msg "$BLUE" " -> Would free $(numfmt --to=iec-i --suffix=B $space_freed)"
|
||||
else
|
||||
print_msg "$GREEN" "\n -> Removed $total_removed old package(s)"
|
||||
print_msg "$GREEN" " -> Freed $(numfmt --to=iec-i --suffix=B $space_freed)"
|
||||
fi
|
||||
local keep=$1
|
||||
local dry_run=$2
|
||||
|
||||
print_info "Cleaning old packages (keeping $keep versions)..."
|
||||
|
||||
cd "$ARCH_DIR"
|
||||
|
||||
# Group packages by name
|
||||
declare -A packages
|
||||
|
||||
for pkg in *.pkg.tar.*; do
|
||||
[[ -f "$pkg" ]] || continue
|
||||
|
||||
# Skip signature files
|
||||
[[ "$pkg" == *.sig ]] && continue
|
||||
|
||||
# Extract package name (remove version and architecture)
|
||||
# Format: name-version-release-arch.pkg.tar.*
|
||||
local pkgname=$(echo "$pkg" | sed -E 's/-[0-9]+.*-(any|x86_64|i686)\.pkg\.tar\..*//')
|
||||
|
||||
# Add to array
|
||||
if [[ -n "${packages[$pkgname]}" ]]; then
|
||||
packages[$pkgname]="${packages[$pkgname]} $pkg"
|
||||
else
|
||||
print_msg "$YELLOW" " -> No old packages to remove"
|
||||
packages[$pkgname]="$pkg"
|
||||
fi
|
||||
done
|
||||
|
||||
# Process each package group
|
||||
local total_removed=0
|
||||
local space_freed=0
|
||||
|
||||
for pkgname in "${!packages[@]}"; do
|
||||
# Convert string to array and sort by modification time (newest first)
|
||||
IFS=' ' read -ra pkg_files <<<"${packages[$pkgname]}"
|
||||
|
||||
# Sort by modification time
|
||||
local sorted_files=($(ls -t "${pkg_files[@]}" 2>/dev/null))
|
||||
local count=${#sorted_files[@]}
|
||||
|
||||
if [[ $count -gt $keep ]]; then
|
||||
print_success " -> Processing $pkgname ($count versions found)"
|
||||
|
||||
# Remove old versions
|
||||
for ((i = $keep; i < $count; i++)); do
|
||||
local file="${sorted_files[$i]}"
|
||||
local size=$(stat -c%s "$file" 2>/dev/null || echo 0)
|
||||
space_freed=$((space_freed + size))
|
||||
|
||||
if [[ "$dry_run" == true ]]; then
|
||||
print_warning " Would remove: $file ($(numfmt --to=iec-i --suffix=B $size))"
|
||||
else
|
||||
print_error " Removing: $file ($(numfmt --to=iec-i --suffix=B $size))"
|
||||
rm -f "$file"
|
||||
rm -f "${file}.sig" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
total_removed=$((total_removed + 1))
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
# Summary
|
||||
if [[ $total_removed -gt 0 ]]; then
|
||||
if [[ "$dry_run" == true ]]; then
|
||||
print_info " -> Would remove $total_removed old package(s)"
|
||||
print_info " -> Would free $(numfmt --to=iec-i --suffix=B $space_freed)"
|
||||
else
|
||||
print_success " -> Removed $total_removed old package(s)"
|
||||
print_success " -> Freed $(numfmt --to=iec-i --suffix=B $space_freed)"
|
||||
fi
|
||||
else
|
||||
print_warning " -> No old packages to remove"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to remove all packages
|
||||
remove_all_packages() {
|
||||
local dry_run=$1
|
||||
|
||||
print_msg "$RED" "==> WARNING: Removing ALL packages from repository!"
|
||||
|
||||
if [[ "$dry_run" != true ]]; then
|
||||
read -p "Are you sure? Type 'yes' to confirm: " confirm
|
||||
if [[ "$confirm" != "yes" ]]; then
|
||||
print_msg "$YELLOW" "Cancelled."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
cd "$ARCH_DIR"
|
||||
|
||||
local count=$(ls -1 *.pkg.tar.* 2>/dev/null | wc -l)
|
||||
|
||||
if [[ $count -eq 0 ]]; then
|
||||
print_msg "$YELLOW" "No packages found to remove"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "$dry_run" == true ]]; then
|
||||
print_msg "$YELLOW" "Would remove $count package(s):"
|
||||
ls -1 *.pkg.tar.* 2>/dev/null | while read -r pkg; do
|
||||
echo " - $pkg"
|
||||
done
|
||||
else
|
||||
rm -f *.pkg.tar.*
|
||||
rm -f *.db* *.files*
|
||||
print_msg "$GREEN" "Removed $count package(s) and database files"
|
||||
local dry_run=$1
|
||||
|
||||
print_error "WARNING: Removing ALL packages from repository!"
|
||||
|
||||
if [[ "$dry_run" != true ]]; then
|
||||
read -p "Are you sure? Type 'yes' to confirm: " confirm
|
||||
if [[ "$confirm" != "yes" ]]; then
|
||||
print_warning "Cancelled."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
cd "$ARCH_DIR"
|
||||
|
||||
local count=$(ls -1 *.pkg.tar.* 2>/dev/null | wc -l)
|
||||
|
||||
if [[ $count -eq 0 ]]; then
|
||||
print_warning "No packages found to remove"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "$dry_run" == true ]]; then
|
||||
print_warning "Would remove $count package(s):"
|
||||
ls -1 *.pkg.tar.* 2>/dev/null | while read -r pkg; do
|
||||
echo " - $pkg"
|
||||
done
|
||||
else
|
||||
rm -f *.pkg.tar.*
|
||||
rm -f *.db* *.files*
|
||||
print_success "Removed $count package(s) and database files"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to show repository disk usage
|
||||
show_disk_usage() {
|
||||
print_msg "$BLUE" "\n==> Repository Disk Usage:"
|
||||
|
||||
cd "$ARCH_DIR"
|
||||
|
||||
local total_size=$(du -sh . 2>/dev/null | cut -f1)
|
||||
local package_count=$(ls -1 *.pkg.tar.* 2>/dev/null | grep -v '\.sig$' | wc -l)
|
||||
|
||||
print_msg "$GREEN" " -> Total size: $total_size"
|
||||
print_msg "$GREEN" " -> Package count: $package_count"
|
||||
|
||||
if [[ $package_count -gt 0 ]]; then
|
||||
print_msg "$GREEN" " -> Average package size: $(du -b *.pkg.tar.* 2>/dev/null | awk '{sum+=$1; count++} END {print sum/count}' | numfmt --to=iec-i --suffix=B)"
|
||||
fi
|
||||
print_info "Repository Disk Usage:"
|
||||
|
||||
cd "$ARCH_DIR"
|
||||
|
||||
local total_size=$(du -sh . 2>/dev/null | cut -f1)
|
||||
local package_count=$(ls -1 *.pkg.tar.* 2>/dev/null | grep -v '\.sig$' | wc -l)
|
||||
|
||||
print_success " -> Total size: $total_size"
|
||||
print_success " -> Package count: $package_count"
|
||||
|
||||
if [[ $package_count -gt 0 ]]; then
|
||||
print_success " -> Average package size: $(du -b *.pkg.tar.* 2>/dev/null | awk '{sum+=$1; count++} END {print sum/count}' | numfmt --to=iec-i --suffix=B)"
|
||||
fi
|
||||
}
|
||||
|
||||
# Main execution
|
||||
main() {
|
||||
print_msg "$BLUE" "================================"
|
||||
print_msg "$BLUE" "Omarchy Repository Cleaner"
|
||||
print_msg "$BLUE" "================================"
|
||||
|
||||
# Parse command line arguments
|
||||
DRY_RUN=false
|
||||
REMOVE_ALL=false
|
||||
SHOW_USAGE=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--keep)
|
||||
KEEP_VERSIONS="$2"
|
||||
shift 2
|
||||
;;
|
||||
--dry-run)
|
||||
DRY_RUN=true
|
||||
shift
|
||||
;;
|
||||
--all)
|
||||
REMOVE_ALL=true
|
||||
shift
|
||||
;;
|
||||
--usage)
|
||||
SHOW_USAGE=true
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --keep N Keep N versions of each package (default: 2)"
|
||||
echo " --dry-run Preview what would be removed without removing"
|
||||
echo " --all Remove ALL packages (dangerous!)"
|
||||
echo " --usage Show disk usage statistics"
|
||||
echo " -h, --help Show this help message"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " $0 # Keep 2 versions (default)"
|
||||
echo " $0 --keep 3 # Keep 3 versions"
|
||||
echo " $0 --dry-run # Preview cleanup"
|
||||
echo " $0 --all --dry-run # Preview complete removal"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
print_msg "$RED" "Unknown option: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Validate keep versions
|
||||
if ! [[ "$KEEP_VERSIONS" =~ ^[0-9]+$ ]] || [[ "$KEEP_VERSIONS" -lt 1 ]]; then
|
||||
print_msg "$RED" "Error: --keep must be a positive integer"
|
||||
exit 1
|
||||
print_header "Omarchy Repository Cleaner"
|
||||
|
||||
# Parse command line arguments
|
||||
DRY_RUN=false
|
||||
REMOVE_ALL=false
|
||||
SHOW_USAGE=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--keep)
|
||||
KEEP_VERSIONS="$2"
|
||||
shift 2
|
||||
;;
|
||||
--dry-run)
|
||||
DRY_RUN=true
|
||||
shift
|
||||
;;
|
||||
--all)
|
||||
REMOVE_ALL=true
|
||||
shift
|
||||
;;
|
||||
--usage)
|
||||
SHOW_USAGE=true
|
||||
shift
|
||||
;;
|
||||
-h | --help)
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --keep N Keep N versions of each package (default: 2)"
|
||||
echo " --dry-run Preview what would be removed without removing"
|
||||
echo " --all Remove ALL packages (dangerous!)"
|
||||
echo " --usage Show disk usage statistics"
|
||||
echo " -h, --help Show this help message"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " $0 # Keep 2 versions (default)"
|
||||
echo " $0 --keep 3 # Keep 3 versions"
|
||||
echo " $0 --dry-run # Preview cleanup"
|
||||
echo " $0 --all --dry-run # Preview complete removal"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
print_error "Unknown option: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Validate keep versions
|
||||
if ! [[ "$KEEP_VERSIONS" =~ ^[0-9]+$ ]] || [[ "$KEEP_VERSIONS" -lt 1 ]]; then
|
||||
print_error "Error: --keep must be a positive integer"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Show dry run notice
|
||||
if [[ "$DRY_RUN" == true ]]; then
|
||||
print_warning "DRY RUN MODE - No changes will be made"
|
||||
fi
|
||||
|
||||
# Execute based on options
|
||||
if [[ "$SHOW_USAGE" == true ]]; then
|
||||
show_disk_usage
|
||||
elif [[ "$REMOVE_ALL" == true ]]; then
|
||||
remove_all_packages "$DRY_RUN"
|
||||
else
|
||||
clean_packages "$KEEP_VERSIONS" "$DRY_RUN"
|
||||
|
||||
# Update database after cleaning (unless dry run)
|
||||
if [[ "$DRY_RUN" != true ]]; then
|
||||
print_info "Updating repository database..."
|
||||
"$BUILD_ROOT/bin/update-repo" >/dev/null 2>&1 && {
|
||||
print_success " -> Database updated successfully!"
|
||||
} || {
|
||||
print_warning " -> Database update failed (may need manual update)"
|
||||
}
|
||||
fi
|
||||
|
||||
# Show dry run notice
|
||||
if [[ "$DRY_RUN" == true ]]; then
|
||||
print_msg "$YELLOW" "DRY RUN MODE - No changes will be made"
|
||||
fi
|
||||
|
||||
# Execute based on options
|
||||
if [[ "$SHOW_USAGE" == true ]]; then
|
||||
show_disk_usage
|
||||
elif [[ "$REMOVE_ALL" == true ]]; then
|
||||
remove_all_packages "$DRY_RUN"
|
||||
else
|
||||
clean_packages "$KEEP_VERSIONS" "$DRY_RUN"
|
||||
|
||||
# Update database after cleaning (unless dry run)
|
||||
if [[ "$DRY_RUN" != true ]]; then
|
||||
print_msg "$BLUE" "\n==> Updating repository database..."
|
||||
"$REPO_DIR/scripts/update-repo.sh" >/dev/null 2>&1 && {
|
||||
print_msg "$GREEN" " -> Database updated successfully!"
|
||||
} || {
|
||||
print_msg "$YELLOW" " -> Database update failed (may need manual update)"
|
||||
}
|
||||
fi
|
||||
|
||||
show_disk_usage
|
||||
fi
|
||||
|
||||
print_msg "$GREEN" "\n==> Cleanup complete!"
|
||||
|
||||
show_disk_usage
|
||||
fi
|
||||
|
||||
echo ""
|
||||
print_success "Cleanup complete!"
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
main "$@"
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
# Meta command for Omarchy repository management
|
||||
# Usage: ./bin/repo <command> [options]
|
||||
|
||||
set -e
|
||||
|
||||
# Get the directory of this script
|
||||
SCRIPT_DIR=$(realpath "${BASH_SOURCE[0]%/*}")
|
||||
BUILD_ROOT=$(realpath "$SCRIPT_DIR/..")
|
||||
|
||||
# Source common functions
|
||||
source "$BUILD_ROOT/lib/message-helpers.sh"
|
||||
|
||||
# Show usage
|
||||
show_usage() {
|
||||
echo "Usage: $0 <command> [options]"
|
||||
echo ""
|
||||
echo "Commands:"
|
||||
echo " build Build AUR packages"
|
||||
echo " update Update repository database"
|
||||
echo " clean Clean old package versions"
|
||||
echo " list List packages in repository"
|
||||
echo " remove Remove a specific package"
|
||||
echo " sync Sync repository to remote"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " $0 build # Build all packages"
|
||||
echo " $0 update --clean # Update database (clean rebuild)"
|
||||
echo " $0 clean --dry-run # Preview cleanup"
|
||||
echo " $0 list # List all packages"
|
||||
echo " $0 remove package-name # Remove a package"
|
||||
echo " $0 sync x86_64 # Sync to remote"
|
||||
echo ""
|
||||
echo "For command-specific help, use:"
|
||||
echo " $0 <command> --help"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Check if no command provided
|
||||
if [[ $# -eq 0 ]]; then
|
||||
show_usage
|
||||
fi
|
||||
|
||||
# Get command and shift arguments
|
||||
COMMAND="$1"
|
||||
shift
|
||||
|
||||
# Route to appropriate script
|
||||
case $COMMAND in
|
||||
build)
|
||||
exec "$SCRIPT_DIR/build" "$@"
|
||||
;;
|
||||
update)
|
||||
exec "$SCRIPT_DIR/update-repo" "$@"
|
||||
;;
|
||||
clean)
|
||||
exec "$SCRIPT_DIR/clean-repo" "$@"
|
||||
;;
|
||||
list)
|
||||
exec "$SCRIPT_DIR/list-packages" "$@"
|
||||
;;
|
||||
remove)
|
||||
exec "$SCRIPT_DIR/remove-package" "$@"
|
||||
;;
|
||||
sync)
|
||||
exec "$SCRIPT_DIR/sync-repo" "$@"
|
||||
;;
|
||||
-h | --help | help)
|
||||
show_usage
|
||||
;;
|
||||
*)
|
||||
print_error "Unknown command: $COMMAND"
|
||||
echo ""
|
||||
show_usage
|
||||
;;
|
||||
esac
|
||||
+33
-6
@@ -1,13 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Default remote
|
||||
REMOTE="pkgs.omarchy.org:omarchy-pkgs"
|
||||
# Source common functions
|
||||
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
||||
source "$BUILD_ROOT/lib/message-helpers.sh"
|
||||
|
||||
# Default remote (production)
|
||||
DEFAULT_REMOTE="pkgs.omarchy.org:omarchy-pkgs"
|
||||
REMOTE="$DEFAULT_REMOTE"
|
||||
SKIP_PROD_CHECK=false
|
||||
|
||||
# Parse arguments
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: $0 [directory] [options]"
|
||||
echo "Usage: $0 <directory> [options]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --remote <remote> Specify rclone remote (default: pkgs.omarchy.org:omarchy-pkgs)"
|
||||
echo " --remote <remote> Specify rclone remote (default: $DEFAULT_REMOTE)"
|
||||
echo " --skip-prod-check Skip production sync confirmation"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " $0 x86_64 # Sync to production (with confirmation)"
|
||||
echo " $0 x86_64 --remote test:bucket # Sync to test remote"
|
||||
echo " $0 x86_64 --skip-prod-check # Sync to production without confirmation"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -21,12 +34,26 @@ while [[ $# -gt 0 ]]; do
|
||||
REMOTE="$2"
|
||||
shift 2
|
||||
;;
|
||||
--skip-prod-check)
|
||||
SKIP_PROD_CHECK=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
print_error "Unknown option: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "Syncing to: $REMOTE"
|
||||
# Check if syncing to production and warn user
|
||||
if [[ "$REMOTE" == "$DEFAULT_REMOTE" ]] && [[ "$SKIP_PROD_CHECK" != true ]]; then
|
||||
print_warning "You are about to sync to PRODUCTION ($REMOTE)"
|
||||
echo ""
|
||||
gum confirm "Are you sure you want to sync to production?" || {
|
||||
print_info "Sync cancelled"
|
||||
exit 0
|
||||
}
|
||||
fi
|
||||
|
||||
print_info "Syncing to: $REMOTE"
|
||||
rclone sync "$DIRECTORY" "$REMOTE/$(basename $DIRECTORY)" --checksum --progress --copy-links --delete-after -v
|
||||
|
||||
+21
-10
@@ -6,7 +6,7 @@ set -e
|
||||
|
||||
# Source common functions
|
||||
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
|
||||
source "$BUILD_ROOT/lib/common.sh"
|
||||
source "$BUILD_ROOT/lib/message-helpers.sh"
|
||||
|
||||
# Repository configuration
|
||||
ARCH_DIR="$BUILD_ROOT/x86_64"
|
||||
@@ -82,18 +82,30 @@ sign_database() {
|
||||
print_info "Signing repository database..."
|
||||
|
||||
# Check if GPG key is available
|
||||
if ! gpg --list-secret-keys 2>/dev/null | grep -q "sec"; then
|
||||
local KEY_ID=$(gpg --list-secret-keys --keyid-format LONG 2>/dev/null | grep "sec" | head -1 | awk '{print $2}' | cut -d'/' -f2)
|
||||
if [[ -z "$KEY_ID" ]]; then
|
||||
print_warning "No GPG key found, skipping signing"
|
||||
print_warning "To enable signing, create a GPG key and configure it"
|
||||
return
|
||||
fi
|
||||
|
||||
# Sign the database
|
||||
gpg --detach-sign --use-agent "$DB_FILE" 2>/dev/null && {
|
||||
print_success "Database signed successfully!"
|
||||
} || {
|
||||
print_warning "Database signing failed (optional)"
|
||||
}
|
||||
# Sign the database using the same method as package signing
|
||||
if [[ -n "$GPG_PASSPHRASE" ]]; then
|
||||
# Use passphrase if available (same as build script)
|
||||
gpg --batch --yes --pinentry-mode loopback --passphrase "$GPG_PASSPHRASE" \
|
||||
--detach-sign --local-user "$KEY_ID" "$DB_FILE" 2>/dev/null && {
|
||||
print_success "Database signed successfully!"
|
||||
} || {
|
||||
print_warning "Database signing failed (optional)"
|
||||
}
|
||||
else
|
||||
# Fall back to agent-based signing
|
||||
gpg --detach-sign --use-agent --local-user "$KEY_ID" "$DB_FILE" 2>/dev/null && {
|
||||
print_success "Database signed successfully!"
|
||||
} || {
|
||||
print_warning "Database signing failed (optional)"
|
||||
}
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to generate repository statistics
|
||||
@@ -148,7 +160,7 @@ main() {
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --clean Remove existing database and rebuild from scratch"
|
||||
echo " --clean Remove existing database and rebuild from scratch. Does not remove package files."
|
||||
echo " --verify Only verify the database"
|
||||
echo " --sign Sign the database with GPG"
|
||||
echo " --stats Show repository statistics only"
|
||||
@@ -184,4 +196,3 @@ main() {
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user