Debian

如何找出 debconf-set-selections 的變數名?

  • July 22, 2018

假設我想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 passwordmysql-server-5.5 mysql-server/root_password_again

我知道我可以.deb通過發布來提取包dpkg-deb -R package.deb EXTRACTDIR/- 但我看不到這些變數的儲存位置。

我如何找出debconf任何其他包的變數?

您可以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.

因此,在 的情況下lightdmshared/default-x-display-manager是一個重要的debconf關鍵。

您可以使用獲取特定已安裝軟體包的變數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

引用自:https://unix.stackexchange.com/questions/457388