Hello Daniel

Just a few hints:

On Friday 14 March 2014 08:35:55 Daniel Pocock wrote:
> a) if my postinst or postrm calls apache2_invoke from inside a function,
> then it fails badly
> 
> b) some of my postinst and postrm code is based on examples I saw in
> other packages, they test -x /usr/sbin/apache2 and it turns out this is
> not a great idea as if somebody does
> 
>    dpkg --remove apache2 loganalyzer
>    dpkg --purge loganalyzer
> 
> then at the moment the loganalyzer postrm runs with the "purge"
> argument, there is no /usr/sbin/apache2 and so it does not remove the
> symlink
> 
> Also, the check for /usr/share/apache2/apache2-maintscript-helper would
> also fail if apache2 had been removed - it is OK for the postrm to just
> proceed without calling apache2_invoke at all if it is no longer there
> or should the postm complain?

Please have another look at the wiki: "apache2_invoke disconf" must be
called both at purge *and* at simple removal. So that should take care of
your question b.

Actually, source apache2-maintscript-helper is using the scripts arguments
- like "postrm purge" - in oder to know what it should do. So it must be called
from the script top level, and not from a function where that environment
changed.

If you really need to call the helpers from a function, I guess you need
if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
        . /usr/share/apache2/apache2-maintscript-helper
fi
at top level, where $1 == 'configure' or whatever.
Then you should be able to call apache2_invoke from a function, providing
you wrap it in a [ -e /usr/share/apache2/apache2-maintscript-helper ] too
of course. I did not test that.

Regarding your question b again, if you try dh_apache2, you'll see that
deconfiguration is done at prerm time too, so that simultaneous removal
of apache and your package should work, no matter the order in wich it
occurs. And the bonus: If there's a bug in (pre|post)(inst|rm), you have
someone else to blame, isn't that nice? ;-)

-- Nirgal

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to