From 5ed56f934dd204cc3a1d757ccf5eac23f8374736 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 14 Sep 2010 18:57:46 +0200 Subject: * apt-pkg/policy.cc: - support 100-pinning in Release file with ButAutomaticUpgrades as requested by the backports crew (Closes: #596097) * apt-pkg/deb/deblistparser.cc: - overrule NotAutomatic in case of ButAutomaticUpgrades --- apt-pkg/deb/deblistparser.cc | 6 ++++++ apt-pkg/depcache.cc | 3 ++- apt-pkg/pkgcache.cc | 1 + apt-pkg/pkgcache.h | 2 +- apt-pkg/policy.cc | 9 +++++---- 5 files changed, 15 insertions(+), 6 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 5fb737970..da8b0271b 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -815,6 +815,12 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI, if (Section.FindFlag("NotAutomatic",FileI->Flags, pkgCache::Flag::NotAutomatic) == false) _error->Warning("Bad NotAutomatic flag"); + if (Section.FindFlag("ButAutomaticUpgrades",FileI->Flags, + pkgCache::Flag::ButAutomaticUpgrades) == false) + _error->Warning("Bad ButAutomaticUpgrades flag"); + // overrule the NotAutomatic setting if needed as they are both present for compatibility + else if ((FileI->Flags & pkgCache::Flag::ButAutomaticUpgrades) == pkgCache::Flag::ButAutomaticUpgrades) + FileI->Flags &= ~pkgCache::Flag::NotAutomatic; return !_error->PendingError(); } diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 018b05e65..d893c42d7 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1615,7 +1615,8 @@ pkgCache::VerIterator pkgDepCache::Policy::GetCandidateVer(PkgIterator const &Pk /* Stash the highest version of a not-automatic source, we use it if there is nothing better */ - if ((J.File()->Flags & Flag::NotAutomatic) != 0) + if ((J.File()->Flags & Flag::NotAutomatic) != 0 || + (J.File()->Flags & Flag::ButAutomaticUpgrades) != 0) { if (Last.end() == true) Last = I; diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index a66a5198d..324445fa7 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -731,6 +731,7 @@ bool pkgCache::VerIterator::Automatic() const { VerFileIterator Files = FileList(); for (; Files.end() == false; Files++) + // Do not check ButAutomaticUpgrades here as it is kind of automatic… if ((Files.File()->Flags & pkgCache::Flag::NotAutomatic) != pkgCache::Flag::NotAutomatic) return true; return false; diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h index 799521784..82a69b2ca 100644 --- a/apt-pkg/pkgcache.h +++ b/apt-pkg/pkgcache.h @@ -146,7 +146,7 @@ class pkgCache /*{{{*/ struct Flag { enum PkgFlags {Auto=(1<<0),Essential=(1<<3),Important=(1<<4)}; - enum PkgFFlags {NotSource=(1<<0),NotAutomatic=(1<<1)}; + enum PkgFFlags {NotSource=(1<<0),NotAutomatic=(1<<1),ButAutomaticUpgrades=(1<<2)}; }; protected: diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index a3286391b..4f9d56775 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -16,7 +16,7 @@ 990 = Config file override package files 989 = Start for preference auto-priorities 500 = Default package files - 100 = The status file + 100 = The status file and ButAutomaticUpgrades sources 0 -> 100 = NotAutomatic sources like experimental -inf -> 0 = Never selected @@ -70,9 +70,10 @@ bool pkgPolicy::InitDefaults() PFPriority[I->ID] = 500; if ((I->Flags & pkgCache::Flag::NotSource) == pkgCache::Flag::NotSource) PFPriority[I->ID] = 100; - else - if ((I->Flags & pkgCache::Flag::NotAutomatic) == pkgCache::Flag::NotAutomatic) - PFPriority[I->ID] = 1; + else if ((I->Flags & pkgCache::Flag::ButAutomaticUpgrades) == pkgCache::Flag::ButAutomaticUpgrades) + PFPriority[I->ID] = 100; + else if ((I->Flags & pkgCache::Flag::NotAutomatic) == pkgCache::Flag::NotAutomatic) + PFPriority[I->ID] = 1; } // Apply the defaults.. -- cgit v1.2.3 From 4d8d8112bb2bdee0f0e3cb46a6677e9fa35d791a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 28 Sep 2010 17:27:44 +0200 Subject: * apt-pkg/contrib/strutl.cc: - add a space between number and unit as required by SI (Closes: #598352) --- apt-pkg/contrib/strutl.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index c1844de40..987f4c3a4 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -340,13 +340,13 @@ string SizeToStr(double Size) { if (ASize < 100 && I != 0) { - sprintf(S,"%'.1f%c",ASize,Ext[I]); + sprintf(S,"%'.1f %c",ASize,Ext[I]); break; } if (ASize < 10000) { - sprintf(S,"%'.0f%c",ASize,Ext[I]); + sprintf(S,"%'.0f %c",ASize,Ext[I]); break; } ASize /= 1000.0; -- cgit v1.2.3 From 01a6e24cd1b601df2f20190b6118c4616e7fedf2 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 29 Sep 2010 19:55:04 +0200 Subject: * apt-pkg/depcache.cc: - do not check endpointer packages instead of only those which prevented NeverAutoRemove settings from having an effect (Closes: #598452) --- apt-pkg/depcache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index 08e683558..2d3dbdf77 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -189,7 +189,7 @@ class pkgDepCache : protected pkgCache::Namespace DefaultRootSetFunc() : Configuration::MatchAgainstConfig("APT::NeverAutoRemove") {}; virtual ~DefaultRootSetFunc() {}; - bool InRootSet(const pkgCache::PkgIterator &pkg) { return pkg.end() == true && Match(pkg.Name()); }; + bool InRootSet(const pkgCache::PkgIterator &pkg) { return pkg.end() == false && Match(pkg.Name()); }; }; struct StateCache -- cgit v1.2.3 From be2db981072866d9bb424c7f92dd0ec0fcdaaa66 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 29 Sep 2010 20:56:30 +0200 Subject: * apt-pkg/packagemanager.cc: - Add a space between period and 'Please' and unfuzzy all translations --- apt-pkg/packagemanager.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 49776aac7..cff34058c 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -328,7 +328,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) // Sanity Check if (List->IsFlag(Pkg,pkgOrderList::Configured) == false) - return _error->Error(_("Could not perform immediate configuration on '%s'." + return _error->Error(_("Could not perform immediate configuration on '%s'. " "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.Name(),1); return true; @@ -492,7 +492,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg) List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); if (List->IsFlag(Pkg,pkgOrderList::Immediate) == true) if (SmartConfigure(Pkg) == false) - return _error->Error(_("Could not perform immediate configuration on already unpacked '%s'." + return _error->Error(_("Could not perform immediate configuration on already unpacked '%s'. " "Please see man 5 apt.conf under APT::Immediate-Configure for details."),Pkg.Name()); return true; } @@ -613,7 +613,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg) // Perform immedate configuration of the package. if (List->IsFlag(Pkg,pkgOrderList::Immediate) == true) if (SmartConfigure(Pkg) == false) - return _error->Error(_("Could not perform immediate configuration on '%s'." + return _error->Error(_("Could not perform immediate configuration on '%s'. " "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.Name(),2); return true; -- cgit v1.2.3 From 0c6aa02ecfbb1b1ecac519527467befae36b7c40 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 2 Oct 2010 09:19:31 +0200 Subject: * apt-pkg/depcache.cc: - do not remove packages which the user requested for installation explicitly while satisfying other install requests (Closes: #598669) --- apt-pkg/depcache.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index d893c42d7..0b5d6d8e6 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1192,6 +1192,16 @@ bool pkgDepCache::IsDeleteOk(PkgIterator const &Pkg,bool rPurge, std::clog << OutputInDepth(Depth) << "Hold prevents MarkDelete of " << Pkg << " FU=" << FromUser << std::endl; return false; } + else if (FromUser == false && Pkg->CurrentVer == 0) + { + StateCache &P = PkgState[Pkg->ID]; + if (P.InstallVer != 0 && P.Status == 2 && (P.Flags & Flag::Auto) != Flag::Auto) + { + if (DebugMarker == true) + std::clog << OutputInDepth(Depth) << "Manual install request prevents MarkDelete of " << Pkg << std::endl; + return false; + } + } return true; } /*}}}*/ -- cgit v1.2.3 From 5473df3fec08eaea6e84b98551cc247e87f4b6df Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 13 Oct 2010 12:45:47 +0200 Subject: * apt-pkg/deb/debindexfile.cc: - Use FileFd::Size() instead of stat()ing the sources/binary/translations indexes directly, so that we have transparent handling of gzipped indexes. --- apt-pkg/deb/debindexfile.cc | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index ba5b3f266..a89a2574f 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -149,10 +149,11 @@ bool debSourcesIndex::Exists() const /* */ unsigned long debSourcesIndex::Size() const { - struct stat S; - if (stat(IndexFile("Sources").c_str(),&S) != 0) + FileFd f = FileFd (IndexFile("Sources"), FileFd::ReadOnlyGzip); + + if (f.Failed()) return 0; - return S.st_size; + return f.Size(); } /*}}}*/ @@ -268,10 +269,11 @@ bool debPackagesIndex::Exists() const /* This is really only used for progress reporting. */ unsigned long debPackagesIndex::Size() const { - struct stat S; - if (stat(IndexFile("Packages").c_str(),&S) != 0) + FileFd f = FileFd (IndexFile("Packages"), FileFd::ReadOnlyGzip); + + if (f.Failed()) return 0; - return S.st_size; + return f.Size(); } /*}}}*/ // PackagesIndex::Merge - Load the index file into a cache /*{{{*/ @@ -458,10 +460,12 @@ bool debTranslationsIndex::Exists() const /* This is really only used for progress reporting. */ unsigned long debTranslationsIndex::Size() const { - struct stat S; - if (stat(IndexFile(Language).c_str(),&S) != 0) + FileFd f = FileFd (IndexFile(Language), FileFd::ReadOnlyGzip); + + if (f.Failed()) return 0; - return S.st_size; + + return f.Size(); } /*}}}*/ // TranslationsIndex::Merge - Load the index file into a cache /*{{{*/ -- cgit v1.2.3 From 9c182afa045dc889a5025d166328c6115924d706 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 13 Oct 2010 13:00:49 +0200 Subject: * apt-pkg/contrib/fileutl.cc: - Fix FileFd::Size() for gzipped files to give the size of the uncompressed data. This fixes cache progress building progress going way over 100%. --- apt-pkg/contrib/fileutl.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index eabaadf90..bf07f6008 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -915,8 +915,27 @@ unsigned long FileFd::Tell() /* */ unsigned long FileFd::Size() { - //TODO: For gz, do we need the actual file size here or the uncompressed length? struct stat Buf; + long size; + off_t orig_pos; + + if (gz) + { + /* unfortunately zlib.h doesn't provide a gzsize(), so we have to do + * this ourselves; the original (uncompressed) file size is the last 32 + * bits of the file */ + orig_pos = lseek(iFd, 0, SEEK_CUR); + if (lseek(iFd, -4, SEEK_END) < 0) + return _error->Errno("lseek","Unable to seek to end of gzipped file"); + if (read(iFd, &size, 4) != 4) + return _error->Errno("read","Unable to read original size of gzipped file"); + size &= 0xFFFFFFFF; + + if (lseek(iFd, orig_pos, SEEK_SET) < 0) + return _error->Errno("lseek","Unable to seek in gzipped file"); + return size; + } + if (fstat(iFd,&Buf) != 0) return _error->Errno("fstat","Unable to determine the file size"); return Buf.st_size; -- cgit v1.2.3 From c988fe215ba08bd2163024d9b1d27b76a9c59696 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 13 Oct 2010 14:08:52 +0200 Subject: * revert commit: * apt-pkg/deb/debsystem.cc: - set dir::state::status based at least on dir This causes problems with alternative rootdirs --- apt-pkg/deb/debsystem.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index ab08a8f4d..7056d771d 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -165,7 +165,7 @@ bool debSystem::Initialize(Configuration &Cnf) which is yet to be determined. The functions in pkgcachegen should be the only users of these */ Cnf.CndSet("Dir::State::extended_states", Cnf.FindDir("Dir::State").append("extended_states")); - Cnf.CndSet("Dir::State::status", Cnf.FindDir("Dir", "/").append("var/lib/dpkg/status")); + Cnf.CndSet("Dir::State::status","/var/lib/dpkg/status"); Cnf.CndSet("Dir::Bin::dpkg","/usr/bin/dpkg"); if (StatusFile) { -- cgit v1.2.3 From 940ff5d6b5634b57c2e622b5295f499a7807f3de Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 13 Oct 2010 14:11:57 +0200 Subject: apt-pkg/deb/debsystem.cc: remove duplicated rootdir (FindFile will prepend the rootdir later anyway) --- apt-pkg/deb/debsystem.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index 7056d771d..8619822df 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -164,7 +164,7 @@ bool debSystem::Initialize(Configuration &Cnf) /* These really should be jammed into a generic 'Local Database' engine which is yet to be determined. The functions in pkgcachegen should be the only users of these */ - Cnf.CndSet("Dir::State::extended_states", Cnf.FindDir("Dir::State").append("extended_states")); + Cnf.CndSet("Dir::State::extended_states", "extended_states"); Cnf.CndSet("Dir::State::status","/var/lib/dpkg/status"); Cnf.CndSet("Dir::Bin::dpkg","/usr/bin/dpkg"); -- cgit v1.2.3 From 44dc669e08353716da835608ea54563b4c8c32bb Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 13 Oct 2010 16:03:56 +0200 Subject: apt-pkg/contrib/fileutl.cc: fix FileFd::Size() for files that are empty or for non-gzip files --- apt-pkg/contrib/fileutl.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index bf07f6008..cbf1d64a9 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -916,10 +916,17 @@ unsigned long FileFd::Tell() unsigned long FileFd::Size() { struct stat Buf; - long size; + unsigned long size; off_t orig_pos; - if (gz) + if (fstat(iFd,&Buf) != 0) + return _error->Errno("fstat","Unable to determine the file size"); + size = Buf.st_size; + + // only check gzsize if we are actually a gzip file, just checking for + // "gz" is not sufficient as uncompressed files will be opened with + // gzopen in "direct" mode as well + if (gz && !gzdirect(gz) && size > 0) { /* unfortunately zlib.h doesn't provide a gzsize(), so we have to do * this ourselves; the original (uncompressed) file size is the last 32 @@ -936,9 +943,7 @@ unsigned long FileFd::Size() return size; } - if (fstat(iFd,&Buf) != 0) - return _error->Errno("fstat","Unable to determine the file size"); - return Buf.st_size; + return size; } /*}}}*/ // FileFd::Close - Close the file if the close flag is set /*{{{*/ -- cgit v1.2.3