You are not logged in.
Hello I'm looking for two commands I can't find in the format I need:
1) sort all pacman manually installed packages (showing package version and install time) sorted by date (newest at the bottom, oldest at the beginning)
2) the same thing but for AUR packages only (I use paru)
Last edited by pepper (2021-12-19 14:09:46)
Offline
First get all "foreign" packages and their information with pacinfo (from pacutils), then filter that with awk and sort:
pacman -Qqm | pacinfo | awk -F ": +" '/^Name:/{pkg=$2} /^Version:/{ver=$2} /^Install Date:/{print $2 "\t" pkg " " ver}' | sort -b -t$'\t' -k1
To limit it to AUR packages fetch the list of aur packages (cache that somewhere) and compare against that first:
wget https://aur.archlinux.org/packages.gz
comm -12 <(pacman -Qqm | sort) <(zcat packages | sort) | pacinfo | awk -F ": +" '/^Name:/{pkg=$2} /^Version:/{ver=$2} /^Install Date:/{print $2 "\t" pkg " " ver}' | sort -b -t$'\t' -k1
Last edited by progandy (2021-12-19 10:55:51)
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
If by "manually installed" you mean "explicitly installed" and if it's okay to assume all foreign packages came from the AUR:
pacman -Qen | expac --timefmt='%F %T' '%n %v %l' - | sort -k3
pacman -Qem | expac --timefmt='%F %T' '%n %v %l' - | sort -k3
Offline
Thank you, I tried to format it in this way:
pacman -Qen | expac --timefmt="%F %T" "[%l] %n (%v)" - | sort -k1
Do you know if there is a way to color the name of the package only (to better read it)?
Offline
All that information is in your pacman.log, it's just a matter of filtering for what you want. E.g.
#!/bin/bash
awk '
/\] installed / { v[$4]=$5; d[$4]=$1; }
END { for (p in v) print d[p], p, v[p] }
' /var/log/pacman.log | sort | grep -wFf <(pacman -Qenq)
# or replace -Qenq with -Qemq for "aur" packages
Although the above solution with expac will be a bit more flexible (i.e., for formatting).
EDIT: for your question on coloring (a good example of the above-mentioned "formatting":
pacman -Qen | expac --timefmt="%F %T" "[%l] $(printf '\033[1;34m')%n$(printf '\033[0m') (%v)" - | sort -k1
Change the 1;34 to suite your preferences.
EDIT 2: see below for a better way of specifying colors w/ expac.
Last edited by Trilby (2021-12-19 14:03:17)
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
Here is an example for my awk solution using ANSI SGR color codes: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
pacman -Qqm | pacinfo | awk -F ": +" '/^Name:/{pkg=$2} /^Version:/{ver=$2} /^Install Date:/{print $2 " | \033[33m" pkg " \033[34m" ver "\033[0m"}' | sort -b -t"|" -k1
For expac you can use \e[#m :
pacman -Qen | expac --timefmt="%F %T" '[%l] \e[32m%n\e[0m (%v)' - | sort
Edit: If the date is the first thing in the line in YYYY-MM-DD HH:MM:SS format (even surrounded by unchanging characters), then you do not need the -k parameter. A simple alphabetic sort will do just fine with that time format.
Edit: If you want to know the date any version of a specific package has been installed the first time and you do not want to know the time of the last update, then you'll have to parse the pacman log as described by trilby.
Last edited by progandy (2021-12-19 14:10:45)
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
thank you all !
Offline
Not a System Administration issue; Moving to pacman forum.
@pepper please read the forum description for "System Administration"
Last edited by fukawi2 (2021-12-20 00:02:01)
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
Another useful tool, paclog of pacutils. It's been awhile for me so I'll have dig in and see if it could be used here. I do recall it filters pacman.log.
Offline