Skip to content

Verify packages

Verify packages #22

name: Verify packages
on:
schedule:
- cron: '0 0 * * *' # Runs daily at midnight UTC
workflow_dispatch: # Allows manual triggering
jobs:
check-packages:
runs-on: ubuntu-latest
container:
image: archlinux:multilib-devel
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Update Pacman and install base packages
run: |
# Update pacman database and install essential tools
pacman -Syyu --noconfirm
pacman -S --noconfirm grep sed coreutils git
- name: Extract GPU packages from install.sh
run: |
# Extract all GPU_PACKAGES values from install.sh
ALL_GPU_PACKAGES=$(grep -E 'export GPU_PACKAGES="[^"]*"' install.sh | \
sed 's/export GPU_PACKAGES="\([^"]*\)"/\1/' | \
tr '\n' ' ' | \
xargs -n1 | sort -u | xargs)
echo "GPU_PACKAGES=$ALL_GPU_PACKAGES" >> $GITHUB_ENV
- name: Extract and validate packages
run: |
# Array to store failed packages
declare -a failed_packages
# Function to validate a single package
validate_package() {
local package="$1"
# Skip empty, comments, argument flags, or variables like $GPU_PACKAGES
if [[ -z "$package" ]] || [[ "$package" == "#"* ]] || [[ "$package" == "-"* ]] || [[ "$package" =~ ^-- ]] || [[ "$package" == *"$"* ]]; then
return 0
fi
# Check package in pacman
if pacman -Ss "^${package}$" > /dev/null 2>&1; then
echo "✅ Package exists in pacman: $package"
# Check package in AUR using curl (direct AUR API query)
elif curl -s "https://aur.archlinux.org/rpc/?v=5&type=info&arg[]=${package}" | grep -q '"resultcount":1'; then
echo "✅ Package exists in AUR: $package"
else
failed_packages+=("$package")
echo "❌ Package not found: $package"
fi
}
# Function to clean and process a line of packages
process_packages() {
local line="$1"
# Remove the command and any arguments like --ask N
cleaned_line=$(echo "$line" | \
sed 's/pacman -S --noconfirm//g' | \
sed 's/paru -S --noconfirm//g' | \
sed 's/--ask [0-9]*//g' | \
sed 's/--needed//g' | \
tr '\\' ' ')
# Process packages on this line
for pkg in $cleaned_line; do
validate_package "$pkg"
done
}
# Process each .sh file
for file in *.sh; do
if [[ -f "$file" ]]; then
echo "📄 Checking packages in $file..."
# Read file line by line
while IFS= read -r line || [[ -n "$line" ]]; do
# Check if line contains pacman or paru install command
if [[ "$line" == *"pacman -S --noconfirm"* ]] || [[ "$line" == *"paru -S --noconfirm"* ]]; then
# Process the current line
process_packages "$line"
# If line ends with \, process continuation lines
if [[ "$line" =~ \\[[:space:]]*$ ]]; then
while IFS= read -r line || [[ -n "$line" ]]; do
# Stop if we hit a line that doesn't end with \ and isn't part of package list
if [[ ! "$line" =~ \\[[:space:]]*$ ]] && [[ ! "$line" =~ ^[[:space:]]*[a-zA-Z0-9] ]]; then
break
fi
# Clean and process the continuation line
process_packages "$line"
done
fi
fi
done < "$file"
fi
done
# Validate GPU_PACKAGES
echo "🔍 Checking GPU_PACKAGES: $GPU_PACKAGES"
for pkg in $GPU_PACKAGES; do
validate_package "$pkg"
done
# Print summary
echo "=== Summary ==="
if [ ${#failed_packages[@]} -eq 0 ]; then
echo "✅ All packages validated successfully!"
exit 0
else
echo "❌ Failed packages:"
printf '%s\n' "${failed_packages[@]}"
echo "Total failed packages: ${#failed_packages[@]}"
exit 1
fi