Просмотр исходного кода

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)

David Kalnischkies лет назад: 17
Родитель
Сommit
6009e60d01
5 измененных файлов с 32 добавлено и 9 удалено
  1. 3 1
      apt-pkg/cachefile.cc
  2. 12 5
      apt-pkg/init.cc
  3. 10 1
      apt-pkg/policy.cc
  4. 6 2
      apt-pkg/sourcelist.cc
  5. 1 0
      debian/changelog

+ 3 - 1
apt-pkg/cachefile.cc

@@ -48,6 +48,7 @@ pkgCacheFile::~pkgCacheFile()
 /* */
 /* */
 bool pkgCacheFile::BuildCaches(OpProgress &Progress,bool WithLock)
 bool pkgCacheFile::BuildCaches(OpProgress &Progress,bool WithLock)
 {
 {
+   const bool ErrorWasEmpty = _error->empty();
    if (WithLock == true)
    if (WithLock == true)
       if (_system->Lock() == false)
       if (_system->Lock() == false)
 	 return 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."));
       return _error->Error(_("The package lists or status file could not be parsed or opened."));
 
 
    /* This sux, remove it someday */
    /* 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"));
       _error->Warning(_("You may want to run apt-get update to correct these problems"));
 
 
    Cache = new pkgCache(Map);
    Cache = new pkgCache(Map);
@@ -91,6 +92,7 @@ bool pkgCacheFile::Open(OpProgress &Progress,bool WithLock)
    Policy = new pkgPolicy(Cache);
    Policy = new pkgPolicy(Cache);
    if (_error->PendingError() == true)
    if (_error->PendingError() == true)
       return false;
       return false;
+
    if (ReadPinFile(*Policy) == false || ReadPinDir(*Policy) == false)
    if (ReadPinFile(*Policy) == false || ReadPinDir(*Policy) == false)
       return false;
       return false;
    
    

+ 12 - 5
apt-pkg/init.cc

@@ -81,19 +81,26 @@ bool pkgInitConfig(Configuration &Cnf)
    
    
    // Read an alternate config file
    // Read an alternate config file
    const char *Cfg = getenv("APT_CONFIG");
    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
    // Read the configuration parts dir
    string Parts = Cnf.FindDir("Dir::Etc::parts");
    string Parts = Cnf.FindDir("Dir::Etc::parts");
    if (FileExists(Parts) == true)
    if (FileExists(Parts) == true)
       Res &= ReadConfigDir(Cnf,Parts);
       Res &= ReadConfigDir(Cnf,Parts);
-      
+   else
+      _error->WarningE("FileExists",_("Unable to read %s"),Parts.c_str());
+
    // Read the main config file
    // Read the main config file
    string FName = Cnf.FindFile("Dir::Etc::main");
    string FName = Cnf.FindFile("Dir::Etc::main");
    if (FileExists(FName) == true)
    if (FileExists(FName) == true)
       Res &= ReadConfigFile(Cnf,FName);
       Res &= ReadConfigFile(Cnf,FName);
-   
+
    if (Res == false)
    if (Res == false)
       return false;
       return false;
    
    

+ 10 - 1
apt-pkg/policy.cc

@@ -267,12 +267,21 @@ class PreferenceSection : public pkgTagSection
 									/*}}}*/
 									/*}}}*/
 // ReadPinDir - Load the pin files from this dir into a Policy		/*{{{*/
 // 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)
 bool ReadPinDir(pkgPolicy &Plcy,string Dir)
 {
 {
    if (Dir.empty() == true)
    if (Dir.empty() == true)
       Dir = _config->FindDir("Dir::Etc::PreferencesParts");
       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());
    DIR *D = opendir(Dir.c_str());
    if (D == 0)
    if (D == 0)
       return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
       return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());

+ 6 - 2
apt-pkg/sourcelist.cc

@@ -158,12 +158,16 @@ bool pkgSourceList::ReadMainList()
    //                  entries in sources.list.d.
    //                  entries in sources.list.d.
    string Main = _config->FindFile("Dir::Etc::sourcelist");
    string Main = _config->FindFile("Dir::Etc::sourcelist");
    if (FileExists(Main) == true)
    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");
    string Parts = _config->FindDir("Dir::Etc::sourceparts");
    if (FileExists(Parts) == true)
    if (FileExists(Parts) == true)
       Res &= ReadSourceDir(Parts);
       Res &= ReadSourceDir(Parts);
-   
+   else
+      _error->WarningE("FileExists",_("Unable to read %s"),Parts.c_str());
+
    return Res;
    return Res;
 }
 }
 									/*}}}*/
 									/*}}}*/

+ 1 - 0
debian/changelog

@@ -39,6 +39,7 @@ apt (0.7.22) UNRELEASED; urgency=low
     array which can (at least in theory) grow dynamic
     array which can (at least in theory) grow dynamic
   * add a segfault handler to MMap to show the Cache-Limit message, which
   * add a segfault handler to MMap to show the Cache-Limit message, which
     can be deactivated with MMap::SegfaultHandler=false (Closes: 535218)
     can be deactivated with MMap::SegfaultHandler=false (Closes: 535218)
+  * display warnings instead of errors if the parts dirs doesn't exist
 
 
   [ Michael Vogt ]
   [ Michael Vogt ]
   * honor the dpkg hold state in new Marker hooks (closes: #64141)
   * honor the dpkg hold state in new Marker hooks (closes: #64141)