[fawkes/el5/master] Update man pages patch for CentOS/RHEL

Tim Niemueller timn at fedoraproject.org
Sat Nov 6 04:31:20 UTC 2010


commit 3f792e7e79470c700638dfade9b26b8fe8fd7806
Author: Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:   Sat Nov 6 00:31:12 2010 -0400

    Update man pages patch for CentOS/RHEL

 fawkes-0.4-man-pages.patch |  842 +-------------------------------------------
 1 files changed, 9 insertions(+), 833 deletions(-)
---
diff --git a/fawkes-0.4-man-pages.patch b/fawkes-0.4-man-pages.patch
index ee2535b..3118616 100644
--- a/fawkes-0.4-man-pages.patch
+++ b/fawkes-0.4-man-pages.patch
@@ -1,831 +1,7 @@
-From d1543fb09687a62afea91fda6fcdbf86ea12e785 Mon Sep 17 00:00:00 2001
-From: Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
-Date: Sat, 30 Oct 2010 00:56:27 -0400
-Subject: [PATCH 01/16] BuildSys config: define TMPDIR and USERDIR
-
----
- etc/buildsys/config.mk |    8 ++++++--
- 1 files changed, 6 insertions(+), 2 deletions(-)
-
-diff --git a/etc/buildsys/config.mk b/etc/buildsys/config.mk
-index 0d534e4..315156a 100644
---- a/etc/buildsys/config.mk
-+++ b/etc/buildsys/config.mk
-@@ -85,6 +85,7 @@ DEPDIR        = $(abspath $(SRCDIR)/.deps_$(BUILD_TYPE))
- BINDIR        = $(abspath $(TOP_BASEDIR)/bin)
- LIBDIR        = $(abspath $(TOP_BASEDIR)/lib)
- CONFDIR       = $(abspath $(TOP_BASEDIR)/cfg)
-+TMPDIR        = /tmp
- PLUGINDIR     = $(abspath $(TOP_BASEDIR)/plugins)
- RESDIR        = $(abspath $(TOP_BASEDIR)/res)
- LIBSRCDIR     = $(abspath $(FAWKES_BASEDIR)/src/libs)
-@@ -105,11 +106,13 @@ EXEC_BASEDIR  ?= $(TOP_BASEDIR)
- EXEC_BINDIR    = $(abspath $(EXEC_BASEDIR)/bin)
- EXEC_LIBDIR    = $(abspath $(EXEC_BASEDIR)/lib)
- EXEC_CONFDIR   = $(abspath $(EXEC_BASEDIR)/cfg)
-+EXEC_USERDIR   = .fawkes
- EXEC_PLUGINDIR = $(abspath $(EXEC_BASEDIR)/plugins)
- EXEC_RESDIR    = $(abspath $(EXEC_BASEDIR)/res)
- EXEC_IFACEDIR  = $(abspath $(EXEC_BASEDIR)/lib/interfaces)
- EXEC_LOGDIR    = $(abspath $(EXEC_BASEDIR)/log)
- EXEC_DOCDIR    = $(abspath $(EXEC_BASEDIR)/doc)
-+EXEC_TMPDIR    = /tmp
- 
- # Some paths divert in submodule configuration
- ifeq ($(SUBMODULE_INTERN),1)
-@@ -164,8 +167,9 @@ LDFLAGS_RPATH    = $(addprefix -Wl$(COMMA)-R,$(LIBDIRS_EXEC_BASE) $(LIBDIRS_BASE
- DEFAULT_INCLUDES = $(addprefix -I,$(BASESRCDIRS) $(LIBSRCDIRS) $(FVSRCDIRS))
- CFLAGS_DEFS      = -DBINDIR=\"$(EXEC_BINDIR)\" -DLIBDIR=\"$(EXEC_LIBDIR)\" \
- 		   -DPLUGINDIR=\"$(EXEC_PLUGINDIR)\" -DIFACEDIR=\"$(EXEC_IFACEDIR)\" \
--		   -DCONFDIR=\"$(EXEC_CONFDIR)\" -DLOGDIR=\"$(EXEC_LOGDIR)\" \
--		   -DRESDIR=\"$(EXEC_RESDIR)\" -DBUILDTYPE=\"$(BUILD_TYPE)\"
-+		   -DCONFDIR=\"$(EXEC_CONFDIR)\" -DUSERDIR=\"$(EXEC_USERDIR)\" \
-+		   -DLOGDIR=\"$(EXEC_LOGDIR)\" -DRESDIR=\"$(EXEC_RESDIR)\" \
-+		   -DTMPDIR=\"$(EXEC_TMPDIR)\" -DBUILDTYPE=\"$(BUILD_TYPE)\"
- 
- CFLAGS_MINIMUM   = -fPIC -pthread $(DEFAULT_INCLUDES) $(CFLAGS_OPENMP) $(CFLAGS_DEFS)
- LDFLAGS_MINIMUM  = $(LIBDIRS_BASE:%=-L%) -rdynamic -fPIC $(LDFLAGS_OPENMP)
--- 
-1.7.2.3
-
-
-From 19623cd5f094ce9bf4abf8a4d44c5faef5705574 Mon Sep 17 00:00:00 2001
-From: Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
-Date: Sat, 30 Oct 2010 00:59:02 -0400
-Subject: [PATCH 02/16] SQLite config: fallback to DBs in user homedir
-
-The configuration can now reside in a user's homedir subfolder (defined
-as USERDIR). This is required to be able to run a system-wide installed
-Fawkes as normal user without requiring to have a world-writable
-sysconfdir. The procedure works like this:
-- try to open host-specific config from sysconfdir, if that fails, open
-  in userdir, if this fails as well throw exception
-- search for default.sql in sysconfdir, then in userdir
-- attach default.db from sysconfdir, then userdir
-
-This means that the .db files might be created in the userhomedir, while
-default.sql is stored in sysconfdir. For now we always try to write to
-the default.sql file that has been used to avoid confusion (i.e. if
-written back to userdir this would not be used the next time). Still
-need to have a graceful error if dumping fails without shouting out
-loud.
----
- src/libs/config/sqlite.cpp |  273 ++++++++++++++++++++++++++++++--------------
- src/libs/config/sqlite.h   |   11 ++-
- 2 files changed, 195 insertions(+), 89 deletions(-)
-
-diff --git a/src/libs/config/sqlite.cpp b/src/libs/config/sqlite.cpp
-index 4b56372..5a3a7a8 100644
---- a/src/libs/config/sqlite.cpp
-+++ b/src/libs/config/sqlite.cpp
-@@ -34,6 +34,8 @@
- #include <cstdlib>
- #include <cstring>
- #include <cerrno>
-+#include <unistd.h>
-+#include <fnmatch.h>
- 
- namespace fawkes {
- 
-@@ -214,21 +216,52 @@ namespace fawkes {
-  * database.
-  */
- 
-+
-+/** Constructor. */
-+SQLiteConfiguration::SQLiteConfiguration()
-+{
-+  opened = false;
-+  mutex = new Mutex();
-+
-+  __sysconfdir   = NULL;
-+  __userconfdir  = NULL;
-+  __default_file = NULL;
-+  __default_sql  = NULL;
-+
-+}
-+
- /** Constructor.
-- * @param conf_path Path where the configuration resides, maybe NULL in which case
-- * the path name for the base databsae supplied to load() must be absolute path
-- * names or relative to the execution directory of the surrounding program.
-+ * @param sysconfdir system configuration directory, will be searched for
-+ * default configuration file, and system will try to create host-specific
-+ * database if writable
-+ * @param userconfdir user configuration directory, will be searched preferably
-+ * for default configuration file, and will be used to create host-specific
-+ * database if sysconfdir is not writable. This directory will be created
-+ * if it does not exist during load().
-  */
--SQLiteConfiguration::SQLiteConfiguration(const char *conf_path)
-+SQLiteConfiguration::SQLiteConfiguration(const char *sysconfdir,
-+					 const char *userconfdir)
- {
--  this->conf_path = conf_path;
-   opened = false;
-   mutex = new Mutex();
- 
-+  __sysconfdir   = strdup(sysconfdir);
-   __default_file = NULL;
--  __default_dump = NULL;
--}
-+  __default_sql  = NULL;
- 
-+  if (userconfdir != NULL) {
-+    __userconfdir  = strdup(userconfdir);
-+  } else {
-+    const char *homedir = getenv("HOME");
-+    if (homedir == NULL) {
-+      __userconfdir = strdup(sysconfdir);
-+    } else {
-+      if (asprintf(&__userconfdir, "%s/%s", homedir, USERDIR) == -1) {
-+	__userconfdir = strdup(sysconfdir);
-+      }
-+    }
-+  }
-+}
- 
- /** Destructor. */
- SQLiteConfiguration::~SQLiteConfiguration()
-@@ -236,12 +269,14 @@ SQLiteConfiguration::~SQLiteConfiguration()
-   if (opened) {
-     opened = false;
-     if ( sqlite3_close(db) == SQLITE_BUSY ) {
--      printf("Boom, we are dead, database cannot be closed because there are open handles\n");
--    } else if ( __default_dump) {
-+      printf("Boom, we are dead, database cannot be closed "
-+	     "because there are open handles\n");
-+    }
-+    if ( __default_sql ) {
-       sqlite3 *tdb;
-       if ( sqlite3_open(__default_file, &tdb) == SQLITE_OK ) {
- 	try {
--	  dump(tdb, __default_dump);
-+	  dump(tdb, __default_sql);
- 	} catch (Exception &e) {
- 	  e.print_trace();
- 	}
-@@ -252,7 +287,9 @@ SQLiteConfiguration::~SQLiteConfiguration()
- 
-   if (__host_file)    free(__host_file);
-   if (__default_file) free(__default_file);
--  if (__default_dump) free(__default_dump);
-+  if (__default_sql)  free(__default_sql);
-+  if (__sysconfdir)   free(__sysconfdir);
-+  if (__userconfdir)  free(__userconfdir);
-   delete mutex;
- }
- 
-@@ -426,10 +463,9 @@ SQLiteConfiguration::import(::sqlite3 *tdb, const char *dumpfile)
- 
- 
- void
--SQLiteConfiguration::import_default(const char *default_dump)
-+SQLiteConfiguration::import_default(const char *default_sql)
- {
--  char *tmpfile = (char *)malloc(strlen(conf_path) + strlen("/tmp_default_XXXXXX") + 1);
--  sprintf(tmpfile, "%s/tmp_default_XXXXXX", conf_path);
-+  char *tmpfile = strdup(TMPDIR"/tmp_default_XXXXXX");
-   tmpfile = mktemp(tmpfile);
-   if ( tmpfile[0] == 0 ) {
-     throw CouldNotOpenConfigException("Failed to create temp file for default DB import");
-@@ -438,7 +474,7 @@ SQLiteConfiguration::import_default(const char *default_dump)
-   // Import .sql file into dump database (temporary file)
-   sqlite3 *dump_db;
-   if ( sqlite3_open(tmpfile, &dump_db) == SQLITE_OK ) {
--    import(dump_db, default_dump);
-+    import(dump_db, default_sql);
-     sqlite3_close(dump_db);
-   } else {
-     throw CouldNotOpenConfigException("Failed to import dump file into temp DB");
-@@ -538,108 +574,173 @@ SQLiteConfiguration::transaction_rollback()
-   }
- }
- 
--
- void
--SQLiteConfiguration::load(const char *name, const char *defaults_name,
--			  const char *tag)
-+SQLiteConfiguration::attach_default(const char *db_file)
- {
-   char *errmsg;
-   char *attach_sql;
-+  if ( asprintf(&attach_sql, SQL_ATTACH_DEFAULTS, db_file) == -1 ) {
-+    throw CouldNotOpenConfigException("Could not create attachment SQL");
-+  }
-+  if (sqlite3_exec(db, attach_sql, NULL, NULL, &errmsg) != SQLITE_OK) {
-+    CouldNotOpenConfigException ce(sqlite3_errmsg(db));
-+    ce.append("Failed to attach default file (%s)",  db_file);
-+    free(attach_sql);
-+    throw ce;
-+  }
-+  free(attach_sql);
-+}
- 
-+
-+void
-+SQLiteConfiguration::load(const char *name, const char *defaults_name,
-+			  const char *tag)
-+{
-   mutex->lock();
- 
--  if ( name ) {
--    __host_file = strdup(name);
--  } else {
-+  if (__default_file) free(__default_file);
-+  if (__default_sql)  free(__default_sql);
-+  __default_file = NULL;
-+  __default_sql  = NULL;
-+
-+  const char *try_paths[] = {__sysconfdir, __userconfdir};
-+  int try_paths_len = 2;
-+
-+  char *host_name;
-+
-+  if (name == NULL) {
-     HostInfo hostinfo;
--    if ( asprintf(&__host_file, "%s.db", hostinfo.short_name()) == -1 ) {
--      __host_file = strdup(hostinfo.short_name());
-+    if ( asprintf(&host_name, "%s.db", hostinfo.short_name()) == -1 ) {
-+      host_name = strdup(hostinfo.short_name());
-     }
-+  } else {
-+    host_name = strdup(name);
-   }
- 
--  if (__default_file)  free(__default_file);
--  if (__default_dump)  free(__default_dump);
--  if (defaults_name) {
--    __default_file = strdup(defaults_name);
--    if (strcmp(defaults_name, ":memory:") != 0) {
--      __default_dump = (char *)malloc(strlen(__default_file) + 5);
--      strcpy(__default_dump, __default_file);
--      strcat(__default_dump, ".sql");
-+  // determine host file
-+  if (strcmp(host_name, ":memory:") == 0) {
-+    if (sqlite3_open(host_name, &db) != SQLITE_OK) {
-+      CouldNotOpenConfigException ce(sqlite3_errmsg(db));
-+      ce.append("Failed to open host db (memory)");
-+      throw ce;
-+    }
-+  } else if (host_name[0] == '/') {
-+    // absolute path, take as is
-+    if (sqlite3_open(host_name, &db) == SQLITE_OK) {
-+      __host_file = strdup(host_name);
-+    } else {
-+      CouldNotOpenConfigException ce(sqlite3_errmsg(db));
-+      ce.append("Failed to open host db (absolute)");
-+      throw ce;
-     }
-   } else {
--    __default_file = strdup("default.db");
--    __default_dump = strdup("default.sql");
-+    // try sysconfdir and userconfdir
-+    for (int i = 0; i < try_paths_len; ++i) {
-+      char *path;
-+      if (asprintf(&path, "%s/%s", try_paths[i], host_name) != -1) {
-+	if (sqlite3_open(path, &db) == SQLITE_OK) {
-+	  __host_file = path;
-+	  break;
-+	} else {
-+	  free(path);
-+	}
-+      }
-+    }
-+    if (__host_file == NULL) {
-+      CouldNotOpenConfigException ce(sqlite3_errmsg(db));
-+      ce.append("Failed to open host db (paths)");
-+      free(host_name);
-+      throw ce;
-+    }
-   }
- 
--  if ( conf_path == NULL ) {
--    conf_path = ".";
-+  if (defaults_name == NULL) {
-+    defaults_name = "default.sql";
-   }
- 
--  if (strcmp(__default_file, ":memory:") != 0) {
--    if ( (access(__default_file, F_OK) != 0) && (__default_file[0] != '/') ) {
--      // the given path was not found as file, add the config path
--      char *tdf = __default_file;
--      if ( asprintf(&__default_file, "%s/%s", conf_path, tdf) == -1 ) {
--	free(tdf);
--	throw CouldNotOpenConfigException("Could not create default filename");
-+  // determine default file
-+  if (strcmp(defaults_name, ":memory:") == 0) {
-+    try {
-+      attach_default(":memory:");
-+    } catch (...) {
-+      free(host_name);
-+      throw;
-+    }
-+    __default_file = strdup(":memory:");
-+  } else {
-+    if (defaults_name[0] == '/') {
-+      // absolute path, take as is
-+      __default_sql = strdup(defaults_name);
-+    } else {
-+      // try sysconfdir and userconfdir
-+      for (int i = 0; i < try_paths_len; ++i) {
-+	char *path;
-+	if (asprintf(&path, "%s/%s", try_paths[i], defaults_name) != -1) {
-+	  if (access(path, F_OK | R_OK) == 0) {
-+	    __default_sql = path;
-+	    break;
-+	  } else {
-+	    free(path);
-+	  }
-+	}
-       }
--      free(tdf);
-     }
--  }
- 
--  if (__default_dump && (access(__default_dump, F_OK) != 0) && (__default_dump[0] != '/') ) {
--    // the given path was not found as file, add the config path
--    char *tdf = __default_dump;
--    if ( asprintf(&__default_dump, "%s/%s", conf_path, tdf) == -1 ) {
--      free(tdf);
--      throw CouldNotOpenConfigException("Could not create default filename");
-+    // Now go for the .db filename
-+
-+    // generate filename
-+    char *defaults_db;
-+    size_t len = strlen(defaults_name);
-+    if (fnmatch("*.sql", defaults_name, FNM_PATHNAME) == 0) {
-+      defaults_db = (char *)calloc(1, len); // yes, that's one byte less!
-+      strncpy(defaults_db, defaults_name, len - 3);
-+      strcat(defaults_db, "db");
-+    } else {
-+      defaults_db = (char *)calloc(1, len + 4);
-+      strcpy(defaults_db, defaults_name);
-+      strcat(defaults_db, ".db");
-     }
--    free(tdf);
--  }
- 
--  if (strcmp(__host_file, ":memory:") != 0) {
--    if ( (access(__host_file, F_OK) != 0) && (__host_file[0] != '/') ) {
--      // the given path was not found as file, add the config path
--      char *thf = __host_file;
--      if ( asprintf(&__host_file, "%s/%s", conf_path, thf) == -1 ) {
--	free(thf);
--	throw CouldNotOpenConfigException("Could not create filename");
-+    if (defaults_db[0] == '/') {
-+      try {
-+	attach_default(defaults_db);
-+	__default_file = defaults_db;
-+      } catch (...) {
-+	free(host_name);
-+	free(defaults_db);
-+	throw;
-+      }
-+    } else {
-+      // check directories
-+      for (int i = 0; i < try_paths_len; ++i) {
-+	char *path;
-+	if (asprintf(&path, "%s/%s", try_paths[i], defaults_db) != -1) {
-+	  try {
-+	    attach_default(path);
-+	    __default_file = path;
-+	    break;
-+	  } catch (CouldNotOpenConfigException &e) {
-+	    free(path);
-+	  }
-+	}
-       }
--      free(thf);
-     }
--  }
-+    free(defaults_db);
- 
--  if ( asprintf(&attach_sql, SQL_ATTACH_DEFAULTS, __default_file) == -1 ) {
--    free(__host_file);
--    free(__default_file);
--    if (__default_dump) free(__default_dump);
--    throw CouldNotOpenConfigException("Could not create attachment SQL");
--  }
--
--  // Now really open the config databases
--  if ( (sqlite3_open(__host_file, &db) != SQLITE_OK) ||
--       (sqlite3_exec(db, attach_sql, NULL, NULL, &errmsg) != SQLITE_OK) ) {
--    CouldNotOpenConfigException ce(sqlite3_errmsg(db));
--    ce.append("Failed to open host file '%s' or attaching default file (%s)",
--	      __host_file, __default_file);
--    free(attach_sql);
--    free(__host_file);
--    free(__default_file);
--    if (__default_dump) free(__default_dump);
--    sqlite3_close(db);
--    throw ce;
-+    if (__default_file == NULL) {
-+      free(host_name);
-+      throw CouldNotOpenConfigException("Could not create default filename");
-+    }
-   }
--  free(attach_sql);
- 
-   init_dbs();
- 
--  if ( __default_dump && access(__default_dump, F_OK | R_OK) == 0 ) {
--    import_default(__default_dump);
--  }
--
--  mutex->unlock();
-+  if ( __default_sql )  import_default(__default_sql);
-+  free(host_name);
- 
-   opened = true;
-+
-+  mutex->unlock();
- }
- 
- 
-diff --git a/src/libs/config/sqlite.h b/src/libs/config/sqlite.h
-index 8d635d2..95113d6 100644
---- a/src/libs/config/sqlite.h
-+++ b/src/libs/config/sqlite.h
-@@ -26,6 +26,8 @@
- 
- #include <config/config.h>
- #include <utils/system/hostinfo.h>
-+#include <list>
-+#include <string>
- 
- struct sqlite3;
- struct sqlite3_stmt;
-@@ -37,7 +39,8 @@ class Mutex;
- class SQLiteConfiguration : public Configuration
- {
-  public:
--  SQLiteConfiguration(const char *conf_path = NULL);
-+  SQLiteConfiguration();
-+  SQLiteConfiguration(const char *sysconfdir, const char *userconfdir = NULL);
-   virtual ~SQLiteConfiguration();
- 
-   virtual void          copy(Configuration *copyconf);
-@@ -167,16 +170,18 @@ class SQLiteConfiguration : public Configuration
-   void dump(::sqlite3 *tdb, const char *dumpfile);
-   void import(::sqlite3 *tdb, const char *dumpfile);
-   void import_default(const char *default_dump);
-+  void attach_default(const char *db_file);
- 
-  private:
-   ::sqlite3 *db;
--  const char *conf_path;
-   bool opened;
-   Mutex *mutex;
- 
-+  char *__sysconfdir;
-+  char *__userconfdir;
-   char *__host_file;
-   char *__default_file;
--  char *__default_dump;
-+  char *__default_sql;
- };
- 
- } // end namespace fawkes
--- 
-1.7.2.3
-
-
-From 95ee402a68cd80288d9a883962c5f3c07b439187 Mon Sep 17 00:00:00 2001
-From: Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
-Date: Sat, 30 Oct 2010 01:05:52 -0400
-Subject: [PATCH 03/16] Main app: better explanation of config parameters
-
----
- src/mainapp/main.cpp |    5 ++---
- 1 files changed, 2 insertions(+), 3 deletions(-)
-
-diff --git a/src/mainapp/main.cpp b/src/mainapp/main.cpp
-index a27f682..7050019 100644
---- a/src/mainapp/main.cpp
-+++ b/src/mainapp/main.cpp
-@@ -126,10 +126,9 @@ usage(const char *progname)
-        << "where [options] is one or more of:" << endl
-        << " -h               These help instructions" << endl
-        << " -C               Cleanup old BB segments" << endl
--       << " -c conffile      Mutable configuration file, created if it does not exist" << endl
--       << "                  if it does however it must contain valid SQLite database" << endl
--       << " -d conffile      Default configuration file, created if it does not exist" << endl
-+       << " -c db-file       Mutable configuration file, created if it does not exist" << endl
-        << "                  if it does however it must contain valid SQLite database" << endl
-+       << " -d sql-file      Default configuration SQL dump file." << endl
-        << " -q[qqq]          Quiet mode, -q omits debug, -qq debug and info," << endl
-        << "                  -qqq omit debug, info and warn, -qqqq no output of logger" << endl
-        << " -l level         Set log level directly mutually exclusive with -q" << endl
--- 
-1.7.2.3
-
-
-From 60b6fe5774f93cbc8044b1052f2fda85fadf1e87 Mon Sep 17 00:00:00 2001
-From: Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
-Date: Sat, 30 Oct 2010 01:06:15 -0400
-Subject: [PATCH 04/16] Main app: create userdir if it does not exist
-
----
- src/mainapp/main_thread.cpp |   20 +++++++++++++++++++-
- 1 files changed, 19 insertions(+), 1 deletions(-)
-
-diff --git a/src/mainapp/main_thread.cpp b/src/mainapp/main_thread.cpp
-index cb7adc0..4361dbf 100644
---- a/src/mainapp/main_thread.cpp
-+++ b/src/mainapp/main_thread.cpp
-@@ -28,7 +28,6 @@
- 
- #include <core/threading/interruptible_barrier.h>
- #include <core/exceptions/system.h>
--#include <core/macros.h>
- #include <config/sqlite.h>
- #include <config/net_handler.h>
- #include <utils/logging/multi.h>
-@@ -48,6 +47,10 @@
- 
- #include <cstdio>
- #include <cstring>
-+#include <sys/types.h>
-+#include <sys/stat.h>
-+
-+#include <core/macros.h>
- 
- using namespace fawkes;
- 
-@@ -130,6 +133,21 @@ FawkesMainThread::FawkesMainThread(ArgumentParser *argp)
-   __multi_logger->set_loglevel(log_level);
-   LibLogger::init(__multi_logger);
- 
-+  /* Prepare home dir directory, just in case */
-+  const char *homedir = getenv("HOME");
-+  if (homedir) {
-+    char *userdir;
-+    if (asprintf(&userdir, "%s/%s", homedir, USERDIR) != -1) {
-+      if (access(userdir, W_OK) != 0) {
-+	if (mkdir(userdir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1) {
-+	  __multi_logger->log_warn("FawkesMainThread", "Failed to create .fawkes "
-+				   "directory %s, trying without", userdir);
-+	}
-+      }
-+      free(userdir);
-+    }
-+  }
-+
-   /* Config stuff */
-   SQLiteConfiguration *sqliteconf = new SQLiteConfiguration(CONFDIR);
-   __config = sqliteconf;
--- 
-1.7.2.3
-
-
-From 84bd75cd35403204512722ed30f559cf3147fca6 Mon Sep 17 00:00:00 2001
-From: Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
-Date: Sat, 30 Oct 2010 18:03:04 -0400
-Subject: [PATCH 05/16] Exception: rename errno() to get_errno()
-
-On Linux these days errno is a macro which is expanded on compilation.
-This makes it impossible to name the method errno(). Therefore it has
-been renamed to get_errno().
----
- src/libs/core/exception.cpp |    2 +-
- src/libs/core/exception.h   |    2 +-
- 2 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/libs/core/exception.cpp b/src/libs/core/exception.cpp
-index cc6c4e1..2593dbb 100644
---- a/src/libs/core/exception.cpp
-+++ b/src/libs/core/exception.cpp
-@@ -640,7 +640,7 @@ Exception::print_trace() throw()
-  * @return error number, may be 0 if not set
-  */
- int
--Exception::errno() throw()
-+Exception::get_errno() throw()
- {
-   return _errno;
- }
-diff --git a/src/libs/core/exception.h b/src/libs/core/exception.h
-index 4b7fed3..4741978 100644
---- a/src/libs/core/exception.h
-+++ b/src/libs/core/exception.h
-@@ -50,7 +50,7 @@ class Exception : public std::exception {
-   void print_backtrace() const throw();
-   char *  generate_backtrace() const throw();
- 
--  int errno() throw();
-+  int get_errno() throw();
- 
-   void          set_type_id(const char *id);
-   const char *  type_id() const;
--- 
-1.7.2.3
-
-
-From 1528f1e7f04612d7316792f96a1c6691c3a90894 Mon Sep 17 00:00:00 2001
-From: Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
-Date: Sat, 30 Oct 2010 18:04:28 -0400
-Subject: [PATCH 06/16] SQLiteConfiguration: do not dump on destruction
-
-The configuration is no longer dumped on destruction, rather a
-try_dump() method is provided to trigger dumping. This is done to be
-able to throw an exception, which should never been done in a dtor.
----
- src/libs/config/sqlite.cpp |   39 +++++++++++++++++++++++++++------------
- src/libs/config/sqlite.h   |    2 ++
- 2 files changed, 29 insertions(+), 12 deletions(-)
-
-diff --git a/src/libs/config/sqlite.cpp b/src/libs/config/sqlite.cpp
-index 5a3a7a8..cb34c92 100644
---- a/src/libs/config/sqlite.cpp
-+++ b/src/libs/config/sqlite.cpp
-@@ -272,17 +272,6 @@ SQLiteConfiguration::~SQLiteConfiguration()
-       printf("Boom, we are dead, database cannot be closed "
- 	     "because there are open handles\n");
-     }
--    if ( __default_sql ) {
--      sqlite3 *tdb;
--      if ( sqlite3_open(__default_file, &tdb) == SQLITE_OK ) {
--	try {
--	  dump(tdb, __default_sql);
--	} catch (Exception &e) {
--	  e.print_trace();
--	}
--	sqlite3_close(tdb);
--      }
--    }
-   }
- 
-   if (__host_file)    free(__host_file);
-@@ -406,7 +395,7 @@ SQLiteConfiguration::dump(::sqlite3 *tdb, const char *dumpfile)
- {
-   FILE *f = fopen(dumpfile, "w");
-   if ( ! f ) {
--    throw CouldNotOpenFileException(dumpfile, errno, "Could not open SQLite dump file");
-+    throw CouldNotOpenFileException(dumpfile, errno, "Could not open dump file");
-   }
- 
-   fprintf(f, "BEGIN TRANSACTION;\n");
-@@ -428,11 +417,37 @@ SQLiteConfiguration::dump(::sqlite3 *tdb, const char *dumpfile)
- }
- 
- 
-+/** Try to dump default configuration.
-+ * This method will try to open the SQL dump file for writing and dump
-+ * the current content of the default database into the file.
-+ * @exception Exception thrown if dumping fails
-+ */
-+void
-+SQLiteConfiguration::try_dump()
-+{
-+  if ( __default_sql ) {
-+    sqlite3 *tdb;
-+    if ( sqlite3_open(__default_file, &tdb) == SQLITE_OK ) {
-+      try {
-+	dump(tdb, __default_sql);
-+	sqlite3_close(tdb);
-+      } catch (Exception &e) {
-+	sqlite3_close(tdb);
-+	throw;
-+      }
-+    }
-+  }
-+}
-+
- void
- SQLiteConfiguration::import(::sqlite3 *tdb, const char *dumpfile)
- {
-   FILE *f = fopen(dumpfile, "r");
- 
-+  if (! f) {
-+    throw CouldNotOpenConfigException("Import failed, could not open dump file");
-+  }
-+
-   char line[4096];
-   char *errmsg;
-   while (! feof(f) ) {
-diff --git a/src/libs/config/sqlite.h b/src/libs/config/sqlite.h
-index 95113d6..ab32b2a 100644
---- a/src/libs/config/sqlite.h
-+++ b/src/libs/config/sqlite.h
-@@ -158,6 +158,8 @@ class SQLiteConfiguration : public Configuration
- 
-   SQLiteValueIterator * modified_iterator();
- 
-+  void try_dump();
-+
-  private:
-   void            init_dbs();
-   std::string     get_type(const char *table, const char *path);
--- 
-1.7.2.3
-
-
-From 52bc811c5c92a421bf088dbb13392b66477150bf Mon Sep 17 00:00:00 2001
-From: Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
-Date: Sat, 30 Oct 2010 18:05:36 -0400
-Subject: [PATCH 07/16] Main app: call dump and provide help
-
-Try to dump the default configuration on destruction. If an error
-occurs, try to be as specific as possible in the error message to
-provide useful help, especially since this can likely happen on
-system-wide installation.
----
- src/mainapp/main_thread.cpp |   35 ++++++++++++++++++++++++++++++++---
- src/mainapp/main_thread.h   |    2 ++
- 2 files changed, 34 insertions(+), 3 deletions(-)
-
-diff --git a/src/mainapp/main_thread.cpp b/src/mainapp/main_thread.cpp
-index 4361dbf..ee0be05 100644
---- a/src/mainapp/main_thread.cpp
-+++ b/src/mainapp/main_thread.cpp
-@@ -47,6 +47,7 @@
- 
- #include <cstdio>
- #include <cstring>
-+#include <cerrno>
- #include <sys/types.h>
- #include <sys/stat.h>
- 
-@@ -149,12 +150,13 @@ FawkesMainThread::FawkesMainThread(ArgumentParser *argp)
-   }
- 
-   /* Config stuff */
--  SQLiteConfiguration *sqliteconf = new SQLiteConfiguration(CONFDIR);
--  __config = sqliteconf;
-+  __sqlite_conf = new SQLiteConfiguration(CONFDIR);
-+  __config = __sqlite_conf;
-   __config->load(__argp->arg("c"), __argp->arg("d"));
- 
-   try {
--    SQLiteConfiguration::SQLiteValueIterator *i = sqliteconf->modified_iterator();
-+    SQLiteConfiguration::SQLiteValueIterator *i =
-+      __sqlite_conf->modified_iterator();
-     while (i->next()) {
-       std::string modtype = i->get_modtype();
-       if (modtype == "changed") {
-@@ -298,6 +300,33 @@ FawkesMainThread::~FawkesMainThread()
- void
- FawkesMainThread::destruct()
- {
-+  try {
-+    __sqlite_conf->try_dump();
-+  } catch (CouldNotOpenFileException &e) {
-+    if (e.get_errno() == EACCES) {
-+      __multi_logger->log_warn("FawkesMainThread", "Cannot write to dump file, "
-+			       "no write ");
-+      __multi_logger->log_warn("FawkesMainThread", "permission for file or "
-+			       "directory. This");
-+      __multi_logger->log_warn("FawkesMainThread", "usually happens if running "
-+			       "with system-wide");
-+      __multi_logger->log_warn("FawkesMainThread", "installed Fawkes as non-root "
-+			       "user. Make");
-+      __multi_logger->log_warn("FawkesMainThread", "configuration changes to the "
-+			       "host-based");
-+      __multi_logger->log_warn("FawkesMainThread", "database (set as non-default "
-+			       "values).");
-+    } else {
-+      __multi_logger->log_warn("FawkesMainThread", "Failed to dump default "
-+			       "config (open), exception follows.");
-+      __multi_logger->log_warn("FawkesMainThread", e);
-+    }
-+  } catch (Exception &e) {
-+    __multi_logger->log_warn("FawkesMainThread", "Failed to dump default config, "
-+			     "exception follows.");
-+    __multi_logger->log_warn("FawkesMainThread", e);
-+  }
-+
-   // Must delete network logger first since network manager has to die before the LibLogger
-   // is finalized.
-   __multi_logger->remove_logger(__network_logger);
-diff --git a/src/mainapp/main_thread.h b/src/mainapp/main_thread.h
-index af9f25d..ec1001f 100644
---- a/src/mainapp/main_thread.h
-+++ b/src/mainapp/main_thread.h
-@@ -35,6 +35,7 @@ namespace fawkes {
-   class ArgumentParser;
-   class LocalBlackBoard;
-   class Configuration;
-+  class SQLiteConfiguration;
-   class ConfigNetworkHandler;
-   class MultiLogger;
-   class NetworkLogger;
-@@ -87,6 +88,7 @@ class FawkesMainThread
-   fawkes::Mutex                *__mainloop_mutex;
-   fawkes::InterruptibleBarrier *__mainloop_barrier;
- 
-+  fawkes::SQLiteConfiguration  *__sqlite_conf;
-   FawkesThreadManager          *__thread_manager;
-   fawkes::PluginManager        *__plugin_manager;
-   fawkes::PluginNetworkHandler *__plugin_nethandler;
--- 
-1.7.2.3
-
-
 From e87b9b6de48920545567d5e952c9ddfe06ffaf48 Mon Sep 17 00:00:00 2001
 From: Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
 Date: Sun, 31 Oct 2010 00:58:03 -0400
-Subject: [PATCH 08/16] BuildSys: add support for generating man pages
+Subject: [PATCH 1/9] BuildSys: add support for generating man pages
 
 Fawkes is lacking user documentation. To improve this support for
 creating man pages has been added. It uses asciidoc to do so, which has
@@ -1063,7 +239,7 @@ index 904652a..9bcbc24 100644
 From 6e03b4798a5d36e22eb614d671525810f32baabd Mon Sep 17 00:00:00 2001
 From: Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
 Date: Sun, 31 Oct 2010 01:00:22 -0400
-Subject: [PATCH 09/16] BuildSys: support system-wide installation of man pages
+Subject: [PATCH 2/9] BuildSys: support system-wide installation of man pages
 
 ---
  etc/buildsys/btypes/config_sysinstall.mk |    3 ++-
@@ -1142,7 +318,7 @@ index 97a4274..0836104 100644
 From 9a0a3b8e0a4279d7b91f74d40fcffe498b0e1200 Mon Sep 17 00:00:00 2001
 From: Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
 Date: Sun, 31 Oct 2010 01:00:54 -0400
-Subject: [PATCH 10/16] Main app: add man page for fawkes
+Subject: [PATCH 3/9] Main app: add man page for fawkes
 
 Added the first man page. It will need further improvements, but it is
 at least a start.
@@ -1303,7 +479,7 @@ index 0000000..8373447
 From 72ce61066f169556498e9cf4042e4ec24e5efa12 Mon Sep 17 00:00:00 2001
 From: Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
 Date: Tue, 2 Nov 2010 23:32:34 -0400
-Subject: [PATCH 11/16] BuildSys/Interfaces: build generator as presubdir
+Subject: [PATCH 4/9] BuildSys/Interfaces: build generator as presubdir
 
 We had a special case for the interface generator that included a
 Makefile snippet either in the generator dir or its parent interfaces
@@ -1512,7 +688,7 @@ index 3394022..0000000
 From 42e12471844c5d993fcc6431a6356160b36735da Mon Sep 17 00:00:00 2001
 From: Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
 Date: Wed, 3 Nov 2010 00:11:19 -0400
-Subject: [PATCH 12/16] ffifacegen: Added man page, handle -h arg better
+Subject: [PATCH 5/9] ffifacegen: Added man page, handle -h arg better
 
 ---
  src/interfaces/generator/Makefile       |    1 +
@@ -1742,7 +918,7 @@ index ebcae6b..d19cf6c 100644
 From 4ab679f56752c3ac96f92977af6e119d26b9330a Mon Sep 17 00:00:00 2001
 From: Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
 Date: Wed, 3 Nov 2010 00:12:07 -0400
-Subject: [PATCH 13/16] BuildSys: print error messages on man page generation
+Subject: [PATCH 6/9] BuildSys: print error messages on man page generation
 
 Messages generated during man page generation were suppressed to avoid
 the "Note: Writing ..." message. This is not helpful on errors though.
@@ -1780,7 +956,7 @@ index 9bcbc24..3bfa793 100644
 From c446a6f005827882bedc61018c61f2845f947f0a Mon Sep 17 00:00:00 2001
 From: Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
 Date: Wed, 3 Nov 2010 00:13:36 -0400
-Subject: [PATCH 14/16] Tools: added man pages
+Subject: [PATCH 7/9] Tools: added man pages
 
 ---
  src/tools/config/Makefile       |    8 ++--
@@ -2205,7 +1381,7 @@ index 0000000..0ada348
 From afa11306894b79da40c48e550182444895d85ace Mon Sep 17 00:00:00 2001
 From: Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
 Date: Fri, 5 Nov 2010 23:01:26 -0400
-Subject: [PATCH 15/16] BuildSys man pages: CentOS fix, allow missing asciidoc
+Subject: [PATCH 8/9] BuildSys man pages: CentOS fix, allow missing asciidoc
 
 + mktemp was called with a flag not available on CentOS/RHEL
 + If asciidoc is not installed, just report that the man page was not
@@ -2270,7 +1446,7 @@ index 3bfa793..58c4af8 100644
 From e62652f950177d4c21d05a5b2a770cebab53d2eb Mon Sep 17 00:00:00 2001
 From: Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
 Date: Sat, 6 Nov 2010 00:21:06 -0400
-Subject: [PATCH 16/16] FireVision tools: add man pages, fix usage info
+Subject: [PATCH 9/9] FireVision tools: add man pages, fix usage info
 
 ---
  src/firevision/tools/Makefile            |   24 +++---


More information about the scm-commits mailing list