Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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