]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/sourcelist.cc
* test/integration/test-hashsum-verification:
[apt.git] / apt-pkg / sourcelist.cc
index a860c7eac51e2e53ef44a933cb7857d5c52406b0..c96ccfd77e5adf3af1843ac58b7276d6045d62d6 100644 (file)
@@ -94,6 +94,13 @@ bool pkgSourceList::Type::ParseLine(vector<metaIndex *> &List,
         if (option.length() < 3)
            return _error->Error(_("Malformed line %lu in source list %s ([option] too short)"),CurLine,File.c_str());
 
+        // accept options even if the last has no space before the ]-end marker
+        if (option.at(option.length()-1) == ']')
+        {
+           for (; *Buffer != ']'; --Buffer);
+           option.resize(option.length()-1);
+        }
+
         size_t const needle = option.find('=');
         if (needle == string::npos)
            return _error->Error(_("Malformed line %lu in source list %s ([%s] is not an assignment)"),CurLine,File.c_str(), option.c_str());
@@ -190,17 +197,17 @@ bool pkgSourceList::ReadMainList()
    string Main = _config->FindFile("Dir::Etc::sourcelist");
    string Parts = _config->FindDir("Dir::Etc::sourceparts");
    
-   if (FileExists(Main) == true)
+   if (RealFileExists(Main) == true)
       Res &= ReadAppend(Main);
-   else if (FileExists(Parts) == false)
+   else if (DirectoryExists(Parts) == false)
       // Only warn if there are no sources.list.d.
-      _error->WarningE("FileExists",_("Unable to read %s"),Main.c_str());
+      _error->WarningE("DirectoryExists", _("Unable to read %s"), Parts.c_str());
 
-   if (FileExists(Parts) == true)
+   if (DirectoryExists(Parts) == true)
       Res &= ReadSourceDir(Parts);
-   else if (FileExists(Main) == false)
+   else if (RealFileExists(Main) == false)
       // Only warn if there is no sources.list file.
-      _error->WarningE("FileExists",_("Unable to read %s"),Parts.c_str());
+      _error->WarningE("RealFileExists", _("Unable to read %s"), Main.c_str());
 
    return Res;
 }
@@ -334,4 +341,22 @@ bool pkgSourceList::ReadSourceDir(string Dir)
 
 }
                                                                        /*}}}*/
+// GetLastModified()                                           /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+time_t pkgSourceList::GetLastModifiedTime()
+{
+   // go over the parts
+   string Main = _config->FindFile("Dir::Etc::sourcelist");
+   string Parts = _config->FindDir("Dir::Etc::sourceparts");
+   vector<string> const List = GetListOfFilesInDir(Parts, "list", true);
+
+   // calculate the time
+   time_t mtime_sources = GetModificationTime(Main);
+   for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)
+      mtime_sources = std::max(mtime_sources, GetModificationTime(*I));
+
+   return mtime_sources;
+}
+                                                                       /*}}}*/