Skip to content

Instantly share code, notes, and snippets.

@fsantini
Created May 31, 2024 20:43
Show Gist options
  • Save fsantini/a537d18c1609163b2448e2025d1ac488 to your computer and use it in GitHub Desktop.
Save fsantini/a537d18c1609163b2448e2025d1ac488 to your computer and use it in GitHub Desktop.
Script to upgrade AUR packages in Manjaro. Doesn't abort everything if one package fails.
#!/bin/bash
# Initialize arrays to keep track of successful and failed builds
successful_builds=()
failed_builds=()
# Get a list of AUR packages that need to be updated
echo "Checking for AUR package updates..."
aur_updates=$(pamac checkupdates -a | grep AUR | awk '{print $1, $2}')
# Check if there are any AUR updates
if [ -z "$aur_updates" ]; then
echo "No AUR package updates available."
exit 0
fi
# Convert to array
readarray aur_updates <<< "$aur_updates"
# Upgrade each AUR package individually
for package_version in "${aur_updates[@]}"; do
package=$(echo $package_version | awk '{print $1}')
version=$(echo $package_version | awk '{print $2}')
echo "Checking version of $package"
stored_version=$(pacman -Qi "$package" | grep -Po '^Version\s*: \K.+')
echo "Stored version $stored_version, available: $version"
if [ "$stored_version" = "$version" ]
then
echo "Versions are equal, skipping..."
continue
fi
echo "Attempting to upgrade $package from AUR..."
if pamac build $package --no-confirm; then
echo "Successfully built $package."
successful_builds+=("$package")
else
echo "Failed to build $package, skipping..."
failed_builds+=("$package")
fi
done
# Print summary
echo "All AUR packages processed."
echo "Successfully built packages: ${successful_builds[*]}"
echo "Failed to build packages: ${failed_builds[*]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment