web-dev-qa-db-ja.com

ソースパッケージのdebian / package.postinstにカスタムステップを追加しますか?

自動生成されたdebian/package.postinst.debhelperファイルを生成されたバイナリに組み込むパッケージがあります。 debian/package.postinstのファイルに独自のコードを配置すると、自動生成されたファイルは結果のバイナリに組み込まれなくなります。

自動生成コードの使用をブロックせずに、生成されたパッケージのpostinstファイルにカスタムコードを追加するにはどうすればよいですか?

8
Matt Joiner

Postinstスクリプトには、変更する可能性のあるdebhelperコマンドを使用している場合、#DEBHELPER#トークンを含める必要があります。結果のスクリプトでは、自動生成されたコンテンツに置き換えられます。 dh_installdebコマンドのマンページを参照してください Manpage icon

例えば:

#!/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
10
andrewsomething