From 07ba622edfeb6dbc1164f46399d6fa0a71eab70b Mon Sep 17 00:00:00 2001 From: aph Date: Sun, 23 Feb 2003 18:44:57 +0000 Subject: [PATCH] bpp-debian-maint-scripts - move down to where debconf is, no content changes at all bpp-debian-control - more suggestions from IRC git-svn-id: svn://anonscm.debian.org/ddp/manuals/trunk/developers-reference@2187 313b444b-1b9f-4f58-a734-7bb04f332e8d --- developers-reference.sgml | 139 +++++++++++++++++++------------------- 1 file changed, 70 insertions(+), 69 deletions(-) diff --git a/developers-reference.sgml b/developers-reference.sgml index 2e1f386..70755c7 100644 --- a/developers-reference.sgml +++ b/developers-reference.sgml @@ -6,7 +6,7 @@ %commondata; - + + + Best practices for maintainer scripts +

+Maintainer scripts include the files debian/postinst, +debian/preinst, debian/prerm and +debian/postrm. These scripts take care of any package +installation or deinstallation setup which isn't handled merely by the +creation or removal of files and directories. The following +instructions supplement the . +

+Maintainer scripts must be idempotent. That means that you need to +make sure nothing bad will happen if the script is called twice where +it would usually be called once. +

+Standard input and output may be redirected (e.g. into pipes) for +logging purposes, so don't rely on them being a tty. +

+All prompting or interactive configuration should be kept to a +minimum. When it is necessary, you should use the +debconf package for the interface. Remember that +prompting in any case can only be in the configure stage of +the postinst script. +

+Keep the maintainer scripts as simple as possible. We suggest you use +pure POSIX shell scripts. Remember, if you do need any bash features, +the maintainer script must have a bash sh-bang line. POSIX shell or +Bash are preferred to Perl, since they enable +debhelper to easily add bits to the scripts. +

+If you change your maintainer scripts, be sure to test package +removal, double installation, and purging. Be sure that a purged +package is completely gone, that is, it must remove any files created, +directly or indirectly, in any maintainer script. +

+If you need to check for the existence of a command, you should use +something like +if [ -x /usr/sbin/install-docs ]; then ... + +If you don't wish to hard-code the path of the command in your +maintainer script, the following POSIX-compliant shell function may +help: + +&example-pathfind; + +You can use this function to search $PATH for a command name, +passed as an argument. It returns true (zero) if the command was +found, and false if not. This is really the most portable way, since +command -v, type, and which are not +POSIX. +

+While which is an acceptable alternative, since +it is from the required debianutils package, it's +not on the root partition. That is, it's in /usr/bin rather +than /bin, so one can't use it in scripts which are run +before the /usr partition is mounted. Most scripts won't have +this problem, though. + + + Configuration management with debconf -

Debconf is a configuration management system which can be used by all the various packaging scripts -- 2.30.2