You are not logged in.

#1 2018-11-14 18:02:06

tdreitz
Member
Registered: 2018-11-14
Posts: 2

[SOLVED] Pacman Hooks: Accessing /var/log/pacman.log?

I'm essentially looking for a list of all the package names I've fed to pacman -S/-R to keep track of things.

The output from pacman -Qqe is a little too verbose for my purposes since it outputs the individual packages from groups without labeling which group they're a member of.

So I wrote an awk script that scrapes pacman's logs for said package names passed to pacman -S/-R.

It works just fine whenever I run it manually but doesn't seem to produce any actual output when run as a hook.

Here's the Exec value of my hook:

gawk -f pachist.awk /var/log/pacman.log | uniq -u | sort > /etc/pkglist.txt

I'm wondering if this is due to pacman locking down /var/log/pacman.log while it's being run?

I'm not very familiar with bash's -c option and this it the only reason I can think of.


P.S. Would be open to any options/commands native to pacman that could produce the output I'm looking for, but so far have come up bupkis in my searches.

Last edited by tdreitz (2018-11-19 18:57:54)

Offline

#2 2018-11-14 18:26:05

Slithery
Forum Moderator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 2,996

Re: [SOLVED] Pacman Hooks: Accessing /var/log/pacman.log?


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2018-11-14 18:35:13

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 20,435
Website

Re: [SOLVED] Pacman Hooks: Accessing /var/log/pacman.log?

The problem is the same as the previously linked thread.  But also note my comment in the other thread.  There is absolutely no reason for your pipeline and thus no need for a shell.  Just use awk properly.  Store each match as a key in an awk associative array incrementing the value, then in the END block print out the keys of the array where the value is 1.  This will give you the same effect as `uniq -u` and `sort`.

But do you really want `uniq -u`?  You know this would leave out any entries that were in there twice? (i.e., it would not list them just once, but would leave them out entirely).

What is your awk script currently doing?

Last edited by Trilby (2018-11-14 18:35:39)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2018-11-14 19:19:39

eschwartz
Trusted User/Bug Wrangler
Registered: 2014-08-08
Posts: 2,533

Re: [SOLVED] Pacman Hooks: Accessing /var/log/pacman.log?

tdreitz wrote:

I'm essentially looking for a list of all the package names I've fed to pacman -S/-R to keep track of things.

The output from pacman -Qqe is a little too verbose for my purposes since it outputs the individual packages from groups without labeling which group they're a member of.

What does "things I pass as explicit options to pacman -S|-R" have to do with "the output of pacman -Qqe except it doesn't label groups"?

What does groups have to do with anything?

But if you just want groups, then I can give you that for free:

pacman -Qqe | expac '%n %G'

First word will be the pkgname, second+ word(s) will be the group(s) if any.

The piped use of pacman is just because I assume you want only explicitly installed, not all packages.

expac '%w %n %G'

Print *all* packages, first word is either "explicit" or "dependency", second word is the pkgname, third+ word(s) is the group(s) if any.

Last edited by eschwartz (2018-11-14 19:22:22)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#5 2018-11-14 22:27:58

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 20,435
Website

Re: [SOLVED] Pacman Hooks: Accessing /var/log/pacman.log?

eschwartz wrote:

What does "things I pass as explicit options to pacman -S|-R" have to do with "the output of pacman -Qqe except it doesn't label groups"?

I'm pretty sure that the OP means if he uses a command `pacman -S vim ed gnome`, he'd want the script called from the hook to get precisely 'vim ed gnome' rather than the expansion of the 'gnome' group to all the package names.  Expac would not really help here as perhaps the pacman command actually did specify specific members of the gnome group - e.g. gvfs and vino - then he'd want the script to be passed those package names, not the group they belong to.  In other words, in all cases, the OP wants specifically what was on pacman's command line.

(WHY the OP wants this is a mystery, and it may be an X-Y problem, but what they are looking for is clear enough to me).

Last edited by Trilby (2018-11-14 22:28:57)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2018-11-14 23:42:52

tdreitz
Member
Registered: 2018-11-14
Posts: 2

Re: [SOLVED] Pacman Hooks: Accessing /var/log/pacman.log?

Trilby wrote:

I'm pretty sure that the OP means if he uses a command `pacman -S vim ed gnome`, he'd want the script called from the hook to get precisely 'vim ed gnome' rather than the expansion of the 'gnome' group to all the package names.

Yes, this is exactly what I'm looking to do.

Trilby wrote:

Just use awk properly.  Store each match as a key in an awk associative array incrementing the value, then in the END block print out the keys of the array where the value is 1.  This will give you the same effect as `uniq -u` and `sort`.

Brand new to awk, so I coudln't figure out how to wait until all records had been processed. Hence the pipe to `uniq` to filter each printed field. Adding the `END` block gives me exactly what I'm looking for.

Thank you!

How would I mark this as solved?

Last edited by tdreitz (2018-11-14 23:44:50)

Offline

#7 2018-11-14 23:50:45

Slithery
Forum Moderator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 2,996

Re: [SOLVED] Pacman Hooks: Accessing /var/log/pacman.log?


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

Board footer

Powered by FluxBB