Well I’m also not sure, then. Perhaps /usr/local/bin
is a better idea. Either way, It shouldn’t be in a /home
directory if it should be accessible to more than 1 user.
pacman already outputs when it makes a pacnew, e.g.
[2020-12-18T19:35:28-0500] [ALPM] upgraded grub (2.04-12 → 2.04-13)
[2020-12-18T19:35:28-0500] [ALPM] warning: /etc/default/grub installed as /etc/default/grub.pacnew
you just want the information at the bottom instead of in the body of the upgrades?
Yes, but when you have 600 packages updated, it is nice to have the red text warning telling you with a summary the number and the list of .pacnew files detected. This way no need to scroll the terminal (and if you don’t have a proper terminal configuration in this case anyway the output is maybe not all in the terminal if it is too long), you can’t miss the message as it is in the last pacman steps at the very bottom of terminal.
This. Because it scrolls to fast for me to catch…
Bash magic. Sorry for poor english in code
Install first:
sudo pacman -Syu mlocate
create a file clean-pacnew with CODE:
#!/usr/bin/env bash
if [ "$(id -u)" = "0" ]; then
echo "This script must be run as normal user" 1>&2
exit 1
fi
BD=$(tput bold)
NM=$(tput sgr0)
ls=$(ls -h --group-directories-first --time-style=+"%d.%m.%Y %H:%M" --color=auto -F)
FINDBKP=$(sudo updatedb && locate -e --regex "\.pac(new|orig|save)$")
pacbklist(){
for i in $FINDBKP
do
ls $i
done
}
pacbkpdel(){
for i in $FINDBKP
do
sudo rm -f $i
done
}
main(){
if [[ -z "$FINDBKP" ]]; then
printf "${BD}ERROR: Pacman backup files not found!${NM}\n"
exit 0
else
printf "${BD}SUCCESS: Found pacman backup files:${NM}\n"
pacbklist
printf "${BD}Type ${NM}Y${BD} to continue and ${NM}DELETE${BD} them all.${NM}\n"
printf "${BD}Type any other key to exit.${NM}\n"
printf "${BD}Answer:${NM}"
read SEL
case "$SEL" in
"Y") pacbkpdel;;
*) exit 0;;
esac
fi
}
main
Launch (or add exec bit and put in bin dir)
bash clean-pacnew
Thanks for sharing your script but what are you replying this to, and what should I do with it?
I believe it is another approach to the script. Not the hook, the script.
You can’t have interactive scripts with pacman hooks.
Didn’t realise. I’m guessing then it’s for finding and sorting it out manually. Or something.
Also it seems this script looks for .pacnew .pacsave and .pacorig files, and backup/delete them.
I have made my own script to handle .pacnew files and view difference with meld, and to optionaly delete them after closing meld.
Manually, it seems.
Well, whatever works for him/her/it. And at least now it’s out there…
using instead of creating NEW hooks with same functionality as pacman self.
Yes I know pacman will output when it will write a pacnew file. But it doesn’t do what my hook does.
So thank you but I don’t need another script, I actually don’t need anything, I’m just sharing for other who don’t want to search in pacman log, and want instant listing of .pacnew files at the very bottom of pacman update.
So, install pacman-contrib and use pacdiff.
sudo pacman -Syu && pacdiff
So, install pacutils, and use paclog in a shell function.
cat .bash_functions
#
# ~/.bash_functions
#
...
pwarn () { paclog --after="$1" | paclog --warnings ; }
...
Sample:
pwarn 2020-10-01
[2020-10-31T09:51:48-0400] [ALPM] warning: /etc/pacman.d/mirrorlist installed as /etc/pacman.d/mirrorlist.pacnew
[2020-12-02T17:22:35-0500] [ALPM] warning: /etc/systemd/homed.conf installed as /etc/systemd/homed.conf.pacnew
[2020-12-05T11:48:28-0500] [ALPM] warning: /etc/pacman.d/mirrorlist installed as /etc/pacman.d/mirrorlist.pacnew
[2021-01-10T08:24:01-0500] [ALPM] warning: /etc/pacman.d/mirrorlist installed as /etc/pacman.d/mirrorlist.pacnew
[2021-01-19T20:55:54-0500] [ALPM] warning: directory permissions differ on /mnt/
filesystem: 775 package: 755
LOL, we don’t need no schtinking hooks.
If you don’t like using pacman hooks, don’t . If you feel like sharing your how-to’s please open a thread.
Please guys no more suggestion about how to use other various method to have ‘similar’ results, because if you do that on all how-to threads, it is infinite, this is by essence how it works, you can achieve the same thing in various different ways, for almost everything. This is completely off topic.
Point of the thread: creating a pacman hook to check for .pacnew files. That’s all.
Opinions not really welcomed.
your first script has an syntax error
else
# echo "no .pacnew files found"
fi
uncomment it!!
I just noticed my initial post has been edited by @Fabby and it now has errors in it, and I can’t edit it now. Fabby, fix the pacman hook or put the previous script path back, because now it doesn’t match…
You changed the executable path.
On a side note, why can’t I edit my own post now? Aren’t we supposed to be able to edit WIKI posts (and aren’t post in tutorial category considered WIKI posts or something like that?)
Yes. It wasn’t a wiki post, but it is now. You should be able to edit it now.
Apparently not by default.