summaryrefslogtreecommitdiff
path: root/apt-pkg/sourcelist.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2017-07-15 15:08:35 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2017-07-26 19:09:04 +0200
commit51751106976b1c6afa8f7991790db87b239fcc84 (patch)
tree1c92d91123c7d27a37ed427d54719516bd0b345a /apt-pkg/sourcelist.cc
parent3317ad864c997f4897756c0a2989c4199e9cda62 (diff)
show warnings instead of errors if files are unreadable
We used to fail on unreadable config/preferences/sources files, but at least for sources we didn't in the past and it seems harsh to refuse to work because of a single file, especially as the error messages are inconsistent and end up being silly (like suggesting to run apt update to fix the problem…). LP: #1701852
Diffstat (limited to 'apt-pkg/sourcelist.cc')
-rw-r--r--apt-pkg/sourcelist.cc36
1 files changed, 13 insertions, 23 deletions
diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc
index 9f0c7f8ae..adf598e48 100644
--- a/apt-pkg/sourcelist.cc
+++ b/apt-pkg/sourcelist.cc
@@ -300,37 +300,32 @@ pkgSourceList::~pkgSourceList()
/* */
bool pkgSourceList::ReadMainList()
{
- // CNC:2003-03-03 - Multiple sources list support.
- bool Res = true;
-#if 0
- Res = ReadVendors();
- if (Res == false)
- return false;
-#endif
-
Reset();
// CNC:2003-11-28 - Entries in sources.list have priority over
// entries in sources.list.d.
string Main = _config->FindFile("Dir::Etc::sourcelist", "/dev/null");
string Parts = _config->FindDir("Dir::Etc::sourceparts", "/dev/null");
-
+
+ _error->PushToStack();
if (RealFileExists(Main) == true)
- Res &= ReadAppend(Main);
+ ReadAppend(Main);
else if (DirectoryExists(Parts) == false && APT::String::Endswith(Parts, "/dev/null") == false)
// Only warn if there are no sources.list.d.
_error->WarningE("DirectoryExists", _("Unable to read %s"), Parts.c_str());
if (DirectoryExists(Parts) == true)
- Res &= ReadSourceDir(Parts);
+ ReadSourceDir(Parts);
else if (Main.empty() == false && RealFileExists(Main) == false &&
APT::String::Endswith(Parts, "/dev/null") == false)
// Only warn if there is no sources.list file.
_error->WarningE("RealFileExists", _("Unable to read %s"), Main.c_str());
for (auto && file: _config->FindVector("APT::Sources::With"))
- Res &= AddVolatileFile(file, nullptr);
+ AddVolatileFile(file, nullptr);
- return Res;
+ auto good = _error->PendingError() == false;
+ _error->MergeWithStack();
+ return good;
}
/*}}}*/
// SourceList::Reset - Clear the sourcelist contents /*{{{*/
@@ -498,17 +493,12 @@ bool pkgSourceList::GetIndexes(pkgAcquire *Owner, bool GetAll) const
/* */
bool pkgSourceList::ReadSourceDir(string const &Dir)
{
- std::vector<std::string> ext;
- ext.push_back("list");
- ext.push_back("sources");
- std::vector<std::string> const List = GetListOfFilesInDir(Dir, ext, true);
-
+ std::vector<std::string> const ext = {"list", "sources"};
// Read the files
- for (vector<string>::const_iterator I = List.begin(); I != List.end(); ++I)
- if (ReadAppend(*I) == false)
- return false;
- return true;
-
+ bool good = true;
+ for (auto const &I : GetListOfFilesInDir(Dir, ext, true))
+ good = ReadAppend(I) && good;
+ return good;
}
/*}}}*/
// GetLastModified() /*{{{*/