On Fri, Feb 22, 2008 at 07:07:54PM +0100, Martin Fuzzey wrote:
> Hi all,
> 
> frequently maintainer scripts modify the same files and to avoid duplication
> of path names etc in all scripts I was wondering if they could be factorized
> anywhere.
> The obvious solution of installing something like
> /usr/share/package/common.sh and sourcing it in the maintainer scripts
> doesn't work as the package files may already have been removed.
> 
> Any ideas or is this impossible?
You can include some kind of common script and use .in files parsed as
with #DEBHELPER# or such.  Perhaps use cpp instead of sed for this, or
someone will suggest a better way yet.

./debian/maintscript-common:
# Begin debian/maintscript-common shell fragment
[...]
# End maintscript-common

./debian/postinst.in:
#! /bin/sh
#  Postinstallation script for foo
#MAINTSCRIPT-COMMON#
[...]

./debian/rules:
clean:
        dh_clean debian/postinst debian/preinst debian/postrm debian/prerm

binary:
        [...]

        set -e; cd debian; for m in postinst preinst postrm prerm; \
        do \
                f='maintscript-common'; \
                [ ! -e "$$m.in" ] && continue; \
                exec <"$$m.in" >"$$m"; \
                sed -e "s/^#MAINTSCRIPT-COMMON#$$//; T; r $$f"; \
        done

        [...]

        dh_installdeb

        [...]
                
Colin watson wrote about a scenario where he apparently needed to do
this:
http://lists.debian.org/debian-devel/2006/12/msg00647.html

Justin


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to