Created
June 12, 2024 23:35
-
-
Save bendavis78/7028462a5902f492a1f2794ac9b769ef to your computer and use it in GitHub Desktop.
Find packages that are causing issues during paru upgrade
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Require argument for the package name | |
if [ -z "$1" ]; then | |
# only show script name in usage | |
echo "Usage: $(basename $0) <package_name>" | |
exit 1 | |
fi | |
pkgname="$1" | |
# List all AUR packages to be updated | |
aur_updates=$(paru -Qua | awk '{print $1}') | |
# Function to recursively check dependencies | |
check_dependencies() { | |
local pkg=$1 | |
local parent=$2 | |
local level=$3 | |
local indent=$(printf '%*s' $level) | |
echo "${indent}Checking dependencies for $pkg..." | |
# Check if the package depends on $pkgname | |
if paru -Si "$pkg" | grep -q "$pkgname"; then | |
echo "${indent}$pkg (directly depends on $pkgname)" | |
return 0 | |
else | |
# Get dependencies of the package | |
paru -Si "$pkg" | awk '/Depends On/ {flag=1; next} /Optional Deps/ {flag=0} flag {print}' | tr -d '[:space:]' | tr ',' '\n' | while read -r dep; do | |
if [[ $dep != "None" && $dep != "" ]]; then | |
echo "${indent} Checking dependency: $dep" | |
check_dependencies "$dep" "$pkg" $((level + 2)) | |
fi | |
done | |
fi | |
} | |
# Check each AUR package for dependencies | |
echo "$aur_updates" | while read -r pkg; do | |
check_dependencies "$pkg" "" 0 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment