From afb1e2e3bb580077c6c917e6ea98baad8f3c39b3 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 10 May 2005 08:27:59 +0000 Subject: * ported/cleaned up the "Automatic dependency handling" patch from Michael Hofmann --- cmdline/apt-get.cc | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 6268f4953..31148a807 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -58,6 +58,7 @@ #include #include #include +#include /*}}}*/ using namespace std; @@ -992,6 +993,26 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, cerr << _("Unable to correct missing packages.") << endl; return _error->Error(_("Aborting install.")); } + + // write the auto-mark list ---------------------------------- + // -- we do it here because there is no libapt::Commit() :/ + FileFd state_file; + string state = _config->FindDir("Dir::State") + "pkgstates"; + + + state_file.Open(state, FileFd::WriteEmpty); + std::ostringstream ostr; + for(pkgCache::PkgIterator p=Cache->PkgBegin(); !p.end();p++) { + if(Cache[p].AutomaticRemove != pkgCache::State::RemoveUnknown) { + ostr.str(string("")); + ostr << "Package: " << p.Name() + << "\nRemove-Reason: " + << (int)(Cache[p].AutomaticRemove) << "\n\n"; + state_file.Write(ostr.str().c_str(), ostr.str().size()); + //std::cout << "Writing auto-mark: " << ostr.str() << endl; + } + } + // ---------------------------------------------------------- _system->UnLock(); pkgPackageManager::OrderResult Res = PM->DoInstall(); @@ -1375,6 +1396,135 @@ bool DoUpgrade(CommandLine &CmdL) return InstallPackages(Cache,true); } /*}}}*/ +// RecurseDirty - Mark used packages as dirty /*{{{*/ +// --------------------------------------------------------------------- +/* Mark all reachable packages as dirty. */ +void RecurseDirty (CacheFile &Cache, pkgCache::PkgIterator Pkg, pkgCache::State::PkgRemoveState DirtLevel) +{ + // If it is not installed, and we are in manual mode, ignore it + if ((Pkg->CurrentVer == 0 && Cache[Pkg].Install() == false || Cache[Pkg].Delete() == true) && + DirtLevel == pkgCache::State::RemoveManual) + { +// fprintf(stdout,"This one is not installed/virtual %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); + return; + } + + // If it is not installed, and it is not virtual, ignore it + if ((Pkg->CurrentVer == 0 && Cache[Pkg].Install() == false || Cache[Pkg].Delete() == true) && + Pkg->VersionList != 0) + { +// fprintf(stdout,"This one is not installed %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); + return; + } + + // If it is similar or more dirty than we are ;-), because we've been here already, don't mark it + // This is necessary because virtual packages just relay the current level, + // so it may be possible e.g. that this was already seen with ::RemoveSuggested, but + // we are ::RemoveRequired + if (Cache[Pkg].Dirty() >= DirtLevel) + { + //fprintf(stdout,"Seen already %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); + return; + } + + // If it is less important than the current DirtLevel, don't mark it + if (Cache[Pkg].AutomaticRemove != pkgCache::State::RemoveManual && + Cache[Pkg].AutomaticRemove > DirtLevel) + { +// fprintf(stdout,"We don't need %s %d %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel, Cache[Pkg].Dirty()); + return; + } + + // Mark it as used + Cache->SetDirty(Pkg, DirtLevel); + + //fprintf(stdout,"We keep %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); + + // We are a virtual package + if (Pkg->VersionList == 0) + { +// fprintf(stdout,"We are virtual %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); + for (pkgCache::PrvIterator Prv = Pkg.ProvidesList(); ! Prv.end(); ++Prv) + RecurseDirty (Cache, Prv.OwnerPkg(), DirtLevel); + return; + } + + // Depending on the type of dependency, follow it + for (pkgCache::DepIterator D = Cache[Pkg].InstVerIter(Cache).DependsList(); ! D.end(); ++D) + { +// fprintf(stdout,"We depend on %s %s\n", D.TargetPkg().Name(), D.DepType()); + + switch(D->Type) + { + case pkgCache::Dep::Depends: + case pkgCache::Dep::PreDepends: + RecurseDirty (Cache, D.TargetPkg(), pkgCache::State::RemoveRequired); + break; + case pkgCache::Dep::Recommends: + RecurseDirty (Cache, D.TargetPkg(), pkgCache::State::RemoveRecommended); + break; + case pkgCache::Dep::Suggests: + RecurseDirty (Cache, D.TargetPkg(), pkgCache::State::RemoveSuggested); + break; + case pkgCache::Dep::Conflicts: + case pkgCache::Dep::Replaces: + case pkgCache::Dep::Obsoletes: + // We don't handle these here + break; + } + } +// fprintf(stdout,"We keep %s %d %d \n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); +} + /*}}}*/ +// DoAutomaticRemove - Remove all automatic unused packages /*{{{*/ +// --------------------------------------------------------------------- +/* Remove unused automatic packages */ +bool DoAutomaticRemove(CacheFile &Cache) +{ + std::cout << "DoAutomaticRemove()" << std::endl; + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) + if(!Cache[Pkg].Dirty() && Cache[Pkg].AutomaticRemove > 0) + std::cout << "has auto-remove information: " << Pkg.Name() + << " " << (int)Cache[Pkg].AutomaticRemove + << std::endl; + + + if (_config->FindB("APT::Get::Remove",true) == false) + return _error->Error(_("We are not supposed to delete stuff, can't start AutoRemover")); + + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) + Cache->SetDirty(Pkg, pkgCache::State::RemoveUnknown); + + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) + RecurseDirty (Cache, Pkg, pkgCache::State::RemoveManual); + + + + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) + { + if (! Cache[Pkg].Dirty() && + (Pkg->CurrentVer != 0 && Cache[Pkg].Install() == false && Cache[Pkg].Delete() == false)) + { + fprintf(stdout,"We could delete %s %d\n", Pkg.Name(), Cache[Pkg].AutomaticRemove); + Cache->MarkDelete(Pkg,_config->FindB("APT::Get::Purge",false)); + } + } + + // Now see if we destroyed anything + if (Cache->BrokenCount() != 0) + { + c1out << _("Hmm, seems like the AutoRemover destroyed something which really\n" + "shouldn't happen. Please file a bug report against apt.") << endl; + c1out << endl; + c1out << _("The following information may help to resolve the situation:") << endl; + c1out << endl; + ShowBroken(c1out,Cache,false); + + return _error->Error(_("Internal Error, AutoRemover broke stuff")); + } + return true; +} + /*}}}*/ // DoInstall - Install packages from the command line /*{{{*/ // --------------------------------------------------------------------- /* Install named packages */ @@ -1546,6 +1696,11 @@ bool DoInstall(CommandLine &CmdL) return _error->Error(_("Broken packages")); } + //if (_config->FindB("APT::Get::AutomaticRemove")) { + if (!DoAutomaticRemove(Cache)) + return false; + //} + /* Print out a list of packages that are going to be installed extra to what the user asked */ if (Cache->InstCount() != ExpectedInst) @@ -1565,6 +1720,8 @@ bool DoInstall(CommandLine &CmdL) if (*J == 0) { List += string(I.Name()) + " "; + //if (_config->FindB("APT::Get::AutomaticRemove")) + Cache[I].AutomaticRemove = pkgCache::State::RemoveRequired; VersionsList += string(Cache[I].CandVersion) + "\n"; } } @@ -2410,6 +2567,7 @@ void GetInitialize() _config->Set("APT::Get::Fix-Broken",false); _config->Set("APT::Get::Force-Yes",false); _config->Set("APT::Get::List-Cleanup",true); + _config->Set("APT::Get::AutomaticRemove",false); } /*}}}*/ // SigWinch - Window size change signal handler /*{{{*/ @@ -2465,6 +2623,7 @@ int main(int argc,const char *argv[]) {0,"remove","APT::Get::Remove",0}, {0,"only-source","APT::Get::Only-Source",0}, {0,"arch-only","APT::Get::Arch-Only",0}, + {0,"experimental-automatic-remove","APT::Get::AutomaticRemove",0}, {0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0}, {'c',"config-file",0,CommandLine::ConfigFile}, {'o',"option",0,CommandLine::ArbItem}, -- cgit v1.2.3 From a83d884db24933000f19dbff706529db057d50c1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 23 Jun 2005 16:40:54 +0000 Subject: * cleanups --- cmdline/apt-get.cc | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 31148a807..9f9ecd375 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -994,25 +994,8 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, return _error->Error(_("Aborting install.")); } - // write the auto-mark list ---------------------------------- // -- we do it here because there is no libapt::Commit() :/ - FileFd state_file; - string state = _config->FindDir("Dir::State") + "pkgstates"; - - - state_file.Open(state, FileFd::WriteEmpty); - std::ostringstream ostr; - for(pkgCache::PkgIterator p=Cache->PkgBegin(); !p.end();p++) { - if(Cache[p].AutomaticRemove != pkgCache::State::RemoveUnknown) { - ostr.str(string("")); - ostr << "Package: " << p.Name() - << "\nRemove-Reason: " - << (int)(Cache[p].AutomaticRemove) << "\n\n"; - state_file.Write(ostr.str().c_str(), ostr.str().size()); - //std::cout << "Writing auto-mark: " << ostr.str() << endl; - } - } - // ---------------------------------------------------------- + Cache->writeStateFile(NULL); _system->UnLock(); pkgPackageManager::OrderResult Res = PM->DoInstall(); @@ -1720,8 +1703,8 @@ bool DoInstall(CommandLine &CmdL) if (*J == 0) { List += string(I.Name()) + " "; - //if (_config->FindB("APT::Get::AutomaticRemove")) - Cache[I].AutomaticRemove = pkgCache::State::RemoveRequired; + // mark each pkg as auto-installed + Cache[I].AutomaticRemove = pkgCache::State::RemoveRequired; VersionsList += string(Cache[I].CandVersion) + "\n"; } } -- cgit v1.2.3 From 80fa0d8a1a77f4dab696dcf11d1908ecda761fab Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 24 Jun 2005 09:36:22 +0000 Subject: * moved most of the real work into depcache::writeStateFile --- cmdline/apt-get.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 9f9ecd375..bc8cd1ae5 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1703,10 +1703,8 @@ bool DoInstall(CommandLine &CmdL) if (*J == 0) { List += string(I.Name()) + " "; - // mark each pkg as auto-installed - Cache[I].AutomaticRemove = pkgCache::State::RemoveRequired; - VersionsList += string(Cache[I].CandVersion) + "\n"; - } + VersionsList += string(Cache[I].CandVersion) + "\n"; + } } ShowList(c1out,_("The following extra packages will be installed:"),List,VersionsList); -- cgit v1.2.3 From d36ab88eb8a5e490e4a817b87f20cb3f890e0da1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 24 Jun 2005 09:58:47 +0000 Subject: * write the state file after a successfull commit from the pkgManager --- cmdline/apt-get.cc | 3 --- 1 file changed, 3 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index bc8cd1ae5..f1496c9e2 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -994,9 +994,6 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, return _error->Error(_("Aborting install.")); } - // -- we do it here because there is no libapt::Commit() :/ - Cache->writeStateFile(NULL); - _system->UnLock(); pkgPackageManager::OrderResult Res = PM->DoInstall(); if (Res == pkgPackageManager::Failed || _error->PendingError() == true) -- cgit v1.2.3 From db1e7193fa7d5b86656c05112b9d6ad6e75845b8 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 24 Jun 2005 12:34:34 +0000 Subject: * moved the importend algorithm to algorithm.h as "pkgMarkUsed()" --- cmdline/apt-get.cc | 144 +++++++++++------------------------------------------ 1 file changed, 28 insertions(+), 116 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index f1496c9e2..54479e224 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1354,106 +1354,6 @@ bool DoUpdate(CommandLine &CmdL) return _error->Error(_("Some index files failed to download, they have been ignored, or old ones used instead.")); return true; -} - /*}}}*/ -// DoUpgrade - Upgrade all packages /*{{{*/ -// --------------------------------------------------------------------- -/* Upgrade all packages without installing new packages or erasing old - packages */ -bool DoUpgrade(CommandLine &CmdL) -{ - CacheFile Cache; - if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false) - return false; - - // Do the upgrade - if (pkgAllUpgrade(Cache) == false) - { - ShowBroken(c1out,Cache,false); - return _error->Error(_("Internal error, AllUpgrade broke stuff")); - } - - return InstallPackages(Cache,true); -} - /*}}}*/ -// RecurseDirty - Mark used packages as dirty /*{{{*/ -// --------------------------------------------------------------------- -/* Mark all reachable packages as dirty. */ -void RecurseDirty (CacheFile &Cache, pkgCache::PkgIterator Pkg, pkgCache::State::PkgRemoveState DirtLevel) -{ - // If it is not installed, and we are in manual mode, ignore it - if ((Pkg->CurrentVer == 0 && Cache[Pkg].Install() == false || Cache[Pkg].Delete() == true) && - DirtLevel == pkgCache::State::RemoveManual) - { -// fprintf(stdout,"This one is not installed/virtual %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); - return; - } - - // If it is not installed, and it is not virtual, ignore it - if ((Pkg->CurrentVer == 0 && Cache[Pkg].Install() == false || Cache[Pkg].Delete() == true) && - Pkg->VersionList != 0) - { -// fprintf(stdout,"This one is not installed %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); - return; - } - - // If it is similar or more dirty than we are ;-), because we've been here already, don't mark it - // This is necessary because virtual packages just relay the current level, - // so it may be possible e.g. that this was already seen with ::RemoveSuggested, but - // we are ::RemoveRequired - if (Cache[Pkg].Dirty() >= DirtLevel) - { - //fprintf(stdout,"Seen already %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); - return; - } - - // If it is less important than the current DirtLevel, don't mark it - if (Cache[Pkg].AutomaticRemove != pkgCache::State::RemoveManual && - Cache[Pkg].AutomaticRemove > DirtLevel) - { -// fprintf(stdout,"We don't need %s %d %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel, Cache[Pkg].Dirty()); - return; - } - - // Mark it as used - Cache->SetDirty(Pkg, DirtLevel); - - //fprintf(stdout,"We keep %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); - - // We are a virtual package - if (Pkg->VersionList == 0) - { -// fprintf(stdout,"We are virtual %s %d %d\n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); - for (pkgCache::PrvIterator Prv = Pkg.ProvidesList(); ! Prv.end(); ++Prv) - RecurseDirty (Cache, Prv.OwnerPkg(), DirtLevel); - return; - } - - // Depending on the type of dependency, follow it - for (pkgCache::DepIterator D = Cache[Pkg].InstVerIter(Cache).DependsList(); ! D.end(); ++D) - { -// fprintf(stdout,"We depend on %s %s\n", D.TargetPkg().Name(), D.DepType()); - - switch(D->Type) - { - case pkgCache::Dep::Depends: - case pkgCache::Dep::PreDepends: - RecurseDirty (Cache, D.TargetPkg(), pkgCache::State::RemoveRequired); - break; - case pkgCache::Dep::Recommends: - RecurseDirty (Cache, D.TargetPkg(), pkgCache::State::RemoveRecommended); - break; - case pkgCache::Dep::Suggests: - RecurseDirty (Cache, D.TargetPkg(), pkgCache::State::RemoveSuggested); - break; - case pkgCache::Dep::Conflicts: - case pkgCache::Dep::Replaces: - case pkgCache::Dep::Obsoletes: - // We don't handle these here - break; - } - } -// fprintf(stdout,"We keep %s %d %d \n", Pkg.Name(), Pkg->AutomaticRemove, DirtLevel); } /*}}}*/ // DoAutomaticRemove - Remove all automatic unused packages /*{{{*/ @@ -1462,30 +1362,23 @@ void RecurseDirty (CacheFile &Cache, pkgCache::PkgIterator Pkg, pkgCache::State: bool DoAutomaticRemove(CacheFile &Cache) { std::cout << "DoAutomaticRemove()" << std::endl; - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) - if(!Cache[Pkg].Dirty() && Cache[Pkg].AutomaticRemove > 0) - std::cout << "has auto-remove information: " << Pkg.Name() - << " " << (int)Cache[Pkg].AutomaticRemove - << std::endl; - if (_config->FindB("APT::Get::Remove",true) == false) - return _error->Error(_("We are not supposed to delete stuff, can't start AutoRemover")); - - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) - Cache->SetDirty(Pkg, pkgCache::State::RemoveUnknown); - - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) - RecurseDirty (Cache, Pkg, pkgCache::State::RemoveManual); - + return _error->Error(_("We are not supposed to delete stuff, can't " + "start AutoRemover")); + // do the actual work + pkgMarkUsed(Cache); + // look over the cache to see what can be removed for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) { if (! Cache[Pkg].Dirty() && - (Pkg->CurrentVer != 0 && Cache[Pkg].Install() == false && Cache[Pkg].Delete() == false)) + (Pkg->CurrentVer != 0 && Cache[Pkg].Install() == false && + Cache[Pkg].Delete() == false)) { - fprintf(stdout,"We could delete %s %d\n", Pkg.Name(), Cache[Pkg].AutomaticRemove); + fprintf(stdout,"We could delete %s %d\n", + Pkg.Name(), Cache[Pkg].AutomaticRemove); Cache->MarkDelete(Pkg,_config->FindB("APT::Get::Purge",false)); } } @@ -1503,6 +1396,25 @@ bool DoAutomaticRemove(CacheFile &Cache) return _error->Error(_("Internal Error, AutoRemover broke stuff")); } return true; +} +// DoUpgrade - Upgrade all packages /*{{{*/ +// --------------------------------------------------------------------- +/* Upgrade all packages without installing new packages or erasing old + packages */ +bool DoUpgrade(CommandLine &CmdL) +{ + CacheFile Cache; + if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false) + return false; + + // Do the upgrade + if (pkgAllUpgrade(Cache) == false) + { + ShowBroken(c1out,Cache,false); + return _error->Error(_("Internal error, AllUpgrade broke stuff")); + } + + return InstallPackages(Cache,true); } /*}}}*/ // DoInstall - Install packages from the command line /*{{{*/ -- cgit v1.2.3 From e004867d0979224adb9cbeb9705f156e16e3fe26 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 27 Jun 2005 16:29:16 +0000 Subject: * merged with mainline Patches applied: * andrelop@debian.org/apt--translation--0--base-0 tag of apt@packages.debian.org/apt--main--0--patch-79 * andrelop@debian.org/apt--translation--0--patch-1 Sync with Matt version. * andrelop@debian.org/apt--translation--0--patch-2 Update pt_BR translation * andrelop@debian.org/apt--translation--0--patch-3 Sync with bubulle's branch. * apt@packages.debian.org/apt--main--0--patch-89 Branch for Debian * apt@packages.debian.org/apt--main--0--patch-90 Update version in configure * apt@packages.debian.org/apt--main--0--patch-91 Fix French man page build * apt@packages.debian.org/apt--main--0--patch-92 Add the current Debian archive signing key * apt@packages.debian.org/apt--main--0--patch-93 Merge with mvo * apt@packages.debian.org/apt--main--0--patch-94 Update changelog * apt@packages.debian.org/apt--main--0--patch-95 Merge Christian's branch * apt@packages.debian.org/apt--main--0--patch-96 Update changelog * apt@packages.debian.org/apt--main--0--patch-97 Update priority of apt-utils to important, to match the override file * bubulle@debian.org--2005/apt--main--0--patch-82 Fix permissions * bubulle@debian.org--2005/apt--main--0--patch-83 French translation spellchecked * bubulle@debian.org--2005/apt--main--0--patch-84 Spell corrections in German translations * bubulle@debian.org--2005/apt--main--0--patch-85 Correct some file permissions * bubulle@debian.org--2005/apt--main--0--patch-86 Correct Hebrew translation * bubulle@debian.org--2005/apt--main--0--patch-87 Sync Portuguese translation with the POT file * bubulle@debian.org--2005/apt--main--0--patch-88 Updated Danish translation (not yet complete) * bubulle@debian.org--2005/apt--main--0--patch-89 Sync with Andre Luis Lopes and Otavio branches * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-22 * added myself to uploaders, changelog is signed with mvo@debian.org and in sync with the debian/experimental upload * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-23 * apt-cache show shows all virtual packages instead of nothing (thanks to otavio) * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-24 * changelog updated * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-25 * make pinning on component work again (we just use the section, as apt-0.6 don't use per-section Release files anymore) * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-27 * updated the changelog * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-28 * merged with my apt--fixes--0 branch * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-29 * added a missing OpProgress::Done() in depCache::Init(), removed the show-virtual-packages patch in apt-cache because matt does not like him :/ * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-30 * fix a stupid bug in the depcache::Init() code * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-31 * merged/removed conflicts with apt--main--0 * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-32 * merged apt--main and make sure that the po files come from apt--main (because they are more recent) --- cmdline/apt-key | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-key b/cmdline/apt-key index be2b19a1a..0685e36f7 100755 --- a/cmdline/apt-key +++ b/cmdline/apt-key @@ -9,14 +9,14 @@ GPG_CMD="gpg --no-options --no-default-keyring --secret-keyring /etc/apt/secring GPG="$GPG_CMD --keyring /etc/apt/trusted.gpg" -ARCHIVE_KEYRING=/usr/share/keyrings/ubuntu-archive-keyring.gpg -REMOVED_KEYS=/usr/share/keyrings/ubuntu-archive-removed-keys.gpg +ARCHIVE_KEYRING=/usr/share/keyrings/debian-archive-keyring.gpg +REMOVED_KEYS=/usr/share/keyrings/debian-archive-removed-keys.gpg update() { if [ ! -f $ARCHIVE_KEYRING ]; then echo >&2 "ERROR: Can't find the archive-keyring" - echo >&2 "Is the ubuntu-keyring package installed?" + echo >&2 "Is the debian-keyring package installed?" exit 1 fi -- cgit v1.2.3 From 120365cee294d00706928b0327ac755ab3448eca Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 28 Jun 2005 08:41:51 +0000 Subject: * cleanups, documentation updates (don't show any debug output if no Debug::pkgAutomaticRemove was set, don't remove if not APT::Get::AutomaticRemove (--automatic-remove) was set) --- cmdline/apt-get.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 3bafd42ba..0236d7e77 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1361,7 +1361,8 @@ bool DoUpdate(CommandLine &CmdL) /* Remove unused automatic packages */ bool DoAutomaticRemove(CacheFile &Cache) { - std::cout << "DoAutomaticRemove()" << std::endl; + if(_config->FindI("Debug::pkgAutoRemove",false)) + std::cout << "DoAutomaticRemove()" << std::endl; if (_config->FindB("APT::Get::Remove",true) == false) return _error->Error(_("We are not supposed to delete stuff, can't " @@ -1597,10 +1598,10 @@ bool DoInstall(CommandLine &CmdL) return _error->Error(_("Broken packages")); } - //if (_config->FindB("APT::Get::AutomaticRemove")) { + if (_config->FindB("APT::Get::AutomaticRemove")) { if (!DoAutomaticRemove(Cache)) return false; - //} + } /* Print out a list of packages that are going to be installed extra to what the user asked */ @@ -2522,7 +2523,7 @@ int main(int argc,const char *argv[]) {0,"remove","APT::Get::Remove",0}, {0,"only-source","APT::Get::Only-Source",0}, {0,"arch-only","APT::Get::Arch-Only",0}, - {0,"experimental-automatic-remove","APT::Get::AutomaticRemove",0}, + {0,"automatic-remove","APT::Get::AutomaticRemove",0}, {0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0}, {'c',"config-file",0,CommandLine::ConfigFile}, {'o',"option",0,CommandLine::ArbItem}, -- cgit v1.2.3 From 0a57c0f0e4d0bc3474ce4d2101f36a997891d30d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 29 Jun 2005 06:11:36 +0000 Subject: * use mark-and-sweep from aptitude now as GC algorithm --- cmdline/apt-get.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 0236d7e77..9d97f8756 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1374,12 +1374,11 @@ bool DoAutomaticRemove(CacheFile &Cache) // look over the cache to see what can be removed for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) { - if (! Cache[Pkg].Dirty() && + if (Cache[Pkg].Garbage && (Pkg->CurrentVer != 0 && Cache[Pkg].Install() == false && Cache[Pkg].Delete() == false)) { - fprintf(stdout,"We could delete %s %d\n", - Pkg.Name(), Cache[Pkg].AutomaticRemove); + fprintf(stdout,"We could delete %s\n", Pkg.Name()); Cache->MarkDelete(Pkg,_config->FindB("APT::Get::Purge",false)); } } -- cgit v1.2.3 From f8ac1720a94468d1384e88a57729e6d9801b56fd Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 30 Jun 2005 13:34:32 +0000 Subject: * slighly more debug output, renamed "--automatic-remove" to "--auto-remove" --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 9d97f8756..cb8fc7724 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2522,7 +2522,7 @@ int main(int argc,const char *argv[]) {0,"remove","APT::Get::Remove",0}, {0,"only-source","APT::Get::Only-Source",0}, {0,"arch-only","APT::Get::Arch-Only",0}, - {0,"automatic-remove","APT::Get::AutomaticRemove",0}, + {0,"auto-remove","APT::Get::AutomaticRemove",0}, {0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0}, {'c',"config-file",0,CommandLine::ConfigFile}, {'o',"option",0,CommandLine::ArbItem}, -- cgit v1.2.3 From 2a7e07c7578048abd9f7bfd4ce0ca5c3696b9f3a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 18 Aug 2005 10:38:58 +0000 Subject: * merged from main Patches applied: * apt@packages.debian.org/apt--main--0--patch-100 Use debian.org address in mainline * apt@packages.debian.org/apt--main--0--patch-101 Update pot file * apt@packages.debian.org/apt--main--0--patch-102 Open 0.6.40 * apt@packages.debian.org/apt--main--0--patch-103 Patch from Jordi Mallach to mark some additional strings for translation * apt@packages.debian.org/apt--main--0--patch-104 Updated Catalan translation from Jordi Mallach * apt@packages.debian.org/apt--main--0--patch-105 Merge from bubulle@debian.org--2005/apt--main--0 * apt@packages.debian.org/apt--main--0--patch-106 Restore lost changelog entries * apt@packages.debian.org/apt--main--0--patch-107 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * apt@packages.debian.org/apt--main--0--patch-108 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * apt@packages.debian.org/apt--main--0--patch-109 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * apt@packages.debian.org/apt--main--0--patch-110 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * bubulle@debian.org--2005/apt--main--0--patch-90 Merge with Matt * bubulle@debian.org--2005/apt--main--0--patch-91 Updated Slovak translation * bubulle@debian.org--2005/apt--main--0--patch-92 Add apt-key French man page * bubulle@debian.org--2005/apt--main--0--patch-93 Update Greek translations * bubulle@debian.org--2005/apt--main--0--patch-94 Merge with Matt * bubulle@debian.org--2005/apt--main--0--patch-95 Sync PO files with the POT file/French translation update * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--base-0 tag of apt@packages.debian.org/apt--main--0--patch-85 * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-1 * inital proof of concept code, understands what dpkg tells it already * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-2 * progress reporting works now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-3 * added "APT::Status-Fd" variable * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-4 * do i18n now too * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-5 * define N_(x) if it is not defined already * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-6 * PackageManager::DoInstall(int status_fd) added (does not break the ABI) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-7 * merged with apt--fixes--0 to make it build again * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-8 * added support for "error" and "conffile-prompt" messages from dpkg * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-9 merge with main * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-10 * use sizeof() for all snprintf() uses; fix a potential line break problem in the status reading code; changed the N_() to _() calls * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-11 * added APT::KeepFDs configuration list for file descriptors that apt should leave open (needed for various frontends like debconf, synaptic) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-12 * fixed a API breakage * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-13 * doc added, should be releasable now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-14 * merged with apt--main--0 * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-15 * more source comments, added Debug::DpkgPM debug code to inspect the dpkg<->apt communication, broke the abi (ok with matt) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-16 * the progress reporting has it's own "Debug::pkgDPkgProgressReporting" debug variable now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-17 * merged PackageOps and TranslatedPackageOps into a single Map with the new DpkgState struct * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-18 * clear the APT::Keep-Fds configuration when it's no longer needed * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-19 * rewrote the reading from dpkg so that it never blocks * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-20 * merged the two status arrays into one * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-21 * added support for download progress reporting too (for Kamion and base-config) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-22 * ABI break; added Configuration::Clear(string List, {int,string} value) added (to remove a single Value from a list); test/conf_clear.cc added * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-23 * remvoed a debug string * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-24 * soname changed, fixed a bug in the parsing code when dpkg send the same state more than once (at the end) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-25 * merged with apt@packages.debian.org/apt--main--0, added changelog entry for the 0.6.40.1 upload * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-26 * fix a bug when out-of-order states are send from dpkg * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-27 * changelog update * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-28 * a real changelog entry now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-29 * changelog finalized * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-30 * propper (and sane) support for pmerror and pmconffile added --- cmdline/apt-get.cc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index cb8fc7724..ac0d56073 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -689,7 +689,7 @@ static bool CheckAuth(pkgAcquire& Fetcher) if (_config->FindB("APT::Get::AllowUnauthenticated",false) == true) { - c2out << "Authentication warning overridden.\n"; + c2out << _("Authentication warning overridden.\n"); return true; } @@ -751,7 +751,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, if (Cache->BrokenCount() != 0) { ShowBroken(c1out,Cache,false); - return _error->Error("Internal error, InstallPackages was called with broken packages!"); + return _error->Error(_("Internal error, InstallPackages was called with broken packages!")); } if (Cache->DelCount() == 0 && Cache->InstCount() == 0 && @@ -766,11 +766,12 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, if (_config->FindB("APT::Get::Simulate") == true) { pkgSimulate PM(Cache); - pkgPackageManager::OrderResult Res = PM.DoInstall(); + int status_fd = _config->FindI("APT::Status-Fd",-1); + pkgPackageManager::OrderResult Res = PM.DoInstall(status_fd); if (Res == pkgPackageManager::Failed) return false; if (Res != pkgPackageManager::Completed) - return _error->Error("Internal error, Ordering didn't finish"); + return _error->Error(_("Internal error, Ordering didn't finish")); return true; } @@ -811,7 +812,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, if (DebBytes != Cache->DebSize()) { c0out << DebBytes << ',' << Cache->DebSize() << endl; - c0out << "How odd.. The sizes didn't match, email apt@packages.debian.org" << endl; + c0out << _("How odd.. The sizes didn't match, email apt@packages.debian.org") << endl; } // Number of bytes @@ -841,7 +842,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, struct statvfs Buf; string OutputDir = _config->FindDir("Dir::Cache::Archives"); if (statvfs(OutputDir.c_str(),&Buf) != 0) - return _error->Errno("statvfs","Couldn't determine free space in %s", + return _error->Errno("statvfs",_("Couldn't determine free space in %s"), OutputDir.c_str()); if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize) return _error->Error(_("You don't have enough free space in %s."), @@ -995,7 +996,8 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, } _system->UnLock(); - pkgPackageManager::OrderResult Res = PM->DoInstall(); + int status_fd = _config->FindI("APT::Status-Fd",-1); + pkgPackageManager::OrderResult Res = PM->DoInstall(status_fd); if (Res == pkgPackageManager::Failed || _error->PendingError() == true) return false; if (Res == pkgPackageManager::Completed) @@ -1790,7 +1792,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) if (Fix.Resolve() == false) { ShowBroken(c1out,Cache,false); - return _error->Error("Internal error, problem resolver broke stuff"); + return _error->Error(_("Internal error, problem resolver broke stuff")); } } @@ -1798,7 +1800,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) if (pkgAllUpgrade(Cache) == false) { ShowBroken(c1out,Cache,false); - return _error->Error("Internal error, problem resolver broke stuff"); + return _error->Error(_("Internal error, problem resolver broke stuff")); } return InstallPackages(Cache,false); @@ -1969,7 +1971,7 @@ bool DoSource(CommandLine &CmdL) struct statvfs Buf; string OutputDir = "."; if (statvfs(OutputDir.c_str(),&Buf) != 0) - return _error->Errno("statvfs","Couldn't determine free space in %s", + return _error->Errno("statvfs",_("Couldn't determine free space in %s"), OutputDir.c_str()); if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize) return _error->Error(_("You don't have enough free space in %s"), -- cgit v1.2.3 From 74a05226eff7041cd8f2380fe599862d350a1ac3 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 9 Nov 2005 11:39:27 +0000 Subject: * merged daniel burrows fixes for the auto-mark code Patches applied: * dburrows@debian.org--2005/apt--auto-mark--0--base-0 tag of michael.vogt@ubuntu.com--2005/apt--auto-mark--0--patch-22 * dburrows@debian.org--2005/apt--auto-mark--0--patch-1 doxygenize the new automark stuff * dburrows@debian.org--2005/apt--auto-mark--0--patch-2 Automatically update package markings after every state-changing public operation, and allow users of the dep-cache to group actions into a single action. * dburrows@debian.org--2005/apt--auto-mark--0--patch-3 Automatically update package markings after every state-changing public operation, and allow users of the dep-cache to group actions into a single action. * dburrows@debian.org--2005/apt--auto-mark--0--patch-4 Make action groups noncopyable * dburrows@debian.org--2005/apt--auto-mark--0--patch-5 Typo fix * dburrows@debian.org--2005/apt--auto-mark--0--patch-6 Add a FromUser flag to MarkKeep. * dburrows@debian.org--2005/apt--auto-mark--0--patch-7 Somehow the ActionGroup definition got duplicated; kill the duplicate. * dburrows@debian.org--2005/apt--auto-mark--0--patch-8 Cancel the automatic flag on packages that are being kept only if they are garbage. * dburrows@debian.org--2005/apt--auto-mark--0--patch-9 Don't clear the 'automatically installed' flag in MarkDelete. * dburrows@debian.org--2005/apt--auto-mark--0--patch-10 Add a FromUser flag to MarkInstall, and fix its handling of the Auto flag. * dburrows@debian.org--2005/apt--auto-mark--0--patch-11 Only clear the Auto flag on manual changes in MarkKeep. * dburrows@debian.org--2005/apt--auto-mark--0--patch-12 Make changes from the internal algorithms automatic. * dburrows@debian.org--2005/apt--auto-mark--0--patch-13 Use ActionGroups in algorithms that make lots of changes, and fix a compile error. * dburrows@debian.org--2005/apt--auto-mark--0--patch-14 Split the sweep code into a separate routine from pkgMarkUsed * dburrows@debian.org--2005/apt--auto-mark--0--patch-15 Update another call of MarkKeep to indicate that it's automatic. * dburrows@debian.org--2005/apt--auto-mark--0--patch-16 Move the mark-and-sweep code into pkgDepCache; call Sweep and document what it and Garbage are for; add a hook that can be used to generate a custom root-set function; move the big blob of regexp stuff into the custom root-set; fix the memory leak in the regexp stuff. * dburrows@debian.org--2005/apt--auto-mark--0--patch-17 Make ActionGroup take a reference instead of a pointer to the cache. * dburrows@debian.org--2005/apt--auto-mark--0--patch-18 Don't mark already-to-be-deleted packages as garbage, to imitate aptitude's behavior. * dburrows@debian.org--2005/apt--auto-mark--0--patch-19 Update apt-get for the new auto-mark protocol. * dburrows@debian.org--2005/apt--auto-mark--0--patch-20 Add a setter method for the Auto flag. * dburrows@debian.org--2005/apt--auto-mark--0--patch-21 Fix the test in apt-get about what to delete. * dburrows@debian.org--2005/apt--auto-mark--0--patch-22 Add a zero-argument mark-and-sweep routine and use it to do a mark-and-sweep on startup (so the garbage flags are initialized properly). * dburrows@debian.org--2005/apt--auto-mark--0--patch-23 Right, Status is 2 for new installs, not 0. * dburrows@debian.org--2005/apt--auto-mark--0--patch-24 POT updates. * dburrows@debian.org--2005/apt--auto-mark--0--patch-25 Actually initialize group_level to 0. * dburrows@debian.org--2005/apt--auto-mark--0--patch-26 Don't make an ActionGroup in Sweep, since there's no point and it also is an infinite loop. * dburrows@debian.org--2005/apt--auto-mark--0--patch-27 Add virtual hooks to control whether the garbage collector considers recommends and/or suggests to be strong links. * dburrows@debian.org--2005/apt--auto-mark--0--patch-28 Call the progress methods in the right order so we don't generate nonsensical progress notifications. * dburrows@debian.org--2005/apt--auto-mark--0--patch-29 Typo fix. * dburrows@debian.org--2005/apt--auto-mark--0--patch-30 Make RecommendsImportant default to true in apt, too. * dburrows@debian.org--2005/apt--auto-mark--0--patch-31 Add a release() method to action groups. * dburrows@debian.org--2005/apt--auto-mark--0--patch-32 Add an 'autoremove' command that is synonymous to '--auto-remove remove'. --- cmdline/apt-get.cc | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index ac0d56073..c8b64f5d8 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1370,19 +1370,23 @@ bool DoAutomaticRemove(CacheFile &Cache) return _error->Error(_("We are not supposed to delete stuff, can't " "start AutoRemover")); - // do the actual work - pkgMarkUsed(Cache); - - // look over the cache to see what can be removed - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) { - if (Cache[Pkg].Garbage && - (Pkg->CurrentVer != 0 && Cache[Pkg].Install() == false && - Cache[Pkg].Delete() == false)) - { - fprintf(stdout,"We could delete %s\n", Pkg.Name()); - Cache->MarkDelete(Pkg,_config->FindB("APT::Get::Purge",false)); - } + pkgDepCache::ActionGroup group(*Cache); + + // look over the cache to see what can be removed + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg) + { + if (Cache[Pkg].Garbage) + { + if(Pkg.CurrentVer() != 0 || Cache[Pkg].Install()) + fprintf(stdout,"We could delete %s\n", Pkg.Name()); + + if(Pkg.CurrentVer() != 0 && Pkg->CurrentState != pkgCache::State::ConfigFiles) + Cache->MarkDelete(Pkg, _config->FindB("APT::Get::Purge", false)); + else + Cache->MarkKeep(Pkg, false, false); + } + } } // Now see if we destroyed anything @@ -1399,6 +1403,7 @@ bool DoAutomaticRemove(CacheFile &Cache) } return true; } + // DoUpgrade - Upgrade all packages /*{{{*/ // --------------------------------------------------------------------- /* Upgrade all packages without installing new packages or erasing old @@ -1450,6 +1455,11 @@ bool DoInstall(CommandLine &CmdL) bool DefRemove = false; if (strcasecmp(CmdL.FileList[0],"remove") == 0) DefRemove = true; + else if (strcasecmp(CmdL.FileList[0], "autoremove") == 0) + { + _config->Set("APT::Get::AutomaticRemove", "true"); + DefRemove = true; + } for (const char **I = CmdL.FileList + 1; *I != 0; I++) { @@ -2533,6 +2543,7 @@ int main(int argc,const char *argv[]) {"upgrade",&DoUpgrade}, {"install",&DoInstall}, {"remove",&DoInstall}, + {"autoremove",&DoInstall}, {"dist-upgrade",&DoDistUpgrade}, {"dselect-upgrade",&DoDSelectUpgrade}, {"build-dep",&DoBuildDep}, -- cgit v1.2.3 From b1a8717ae8e07101cfae03b978d57b793884a3d9 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 26 Jun 2006 09:17:05 +0200 Subject: * cmdline/apt-mark: - very simple tool to manipulate the extended_states for autoinstall * apt-pkg/depcache.cc: - keep exisiting data in "extended_states" to make other tools happy --- cmdline/apt-mark | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 cmdline/apt-mark (limited to 'cmdline') diff --git a/cmdline/apt-mark b/cmdline/apt-mark new file mode 100755 index 000000000..533ed8715 --- /dev/null +++ b/cmdline/apt-mark @@ -0,0 +1,63 @@ +#!/usr/bin/python + +from optparse import OptionParser + +try: + import apt_pkg +except ImportError: + print "Error importing apt_pkg, is python-apt installed?" + +import sys +import os.path + +actions = { "markauto" : 1, + "unmarkauto": 0 + } + +if __name__ == "__main__": + apt_pkg.init() + + # option parsing + parser = OptionParser() + parser.usage = "%prog [options] {markauto|unmarkauto} packages..." + parser.add_option("-f", "--file", action="store", type="string", + dest="filename", + help="read/write a different file") + parser.add_option("-v", "--verbose", + action="store_true", dest="verbose", default=False, + help="print verbose status messages to stdout") + (options, args) = parser.parse_args() + if len(args) < 2: + parser.error("not enough argument") + + # get pkgs to change + if args[0] not in actions.keys(): + parser.error("first argument must be 'markauto' or 'unmarkauto'") + pkgs = args[1:] + action = actions[args[0]] + + # get the state-file + if not options.filename: + STATE_FILE = apt_pkg.Config.FindDir("Dir::State") + "extended_states" + else: + STATE_FILE=options.state_file + + # open the statefile + if os.path.exists(STATE_FILE): + tagfile = apt_pkg.ParseTagFile(open(STATE_FILE)) + outfile = open(STATE_FILE+".tmp","w") + while tagfile.Step(): + pkgname = tagfile.Section.get("Package") + autoInst = tagfile.Section.get("Auto-Installed") + if pkgname in pkgs: + if options.verbose: + print "changing %s to %s" % (pkgname,action) + newsec = apt_pkg.RewriteSection(tagfile.Section, + [], + [ ("Auto-Installed",str(action)) ] + ) + outfile.write(newsec+"\n") + else: + outfile.write(str(tagfile.Section)+"\n") + # all done, rename the tmpfile + os.rename(outfile.name, STATE_FILE) -- cgit v1.2.3