Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking for up-to-date pkg versions and update if necessary. #4028

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions scripts/blackman
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,45 @@ is_installed() {
pacman -Qi "$1" &> /dev/null
}

update() {
# Check for updates for the installed packages
printf "Checking for updates...\n"
local updates=()
for pack in packages/*/ aur/*/ ; do (
source "$(realpath -f "$pack/PKGBUILD")"
if is_installed "$pkgname" ; then
local local_ver=$(pacman -Q "$pkgname" | cut -d' ' -f2)
local remote_ver="$pkgver-$pkgrel"
if [[ "$local_ver" != "$remote_ver" ]] ; then
updates+=("$pkgname")
fi
fi;;
) ; done

# Prompt the user to install the updates if available
if [[ ${#updates[@]} -gt 0 ]] ; then
printf "The following packages have updates available:"
printf '%s\n' "${updates[@]}"
read -r -p "Do you want to install them? [Y/n] " choice
case "$choice" in
y|Y|'')
for pack in "${updates[@]}" ; do
do_sync "$pack"
done
;;
n|N)
printf "Update cancelled."
;;
*)
printf "Invalid input."
;;
esac
else
printf "All packages are up to date."
fi
}


case $action in
sync)
# Check for targets.
Expand Down Expand Up @@ -131,6 +170,10 @@ case $action in
) ; done
done
;;
update)
update
;;
*)
groups)
for pack in packages/*/ aur/*/ ; do (
source $pack/PKGBUILD
Expand Down