X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/f49d103adc47c5c34f4ca852605ee55710e486b9..acfbd607bd92cc1ba391873ce0ccec7103d858e0:/apt-private/private-update.cc diff --git a/apt-private/private-update.cc b/apt-private/private-update.cc index 61259748d..860d84b86 100644 --- a/apt-private/private-update.cc +++ b/apt-private/private-update.cc @@ -1,36 +1,23 @@ // Include files /*{{{*/ #include<config.h> -#include <apt-pkg/aptconfiguration.h> -#include <apt-pkg/error.h> -#include <apt-pkg/cmndline.h> -#include <apt-pkg/init.h> -#include <apt-pkg/depcache.h> -#include <apt-pkg/sourcelist.h> -#include <apt-pkg/algorithms.h> #include <apt-pkg/acquire-item.h> -#include <apt-pkg/strutl.h> -#include <apt-pkg/fileutl.h> -#include <apt-pkg/clean.h> -#include <apt-pkg/srcrecords.h> -#include <apt-pkg/version.h> #include <apt-pkg/cachefile.h> -#include <apt-pkg/cacheset.h> -#include <apt-pkg/sptr.h> -#include <apt-pkg/md5.h> -#include <apt-pkg/versionmatch.h> -#include <apt-pkg/progress.h> -#include <apt-pkg/pkgsystem.h> -#include <apt-pkg/pkgrecords.h> -#include <apt-pkg/indexfile.h> +#include <apt-pkg/cmndline.h> +#include <apt-pkg/error.h> +#include <apt-pkg/fileutl.h> +#include <apt-pkg/sourcelist.h> +#include <apt-pkg/update.h> +#include <apt-pkg/acquire.h> +#include <apt-pkg/configuration.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> +#include <apt-private/acqprogress.h> +#include <apt-private/private-cachefile.h> +#include <apt-private/private-output.h> +#include <apt-private/private-update.h> -#include "private-cachefile.h" -#include "private-output.h" -#include "acqprogress.h" +#include <ostream> +#include <string> #include <apti18n.h> /*}}}*/ @@ -88,6 +75,27 @@ bool DoUpdate(CommandLine &CmdL) return false; } + // show basic stats (if the user whishes) + if (_config->FindB("APT::Cmd::Show-Update-Stats", false) == true) + { + int upgradable = 0; + Cache.Open(); + for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() != true; ++I) + { + pkgDepCache::StateCache &state = Cache[I]; + if (I->CurrentVer != 0 && state.Upgradable() && state.CandidateVer != NULL) + upgradable++; + } + const char *msg = P_( + "%i package can be upgraded. Run 'apt list --upgradable' to see it.\n", + "%i packages can be upgraded. Run 'apt list --upgradable' to see them.\n", + upgradable); + if (upgradable == 0) + c1out << _("All packages are up to date.") << std::endl; + else + ioprintf(c1out, msg, upgradable); + } + return true; } /*}}}*/