+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
+ delete *I;
+ SrcList.clear();
+ for (auto F = VolatileFiles.begin(); F != VolatileFiles.end(); ++F)
+ delete (*F);
+ VolatileFiles.clear();
+}
+ /*}}}*/
+// SourceList::ReadMainList - Read the main source list from etc /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+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");
+
+ if (RealFileExists(Main) == true)
+ Res &= 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);
+ 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);
+
+ return Res;
+}
+ /*}}}*/
+// SourceList::Reset - Clear the sourcelist contents /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgSourceList::Reset()
+{
+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
+ delete *I;
+ SrcList.clear();
+}
+ /*}}}*/
+// SourceList::Read - Parse the sourcelist file /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool pkgSourceList::Read(string const &File)
+{
+ Reset();
+ return ReadAppend(File);
+}
+ /*}}}*/
+// SourceList::ReadAppend - Parse a sourcelist file /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool pkgSourceList::ReadAppend(string const &File)
+{
+ if (flExtension(File) == "sources")
+ return ParseFileDeb822(File);
+ else
+ return ParseFileOldStyle(File);
+}
+ /*}}}*/
+// SourceList::ReadFileOldStyle - Read Traditional style sources.list /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool pkgSourceList::ParseFileOldStyle(std::string const &File)
+{
+ // Open the stream for reading
+ ifstream F(File.c_str(),ios::in /*| ios::nocreate*/);
+ if (F.fail() == true)
+ return _error->Errno("ifstream::ifstream",_("Opening %s"),File.c_str());
+
+ std::string Buffer;
+ for (unsigned int CurLine = 1; std::getline(F, Buffer); ++CurLine)