Skip to content

Verify packages

Verify packages #8

name: Verify Arch Linux 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:latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Update Pacman and Install Base Packages
run: |
# Enable multilib repository
sed -i '/\[multilib\]/,/Include/s/^#//' /etc/pacman.conf
# Update pacman database and install essential tools
pacman -Syyu --noconfirm
pacman -S --noconfirm grep sed coreutils
- name: Extract and validate packages
run: |
failed_packages=()
validate_package() {
local package=$1
# Skip if empty, starts with #, or starts with --
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
}
# Find all .sh files in root directory
for file in *.sh; do
if [ -f "$file" ]; then
echo "📄 Checking packages in $file..."
# Extract multi-line package installations
while IFS= read -r line; do
if [[ "$line" =~ ^pacman\ -S\ --noconfirm ]]; then
# Start capturing packages
in_package_list=1
# Extract packages from the first line, skipping pacman command and known arguments
packages=$(echo "$line" | sed 's/pacman -S --noconfirm//g' | sed 's/--ask [0-9]//g' | tr '\\' ' ')
for pkg in $packages; do
validate_package "$pkg"
done
elif [ "$in_package_list" = "1" ] && [[ "$line" =~ ^[[:space:]]*[^[:space:]].*\\ *$ ]]; then
# Continue capturing packages from continuation lines
packages=$(echo "$line" | sed 's/\\//g')
for pkg in $packages; do
validate_package "$pkg"
done
else
in_package_list=0
fi
done < "$file"
fi
done
# Print summary of failed packages
if [ ${#failed_packages[@]} -eq 0 ]; then
echo "✅ All packages validated successfully!"
exit 0
else
echo "❌ The following packages were not found:"
printf '%s\n' "${failed_packages[@]}"
echo "Total failed packages: ${#failed_packages[@]}"
exit 1
fi