我是创建 deb packgaes 的初学者。我为用户创建了带有答案的 deb 包。但是当我跑步时sudo apt install ./mypackge.deb
我得到同样的错误
Setting up test (0.0) ...
Can't exec "/var/lib/dpkg/info/test.config": No such file or directory at /usr/lib/x86_64-linux-gnu/perl-base/IPC/Open3.pm line 178.
open2: exec of /var/lib/dpkg/info/test.config configure failed: No such file or directory at /usr/share/perl5/Debconf/ConfModule.pm line 59.
dpkg: error processing package test (--configure):
installed test package post-installation script subprocess returned error exit status 2
我的 debian/配置
#!/bin/sh
# Source debconf library.
. /usr/share/debconf/confmodule
set -e # fail on any error
set -u # treat unset variables as errors
# ======[ Trap Errors ]======#
set -E # let shell functions inherit ERR trap
# Trap non-normal exit signals:
# 1/HUP, 2/INT, 3/QUIT, 15/TERM, ERR
trap err_handler 1 2 3 15 ERR
function err_handler {
local exit_status=${1:-$?}
logger -s -p "syslog" -t "TEST script '$0' error code $exit_status (line $BASH_LINENO: '$BASH_COMMAND')"
exit $exit_status
}
# Ask questions
db_set test/migrate1 no
db_set test/migrate2 no
db_input critical test/migrate1 || true
db_input critical test/migrate2 || true
# Show interface
db_go
exit 0
Debian/模板
Template: test/migrate1
Type: select
Choices: yes, no
Default: no
Description: Create default schema?
Create schema
Template: test/migrate2
Type: select
Choices: yes, no
Default: no
Description: Upload fixtures?
Upload fixtures
我的 debian/postinst
#!/bin/bash
export DEBCONF_DEBUG=developer
. /usr/share/debconf/confmodule
set -e # fail on any error
set -u # treat unset variables as errors
# ======[ Trap Errors ]======#
set -E # let shell functions inherit ERR trap
# Trap non-normal exit signals:
# 1/HUP, 2/INT, 3/QUIT, 15/TERM, ERR
trap err_handler 1 2 3 15 ERR
function err_handler {
local exit_status=${1:-$?}
logger -s -p "syslog" -t "SYMFONY script '$0' error code $exit_status (line $BASH_LINENO: '$BASH_COMMAND')"
exit $exit_status
}
#Clean db if purge
if [ "$1" == "purge" ] && [ -e /usr/share/debconf/confmodule ] ; then
. /usr/share/debconf/confmodule
db_purge
fi
#Settingup DB
mysql -e "CREATE USER IF NOT EXISTS 'symfony'@'localhost' IDENTIFIED BY '123456';"
mysql -e "CREATE DATABASE IF NOT EXISTS symfony CHARACTER SET utf8 COLLATE utf8_unicode_ci;"
mysql -e "GRANT ALL PRIVILEGES ON symfony.* TO 'symfony'@'localhost';"
# Fetching configuration from debconf
case "$1" in
install|upgrade)
db_get test-symfony/migrate1
if [ "$RET" == "yes" ]; then
cd /var/www/test-symfony/bin
./console doctrine:schema:create
fi
;;
abort-upgrade)
;;
*)
echo "preinst called with unknown argument \$1'" >&2
exit 0
;;
esac
case "$1" in
configure)
db_get test-symfony/migrate2
if [ "$RET" == "yes" ]; then
cd /var/www/test-symfony/bin
./console doctrine:fixtures:upload
fi
echo "you have entered ::$RET" >&2
;;
esac
#Settingup permissions and service
chown nginx:nginx /var/www/test.com
chown nginx:nginx /var/cache/ngx_pagespeed
sleep 2
sudo systemctl enable nginx.service
sudo systemctl start nginx.service
sudo systemctl is-enabled nginx.service
exit 0
我尝试了不同的 config/postinst 变体,使用了 debconf 手册中的示例,但得到了相同的错误。
Can't exec "/var/lib/dpkg/info/test.config.....
如果您指出我的错误,那就太好了。纳克斯