Nhìn vào tệp cmdline/apt-get.cctừ tarball nguồn tại http://packages.ubfox.com/source/maverick/apt , tôi có thể thấy đó --auto-removelà một đối số cho phép APT::Get::AutomaticRemovecài đặt.
Các lệnh autoremovevà removecả hai gọi hàm DoInstall.
Lệnh "autoremove" APT::Get::AutomaticRemovecũng thiết lập và do đó nó cũng giống như vậy --auto-remove.
Nhìn vào DoAutomaticRemovehàm, có thể thấy rõ rằng việc bật APT::Get::AutomaticRemovecài đặt ( --auto-removevà autoremovethực hiện điều này) sẽ khiến Apt lặp qua tất cả các gói đã cài đặt và đánh dấu các gói không sử dụng để xóa.
Từ 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);
Từ 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;
}
Từ chức năng 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);
}
}
Tôi không thể nói liệu nó có ý định hay không, bạn có thể điền vào một lỗi / đặt câu hỏi tại launchpad.net .
Hiện tại, không thể loại trừ các gói khỏi bị xóa bởi apt-get autoremove. Nếu bạn muốn giữ các gói, hãy chạy apt-get -s autoremove, sao chép các gói khỏi danh sách và xóa các gói khỏi danh sách mà bạn muốn giữ. Cuối cùng, loại bỏ các gói đó: sudo apt-get purge [packages-to-be-removed](thanh lọc cũng loại bỏ các tệp cấu hình, nếu có)