如何在Debian系统上安装Debian软件包时读取输入

for*_*t17 7 linux ubuntu debian package debconf

我创建了一个小的Debian软件包,它必须从用户那里获取输入并打印出来.

为了在postinst脚本上从用户"read"命令获取输入将无法在Debian系统上运行我不知道究竟是什么原因,但它在Ubuntu系统中有效.

后来我发现我们必须使用模板文件为Debian系统使用"debconf".

模板文件:

Template: test/input
Type: text
Description: enter some text, which will be displayed
Run Code Online (Sandbox Code Playgroud)

postinst脚本:

 db_get test/input
    echo "you have entered ::$RET" >&2
Run Code Online (Sandbox Code Playgroud)

但是,当我安装我的测试包时,我收到此错误:

Can't exec "postinst": No such file or directory at /usr/share/perl/5.10/IPC/Open3.pm line 168. <br>open2: exec of postinst configure failed at /usr/share/perl5/Debconf/ConfModule.pm line 59

有谁知道我做错了什么?

Mih*_* An 1

您的postinst脚本应如下所示:

#!/bin/bash

set -e

. /usr/share/debconf/confmodule

case "$1" in
  configure)
    db_get test/input
    echo "you have entered ::$RET" >&2
  ;;
esac
db_stop
Run Code Online (Sandbox Code Playgroud)