diff --git a/arangod/RestServer/arangod.cpp b/arangod/RestServer/arangod.cpp index b296ce6d81..c858f7a5f9 100644 --- a/arangod/RestServer/arangod.cpp +++ b/arangod/RestServer/arangod.cpp @@ -105,7 +105,7 @@ static int runServer(int argc, char** argv) { auto options = std::make_shared( argv[0], "Usage: " + name + " []", "For more information use:"); - application_features::ApplicationServer server(options); + application_features::ApplicationServer server(options, SBIN_DIRECTORY); std::vector nonServerFeatures = { "Action", "Affinity", diff --git a/arangosh/Benchmark/arangobench.cpp b/arangosh/Benchmark/arangobench.cpp index d8ef0e14ca..90313a3af5 100644 --- a/arangosh/Benchmark/arangobench.cpp +++ b/arangosh/Benchmark/arangobench.cpp @@ -49,7 +49,7 @@ int main(int argc, char* argv[]) { std::shared_ptr options(new options::ProgramOptions( argv[0], "Usage: arangobench []", "For more information use:")); - ApplicationServer server(options); + ApplicationServer server(options, BIN_DIRECTORY); int ret; diff --git a/arangosh/Dump/arangodump.cpp b/arangosh/Dump/arangodump.cpp index ce3f56dd08..9b28cc13f1 100644 --- a/arangosh/Dump/arangodump.cpp +++ b/arangosh/Dump/arangodump.cpp @@ -46,7 +46,7 @@ int main(int argc, char* argv[]) { std::shared_ptr options(new options::ProgramOptions( argv[0], "Usage: arangodump []", "For more information use:")); - ApplicationServer server(options); + ApplicationServer server(options, BIN_DIRECTORY); int ret; diff --git a/arangosh/Import/arangoimp.cpp b/arangosh/Import/arangoimp.cpp index 34fafbcda6..3366879e2d 100644 --- a/arangosh/Import/arangoimp.cpp +++ b/arangosh/Import/arangoimp.cpp @@ -47,7 +47,7 @@ int main(int argc, char* argv[]) { std::shared_ptr options(new options::ProgramOptions( argv[0], "Usage: arangoimp []", "For more information use:")); - ApplicationServer server(options); + ApplicationServer server(options, BIN_DIRECTORY); int ret; diff --git a/arangosh/Restore/arangorestore.cpp b/arangosh/Restore/arangorestore.cpp index 4fd8266bcb..d09dd9f3ce 100644 --- a/arangosh/Restore/arangorestore.cpp +++ b/arangosh/Restore/arangorestore.cpp @@ -47,7 +47,7 @@ int main(int argc, char* argv[]) { std::shared_ptr options(new options::ProgramOptions( argv[0], "Usage: arangorestore []", "For more information use:")); - ApplicationServer server(options); + ApplicationServer server(options, BIN_DIRECTORY); int ret; diff --git a/arangosh/Shell/arangosh.cpp b/arangosh/Shell/arangosh.cpp index ceb8e4c2d7..2194740586 100644 --- a/arangosh/Shell/arangosh.cpp +++ b/arangosh/Shell/arangosh.cpp @@ -53,7 +53,7 @@ int main(int argc, char* argv[]) { std::shared_ptr options(new options::ProgramOptions( argv[0], "Usage: " + name + " []", "For more information use:")); - ApplicationServer server(options); + ApplicationServer server(options, BIN_DIRECTORY); int ret; diff --git a/arangosh/VPack/arangovpack.cpp b/arangosh/VPack/arangovpack.cpp index 09a34a2886..7617469106 100644 --- a/arangosh/VPack/arangovpack.cpp +++ b/arangosh/VPack/arangovpack.cpp @@ -44,7 +44,7 @@ int main(int argc, char* argv[]) { std::shared_ptr options(new options::ProgramOptions( argv[0], "Usage: arangovpack []", "For more information use:")); - ApplicationServer server(options); + ApplicationServer server(options, BIN_DIRECTORY); int ret; diff --git a/lib/ApplicationFeatures/ApplicationFeature.cpp b/lib/ApplicationFeatures/ApplicationFeature.cpp index 65773baed5..9f0b5495bc 100644 --- a/lib/ApplicationFeatures/ApplicationFeature.cpp +++ b/lib/ApplicationFeatures/ApplicationFeature.cpp @@ -47,7 +47,8 @@ void ApplicationFeature::collectOptions(std::shared_ptr) {} // load options from somewhere. this method will only be called for enabled // features -void ApplicationFeature::loadOptions(std::shared_ptr) {} +void ApplicationFeature::loadOptions(std::shared_ptr, + const char* binaryPath) {} // validate the feature's options. this method will only be called for active // features, after the ApplicationServer has determined which features should be diff --git a/lib/ApplicationFeatures/ApplicationFeature.h b/lib/ApplicationFeatures/ApplicationFeature.h index b590f8a23a..e4a2c942c7 100644 --- a/lib/ApplicationFeatures/ApplicationFeature.h +++ b/lib/ApplicationFeatures/ApplicationFeature.h @@ -102,7 +102,8 @@ class ApplicationFeature { // load options from somewhere. this method will only be called for enabled // features - virtual void loadOptions(std::shared_ptr); + virtual void loadOptions(std::shared_ptr, + const char* binaryPath); // validate the feature's options. this method will only be called for active // features, after the ApplicationServer has determined which features should diff --git a/lib/ApplicationFeatures/ApplicationServer.cpp b/lib/ApplicationFeatures/ApplicationServer.cpp index 210024d4c9..8baa8fb6c4 100644 --- a/lib/ApplicationFeatures/ApplicationServer.cpp +++ b/lib/ApplicationFeatures/ApplicationServer.cpp @@ -34,8 +34,9 @@ using namespace arangodb::options; ApplicationServer* ApplicationServer::server = nullptr; -ApplicationServer::ApplicationServer(std::shared_ptr options) - : _options(options), _stopping(false) { +ApplicationServer::ApplicationServer(std::shared_ptr options, + const char *binaryPath) + : _options(options), _stopping(false), _binaryPath(binaryPath) { if (ApplicationServer::server != nullptr) { LOG(ERR) << "ApplicationServer initialized twice"; } @@ -325,7 +326,7 @@ void ApplicationServer::parseOptions(int argc, char* argv[]) { for (auto it = _orderedFeatures.begin(); it != _orderedFeatures.end(); ++it) { if ((*it)->isEnabled()) { LOG_TOPIC(TRACE, Logger::STARTUP) << (*it)->name() << "::loadOptions"; - (*it)->loadOptions(_options); + (*it)->loadOptions(_options, _binaryPath); } } } diff --git a/lib/ApplicationFeatures/ApplicationServer.h b/lib/ApplicationFeatures/ApplicationServer.h index 4166a9f3d1..04e92b5320 100644 --- a/lib/ApplicationFeatures/ApplicationServer.h +++ b/lib/ApplicationFeatures/ApplicationServer.h @@ -162,7 +162,8 @@ class ApplicationServer { static void forceDisableFeatures(std::vector const&); public: - explicit ApplicationServer(std::shared_ptr); + explicit ApplicationServer(std::shared_ptr, + const char *binaryPath); ~ApplicationServer(); @@ -303,6 +304,9 @@ class ApplicationServer { // help section displayed std::string _helpSection; + + // the install directory of this program: + const char* _binaryPath; }; } } diff --git a/lib/ApplicationFeatures/ConfigFeature.cpp b/lib/ApplicationFeatures/ConfigFeature.cpp index 3b0f600640..7f56e92201 100644 --- a/lib/ApplicationFeatures/ConfigFeature.cpp +++ b/lib/ApplicationFeatures/ConfigFeature.cpp @@ -63,8 +63,9 @@ void ConfigFeature::collectOptions(std::shared_ptr options) { new BooleanParameter(&_checkConfiguration)); } -void ConfigFeature::loadOptions(std::shared_ptr options) { - loadConfigFile(options, _progname); +void ConfigFeature::loadOptions(std::shared_ptr options, + const char* binaryPath) { + loadConfigFile(options, _progname, binaryPath); if (_checkConfiguration) { exit(EXIT_SUCCESS); @@ -72,7 +73,8 @@ void ConfigFeature::loadOptions(std::shared_ptr options) { } void ConfigFeature::loadConfigFile(std::shared_ptr options, - std::string const& progname) { + std::string const& progname, + const char* binaryPath) { if (StringUtils::tolower(_file) == "none") { LOG_TOPIC(DEBUG, Logger::CONFIG) << "use no config file at all"; return; @@ -151,7 +153,7 @@ void ConfigFeature::loadConfigFile(std::shared_ptr options, if (!FileUtils::exists(filename)) { filename = - FileUtils::buildFilename(FileUtils::configDirectory(), basename); + FileUtils::buildFilename(FileUtils::configDirectory(binaryPath), basename); LOG_TOPIC(DEBUG, Logger::CONFIG) << "checking '" << filename << "'"; diff --git a/lib/ApplicationFeatures/ConfigFeature.h b/lib/ApplicationFeatures/ConfigFeature.h index bcee29c06d..e094560945 100644 --- a/lib/ApplicationFeatures/ConfigFeature.h +++ b/lib/ApplicationFeatures/ConfigFeature.h @@ -33,7 +33,8 @@ class ConfigFeature final : public application_features::ApplicationFeature { public: void collectOptions(std::shared_ptr) override final; - void loadOptions(std::shared_ptr) override final; + void loadOptions(std::shared_ptr, + const char* binaryPath) override final; private: std::string _file; @@ -41,7 +42,8 @@ class ConfigFeature final : public application_features::ApplicationFeature { private: void loadConfigFile(std::shared_ptr, - std::string const& progname); + std::string const& progname, + const char* binaryPath); private: std::string _progname; diff --git a/lib/Basics/FileUtils.cpp b/lib/Basics/FileUtils.cpp index 338429d84d..7dff02c2bd 100644 --- a/lib/Basics/FileUtils.cpp +++ b/lib/Basics/FileUtils.cpp @@ -592,8 +592,8 @@ std::string homeDirectory() { return result; } -std::string configDirectory() { - char* dir = TRI_LocateConfigDirectory(); +std::string configDirectory(const char* binaryPath) { + char* dir = TRI_LocateConfigDirectory(binaryPath); if (dir == nullptr) { return currentDirectory(); diff --git a/lib/Basics/FileUtils.h b/lib/Basics/FileUtils.h index 97ae1bdefd..75f93e13ae 100644 --- a/lib/Basics/FileUtils.h +++ b/lib/Basics/FileUtils.h @@ -222,7 +222,7 @@ std::string homeDirectory(); /// @brief returns the config directory //////////////////////////////////////////////////////////////////////////////// -std::string configDirectory(); +std::string configDirectory(const char* binaryPath); //////////////////////////////////////////////////////////////////////////////// /// @brief returns the base name diff --git a/lib/Basics/files.cpp b/lib/Basics/files.cpp index 8b0ec2daa9..336338cca7 100644 --- a/lib/Basics/files.cpp +++ b/lib/Basics/files.cpp @@ -2325,10 +2325,10 @@ void TRI_SetUserTempPath(std::string const& path) { TempPath = path; } #if _WIN32 -std::string TRI_LocateInstallDirectory() { - return TRI_LocateBinaryPath(nullptr) + - std::string(1, TRI_DIR_SEPARATOR_CHAR) + ".." + - std::string(1, TRI_DIR_SEPARATOR_CHAR); +std::string TRI_LocateInstallDirectory(const char *binaryPath) { + std::string thisPath = TRI_LocateBinaryPath(null); + return TRI_GetInstallRoot(thisPath, binaryPath) + + std::string(1, TRI_DIR_SEPARATOR_CHAR); } #endif @@ -2341,14 +2341,14 @@ std::string TRI_LocateInstallDirectory() { #if _WIN32 -char* TRI_LocateConfigDirectory() { +char* TRI_LocateConfigDirectory(const char* binaryPath) { char* v = LocateConfigDirectoryEnv(); if (v != nullptr) { return v; } - std::string r = TRI_LocateInstallDirectory(); + std::string r = TRI_LocateInstallDirectory(binaryPath); r += _SYSCONFDIR_; @@ -2359,7 +2359,7 @@ char* TRI_LocateConfigDirectory() { #elif defined(_SYSCONFDIR_) -char* TRI_LocateConfigDirectory() { +char* TRI_LocateConfigDirectory(const char* binaryPath) { char* v = LocateConfigDirectoryEnv(); if (v != nullptr) { diff --git a/lib/Basics/files.h b/lib/Basics/files.h index 4f3d900e20..abead574b0 100644 --- a/lib/Basics/files.h +++ b/lib/Basics/files.h @@ -343,7 +343,7 @@ std::string TRI_LocateInstallDirectory(); /// @brief locate the configuration directory //////////////////////////////////////////////////////////////////////////////// -char* TRI_LocateConfigDirectory(); +char* TRI_LocateConfigDirectory(const char * binaryPath); //////////////////////////////////////////////////////////////////////////////// /// @brief get the address of the null buffer diff --git a/lib/Logger/LoggerFeature.cpp b/lib/Logger/LoggerFeature.cpp index 7f9a85e477..a9f0c9c431 100644 --- a/lib/Logger/LoggerFeature.cpp +++ b/lib/Logger/LoggerFeature.cpp @@ -123,7 +123,8 @@ void LoggerFeature::collectOptions(std::shared_ptr options) { } void LoggerFeature::loadOptions( - std::shared_ptr options) { + std::shared_ptr options, + const char *binaryPath) { // for debugging purpose, we set the log levels NOW // this might be overwritten latter Logger::setLogLevel(_levels); diff --git a/lib/Logger/LoggerFeature.h b/lib/Logger/LoggerFeature.h index f9593b0cc0..bb29998c4c 100644 --- a/lib/Logger/LoggerFeature.h +++ b/lib/Logger/LoggerFeature.h @@ -33,7 +33,8 @@ class LoggerFeature final : public application_features::ApplicationFeature { public: void collectOptions(std::shared_ptr) override final; - void loadOptions(std::shared_ptr) override final; + void loadOptions(std::shared_ptr, + const char *binaryPath) override final; void validateOptions(std::shared_ptr) override final; void prepare() override final; void unprepare() override final; diff --git a/scripts/build-deb.sh b/scripts/build-deb.sh index f946e43aff..9316cbdc81 100755 --- a/scripts/build-deb.sh +++ b/scripts/build-deb.sh @@ -14,6 +14,7 @@ cd ${DIR}/.. --buildDir build-deb \ --targetDir /var/tmp/ \ --jemalloc \ + --noopt \ $@ cd ${DIR}/.. diff --git a/scripts/build-rpm.sh b/scripts/build-rpm.sh index 0a298651fd..df2ee8350c 100755 --- a/scripts/build-rpm.sh +++ b/scripts/build-rpm.sh @@ -13,6 +13,7 @@ cd ${DIR}/.. --buildDir build-rpm \ --targetDir /var/tmp/ \ --jemalloc \ + --noopt \ $@ cd ${DIR}/..