当前位置: 首页>>技术教程>>正文


如何删除deb而不删除其依赖项

, , , , ,

问题描述

我想安装最新版本的boto,我通过python setup.py install安装

然而,当我尝试删除旧版本时,以下软件包也会被删除:

apt-get remove python-boto
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  cloud-init cloud-utils euca2ools python-boto

如何告诉程序包管理器删除boto,并将它标记为外部安装(或类似的东西),以便apt不会尝试修复丢失的依赖项?

谢谢你,马克西姆。

最佳解决方案

您可以使用equivs实用程序创建虚拟.deb包,它将提供依赖项而无需安装任何文件。然后使用dpkg -i fake.deb将当前安装的软件包替换为虚拟版本。

次佳解决方案

直接使用dpkg,而不是apt-get或aptitude:

sudo dpkg -r --force-depends "package"

第三种解决方案

我知道这是一个老帖子,但由于我最近有类似的问题,我想分享我的解决方案,希望将来有人发现它有用。

如果你通过aptitude安装了一个包,它会自动为依赖项(auto)分配标志,当你再次尝试删除你的包时,它会尝试删除所有仍然设置了自动标志的依赖项。

正如你在我的案例中看到的那样,我想删除它的zabbix:

uman@mango:~$ sudo aptitude purge zabbix-server-mysql zabbix-frontend-php
The following packages will be REMOVED:  
  apache2{u} dbconfig-common{u} fping{u} javascript-common{u} libhtml-template-perl{u} libiksemel3{u} libjs-prototype{u} 
  libjs-scriptaculous{u} libopenipmi0{u} libt1-5{u} mysql-server{u} mysql-server-5.1{u} mysql-server-core-5.1{u} php5{u} php5-gd{u} 
  php5-mysql{u} snmpd{u} wwwconfig-common{u} zabbix-frontend-php{p} zabbix-server-mysql{p} 
0 packages upgraded, 0 newly installed, 20 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 44.9 MB will be freed.
Do you want to continue? [Y/n/?]

如果我们查看apache包,它看起来像这样

uman@mango:~$ aptitude search ^apache2
i A apache2        - Apache HTTP Server metapackage
<snip>

第一个标志”i”告诉我们安装了apache下一个标志”A”代表自动安装

所以为了解决这个问题并且没有安装apache,mysql和php,我们可以像这样删除带有aptitude的auto标志:

uman@mango:~$ sudo aptitude unmarkauto apache2 mysql-server php5
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.

现在,删除zabbix包时看起来像这样:

uman@mango:~$ sudo aptitude purge zabbix-server-mysql zabbix-frontend-php
The following packages will be REMOVED:  
  dbconfig-common{u} fping{u} javascript-common{u} libiksemel3{u} libjs-prototype{u} libjs-scriptaculous{u} libopenipmi0{u} libt1-5{u} 
  php5-gd{u} wwwconfig-common{u} zabbix-frontend-php{p} zabbix-server-mysql{p} 
0 packages upgraded, 0 newly installed, 12 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 16.6 MB will be freed.
Do you want to continue? [Y/n/?] 

有关更多详细信息,请查看aptitude手册页

第四种方案

这正是apt-mark hold的用途。

apt-mark hold package_name

从文档:

hold is used to mark a package as held back, which will prevent the package from being automatically installed, upgraded or removed. The command is only a wrapper around dpkg –set-selections and the state is therefore

要取消包裹:

apt-mark unhold package_name

第五种方案

AFAIK无法删除使用APT的软件包,也无法删除依赖它的软件包。

参考:http://www.debian.org/doc/manuals/apt-howto/ch-apt-get.en.html

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/2969.html,未经允许,请勿转载。