debconf开发小本本

这篇博客深入探讨了如何在bash脚本中使用debconf进行软件包开发,涵盖了templates模板文件的创建、本地化、shell接口的运用以及实际操作示例,帮助开发者更好地理解和实践debconf在软件开发中的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

debconf开发者手册

主要针对bash脚本/程序的debconf开发
0814更新:一个基于debconf开发的demo

普通shell脚本

#!/bin/sh -e
echo -n "Do you like debian? [yn] "
read like
case "$like" in
n*|N*)
    echo "Poor misguided one. Why are you installing this package, then?"
    /etc/init.d/subliminal_messages start "I like debian."
;;
esac

debconf的templates模板文件示例


Template: packagename/something
Type: [select,multiselect,string,boolean,note,text,password]
Default: [an optional default value]
Description: Blah blah blah?
 Blah blah blah. Blah blah. Blah blah blah. Blah blah? Blah
 blah blah blah. Blah blah blah. Blah blah.
 .
 Blah blah blah. Blah blah. Blah blah blah. Blah blah. Blah blah blah.
 blah.

Template: ....
....
  1. 注意Type域有select, multiselect, string, boolean, note, text, password几种类型选一个
  2. Description域后面紧接着一段简短描述,下面写详细描述。且.表示一行空行
  3. Type域详细描述:
Type Description
string Holds any arbitrary string of data.
boolean Holds “true” or “false”.
select Holds one of a finite number of possible values. These values must be specified in a field named Choices:. Separate the possible values with commas and spaces, like this: Choices: yes, no, maybe
multiselect Just like the select data type, except the user can choose any number of items from the list. This means that the Default: field and the actual value of the question may be a comma and space delimited list of values, just like the Choices: field.Note: For compatability with old versions of Debconf, if you use this data type, please make your package depend on debconf (>= 0.2.26)
note This template is a note that can be displayed to the user. As opposed to text, it is something important, that the user really should see. If debconf is not running interactively, it might be saved to a log file
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值