From: David Kalnischkies Date: Wed, 15 Jul 2009 21:57:07 +0000 (+0200) Subject: display warnings instead of errors if the parts dirs doesn't exist X-Git-Tag: 0.7.22~13^2~1 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/6009e60d0192832277242438ad7ca2fc24a4c075?ds=inline display warnings instead of errors if the parts dirs doesn't exist Parts dirs are /etc/apt/{sources.list,apt.conf,preferences}.d (in the default setup) --- diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc index 0b1efb9ff..790312dc8 100644 --- a/apt-pkg/cachefile.cc +++ b/apt-pkg/cachefile.cc @@ -48,6 +48,7 @@ pkgCacheFile::~pkgCacheFile() /* */ bool pkgCacheFile::BuildCaches(OpProgress &Progress,bool WithLock) { + const bool ErrorWasEmpty = _error->empty(); if (WithLock == true) if (_system->Lock() == false) return false; @@ -70,7 +71,7 @@ bool pkgCacheFile::BuildCaches(OpProgress &Progress,bool WithLock) return _error->Error(_("The package lists or status file could not be parsed or opened.")); /* This sux, remove it someday */ - if (_error->empty() == false) + if (ErrorWasEmpty == true && _error->empty() == false) _error->Warning(_("You may want to run apt-get update to correct these problems")); Cache = new pkgCache(Map); @@ -91,6 +92,7 @@ bool pkgCacheFile::Open(OpProgress &Progress,bool WithLock) Policy = new pkgPolicy(Cache); if (_error->PendingError() == true) return false; + if (ReadPinFile(*Policy) == false || ReadPinDir(*Policy) == false) return false; diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc index 4abfb726f..63caade36 100644 --- a/apt-pkg/init.cc +++ b/apt-pkg/init.cc @@ -81,19 +81,26 @@ bool pkgInitConfig(Configuration &Cnf) // Read an alternate config file const char *Cfg = getenv("APT_CONFIG"); - if (Cfg != 0 && FileExists(Cfg) == true) - Res &= ReadConfigFile(Cnf,Cfg); - + if (Cfg != 0) + { + if (FileExists(Cfg) == true) + Res &= ReadConfigFile(Cnf,Cfg); + else + _error->WarningE("FileExists",_("Unable to read %s"),Cfg); + } + // Read the configuration parts dir string Parts = Cnf.FindDir("Dir::Etc::parts"); if (FileExists(Parts) == true) Res &= ReadConfigDir(Cnf,Parts); - + else + _error->WarningE("FileExists",_("Unable to read %s"),Parts.c_str()); + // Read the main config file string FName = Cnf.FindFile("Dir::Etc::main"); if (FileExists(FName) == true) Res &= ReadConfigFile(Cnf,FName); - + if (Res == false) return false; diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index 26d1c17bd..81fdb0431 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -267,12 +267,21 @@ class PreferenceSection : public pkgTagSection /*}}}*/ // ReadPinDir - Load the pin files from this dir into a Policy /*{{{*/ // --------------------------------------------------------------------- -/* */ +/* This will load each pin file in the given dir into a Policy. If the + given dir is empty the dir set in Dir::Etc::PreferencesParts is used. + Note also that this method will issue a warning if the dir does not + exists but it will return true in this case! */ bool ReadPinDir(pkgPolicy &Plcy,string Dir) { if (Dir.empty() == true) Dir = _config->FindDir("Dir::Etc::PreferencesParts"); + if (FileExists(Dir) == false) + { + _error->WarningE("FileExists",_("Unable to read %s"),Dir.c_str()); + return true; + } + DIR *D = opendir(Dir.c_str()); if (D == 0) return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str()); diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index fea645078..47a08ad90 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -158,12 +158,16 @@ bool pkgSourceList::ReadMainList() // entries in sources.list.d. string Main = _config->FindFile("Dir::Etc::sourcelist"); if (FileExists(Main) == true) - Res &= ReadAppend(Main); + Res &= ReadAppend(Main); + else + _error->WarningE("FileExists",_("Unable to read %s"),Main.c_str()); string Parts = _config->FindDir("Dir::Etc::sourceparts"); if (FileExists(Parts) == true) Res &= ReadSourceDir(Parts); - + else + _error->WarningE("FileExists",_("Unable to read %s"),Parts.c_str()); + return Res; } /*}}}*/ diff --git a/debian/changelog b/debian/changelog index 786b8a86f..e4da484d4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -39,6 +39,7 @@ apt (0.7.22) UNRELEASED; urgency=low array which can (at least in theory) grow dynamic * add a segfault handler to MMap to show the Cache-Limit message, which can be deactivated with MMap::SegfaultHandler=false (Closes: 535218) + * display warnings instead of errors if the parts dirs doesn't exist [ Michael Vogt ] * honor the dpkg hold state in new Marker hooks (closes: #64141)