删除损坏的包

删除损坏的包

最近,由于对 phpmyadmin 设置感到沮丧,我决定从头开始。

不幸的是,在卸载阶段,系统提示我输入 mysql 的 root 密码,而我当时手头没有该密码。可以说,它告诉我,由于它无法正确清洁其数据库连接器,因此会有残留组件。

当我回到家时,我尝试删除该软件包,aptitude purge结果发现aptitude remove它并没有比看到 phpmyadmin 更有效,尝试删除它,但失败了,因为与该软件包关联的目录已经从我之前的尝试中删除了。

我尝试重新安装 phpmyadmin,但 aptitude 只是说没有可用的更新,并且什么也没做,如果有更新,我可能会遇到同样的问题。

在这方面,我继续清理 mysql,删除它使用的数据库,并从用户表中清除它。然而,我不知道包装中还剩下什么,甚至不知道如何清洁 aptitude 的挂钩。

的结果dpkg --purge

ickronia:/home/ken# dpkg --purge phpmyadmin
(Reading database ... 27158 files and directories currently installed.)
Removing phpmyadmin ...
/var/lib/dpkg/info/phpmyadmin.prerm: line 5: /usr/share/dbconfig-common/dpkg/prerm.mysql: No such file or directory
dpkg: error processing phpmyadmin (--purge):
 subprocess pre-removal script returned error exit status 1
/var/lib/dpkg/info/phpmyadmin.postinst: line 35: /usr/share/dbconfig-common/dpkg/postinst.mysql: No such file or directory
dpkg: error while cleaning up:
 subprocess post-installation script returned error exit status 1
Errors were encountered while processing:
phpmyadmin

按照 Gile 的建议,我尝试重新安装依赖项 dbconfig-common

ickronia:/home/ken# aptitude reinstall dbconfig-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Reading task descriptions... Done
dbconfig-common is not currently installed, so it will not be reinstalled.
dbconfig-common is not currently installed, so it will not be reinstalled.
The following packages are BROKEN:
  phpmyadmin
0 packages upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Need to get 0B of archives. After unpacking 0B will be used.
The following packages have unmet dependencies:
  phpmyadmin: Depends: php5-mcrypt but it is not installable
              Depends: dbconfig-common but it is not installable
              Depends: libjs-mootools (>= 1.2.4.0~debian1-1) which is a virtual  package.
The following actions will resolve these dependencies:

Remove the following packages:
phpmyadmin

Score is 121

Accept this solution? [Y/n/q/?] n

*** No more solutions available ***

The following actions will resolve these dependencies:

Remove the following packages:
phpmyadmin

Score is 121

Accept this solution? [Y/n/q/?] n

*** No more solutions available ***

The following actions will resolve these dependencies:

Remove the following packages:
phpmyadmin

Score is 121

Accept this solution? [Y/n/q/?] y
The following packages will be REMOVED:
  phpmyadmin{a}
0 packages upgraded, 0 newly installed, 1 to remove and 3 not upgraded.
Need to get 0B of archives. After unpacking 17.7MB will be freed.
Do you want to continue? [Y/n/?] y
Writing extended state information... Done
(Reading database ... 27158 files and directories currently installed.)
Removing phpmyadmin ...
/var/lib/dpkg/info/phpmyadmin.prerm: line 5: /usr/share/dbconfig-common/dpkg/prerm.mysql: No such file or directory
dpkg: error processing phpmyadmin (--remove):
 subprocess pre-removal script returned error exit status 1
/var/lib/dpkg/info/phpmyadmin.postinst: line 35: /usr/share/dbconfig-common/dpkg/postinst.mysql: No such file or directory
dpkg: error while cleaning up:
 subprocess post-installation script returned error exit status 1
Errors were encountered while processing:
 phpmyadmin
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install.  Trying to recover:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Writing extended state information... Done
Reading task descriptions... Done

ickronia:/home/ken#

看来 phpmyadmin 干净地清除了 dbconfig-common

ickronia:/usr/share/dbconfig-common# ls -alF
total 12
drwxr-xr-x  3 root root 4096 2011-02-09 08:09 ./
drwxr-xr-x 98 root root 4096 2011-01-20 21:42 ../
drwxr-xr-x  3 root root 4096 2011-01-05 11:08 data/
ickronia:/usr/share/dbconfig-common#

按照 Giles 的建议尝试从档案中删除 dpkg

ickronia:/usr/share/dbconfig-common# dpkg -i /var/cache/apt/archives/{dbconfig-common,php5-mcrypt,libjs-mootools}*.deb
Selecting previously deselected package dbconfig-common.
(Reading database ... 27161 files and directories currently installed.)
Unpacking dbconfig-common (from .../dbconfig-common_1.8.46_all.deb) ...
Selecting previously deselected package php5-mcrypt.
Unpacking php5-mcrypt (from .../php5-mcrypt_5.3.3-6_i386.deb) ...
Selecting previously deselected package libjs-mootools.
Unpacking libjs-mootools (from .../libjs-mootools_1.2.5~debian1-2_all.deb) ...
Setting up dbconfig-common (1.8.46) ...
dpkg: dependency problems prevent configuration of php5-mcrypt:
 php5-mcrypt depends on libltdl7 (>= 2.2.6b); however:
  Package libltdl7 is not installed.
 php5-mcrypt depends on libmcrypt4; however:
  Package libmcrypt4 is not installed.
dpkg: error processing php5-mcrypt (--install):
 dependency problems - leaving unconfigured
Setting up libjs-mootools (1.2.5~debian1-2) ...
Processing triggers for man-db ...
Processing triggers for libapache2-mod-php5 ...
Reloading web server config: apache2.
Errors were encountered while processing:
 php5-mcrypt
ickronia:/usr/share/dbconfig-common#

我有一个在 php 上运行的网络服务器,但我愿意冒着停机的风险来解决这个问题。

答案1

phpmyadmin依赖于取决于dbconfig-common, 其中包含/usr/share/dbconfig-common/dpkg/prerm.mysql。看来您已成功卸载dbconfig-common而未卸载phpmyadmin,这不应该发生(您是否尝试过--force某些操作?)。

我的建议是先尝试一下aptitude reinstall dbconfig-common。如果有效,您应该拥有一个处于一致状态的系统,您可以aptitude purge phpmyadmin再次尝试。

您可以做的另一件事是注释掉 中的有问题的行/var/lib/dpkg/info/phpmyadmin.prerm。这可能会让您能够卸载phpmyadmin。我怀疑你在手动编辑这些 mysql 表时做了该行应该做的事情,但我phpmyadmin一般不知道或数据库管理员,所以我只是猜测。

remove和之间的区别purge在于,remove仅删除程序及其数据文件(您可以重新下载的内容),而purge首先执行操作remove,然后还删除配置文件(您可能在本地编辑的内容)。如果remove失败了,也会的purge

答案2

有时,包管理系统非常糟糕(通常在循环依赖链中),我发现删除有问题的包的唯一命令组合是:

  • cd /var/lib/dpkg/info ; rm <packagename.*>
  • dpkg --purge --force-remove-reinstreq <packagename>
  • 或者dpkg --remove --force-remove-reinstreq <packagename>
  • 然后apt-get install <packagename>重新安装包

有时,状态覆盖文件可能也需要修复,并且上述过程可能会引发与此相关的错误。如何修复状态覆盖文件取决于它是否是标记用户的错误。

一般来说:

  • 状态覆盖文件位于:/var/lib/dpkg/statoverride
  • 您可以通过运行以下命令来更新它:dpkg-statoverride --remove <stateoverride-filename>
  • 如果您知道自己在做什么,您甚至可以手动编辑它们

答案3

(我假设您的意思是aptitude purgeand apt-get remove,因为您引用的命令不存在)

尝试dpkg --purge phpmyadmin。它比其他工具级别较低,因此在这种情况下可能更有效。

答案4

您可能需要运行“apt-get -f install”来纠正这些问题:

The following packages have unmet dependencies:
 postgresql-client-9.1 : Breaks: postgresql-9.1 (< 9.1.11-0ubuntu0.12.04) but 9.1.10-0ubuntu12.04 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

我遇到了上述问题,使用“sudo dpkg --purge postgresql-9.1”命令问题解决了

相关内容