]> granicus.if.org Git - icinga2/commitdiff
Fixed loading components when using a custom --libdir.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 2 Oct 2012 07:26:17 +0000 (09:26 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 2 Oct 2012 07:26:17 +0000 (09:26 +0200)
configure.ac
icinga-app/icinga.cpp
lib/base/application.cpp
lib/base/application.h
lib/base/component.cpp

index e7c1eb55e680c1e0b051a02e35f0fcea3e511228..e75ffb19f2b73bec0bfb23f9dfa2fd84fa86165b 100644 (file)
@@ -72,6 +72,9 @@ AC_DEFINE_UNQUOTED([ICINGA_PREFIX], "$ICINGA_PREFIX", [The installation prefix.]
 AS_AC_EXPAND([ICINGA_LOCALSTATEDIR], $localstatedir)
 AC_DEFINE_UNQUOTED([ICINGA_LOCALSTATEDIR], "$ICINGA_LOCALSTATEDIR", [The local state dir.])
 
+AS_AC_EXPAND([ICINGA_PKGLIBDIR], $libdir/$PACKAGE_NAME)
+AC_DEFINE_UNQUOTED([ICINGA_PKGLIBDIR], "$ICINGA_PKGLIBDIR", [The package lib dir.])
+
 AC_CONFIG_FILES([
 Makefile
 components/Makefile
index 8a7e1ad3a6031c4122f42bf4cb31c2fc1ebcd49b..8402df55f09720e70372a0c4f0174942f785b988 100644 (file)
@@ -121,6 +121,10 @@ int main(int argc, char **argv)
        Application::SetLocalStateDir(ICINGA_LOCALSTATEDIR);
 #endif /* ICINGA_LOCALSTATEDIR */
 
+#ifdef ICINGA_PKGLIBDIR
+       Application::SetPkgLibDir(ICINGA_PKGLIBDIR);
+#endif /* ICINGA_PKGLIBDIR */
+
        Logger::Write(LogInformation, "icinga", "Icinga application loader"
 #ifndef _WIN32
                " (version: " ICINGA_VERSION ")"
@@ -134,13 +138,7 @@ int main(int argc, char **argv)
                return EXIT_FAILURE;
        }
 
-       String exeDirectory = Utility::DirName(Application::GetExePath(argv[0]));
-       Component::AddSearchDir(exeDirectory + "/../lib/icinga2");
-       Component::AddSearchDir(exeDirectory + "/../lib64/icinga2");
-
-#ifdef ICINGA_LIBDIR
-       Component::AddSearchDir(ICINGA_LIBDIR);
-#endif /* ICINGA_LIBDIR */
+       Component::AddSearchDir(Application::GetPkgLibDir());
 
        try {
                DynamicObject::BeginTx();
index 0ebdd92adacc8eba00865e5d17d10ebeda0ba3d6..42b72a42128e7882e78034891c7750fe8357c9d6 100644 (file)
@@ -31,6 +31,7 @@ bool Application::m_Debugging = false;
 boost::thread::id Application::m_MainThreadID;
 String Application::m_PrefixDir;
 String Application::m_LocalStateDir;
+String Application::m_PkgLibDir;
 
 /**
  * Constructor for the Application class.
@@ -408,7 +409,7 @@ void Application::ClosePidFile(void)
 String Application::GetPrefixDir(void)
 {
        if (m_PrefixDir.IsEmpty())
-               return "./";
+               return ".";
        else
                return m_PrefixDir;
 }
@@ -431,7 +432,7 @@ void Application::SetPrefixDir(const String& path)
 String Application::GetLocalStateDir(void)
 {
        if (m_LocalStateDir.IsEmpty())
-               return "./var/";
+               return "./var";
        else
                return m_LocalStateDir;
 }
@@ -446,3 +447,25 @@ void Application::SetLocalStateDir(const String& path)
        m_LocalStateDir = path;
 }
 
+/**
+ * Retrives the path for the package lib dir.
+ *
+ * @returns The path.
+ */
+String Application::GetPkgLibDir(void)
+{
+       if (m_PkgLibDir.IsEmpty())
+               return ".";
+       else
+               return m_PkgLibDir;
+}
+
+/**
+ * Sets the path for the package lib dir.
+ *
+ * @param path The new path.
+ */
+void Application::SetPkgLibDir(const String& path)
+{
+       m_PkgLibDir = path;
+}
index 390a7dc2fdfedd65403b2064bccd3fef0eceb046..ca7aef88b5377043bea1ec5382bb1dcb3a511747 100644 (file)
@@ -68,6 +68,9 @@ public:
        static String GetLocalStateDir(void);
        static void SetLocalStateDir(const String& path);
 
+       static String GetPkgLibDir(void);
+       static void SetPkgLibDir(const String& path);
+
 protected:
        void RunEventLoop(void);
 
@@ -82,6 +85,7 @@ private:
        static boost::thread::id m_MainThreadID; /**< ID of the main thread. */
        static String m_PrefixDir; /**< The installation prefix. */
        static String m_LocalStateDir; /**< The local state dir. */
+       static String m_PkgLibDir; /**< The package lib dir. */
 
 #ifndef _WIN32
        static void SigIntHandler(int signum);
index e8c3950bed4e85559ec613d315b9f25c1b508be7..bc66042c69134be17acffd85d91b44034ec9f07a 100644 (file)
@@ -123,6 +123,9 @@ void Component::Start(void)
  */
 void Component::AddSearchDir(const String& componentDirectory)
 {
+       Logger::Write(LogInformation, "base", "Adding library search dir: " +
+           componentDirectory);
+
 #ifdef _WIN32
        SetDllDirectory(componentDirectory.CStr());
 #else /* _WIN32 */