You are not logged in.

#1 2021-12-19 09:56:22

pepper
Member
Registered: 2017-12-09
Posts: 46

[SOLVED] list maually installed packages from AUR and from PACMAN

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

#2 2021-12-19 10:50:55

progandy
Member
Registered: 2012-05-17
Posts: 4,766

Re: [SOLVED] list maually installed packages from AUR and from PACMAN

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 ' |

Online

#3 2021-12-19 10:53:42

Raynman
Member
Registered: 2011-10-22
Posts: 1,359

Re: [SOLVED] list maually installed packages from AUR and from PACMAN

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

#4 2021-12-19 13:28:35

pepper
Member
Registered: 2017-12-09
Posts: 46

Re: [SOLVED] list maually installed packages from AUR and from PACMAN

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

#5 2021-12-19 13:54:28

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 26,179
Website

Re: [SOLVED] list maually installed packages from AUR and from PACMAN

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

#6 2021-12-19 13:57:00

progandy
Member
Registered: 2012-05-17
Posts: 4,766

Re: [SOLVED] list maually installed packages from AUR and from PACMAN

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 ' |

Online

#7 2021-12-19 14:09:08

pepper
Member
Registered: 2017-12-09
Posts: 46

Re: [SOLVED] list maually installed packages from AUR and from PACMAN

thank you all !

Offline

#8 2021-12-20 00:01:31

fukawi2
Administrator
From: .vic.au
Registered: 2007-09-28
Posts: 6,164
Website

Re: [SOLVED] list maually installed packages from AUR and from PACMAN

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)

Offline

#9 2021-12-20 03:48:58

NuSkool
Member
Registered: 2015-03-23
Posts: 122

Re: [SOLVED] list maually installed packages from AUR and from PACMAN

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

Board footer

Powered by FluxBB