Skip to content

Verify packages

Verify packages #14

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
- 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, or argument flags
if [[ -z "$package" ]] || [[ "$package" == "#"* ]] || [[ "$package" == "-"* ]]; then
return 0
fi
if ! pacman -Ss "^${package}$" > /dev/null 2>&1; then
failed_packages+=("$package")
echo "❌ Package not found: $package"
else
echo "✅ Package exists: $package"
fi
}
# 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 install command
if [[ "$line" == *"pacman -S --noconfirm"* ]]; then
# Remove the pacman command and any arguments like --ask N
cleaned_line=$(echo "$line" | \
sed 's/pacman -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
# 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
cleaned_line=$(echo "$line" | sed 's/\\//g')
for pkg in $cleaned_line; do
validate_package "$pkg"
done
done
fi
fi
done < "$file"
fi
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