Thêm các bước tùy chỉnh để debian / pack.postinst của gói nguồn?


8

Tôi có một gói kết hợp một debian/package.postinst.debhelpertệp được tạo tự động vào tệp nhị phân được tạo. Khi tôi đặt mã của riêng mình vào một tệp tại debian/package.postinst, tệp được tạo tự động không còn được tích hợp vào tệp nhị phân kết quả.

Làm cách nào để thêm mã tùy chỉnh vào postinsttệp trong gói được tạo mà không chặn sử dụng mã được tạo tự động?

Câu trả lời:


10

Tập lệnh postinst của bạn sẽ bao gồm một #DEBHELPER#mã thông báo nếu bạn đang sử dụng bất kỳ lệnh gỡ lỗi nào có thể sửa đổi nó. Nó sẽ được thay thế trong tập lệnh kết quả bằng nội dung được tạo tự động. Xem trang dành cho dh_installdeblệnhBiểu tượng trang

Ví dụ:

#!/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
Khi sử dụng trang web của chúng tôi, bạn xác nhận rằng bạn đã đọc và hiểu Chính sách cookieChính sách bảo mật của chúng tôi.
Licensed under cc by-sa 3.0 with attribution required.