将自定义步骤添加到源包的debian / package.postinst?


8

我有一个将自动生成的debian/package.postinst.debhelper文件合并到生成的二进制文件中的软件包。当我将自己的代码放入的文件中时debian/package.postinst,自动生成的文件将不再合并到生成的二进制文件中。

如何postinst在不阻止使用自动生成代码的情况下将自定义代码添加到生成包中的文件?

Answers:


12

#DEBHELPER#如果您正在使用可能会对其进行修改的任何debhelper命令,则postinst脚本应包含一个令牌。它会在结果脚本中被自动生成的内容替换。请参见手册页以获取dh_installdeb命令联机帮助页图标

例如:

#!/bin/sh
# postinst script for webpy-example
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

# source debconf library
. /usr/share/debconf/confmodule

# Source dbconfig-common functions
if [ -f /usr/share/dbconfig-common/dpkg/postinst.pgsql  ]; then
  . /usr/share/dbconfig-common/dpkg/postinst.pgsql
fi

case "$1" in

  configure)
    # Set up our config for apache
    /bin/cp /usr/share/webpy-example/postinstall/webpy-config /etc/apache2/conf.d/
    /usr/sbin/a2enmod wsgi
    /usr/sbin/a2enmod rewrite
    /etc/init.d/apache2 reload

    # set up database
    dbc_pgsql_createdb_encoding="UTF8"
    dbc_generate_include=template:/usr/share/webpy-example/lib/credentials.py
    dbc_generate_include_args="-U -o template_infile='/usr/share/doc/webpy-example/credentials_template.py'"
    dbc_generate_include_owner="root:www-data"
    dbc_generate_include_perms="0660"
    dbc_go webpy-example $@ || true
  ;;

  abort-upgrade|abort-remove|abort-deconfigure)
    exit 0
  ;;

  *)
    echo "postinst called with unknown argument \`$1'" >&2
    exit 1
  ;;

esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

db_stop

exit 0
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.