You are not logged in.

#1 2017-09-19 18:47:45

zerophase
Member
Registered: 2015-09-03
Posts: 228

Passing explicitly installed / removed package to pacman hook.

I'm trying to pass explicitly installed package names to a script my hook is running for recording installed packages so I can easily reinstall across multiple machines.  I have NeedsTargets in the hook, but that passes all of the packages installed from executing pacman to the script. Is there anyway to whittle this down to just the explicitly installed packages during post transaction?

Offline

#2 2017-09-19 18:55:07

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Passing explicitly installed / removed package to pacman hook.

Would running...

pacman -Qqet

in a pre-transaction hook and again in a post-transaction hook and diffing the two work?


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 2017-09-19 19:12:42

zerophase
Member
Registered: 2015-09-03
Posts: 228

Re: Passing explicitly installed / removed package to pacman hook.

slithery wrote:

Would running...

pacman -Qqet

in a pre-transaction hook and again in a post-transaction hook and diffing the two work?

The works if I run it in a PreTransaction hook for removal, and PostTransaction for Install.

pkgs=$(</dev/stdin)
native=$(pacman -Qenq | grep "$pkgs")

Offline

#4 2017-09-19 19:21:55

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

Re: Passing explicitly installed / removed package to pacman hook.

This seems like an odd approach: you want to continually update a list you'll only periodically need.  When you need the list, I assume you'll copy/move the list file somewhere.  Why not just generate it at the time it's needed with `pacman -Qeq`?

If you really want to do this in a hook, though, there is no need for the before and after.  Your script is already getting a list of just the packages that are being installed, so just check which (if any) of those are explicit:

pacman -Qeq $@

EDIT: or if the list of packages are coming via stdin:

pacman -Qeq -

Last edited by Trilby (2017-09-19 19:23:37)


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

Offline

#5 2017-09-19 19:46:13

zerophase
Member
Registered: 2015-09-03
Posts: 228

Re: Passing explicitly installed / removed package to pacman hook.

Trilby wrote:

This seems like an odd approach: you want to continually update a list you'll only periodically need.  When you need the list, I assume you'll copy/move the list file somewhere.  Why not just generate it at the time it's needed with `pacman -Qeq`?

If you really want to do this in a hook, though, there is no need for the before and after.  Your script is already getting a list of just the packages that are being installed, so just check which (if any) of those are explicit:

pacman -Qeq $@

EDIT: or if the list of packages are coming via stdin:

pacman -Qeq -

I just want it to be up to date in case I accidentally destroy some data doing an rsync restore.  It's just there in case something bad happens when rolling the system back, so I can get everything up again in the shortest time possible.

Offline

#6 2017-09-20 16:47:07

apg
Developer
Registered: 2012-11-10
Posts: 211

Re: Passing explicitly installed / removed package to pacman hook.

If you're going to run `pacman -Qeq` why bother with NeedsTargets at all?  Just write the full `pacman -Qeq` output to the file after every transaction.

Offline

#7 2017-09-20 18:35:19

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

Re: Passing explicitly installed / removed package to pacman hook.

zerophase wrote:

I just want it to be up to date in case I accidentally destroy some data doing an rsync restore.  It's just there in case something bad happens when rolling the system back, so I can get everything up again in the shortest time possible.

I'm still missing why this needs to be tied at all to updates.  Just generate the list right before doing your rsync restore.  Surely you update *far* more often than you have to restore from a backup.


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

Offline

#8 2017-09-23 04:07:20

zerophase
Member
Registered: 2015-09-03
Posts: 228

Re: Passing explicitly installed / removed package to pacman hook.

Trilby wrote:
zerophase wrote:

I just want it to be up to date in case I accidentally destroy some data doing an rsync restore.  It's just there in case something bad happens when rolling the system back, so I can get everything up again in the shortest time possible.

I'm still missing why this needs to be tied at all to updates.  Just generate the list right before doing your rsync restore.  Surely you update *far* more often than you have to restore from a backup.

I have it setup so the hook doesn't fire every update. Just when I install or remove a package. I'm also going to be picking up a laptop soon that should be fine with most of the same packages. I'm just trying to automate a very minor maintenance task.

Last edited by zerophase (2017-09-23 04:08:54)

Offline

Board footer

Powered by FluxBB