<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dipplum.com &#187; debconf</title>
	<atom:link href="http://dipplum.com/tag/debconf/feed/" rel="self" type="application/rss+xml" />
	<link>http://dipplum.com</link>
	<description>Be  the change you wanna see in the world</description>
	<lastBuildDate>Sat, 12 Nov 2011 07:38:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>debconf 和 dpkg-preconfgure 的用法</title>
		<link>http://dipplum.com/2009/06/20/debconf-dpkg-preconfigure-usage/</link>
		<comments>http://dipplum.com/2009/06/20/debconf-dpkg-preconfigure-usage/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 06:15:42 +0000</pubDate>
		<dc:creator>li</dc:creator>
				<category><![CDATA[开源软件]]></category>
		<category><![CDATA[debconf]]></category>
		<category><![CDATA[Debian]]></category>

		<guid isPermaLink="false">http://dipplum.com/2009/06/20/debconf-dpkg-preconfigure-usage/</guid>
		<description><![CDATA[debconf 是 Debian 使用的一种软件包配置方法。支持 debconf 的软件在安装时，会弹出对话框，要求用户输入一定配置参数。 在非交互式环境下安装这类软件，用户无法在线提供软件的配置项。因此用户需要通过 dpkg-preconfigure 预先指定软件配置。 目前 dpkg-preconfigure 的用法比较奇怪。没有非常完美的用法，总觉得怪怪的。下面这个方案应该是我从网上可以找到，综合比较靠谱的。 1. 导入 debconf 模板 debconf 模板包含软件的配置项的名称、说明、默认值等内容。一般来说 debconf 模板是包含在 deb 包中。由于需要在安装 deb 时自动提供软件配置，所以需要在安装 deb 包之前，提前导入 debconf 模板。过程如下。 apt-get clean (清除 apt/cache 中缓存的 Debian 包) apt-get install -d mysql-server-5.0 (下载 mysql-server-5.0，不安装) dpkg-preconfigure /var/cache/apt/archives/mysql-server-5.0*.deb (导入 debconf 模板) 不完美的地方就在这里：导入一个软件的配置项，竟然要用三个命令。总觉得应该一个命令搞定。。。 2. 指定 debconf 配置 模板导入之后，可以使用 debconf-set-selections 设置软件配置。用下面的命令： # [...]]]></description>
			<content:encoded><![CDATA[<p>debconf 是 Debian 使用的一种软件包配置方法。支持 debconf 的软件在安装时，会弹出对话框，要求用户输入一定配置参数。</p>
<p>在非交互式环境下安装这类软件，用户无法在线提供软件的配置项。因此用户需要通过 dpkg-preconfigure 预先指定软件配置。 </p>
<p>目前 dpkg-preconfigure 的用法比较奇怪。没有非常完美的用法，总觉得怪怪的。下面这个方案应该是我从网上可以找到，综合比较靠谱的。</p>
<p><strong>1. 导入 debconf 模板</strong></p>
<p>debconf 模板包含软件的配置项的名称、说明、默认值等内容。一般来说 debconf 模板是包含在 deb 包中。由于需要在安装 deb 时自动提供软件配置，所以需要在安装 deb 包之前，提前导入 debconf 模板。过程如下。</p>
<ul>
<li>apt-get clean (清除 apt/cache 中缓存的 Debian 包) </li>
<li>apt-get install -d mysql-server-5.0 (下载 mysql-server-5.0，不安装) </li>
<li>dpkg-preconfigure /var/cache/apt/archives/mysql-server-5.0*.deb (导入 debconf 模板) </li>
</ul>
<p>不完美的地方就在这里：导入一个软件的配置项，竟然要用三个命令。总觉得应该一个命令搞定。。。 </p>
<p><strong>2. 指定 debconf 配置</strong></p>
<p>模板导入之后，可以使用 debconf-set-selections 设置软件配置。用下面的命令：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># debconf-set-selections</span>
<span style="color: #c20cb9; font-weight: bold;">debconf</span> mysql-server-<span style="color: #000000;">5.0</span><span style="color: #000000; font-weight: bold;">/</span>start_on_boot <span style="color: #000000; font-weight: bold;">select</span> <span style="color: #c20cb9; font-weight: bold;">true</span>
<span style="color: #c20cb9; font-weight: bold;">debconf</span> mysql-server-<span style="color: #000000;">5.0</span><span style="color: #000000; font-weight: bold;">/</span>start_on_boot seen <span style="color: #c20cb9; font-weight: bold;">true</span>
<span style="color: #7a0874; font-weight: bold;">&#40;</span>ctrl+d<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>上面命令将 mysql-server-5.0/start_on_boot 设置为 true，并且设置配置项已经显示（区分配置项的值是默认值，还是用户输入值）。一般来说，软件安装时，只会显示 seen 为 false 的那些配置参数。</p>
<p>如果不知道软件有哪些配置选项，可以用 debconf-show 看到：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># debconf-show mysql-server-5.0</span>
  mysql-server<span style="color: #000000; font-weight: bold;">/</span>root_password_again: <span style="color: #7a0874; font-weight: bold;">&#40;</span>password omitted<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">*</span> mysql-server<span style="color: #000000; font-weight: bold;">/</span>root_password: <span style="color: #7a0874; font-weight: bold;">&#40;</span>password omitted<span style="color: #7a0874; font-weight: bold;">&#41;</span>
  mysql-server-<span style="color: #000000;">5.0</span><span style="color: #000000; font-weight: bold;">/</span>really_downgrade: <span style="color: #c20cb9; font-weight: bold;">false</span>
  mysql-server-<span style="color: #000000;">5.0</span><span style="color: #000000; font-weight: bold;">/</span>need_sarge_compat: <span style="color: #c20cb9; font-weight: bold;">false</span>
  mysql-server-<span style="color: #000000;">5.0</span><span style="color: #000000; font-weight: bold;">/</span>start_on_boot: <span style="color: #c20cb9; font-weight: bold;">true</span>
  mysql-server<span style="color: #000000; font-weight: bold;">/</span>error_setting_password:
  mysql-server-<span style="color: #000000;">5.0</span><span style="color: #000000; font-weight: bold;">/</span>nis_warning:
  mysql-server-<span style="color: #000000;">5.0</span><span style="color: #000000; font-weight: bold;">/</span>postrm_remove_databases: <span style="color: #c20cb9; font-weight: bold;">false</span>
  mysql-server-<span style="color: #000000;">5.0</span><span style="color: #000000; font-weight: bold;">/</span>need_sarge_compat_done: <span style="color: #c20cb9; font-weight: bold;">true</span>
  mysql-server<span style="color: #000000; font-weight: bold;">/</span>password_mismatch:</pre></div></div>

<p>上面每行输出中第一个 * 表示 seen 为 true，没有星号表示 seen 为 false；每行输出中，冒号前面配置项，冒号后是值。 </p>
<p><strong>3. 安装软件</strong></p>
<p>如果所有的 debconf 选项都通过上面的方法设置完毕。用下面的方法安装</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> mysql-server-<span style="color: #000000;">5.0</span></pre></div></div>

<p>此时应该不会显示 debconf 的对话框。</p>
]]></content:encoded>
			<wfw:commentRss>http://dipplum.com/2009/06/20/debconf-dpkg-preconfigure-usage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

