论坛首页 综合技术版 Linux

gentoo配置文件更新器etc-update详解

浏览 192 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
最后更新时间:2008-06-16 关键字: linux etc-update gentoo

首先推广一下javaeye的 gentoo圈子

 

介绍

etc-update是一个类似版本管理工具中的merge功能的gentoo工具。当你更新系统或软件后,难免会有新的配置选项下来,这样,就会跟老的配置内容有冲突。etc-update可以帮助你解决这些冲突。

另外,etc-update还有个备份配置文件功能,具体可以参看/etc/dispatch-conf里的配置说明。


使用

  1. 运行 etc-update 命令
  2. 你会看到一个冲突文件列表。针对每个文件,你能:
    1. 自动解决冲突
    2. 丢弃更新的内容
    3. 交互式解决冲突
    4. 忽略更新,保持原样

如果你查看冲突情况,按 enter

如果想退出,按 q


常用的方式:交互式解决冲突

available command:

  • 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.


这种交互方式,官方wiki上推荐用的。
但是个人还是觉得不好用,可能是因为对vim情有独钟的缘故。建议直接使用vimdiff。
用 do,dp 之类的内部指令来实现,效率更高。

当然要使用 vimdiff 作为比较工具,需要修改配置文件。如下:

# For emacs-users (see NOTE_2)
# diff_command="eval emacs -nw --eval=\'\(ediff\ \"%file1\"\ \"%file2\"\)\'"
#using_editor=1

 # vim-users: you CAN use vimdiff for diff_command. (see NOTE_1 and NOTE_2)
 diff_command="vim -d %file1 %file2"
 using_editor=1
 
 #diff_command="diff -uN %file1 %file2"
 #using_editor=0

保留 vim 那行注释,注释掉其他的 diff_command 就行了。注意 using_editor = 1

etc-update配置文件说明:

etc-update的配置文件在 /etc/etc-update.conf

自动解决冲突

eu_automerge=yes/no

解决冲突过程中,调用的系统指令附加参数

比如给rm,cp,mv等系统指令添加参数

rm_opts="-i"
mv_opts="-i"
cp_opts="-i"

比较指令

默认的比较指令

diff_command="diff -uN %file1 %file2"
using_editor=0

使用vimdiff作为比较指令:

diff_command="vim -d %file1 %file2"
using_editor=1

冲突解决命令

sdiff -s -o %merged %orig %new

彩色的比较工具

如果你比较喜欢彩色的比较工具,你可以安装 colordiff 这个小工具。

# emerge colordiff
File: /etc/etc-update.conf
diff_command="colordiff -uN %file1 %file2"

You may also need to change less to accept raw input if you are using it as your pager.

File: /etc/etc-update.conf
pager="less -r"


   
论坛首页 综合技术版 Linux

跳转论坛:
JavaEye推荐