假设我想mysql
从脚本安装,而不被询问任何配置问题,例如我想设置什么 root 密码apt
。然后我会预设debconf
变量:
echo mysql-server-5.5 mysql-server/root_password password xyzzy | debconf-set-selections
echo mysql-server-5.5 mysql-server/root_password_again password xyzzy | debconf-set-selections
我从教程中得到了这个。我不清楚的是:这家伙是如何找到变量名称的?他怎么知道他必须分别设置mysql-server-5.5 mysql-server/root_password password
和mysql-server-5.5 mysql-server/root_password_again
?
我知道我可以.deb
通过发出来提取包dpkg-deb -R package.deb EXTRACTDIR/
- 但我看不到这些变量的存储位置。
我如何找到debconf
任何其他包的变量?
答案1
您可以获得特定的变量已安装封装使用debconf-show packagename
前任。
$ sudo debconf-show mysql-server-5.7
* mysql-server/root_password: (password omitted)
* mysql-server/root_password_again: (password omitted)
mysql-server-5.7/start_on_boot: true
mysql-server/no_upgrade_when_using_ndb:
mysql-server/password_mismatch:
mysql-server-5.7/really_downgrade: false
mysql-server-5.7/nis_warning:
mysql-server-5.7/postrm_remove_databases: false
mysql-server-5.7/installation_freeze_mode_active:
您可以使用 获取数据库中具有变量的所有已安装软件包的列表debconf-show --listowners
,因此,如果您不确定软件包名称是什么,您可以执行类似的操作
# debconf-show --listowners | grep mysql | xargs debconf-show
* mysql-server/root_password: (password omitted)
* mysql-server/root_password_again: (password omitted)
mysql-server-5.7/postrm_remove_databases: false
mysql-server-5.7/nis_warning:
mysql-server-5.7/installation_freeze_mode_active:
mysql-server/password_mismatch:
mysql-server-5.7/start_on_boot: true
mysql-server/no_upgrade_when_using_ndb:
mysql-server-5.7/really_downgrade: false
答案2
debconf
您可以检查使用中存储的内容debconf-get-selections
。如果您实际上已经完成安装,这将很有用。
或者,这些设置用于包维护者脚本。使用dpkg-deb
您运行的命令,它们位于DEBIAN
的子目录中EXTRACTDIR
。
举个例子,来自lightdm
:
$ grep db_ lightdm/DEBIAN -R
lightdm/DEBIAN/postrm: db_purge
lightdm/DEBIAN/prerm: db_unregister shared/default-x-display-manager
lightdm/DEBIAN/prerm: if db_get shared/default-x-display-manager; then
lightdm/DEBIAN/prerm: db_metaget shared/default-x-display-manager owners
lightdm/DEBIAN/prerm: db_subst shared/default-x-display-manager choices "$RET"
lightdm/DEBIAN/prerm: db_get shared/default-x-display-manager
lightdm/DEBIAN/prerm: if db_get "$RET"/daemon_name; then
lightdm/DEBIAN/prerm: db_fset shared/default-x-display-manager seen false
lightdm/DEBIAN/prerm: db_input critical shared/default-x-display-manager || true
lightdm/DEBIAN/prerm: db_go
lightdm/DEBIAN/prerm: db_get shared/default-x-display-manager
lightdm/DEBIAN/prerm: db_get "$RET"/daemon_name
lightdm/DEBIAN/postinst: if db_get shared/default-x-display-manager; then
lightdm/DEBIAN/postinst: if db_get "$DEFAULT_DISPLAY_MANAGER"/daemon_name; then
lightdm/DEBIAN/postinst:db_stop
lightdm/DEBIAN/config:if db_metaget shared/default-x-display-manager owners; then
lightdm/DEBIAN/config:if db_metaget shared/default-x-display-manager choices; then
lightdm/DEBIAN/config: db_subst shared/default-x-display-manager choices "$OWNERS" || :
lightdm/DEBIAN/config: db_fset shared/default-x-display-manager seen false || :
lightdm/DEBIAN/config: db_set shared/default-x-display-manager "$CURRENT_DEFAULT"
lightdm/DEBIAN/config: if db_get shared/default-x-display-manager; then
lightdm/DEBIAN/config: db_set shared/default-x-display-manager lightdm
lightdm/DEBIAN/config: db_fset shared/default-x-display-manager seen true
lightdm/DEBIAN/config: db_input high shared/default-x-display-manager || :
lightdm/DEBIAN/config: db_go || :
lightdm/DEBIAN/config:if db_get shared/default-x-display-manager; then
各种db_*
函数都是用于处理的辅助函数debconf
,从 获得/usr/share/debconf/confmodule
。
因此,在 的情况下lightdm
,shared/default-x-display-manager
是一个重要的debconf
关键。