What is the standard way to share code between the dpkg scripts (preinst, postinst, prerm, postrm)?

I can see how to share code between just postinst and prerm (by installing it as part of the package), but can't see any way to share with preinst and postrm.


I'm pretty sure there's nothing to be done. You can rely on a Pre-Depend:, but these are to be avoided unless absolutely necessary, as they're a heavy burden on the dependency chain.

You can pre-process the scripts, if there's code to be shared. The debhelper tools already do this, inserting boilerplate into the various maintainer scripts.

It's rare to need to do complicated things in preinst or postinst. The main adhockery tends to be handling tricky upgrades, and that's usually custom code in a preinst.

| improve this answer | |
  • Pre-processing the scripts sounds like a reasonable option. Thanks. – Ben Butler-Cole Feb 22 '12 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.