I structured my debian package in following way
preinst script
which displays EULA to user and ask for choice 'y' or 'n'.postinst script
which install the package and updates the initrd image.prerm script
,before un installing package checks for a condition if the condition matches then it exits from prerm withexit 1
.postrm script
unloads the package if the check in prerm script fails and it update the initrd image.
Now I have following questions
Lets say package is already installed on machine and user is trying to reinstall or upgrade it .Now if user says 'yes' to EULA, what debian will do? I observed it simply -uninstall previously installed package and reinstall it which is perfectly fine.But if user says 'n' to EULA how would I exit from uninstallation process?I did it adding
exit 1
in preinst script but its not working.I observed that if you saydpkg -i package
,debian first checks if package is already installed, If package is already installed then it unloads the package even before calling preinst script(`checked it using lsmod) so if you say 'n' to EULA it starts rolling back the changes i.e reinstalling unloaded package by calling postinst script which looks like weird behaviour to end user as user has already said 'n' to EULA.I tried adding a check if module is present the do not re install it but as I said whenever you say dpkg -i package ,debian first removes the module and fails my check.So how can avoid reinstalling package if user says no to EULA?If I say
dpkg -r package
and myprerm script fails and exits with status 1
.Here the same thing happens as above.If you saydpkg -r package
,debian unloads the package before calling prerm script then it checks for the condition inprerm
if it matches it exits from it and starts rolling back the changes by calling postinst script which is once again weird behaviour.
I know Its a default behavior of debian but what if I want to override default behaviour?
dpkg
uses; do you mean "unpack"? – derobert Jul 8 at 8:40