Skip to main content
Topic: Pacman hook using pacman command (Read 356 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Pacman hook using pacman command

I made an "autoremove" hook that removes packages no more necessary, but since it is executed when pacman is in use:
Code: [Select]
(1/3) autoremove.hook
error: failed to init transaction (unable to lock database)
error: could not lock database: File exists
  if you're sure a package manager is not already
  running, you can remove /var/lib/pacman/db.lck
error: command failed to execute correctly

I saw the command on some wiki:
Code: [Select]
pacman -Qtdq | pacman -Rns -

I think that would be nice to have an option in the pacman config to do this automatically.

 

Re: Pacman hook using pacman command

Reply #1
Won't simply running pacman -Rns on the target package also remove the leftovers, at least majority of the time?

I wouldn't recommend deleting the lock file when another hook may take place after yours, executing concurrently and corrupting the db like that.

Re: Pacman hook using pacman command

Reply #2
Won't simply running pacman -Rns on the target package also remove the leftovers, at least majority of the time?
I didn't think about that, I don't know pacman so well yet.
It seems fine thanks.