25 apt
我认为在apt-get autoremove没有任何后续参数的情况下运行apt-get autoremove xxx会删除系统上所有未使用的依赖项,而运行会删除 xxx 及其未使用的依赖项。
然而我发现并非如此。运行apt-get autoremove xxx不仅会删除 xxx 及其未使用的依赖项,还会删除所有其他未使用的依赖项。
然后我尝试运行apt-get remove --auto-remove xxx,认为这只会删除 xxx 及其未使用的依赖项。令我惊讶的是,这也删除了 xxx、其未使用的依赖项以及所有其他未使用的依赖项。
这让我想到了两个相关的问题。
(1) 这是命令的预期行为吗?
(2) 有没有一种简单的方法可以在不删除其他未使用的依赖项的情况下删除xxx及其未使用的依赖项?
(它似乎aptitude remove也以类似的方式运行。)
Lek*_*eyn 21
查看cmdline/apt-get.cc来自http://packages.ubuntu.com/source/maverick/apt源 tarball的文件,我可以看到这--auto-remove是一个启用APT::Get::AutomaticRemove设置的参数。
命令autoremove和remove两者都调用函数DoInstall。
命令“autoremove”APT::Get::AutomaticRemove也会设置,因此它与--auto-remove.
查看该DoAutomaticRemove函数,可以清楚地看到启用APT::Get::AutomaticRemove设置(--auto-remove并autoremove执行此操作)会导致 Apt 循环遍历所有已安装的软件包并将未使用的软件包标记为删除。
来自main():
CommandLine::Args Args[] = {
// ... stripped to save space
{0,"auto-remove","APT::Get::AutomaticRemove",0},
// ...
}
CommandLine::Dispatch Cmds[] = { // ...
{"remove",&DoInstall},
{"purge",&DoInstall},
{"autoremove",&DoInstall},
// ...
}
// ...
// Parse the command line and initialize the package library
CommandLine CmdL(Args,_config);
Run Code Online (Sandbox Code Playgroud)
来自DoInstall():
unsigned short fallback = MOD_INSTALL;
if (strcasecmp(CmdL.FileList[0],"remove") == 0)
fallback = MOD_REMOVE;
else if (strcasecmp(CmdL.FileList[0], "purge") == 0)
{
_config->Set("APT::Get::Purge", true);
fallback = MOD_REMOVE;
}
else if (strcasecmp(CmdL.FileList[0], "autoremove") == 0)
{
_config->Set("APT::Get::AutomaticRemove", "true");
fallback = MOD_REMOVE;
}
Run Code Online (Sandbox Code Playgroud)
从功能DoAutomaticRemove:
bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove", false);
// ...
// look over the cache to see what can be removed
for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) {
if (doAutoRemove) {
if(Pkg.CurrentVer() != 0 &&
Pkg->CurrentState != pkgCache::State::ConfigFiles)
Cache->MarkDelete(Pkg, purgePkgs);
else
Cache->MarkKeep(Pkg, false, false);
}
}
Run Code Online (Sandbox Code Playgroud)
我不能说它是否有意,您可以在launchpad.net 上填写错误/提出问题。
目前,无法通过apt-get autoremove. 如果要保留包,请运行apt-get -s autoremove,从列表中复制包并从列表中删除要保留的包。最后,删除这些包:(sudo apt-get purge [packages-to-be-removed]清除也会删除配置文件,如果有的话)
| 归档时间: |
|
| 查看次数: |
66930 次 |
| 最近记录: |