手册:片段/使用Portage/额外的工具

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Handbook:Parts/Portage/Tools and the translation is 82% complete.
Outdated translations are marked like this.

dispatch-conf

dispatch-conf是一个帮助合并 ._cfg0000_<name>的工具。 ._cfg0000_<name>是由Portage在它要覆盖被CONFIG_PROTECT变量所保护的某个目录里的文件时建立的。

使用 dispatch-conf,能够在合并配置文件并升级更新的同时保持所有更新记录。 dispatch-conf以RCS版本管理系统或是补丁的方式来保存配置文件间的差别。这意味着如果你在升级配置文件犯下错误时,你可以随时退回到你的配置文件的之前版本。

使用 dispatch-conf,,你可以保持配置文件原来的样子,或者使用新的配置文件,你还可以编辑当前文件或交互式地合并更新。除此之外, dispatch-conf,还有一些很棒的特性:

  • 可以自动合并仅有注释变更的文件。
  • 可自动合并仅有空白符数量的不同的文件。

首先编辑 /etc/dispatch-conf.conf ,并且创建 archive-dir 变量设定的目录,然后执行 dispatch-conf:

root #dispatch-conf

当运行 dispatch-conf的时候,程序会带你把每个改变了的配置文件挨个过一边。按 u来用新配置文件更新(替换)现在的配置文件,然后继续处理下一个。按z来删除新配置文件,然后继续处理下一个。按 n 键让 dispatch-conf 跳转到下一个文件。 这样可以将合并推迟到将来的某个时间。当处理完所有的配置文件之后, dispatch-conf就会退出。你也可以随时按q 来退出。

更多信息,请查阅dispatch-conf手册页。它会告诉你交互式的合并新旧配置文件,编辑新配置文件,检查两个文件间的差异等等。

user $man dispatch-conf

etc-update

你也可以使用 etc-update来合并配置文件。它不像dispatch-conf那样简单易用,功能也少,但是它也能提供交互式合并功能并且能自动合并一些简单的改变。

不过,和dispatch-conf不同的是, etc-update 保留你的配置文件的旧版本。一旦你更新了文件,旧版本就永远丢失了。所以要非常小心,因为使用etc-update 与使用 dispatch-conf 相比明显的不安全。

root #etc-update

在整合简单直观的更动后,系统会提示你一个需要更新的受保护的文件列表。在最底下会提示你可选的操作选项:

代码 etc-update 输出选项
Please select a file to edit by entering the corresponding number.
              (-1 to exit) (-3 to auto merge all remaining files)
                           (-5 to auto-merge AND not use 'mv -i'):

如果你输入-1, etc-update将直接退出且不执行任何变更。如果你输入-3 或者 -5,所有列出的配置文件将被更新的版本覆盖。因此先选出无需自动升级的配置文件非常重要,而具体步骤也很简单,只需要输入在该配置文件左边显示的数字就可以了。

我们选择配置文件/etc/pear.conf作为范例:

代码 更新指定的配置文件
Beginning of differences between /etc/pear.conf and /etc/._cfg0000_pear.conf
[...]
End of differences between /etc/pear.conf and /etc/._cfg0000_pear.conf
(1) Replace original with update
(2) Delete update, keeping original as is
(3) Interactively merge original with update
(4) Show differences again

现在你可以看到这两个文件之间的差别。如果你认为升级的配置文件可以正确无误的投入使用,输入1.。如果你认为升级的配置文件是不必要的,或者它也没有提供任何新的或有用的信息,输入2.。如果你想交互地升级你当前的配置文件,输入3.。

这里我们就不再赘述交互性整合的详细过程。出于完整性的考虑,我们将列出在整合两个文件时可以用到的所有的命令。你将看到来自新旧文件的两行内容和一个提示符,在提示符这里你可以输入以下命令:

代码 用交互方式配置时可以使用的命令
ed:     Edit then use both versions, each decorated with a header.
eb:     Edit then use both versions.
el:     Edit then use the left version.
er:     Edit then use the right version.
e:      Edit a new version.
l:      Use the left version.
r:      Use the right version.
s:      Silently include common lines.
v:      Verbosely include common lines.
q:      Quit.

当你完成重要的配置文件的更新后,余下的其它配置文件你就可以采用自动更新的方法了。当无法再找到任何可更新的配置文件时etc-update将退出。

quickpkg

利用quickpkg可以对系统中已安装的包进行打包归档。这些归档文件可以作为预编译包使用。运行quickpkg非常简单:只要加上你想要制作的软件包的名字就可以了。

例如,要打包curl,arts,procps;

root #quickpkg curl orage procps

预编译包会保存在 $PKGDIR 默认为 (/var/cache/binpkgs/ )。这些包的保存在$PKGDIR/CATEGORY中。