LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 3698|回复: 4

[gentoo]我不能执行“emerge<package-name>”, 提示xx config文件需

[复制链接]
发表于 2004-5-28 13:42:44 | 显示全部楼层 |阅读模式
原文:
http://forums.gentoo.org/viewtopic.php?t=23475


我不能执行“emerge<package-name>”, 提示xx config文件需要更新。我该怎么做?

答:你看到如下的讯息:

* Regenerating GNU info directory index...
* Processed 70 info files.
* IMPORTANT: 40 config files in /etc need updating.
* Type emerge --help config to learn how to update config files.

如果我们执行emerge –help config, 我们将看到:
******************************
**Config file management support (preliminary) -->翻译文章最后

Portage has a special feature called "config file protection". The purpose of
this feature is to prevent new package installs from clobbering existing
configuration files. By default, config file protection is turned on for /etc
and the KDE configuration dirs; more may be added in the future.

When Portage installs a file into a protected directory tree like /etc, any
existing files will not be overwritten. If a file of the same name already
exists, Portage will change the name of the to-be- installed file from 'foo' to
'._cfg0000_foo'. If '._cfg0000_foo' already exists, this name becomes
'._cfg0001_foo', etc. In this way, existing files are not overwritten,
allowing the administrator to manually merge the new config files and avoid any
unexpected changes.

In addition to protecting overwritten files, Portage will not delete any files
from a protected directory when a package is unmerged. While this may be a
little bit untidy, it does prevent potentially valuable config files from being
deleted, which is of paramount importance.

Protected directories are set using the CONFIG_PROTECT variable, normally
defined in /etc/make.globals. Directory exceptions to the CONFIG_PROTECTed
directories can be specified using the CONFIG_PROTECT_MASK variable. To find
files that need to be updated in /etc, type:

# find /etc -iname '._cfg????_*'

You can disable this feature by setting CONFIG_PROTECT="-*" in /etc/make.conf.
Then, Portage will mercilessly auto-update your config files. Alternatively,
you can leave Config File Protection on but tell Portage that it can overwrite
files in certain specific /etc subdirectories. For example, if you wanted
Portage to automatically update your rc scripts and your wget configuration,
but didn't want any other changes made without your explicit approval, you'd
add this to /etc/make.conf:

CONFIG_PROTECT_MASK="/etc/wget /etc/rc.d"

***************************************
以上解释了发生了什么事情。 我就不重复说明了。下一步, 我们将用find指令找寻我们需要更行的清单(find /etc/ -iname '/_cg????_*'). 比如以下的源码:

Code:
# find /etc -iname '._cfg????_*'
/etc/conf.d/._cfg0000_net
/etc/init.d/._cfg0000_clock
/etc/init.d/._cfg0000_bootmisc
/etc/init.d/._cfg0000_checkfs
/etc/skel/._cfg0000_.bash_profile
/etc/skel/._cfg0000_.bashrc
/etc/._cfg0000_fstab
/etc/._cfg0000_hosts
/etc/._cfg0000_modules.autoload

注意:输出文件是根据你的系统和你安装的软件包而不同的。作为参考, 以上的只是你安装完baselayout后的一部分清单。

如果你并没有修改任何文件, 那么更新将是安全进行的。两个更新配置文件(config)的办法:用“diff”指令或者用“etc-update”指令。

使用DIFF指令的解决办法:
/etc/init.d/bootmisc是一个你还没有修改的文件。如果我们用diff来执行这些文件,以下是他的输出样本

Code:
# diff  bootmisc ._cfg0000_bootmisc
3,4c3,4
< # Distributed under the terms of the GNU General Public License, v2 or later
< # $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/bootmisc,v 1.22 2002/11/04 14:51:07 azarah Exp $
---
> # Distributed under the terms of the GNU General Public License v2
> # $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/bootmisc,v 1.23 2002/11/18 13:07:02 azarah Exp $

以上的例子中,只有“Distributed”和“Header”这两行有差异。这几行并不是很重要, 所以我们可以将新的文件(my.-cfg0000_bootmisc.bootmisc)来更换旧的文件。

使用etc-update解决办法:
需要指令。

**
配置文件的管理支持(初稿):
Portage有一个很特别的功能被称作“配置文件保护功能”。这个功能的目的是为了防止新版软件安装时覆盖了现有的配置文件(configuration files)。默认情况下,/etc/里的配置文件和KDE的配置文件目录(dirs)是被启动的。更多的配置保护也会在以后不断加入。
当PORTAGE把文件安装到被保护的目录下(如etc), 任何现有的文件都不会被覆写。如果现有的文件名已经存在(如“foo"), PORTAGE会自动将安装的文件名“foo"改成“._cfg0000_foo ”, 如果 “._cfg0000_foo”也存在了, 那么将由“._cfg0001_foo”代替, 以此类推。这种办法可以避免现有文件被覆些, 同时也允许管理人员手动merge新的配置文件从而避免了任何无法预测的改变。
除了防止覆写外, 当软件包被删除的时候PORTAGE不会删除任何在保护目录下的配置文件。虽然这个看上去有点杂乱, 但确实有效的保护了那些有价值并且相当重要的配置文件不被删除。

被保护目录是通过CONIG_PROTECT的变量被设定的, 一般是被定义在/etc/make.globals里。目录对于被CONFIG_PROTECT的例外可以通过CONIG_PROTECT_MASK变量来被指定。想要找寻哪些/etc里的配置文件需要更新, 输入:


# find /etc -iname '._cfg????_*'

你可以通过设定“CONFIG_PROTECT=”CONFIG_PROTECT="-*" in /etc/make.conf. “来关闭这个功能。那么以后PORTAGE将会自动更新你的配置文件并覆写现有的文件。另外, 你可以将配置文件保护功能开启, 但告诉PORTAGE可以覆写到指定的几个/etc/里的子目录里。比如, 如果你想要PORTAGE自动更新你的rc脚本和wget配置文件, 但是你又不想在没有你的允许下作任何其他的修改, 你可以在/etc/make.conf里加上这行:

CONFIG_PROTECT_MASK="/etc/wget /etc/rc.d"
发表于 2004-5-28 14:59:38 | 显示全部楼层
Another way to do such things:
http://www.linuxsir.cn/forum.php ... 15&pagenumber=2 (scroll to the bottom).
发表于 2008-1-22 07:52:27 | 显示全部楼层
Another way to do such things:

代码: 全选
    su


代码: 全选
    enter password


代码: 全选
    emerge --sync && layman -S


代码: 全选
    emerge equo

代码: 全选
equo conf update

>>  @@ Scanning filesystem...                                                   
>> (1)  file: /etc/entropy/remote.conf                                          
>> (2)  file: /etc/entropy/repositories.conf                                    
>> (3)  file: /etc/entropy/packages/package.unmask                              
>> Please choose a file to update by typing its identification number.         
>> Other options are:                                                           
>>   (-1) Exit                                                                  
>>   (-3) Automerge all the files asking you one by one                        
>>   (-5) Automerge all the files without questioning                           
>>   (-7) Discard all the files asking you one by one                           
>>   (-9) Discard all the files without questioning                             
Your choice (type a number and press enter): 在此输入括号里的数字
回复 支持 反对

使用道具 举报

发表于 2008-1-23 11:36:27 | 显示全部楼层
<img src="http://www.linuxsir.cn/bbs/upload/avatars/avatar34925_23.gif"/>
回复 支持 反对

使用道具 举报

发表于 2008-1-23 11:38:23 | 显示全部楼层
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表