You are not logged in.

#1 2026-05-21 15:39:25

LinuxLover471
Member
From: Asia, India
Registered: 2025-02-23
Posts: 174

A Script to: Check for package updates with pkgctl and bump version

Hi! I hope that you are doing well.

I maintain some packages myself and all of us maintainers know how tedious it is to check for the updates of each and every package by ourselves, so we just use pkgctl version check and pkgctl version upgrade.

Though I noticed that it's also TOO tedious to run the above listed separately on each package, and then handle the edge cases like somebody else ( example: a co-maintainer ) already having bumped the package.

So I decided to make a script that does the job for you.

#!/bin/bash

pkgpath=$HOME/repos/aur/

if ! pacman -Qi devtools git nvchecker >/dev/null 2>&1; then
    sudo pacman -S --needed devtools git nvchecker
fi

for pkgdir in "$pkgpath"*; do
    echo
    echo "===> $pkgdir <==="

    cd "$pkgdir"
    pkgctl version check
    case $? in
    # Skip to next iteration if Upto-date OR .nvchecker.toml file is missing.
    0 | 3) continue ;;
    esac

    echo "=> Repo might be out-of-date <="
    echo "-> Running git pull <="
    git pull

    pkgctl version check
    case $? in
    0 | 3) continue ;;
    esac

    read -n1 -rp "Do you want to upgrade (bump) the package? [y/N]:" upg_choice
    upg_choice="${upg_choice,,}"

    if [[ $upg_choice == "y" ]]; then
        pkgctl version upgrade
        makepkg --printsrcinfo >.SRCINFO

        read -n1 -rp "Do you want to push the update? [y/N]:" push_choice
        push_choice="${push_choice,,}"

        if [[ $push_choice == "y" ]]; then
            read -rp "What commit message do you want to give?:" commit_msg
            git add .
            git commit -m "$commit_msg"
            git push
        fi
        continue
    fi
    echo "Skipping updating the package."
done

It doesn't have a specific name, it's simply saved as 'check_package_updates.sh' on my system, and aliased via .bashrc to 'check_package_updates' so that I can run it from any directory.

Even though I have tried to make this fast and correct to the extent of my knowledge, If you feel that anything can be improved, please don't hesitate to reach me!

I hope that you find this little script of mine useful!
Have fun!

Last edited by LinuxLover471 (2026-05-22 07:30:30)


--- asyync1024

Offline

#2 2026-05-21 17:45:41

gromit
Administrator
From: Germany
Registered: 2024-02-10
Posts: 1,529
Website

Re: A Script to: Check for package updates with pkgctl and bump version

Did you already see pkgctl version check, pkgctl version upgrade and pkgctl version setup?

Offline

#3 2026-05-22 07:23:28

LinuxLover471
Member
From: Asia, India
Registered: 2025-02-23
Posts: 174

Re: A Script to: Check for package updates with pkgctl and bump version

@gromit
I didn't know that such tool existed! Holy cow. I have improved my original script which will now be using pkgctl version AND will have the ability to bump packages, and push via git, which isn't done by default.
Thanks for the insight!


--- asyync1024

Offline

Board footer

Powered by FluxBB