如何删除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" 

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

如果你通过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  

第一个标志“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用于将包标记为后退,这将阻止自动安装,升级或删除包。 该命令只是dpkg –set-selections的包装器,因此状态是

要取消包裹:

apt-mark unhold package_name

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

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

要完成JoãoPinto的答案,您可以使用我的小脚本来修复损坏的包,这个脚本将创建包含equivs的虚拟包并安装它。 你可以在我的博客上用法语找到一篇文章。

或直接在gist代码上 。

要使用它:

 $ ./gen-dummy-package.sh --install|i [packageName]+ # eg : $ ./gen-dummy-package.sh -i rfkill nome-bluetooth bluez