mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-21 12:44:58 +02:00
Fixed loading components when using a custom --libdir.
This commit is contained in:
parent
e6254baea3
commit
115489a531
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user