เมื่อดูในไฟล์cmdline/apt-get.cc
จากแหล่ง tarball ที่http://packages.ubuntu.com/source/maverick/aptฉันจะเห็นว่า--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);
จาก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;
}
จากฟังก์ชั่น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);
}
}
ฉันไม่สามารถพูดไม่ว่าจะตั้งใจหรือไม่คุณสามารถกรอกข้อผิดพลาด / ถามคำถามที่launchpad.net
apt-get autoremove
ในขณะที่มันเป็นไปไม่ได้ที่จะไม่รวมแพคเกจจากการลบโดย หากคุณต้องการเก็บแพคเกจให้รันapt-get -s autoremove
คัดลอกแพ็กเกจจากรายการและลบแพ็กเกจออกจากรายการที่คุณต้องการเก็บไว้ สุดท้ายให้ลบแพ็คเกจเหล่านี้: sudo apt-get purge [packages-to-be-removed]
(ลบไฟล์การกำหนดค่าด้วยถ้ามี)