You are not logged in.

#1 2016-05-05 08:13:07

uiii
Member
Registered: 2009-02-25
Posts: 27

Interrupt package uninstallation

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

#2 2016-05-05 08:28:33

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,863
Website

Re: Interrupt package uninstallation

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

#3 2016-05-05 08:44:47

uiii
Member
Registered: 2009-02-25
Posts: 27

Re: Interrupt package uninstallation

WorMzy wrote:

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

#4 2016-05-05 09:10:03

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,863
Website

Re: Interrupt package uninstallation

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

#5 2016-05-05 09:25:50

uiii
Member
Registered: 2009-02-25
Posts: 27

Re: Interrupt package uninstallation

WorMzy wrote:

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.

WorMzy wrote:

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

#6 2016-05-06 13:26:57

Lone_Wolf
Forum Moderator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,922

Re: Interrupt package uninstallation

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

#7 2016-05-06 22:55:14

Ropid
Member
Registered: 2015-03-09
Posts: 1,069

Re: Interrupt package uninstallation

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

Board footer

Powered by FluxBB