You are not logged in.
Hi,
is it possible to interrupt an uninstallation of a package if a conditions are not met? E.g. if some environment variable is not set. I tried to put exit 1 or return 1 in the pre_remove, it will print error but the uninstallation continues. I need this because I'm doing some backup restore during uninstallation and I need a path to backup directory. Please do not tell me if this is good or bad it's only for my personal packages.
Thanks
Richard
Offline
Not as far as I know. Put your check before you call pacman -R.
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
Put your check before you call pacman -R.
That is the point, I need to prevent pacman to uninstall the package, because my custom wrapper application should be used. So I can't put check before pacman is used.
Last edited by uiii (2016-05-05 08:45:19)
Offline
I don't understand. If you don't want pacman to remove a package, don't tell pacman to remove the package.
The only reason I can think of that pacman would abort during a package removal (and not at the start of a transaction) would be if the filesystem became read-only.
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
If you don't want pacman to remove a package, don't tell pacman to remove the package.
I don't want to use it, it's for cases when I accidentally use pacman to remove the package. And now it is only for my personal use, but later, maybe, I will make it public.
The only reason I can think of that pacman would abort during a package removal (and not at the start of a transaction) would be if the filesystem became read-only.
I've tried something similar - kill the pacman process, but it leaves a lock file in the filesystem so I have to remove it after. I think that making the filesystem read-only (actually I don't event know how to do it on running system) will result to the same.
Last edited by uiii (2016-05-05 09:26:18)
Offline
uiii, this looks like you could solve it with a pacman hook ( man alpm-hooks ) .
the hook would look something like this:
[Trigger]
Type = Package
Operation = Remove
Target = special_package1
Target = special_package2
Target = special_package3
[Action]
Description = Backup some stuff BEFORE removal
When = PreTransaction
Exec = /usr/bin/my_special_backup.sh
AbortOnFail
# if backup is not succesfull, my_special_backup.sh should return non-zero, causing the removal to abort
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
(A works at time B) && (time C > time B ) ≠ (A works at time C)
Offline
There is a setting "HoldPkg = ..." in /etc/pacman.conf. The man-page says this about it:
"If a user tries to --remove a package that’s listed in HoldPkg, pacman will ask for confirmation before proceeding. Shell-style glob patterns are allowed."
Offline