[root tip] [HowTo] Check if your AUR build scripts have been updated

:reminder_ribbon: AUR usage != Manjaro stable branch

Test if you are AUR ready by running below snippet in a terminal

if [[ $(pacman-mirrors -G) == 'stable' ]]; then echo 'AUR is a no-go'; else echo 'OK - go ahead'; fi

The Arch way

Every AUR build script page has a notification subscription → in upper right box.

This is a simple as it gets - when the script is updated you get a mail notification.

But Pamac can do that?

And you are correct - it can.

Even so it has proven countless times this is a bad idea.

  1. An otherwise successful sync breaks due invalid AUR database
  2. You run into issues when a package and dependencies is demoted from repo to AUR
  3. Duplicate package names - where version in AUR is higher than official repo.
    [Example 1] [Example 2]

That just a couple of stumbling points the last couple of months.

So do yourself a favour and revert Pamac → Preferences → Third Party → Check for updates to the default - which is disabled.

One simple solutions is to run a script after login

The script

The script requires yay to be installed

sudo pacman -Syu yay

Create a script - check-aur.sh - place it in ~/.local/bin and make it executable with content

#!/usr/bin/env bash

if ! command -v yay > /dev/null; then 
    echo ":: Yay not found... (sudo pacman -S yay)"
    exit 1
fi

aur_changed=$(yay -Quaq)

if ! [[ -z ${aur_changed} ]]; then
    if ! stty &>/dev/null; then
        notify-send -u normal "Notification of AUR changes"  "$aur_changed"
        exit
    fi
    printf "${aur_changed}"
fi

chmod +x ~/.local/bin/check-aur.sh

The script will do

  • check if yay is installed - if not exit
  • execute yay -Quaq and store the response in a variable
  • if there is any content in the response
    • if run by a service use the system notification daemon to pop a notification
    • if run from command line output to console

autorun after login

To run it one time after login create a user service file

First create the service folder structure

mkdir -p ~/.config/systemd/user

Then create a file ~/.config/systemd/user/check-aur.service - paste the following content

[Unit]
Description=Check for changes to AUR my buildscrpts
# wait for network
After=syslog.target network.target default.target

[Service]
Type=simple
ExecStartPre=/bin/sleep 30
ExecStart=/home/%u/.local/bin/check-aur.sh

[Install]
WantedBy=default.target

Start the user service - do not use sudo

systemctl --user enable check-aur.service

After login the service will activate and do the following

  • wait 30 seconds
  • run the check-aur.sh script
  • execute the script and exit

oh-no no updates - what shall I make of my time


If you are not satisfied with the popup shortly after login create a timer

:reminder_ribbon: Do not flood AUR with useless traffic

Create a complementary timer ~/.config/systemd/user/check-aur.timer with content - example is 4 hours

[Unit]
Description=Schedule AUR change checks

[Timer]
OnBootSec=10m
Persistent=true
OnCalendar=0/4:00:00
OnUnitActiveSec=4h

[Install]
WantedBy=timers.target

The timer will do this

  • wait until 10m after boot
  • activate the check-aur.service
  • re-activate the service every 4 hours while system is up

When using a timer - you need to disable the service - otherwise the timer refuse to activate it.

systemctl --user disable --now check-aur.service

Then activate the timer

systemctl --user enable --now check-aur.timer
2 Likes

I suppose there is no other way to check without using yay in that script? :thinking:
Ahh well, im sure it will help some ppl :vulcan_salute: