summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2009-07-15 23:57:07 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2009-07-15 23:57:07 +0200
commit6009e60d0192832277242438ad7ca2fc24a4c075 (patch)
treeca691ec88f3522952210a534df6551813b80778c /apt-pkg
parent9d800312c90b7d3b52f2f4c3cea3ebfc67bf000b (diff)
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)
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/cachefile.cc4
-rw-r--r--apt-pkg/init.cc17
-rw-r--r--apt-pkg/policy.cc11
-rw-r--r--apt-pkg/sourcelist.cc8
4 files changed, 31 insertions, 9 deletions
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;
}
/*}}}*/