yay/.gitea/workflows/up-to-date.sh
Sebastiaan de Schaetzen a383314040
Some checks failed
/ Wake Runner (push) Has been skipped
/ Check if rebuild is necessary (push) Has been skipped
/ Update from AUR (push) Failing after 7s
/ Build and Push (push) Has been skipped
Add up-to-date check to not recompile things that have not changed
2025-04-23 11:56:23 +02:00

48 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# Exit on any error
set -e
# Source the PKGBUILD in a subshell to avoid polluting the global environment
(
source ./PKGBUILD
# Convert pkgname to array in case it's a single string
pkgnames=("${pkgname[@]}")
for pkg in "${pkgnames[@]}"; do
echo "Checking package: $pkg"
if pacman -Si "$pkg" &>/dev/null; then
echo "Package '$pkg' exists in a repository."
# Get the package build date
pkg_build_date=$(date -d "$(pacman -Si "$pkg" | grep 'Build Date' | cut -d: -f2-)" +%s)
all_deps=("${depends[@]}" "${makedepends[@]}" "${optdepends[@]}")
# Check each dependency
for dep in "${all_deps[@]}"; do
dep_name=$(echo "$dep" | sed 's/[<>=].*//') # Remove version constraints
echo "Querying dependency: $dep_name"
if pacman -Si "$dep_name" &>/dev/null; then
dep_build_date=$(date -d "$(pacman -Si "$dep_name" | grep 'Build Date' | cut -d: -f2-)" +%s)
if (( dep_build_date >= pkg_build_date )); then
echo "Dependency '$dep_name' has newer or equal build date than '$pkg'."
exit 1
fi
else
echo "Dependency '$dep_name' not found in repositories. Skipping."
fi
done
echo "All dependencies are older than package '$pkg'."
exit 0
else
echo "Package '$pkg' does NOT exist in any repository."
exit 1
fi
done
)