[Buildd-tools-devel] [PATCH 09/22] Don't fail on missing schroot.conf.

Jan-Marek Glogowski glogow at fbihome.de
Thu Mar 26 21:13:47 UTC 2009


There might be some chroots in chroot.d.
In verbose mode log an info exception.
We'll fail later, if there aren't any chroots.
---
 bin/schroot/schroot-main-base.cc |   35 +++++++++++++++++++++++++++++------
 bin/schroot/schroot-main-base.h  |    1 +
 2 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/bin/schroot/schroot-main-base.cc b/bin/schroot/schroot-main-base.cc
index 12bcfbb..b27f5a5 100644
--- a/bin/schroot/schroot-main-base.cc
+++ b/bin/schroot/schroot-main-base.cc
@@ -56,6 +56,10 @@ namespace
       // TRANSLATORS: %4% = file
       // TRANSLATORS: %5% = file
       emap(main_base::CHROOT_FILE2,      N_("No chroots are defined in '%4%' or '%5%'")),
+      // TRANSLATORS: %4% = file
+      // TRANSLATORS: %5% = file
+      // TRANSLATORS: %6% = file
+      emap(main_base::CHROOT_FILE3,      N_("No chroots are defined in '%4%', '%5%' or '%6%'")),
       // TRANSLATORS: %1% = file
       emap(main_base::CHROOT_NOTDEFINED, N_("The specified chroots are not defined in '%1%'")),
       // TRANSLATORS: %1% = chroot name
@@ -162,8 +166,24 @@ main_base::load_config ()
      any chroot type or session, or displaying chroot information. */
   if (this->options->load_chroots == true)
     {
-      this->config->add(SCHROOT_CONF, false);
-      this->config->add(SCHROOT_CONF_CHROOT_D, false);
+      try 
+	{
+	  this->config->add(SCHROOT_CONF, false);
+	}
+      catch (sbuild::stat::error const& e) 
+	{
+	  if (this->options->verbose)
+	    log_exception_info(e);
+	}
+      try 
+	{
+          this->config->add(SCHROOT_CONF_CHROOT_D, false);
+	}
+      catch (sbuild::chroot_config::error const& e)
+	{
+	  if (this->options->verbose)
+	    log_exception_info(e);
+	}
     }
   /* The session chroot list is used when running or ending an
      existing session, or displaying chroot information. */
@@ -196,12 +216,15 @@ main_base::run_impl ()
       if (this->options->load_chroots == true &&
 	  this->options->load_sessions == true)
 	log_exception_warning
-	  (error(CHROOT_FILE2, SCHROOT_CONF, SCHROOT_SESSION_DIR));
+	  (error(CHROOT_FILE3, SCHROOT_CONF, 
+	    SCHROOT_CONF_CHROOT_D, SCHROOT_SESSION_DIR));
       else
 	{
-	  const char *cfile = (this->options->load_sessions)
-	    ? SCHROOT_SESSION_DIR : SCHROOT_CONF;
-	  log_exception_warning(error(CHROOT_FILE, cfile));
+	  if (this->options->load_sessions)
+	    log_exception_warning(error(CHROOT_FILE, SCHROOT_SESSION_DIR));
+	  else
+	    log_exception_warning
+	      (error(CHROOT_FILE2, SCHROOT_CONF, SCHROOT_CONF_CHROOT_D));
 	}
     }
 
diff --git a/bin/schroot/schroot-main-base.h b/bin/schroot/schroot-main-base.h
index 22af8aa..50fbc12 100644
--- a/bin/schroot/schroot-main-base.h
+++ b/bin/schroot/schroot-main-base.h
@@ -41,6 +41,7 @@ namespace schroot
 	CHROOTS_NOTFOUND,  ///< Chroots not found.
 	CHROOT_FILE,       ///< No chroots are defined in ....
 	CHROOT_FILE2,      ///< No chroots are defined in ... or ....
+	CHROOT_FILE3,      ///< No chroots are defined in .., ... or ....
 	CHROOT_NOTDEFINED, ///< The specified chroots are not defined.
 	CHROOT_NOTFOUND    ///< Chroot not found.
       };
-- 
1.6.2.1




More information about the Buildd-tools-devel mailing list