apt-get 安装 git-core 失败

apt-get 安装 git-core 失败

跑步后sudo apt-get install git-core,我得到

Unpacking git-core (from .../git-core_1%3a1.7.4.1-3_all.deb) ...
Errors were encountered while processing:
 /var/cache/apt/archives/git_1%3a1.7.4.1-3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

所以我按照使用 Apt-Get 安装 Git 时出错但那也不起作用。

我运行后遇到了这个问题sudo dpkg --remove --force-remove-reinstreq git

dpkg: warning: overriding problem because --force enabled:
 Package is in a very bad inconsistent state - you should
 reinstall it before attempting a removal.
(Reading database ... 
dpkg: warning: files list file for package `git' missing, assuming package has no files currently installed.
dpkg: warning: files list file for package `git-man' missing, assuming package has no files currently installed.
dpkg: warning: files list file for package `git-core' missing, assuming package has no files currently installed.
(Reading database ... 79719 files and directories currently installed.)
Removing git ...

在某个时候,我被要求运行sudo apt-get -f install修复问题,但它说要安装 git

The following extra packages will be installed:
  git
Suggested packages:
  git-doc git-el git-arch git-cvs git-svn git-email git-daemon-run git-gui gitk gitweb
The following NEW packages will be installed:
  git
0 upgraded, 1 newly installed, 0 to remove and 480 not upgraded.
1 not fully installed or removed.
Need to get 4,658kB of archives.
After this operation, 10.9MB of additional disk space will be used.

单击“是”后,错误再次出现:

Do you want to continue [Y/n]? y
Get:1 http://ubuntu.mirror.cambrium.nl/ubuntu/ natty/main git 1:1.7.4.1-3 [4,658kB]
Fetched 4,658kB in 5s (907kB/s)
Selecting previously deselected package git.
(Reading database ... 
dpkg: warning: files list file for package `git-man' missing, assuming package has no files currently installed.

dpkg: warning: files list file for package `git-core' missing, assuming package has no files currently installed.
(Reading database ... 79719 files and directories currently installed.)
Unpacking git (from .../git_1%3a1.7.4.1-3_amd64.deb) ...
/var/lib/dpkg/tmp.ci/preinst: 12: dpkg-maintscript-helper: not found
dpkg: error processing /var/cache/apt/archives/git_1%3a1.7.4.1-3_amd64.deb (--unpack):
 subprocess new pre-installation script returned error exit status 127
/var/lib/dpkg/tmp.ci/postrm: 14: dpkg-maintscript-helper: not found
dpkg: error while cleaning up:
 subprocess new post-removal script returned error exit status 127
Errors were encountered while processing:
 /var/cache/apt/archives/git_1%3a1.7.4.1-3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

由于某些原因,当我这样做时dpgk --get-selections | grep git,我得到:

git                                             install
git-core                                        install
git-man                                         install

所以我陷入了这个循环。我该如何解决?

在 Ubuntu 10.04.4 LTS 上

答案1

试试这个,对我来说大多数时候都有效

$ sudo apt-get remove git-core
$ sudo apt-get autoremove

$ cd /var/cache/apt/archives

并删除存在管理员权限问题的 git 文件。

$ rm git_1%3a1.7.4.1-3_amd64.deb

或相应的文件。

然后运行

$ sudo apt-get update

$ sudo apt-get install git-core

如果问题仍然存在,请尝试删除 /var/cache/apt/archives 中的所有文件

$ sudo rm /var/cache/apt/archives/*

然后运行

$ sudo apt-get update
$ sudo apt-get install git-core

相关内容