debconf 找不到模板

debconf 找不到模板

我一直在尝试为我的个人项目生成 deb 文件。该项目使用 sbt 和 sbt-native-packager 生成 deb 文件,我将其安装在我的服务器上。

我在我的控制存档中添加了templatesconfigpostinst脚本(并确认它们已解压),但 debconf 似乎没有检测到新模板。 sudo debconf-show t-budget出现空白并且每次db_input返回10 "t-budget/<template>" doesn't exist

除了将文件放在我的控制存档中之外,我还需要做些什么才能将这些模板添加到数据库中吗?

旁注:我提到 sbt-native-packager 因为我没有直接使用 deb 创建工具可能相关,但看起来我所拥有的应该可以工作,如果这是该工具的限制,我想知道问题是什么,以便我可以解决它。

这些是我尝试使用的配置文件:

$ ls -lht /var/lib/dpkg/info/t-budget.*
-rw-r--r-- 1 root root  27K Sep  4 21:54 /var/lib/dpkg/info/t-budget.md5sums
-rw-r--r-- 1 root root  20K Sep  4 21:54 /var/lib/dpkg/info/t-budget.list
-rw-r--r-- 1 root root 1.1K Sep  4 20:51 /var/lib/dpkg/info/t-budget.conffiles
-rwxr-xr-x 1 root root  815 Sep  4 20:51 /var/lib/dpkg/info/t-budget.config
-rwxr-xr-x 1 root root 2.9K Sep  4 20:51 /var/lib/dpkg/info/t-budget.postinst
-rwxr-xr-x 1 root root  100 Sep  4 20:51 /var/lib/dpkg/info/t-budget.postrm
-rwxr-xr-x 1 root root 1.9K Sep  4 20:51 /var/lib/dpkg/info/t-budget.preinst
-rwxr-xr-x 1 root root 2.9K Sep  4 20:51 /var/lib/dpkg/info/t-budget.prerm
-rwxr-xr-x 1 root root 1.6K Sep  4 20:51 /var/lib/dpkg/info/t-budget.templates

/var/lib/dpkg/info/t-budget.templates

Template: t-budget/database/ip
Type: string
Default: localhost
Description: What is the host of your PostgreSQL server?
 T-Budget needs a postgresql server to store it's data.
 You can host one locally or have it connect over the network.
 Enter the host's domain name or IP address.
 Note: If the database is not the localhost, the install script will not be able to configure it automatically.

Template: t-budget/database/name
Type: string
Default: budget
Description: What is the name of your database?
 A single postgres server can host several isolated databases.
 It is recommended that T-Budget run on it's own database to maximize security and data integrity.

Template: t-budget/database/username
Type: string
Default: t-budget
Description: What is the PostgreSQL username?
 T-Budget should use an isolated username with limited permissions to the rest of the system.
 To create a new user, enter a username which is not yet in use.

Template: t-budget/database/password
Type: password
Description: What is the PostgreSQL password?
 If creating a new user, it will be created with this password.
 If using an existing user, this password will need to match the current password of that user.

Template: t-budget/hostnames
Type: string
Description: What is the hostname of your server?
 What is the domain name of the server users will use to access T-Budget?
 Used for security protocols.
 You can input multiple hostnames seperated by a space.
 You can also prefix your hostname with a '.' to include all subdomains in addition to the hostname.

/var/lib/dpkg/info/t-budget.config

#!/bin/sh

set -e

# Source debconf library.
. /usr/share/debconf/confmodule
db_version 2.0

echo "configuring..." 1>&2
db_clear
echo "CLEAR: $RET" 1>&2
db_purge
echo "PRUGE: $RET" 1>&2

db_input high     t-budget/database/ip       || true
echo "INPUT high t-budget/database/ip: $RET" 1>&2
db_input high     t-budget/database/name     || true
echo "INPUT high t-budget/database/name: $RET" 1>&2
db_input high     t-budget/database/username || true
echo "INPUT high t-budget/database/username: $RET" 1>&2
db_input critical t-budget/database/password || true
echo "INPUT critical t-budget/database/password: $RET" 1>&2
db_go
echo "GO: $RET" 1>&2

db_input critical t-budget/hostnames || true
echo "INPUT critical t-budget/hostnames: $RET" 1>&2
db_go
echo "GO: $RET" 1>&2

# TODO: validate input

/var/lib/dpkg/info/t-budget.postinst

#!/bin/sh

# Source debconf library.
. /usr/share/debconf/confmodule

# generate config files...

答案1

因此,在查看了官方存储库中的工作示例并逐一使其与我的匹配后,我发现了问题:

db_purge

此行将从数据库中删除所有模板。我添加它是因为我正在复制另一个示例,所以我不确定该示例是如何工作的,但删除这一行解决了问题。

相关内容