首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用debconf帖子创建deb包

使用debconf帖子创建deb包
EN

Stack Overflow用户
提问于 2021-08-10 12:44:55
回答 1查看 112关注 0票数 0

我在创建deb packgaes方面做得很好。我创建了为用户提供答案的deb包。但是当我运行sudo apt install ./mypackge.deb

我得到了同样的错误

代码语言:javascript
复制
 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/config

代码语言:javascript
复制
#!/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/模板

代码语言:javascript
复制
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

代码语言:javascript
复制
#!/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手册中的示例,但得到了相同的错误。

代码语言:javascript
复制
 Can't exec "/var/lib/dpkg/info/test.config.....

如果你能指出我的错误就好了。技术

EN

回答 1

Stack Overflow用户

发布于 2021-08-13 14:27:57

我假设您的.deb缺少config maintainer脚本(可能还缺少templates文件)。你可以向dpkg-deb -I test.deb查询。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68727070

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档