emerge 小计

Gentoo自定义包管理
本文介绍如何在Gentoo Linux系统中通过Local Portage Overlay来自定义软件包的安装,包括添加覆盖目录、修改ebuild文件及使用patch解决bug或增加功能的方法。
emerge和ebuild是Gentoo的包管理核心,其中emerge是ebuild的更高层次的应用。
多数情况下,一般是不需要自己打patch,可是有时候,当前版本系统确实有bug,或者想在本地版本中,给软件增加一些小功能,在这样的情况下,是不得不自己来处理一下了。在Gentoo中,这称之为:[url=http://www.gentoo-wiki.info/Local_Portage_Overlay]Local Portage Overlay [/url]
[list=1]
[*]在/etc/make.conf增加[quote]PORTDIR_OVERLAY="/usr/local/portage"[/quote]
[*]在/usr/local/portage创建跟原来软件相同的分类和名字,比如[quote]mkdir -p /usr/local/portage/x11-drivers/nvidia-drivers[/quote]
[*]获取ebuild文件,比如从/usr/portage中获取
[*]修改ebuild文件,参考[url=http://devmanual.gentoo.org/ebuild-writing/index.html]Ebuild Writing[/url]
[*]执行digest[quote]ebuild nvidia-drivers-100.14.11.ebuild digest[/quote]
[*]emerge nvidia-drivers,或者指定特定版本:emerge =nvidia-drivers-100.14.11
[/list]
以上是自己定制emerge的基本步骤。我碰到的其他问题,在此也简单罗列一下:
[list]
[*]关于自动打patch的问题,比如打算在src_prepare过程中执行epatch,那么需要EAPI=2
[*]关于patch文件的生成,可以用diff -u oldfile newfile来生成,很方便
[*][2010-7-18 updated]被关键字屏蔽(masked)的处理,在/etc/portage/package.keywords增加相应的package就好了,比如[quote]echo "dev-db/mongodb" >>/etc/portage/package.keywords[/quote]
[/list]
TCUTTER - Tin Cutter In a Tin Cutting factory there is a machine for cutting parts from tin plates. It has an extraordinarily sharp knife able to make horizontal or vertical segment cuts in the tin plates. Each cutting process consists of a sequence of such cuts. Each segment cut is given by its endpoints that are always located inside the tin plate. During the cutting process some parts of tin plate can fall out and so some holes in the plate can emerge. Factory management needs to predict the number of holes in the plate at the end of the given sequence of cuts. Write a program that answers this question. Single segment cuts are not considered to be holes. Here there are examples of some situations that can arise after cutting: two holes two holes one hole one hole Input The input file consists of blocks of lines. Each block except the last describes one cutting process. In the first line of the block there is a number N <= 100. indicating the number of segment cuts in the cutting process. These cuts are defined by the following N lines. The line defining one segment cut has the form X1 Y1 X2 Y2 where X1 Y1 and X2 Y2 are the co-ordinates of the end points of the segment cut. They are separated by one space. The co-ordinates are integers and always define horizontal or vertical segment (i.e. segment parallel with x or y axis). The last block consists of just one line containing 0. Output The output file contains the lines corresponding to the blocks in the input file. Each such line contains the number of holes that remain in the tin plate after the execution of the corresponding cuts. There is no line in the output file corresponding to the last "null" block of the input file. Example Input: 4 0 1 1 1 1 1 1 0 1 0 0 0 0 0 0 1 2 0 1 2 1 1 2 1 0 0 Output: 1 0
07-04
<think>我们正在讨论Gentoo Linux中的emerge命令,特别是如何卸载软件包。根据引用[2],我们看到了一些emerge命令的常用选项,但并没有直接提到卸载。不过,我们可以结合Gentoo的知识来回答。 在Gentoo中,卸载软件包通常使用`emerge --unmerge`(或简写为`emerge -C`)命令。 但是,需要注意的是,卸载软件包时,Gentoo的Portage系统默认不会自动移除那些作为依赖被安装但现在不再被任何软件包依赖的包。这也就是引用[1]中提到的“当我们将这个软件卸载后,其他的软件包貌似没有完全删除”的问题。 因此,我们可以这样操作: 1. 卸载指定软件包:`emerge -C package_name` 2. 为了清理不再需要的依赖,我们可以运行`emerge --depclean`(或`emerge -c`)来移除那些不再被依赖的包。 但是,在运行`emerge --depclean`之前,建议先更新系统(以确保依赖关系是最新的)并重新计算依赖关系: emerge --update --deep --with-bdeps=y @world emerge --depclean 然后,我们还可以运行`revdep-rebuild`(需要先安装`gentoolkit`)来修复因为卸载而可能破坏的依赖关系。 另外,引用[5]中提到了一些查询命令,比如`--search`等,这些在卸载前可以用来确认软件包名称。 所以,完整的步骤可以是: 1. 确认要卸载的软件包名称:`emerge -s package_name` 2. 卸载软件包:`emerge -C package_name` 3. 更新系统(可选,但推荐):`emerge -uDU @world` 4. 运行depclean:`emerge --depclean` 5. 运行revdep-rebuild:`revdep-rebuild` 注意:卸载软件包需要管理员权限,所以通常使用sudo。 但是,用户的问题中并没有提到是否要同时清理依赖,所以我们可以给出两种选择: - 仅卸载软件包(不自动清理依赖) - 卸载并清理不再需要的依赖(推荐,但需要谨慎操作) 另外,引用[1]中提到了卸载后其他软件包没有完全删除的问题,所以我们可以特别说明清理依赖的步骤。 因此,回答如下:</think>### 如何使用 emerge 命令卸载软件包 在 Gentoo Linux 中,使用 `emerge` 命令卸载软件包的核心命令是: ```bash emerge --unmerge <package-name> # 或简写 emerge -C <package-name> ``` #### 完整卸载流程: 1. **卸载指定软件包** ```bash sudo emerge -C <package-name> # 例如:sudo emerge -C firefox ``` * 系统会显示将被移除的软件包列表,需确认操作 2. **清理孤立依赖包**(卸载后必做) ```bash sudo emerge --depclean # 或简写 emerge -c ``` * 此步骤移除被卸载软件依赖但不再被其他程序使用的包[^1][^2] 3. **重建依赖关系**(可选但推荐) ```bash sudo revdep-rebuild # 需要安装 gentoolkit ``` * 修复因卸载可能破坏的依赖链(先安装:`emerge gentoolkit`) --- #### 关键注意事项: 1. **卸载前检查依赖** 使用 `--depclean` 前建议先模拟检测: ```bash emerge -cpv # 显示将被清理的包(不实际执行) ``` 2. **避免误删依赖** 若需保留特定包的依赖,使用: ```bash emerge --noreplace <keep-package> # 标记为手动安装 ``` 3. **查看软件包关系** ```bash equery d <package-name> # 显示依赖树(需 gentoolkit) ``` --- ### 示例操作流 ```bash # 1. 卸载 Chromium 浏览器 sudo emerge -C www-client/chromium # 2. 清理孤立依赖 sudo emerge -cp # 预览将删除的包 sudo emerge -c # 确认执行清理 # 3. 重建依赖 sudo revdep-rebuild ``` > ⚠️ 警告:直接使用 `emerge -C` 不会自动移除依赖包,必须配合 `depclean` 才能彻底清理[^1][^5]。卸载系统关键包可能导致不稳定,建议通过 `emerge -pv <package>` 确认影响范围后再操作。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值