From 751b237603a2958cce3563b343a7b811a9dca399 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Fri, 29 Mar 2024 05:34:32 -0600 Subject: [PATCH] fix: Make the etc directory configurable so it installs without being root --- Makefile.am | 4 ++-- src/replicator/planetreplicator.cc | 3 ++- src/stats/statsconfig.cc | 3 ++- src/testsuite/libunderpass.all/Makefile.am | 3 +++ src/testsuite/libunderpass.all/geo-test.cc | 4 +++- src/underpass.cc | 3 ++- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index f6eb71a0..7c35fa6f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -92,8 +92,7 @@ AM_CXXFLAGS = \ -fno-builtin-malloc \ -fno-builtin-calloc \ -fno-builtin-realloc \ - -fno-builtin-free \ - -DETCDIR=$(ETCDIR) + -fno-builtin-free else AM_CXXFLAGS = \ -rdynamic \ @@ -104,6 +103,7 @@ endif AM_CPPFLAGS = \ -DPKGLIBDIR=\"$(pkglibdir)\" \ -DSRCDIR=\"$(srcdir)\" \ + -DETCDIR=\"$(ETCDIR)\" \ -DBOOST_LOCALE_HIDE_AUTO_PTR # Optionally timing can be turned on, which produces volumes of output which adds too much # clutter to the output. This should only be enabled when doing performance tuning. diff --git a/src/replicator/planetreplicator.cc b/src/replicator/planetreplicator.cc index 1e873411..eb24febb 100644 --- a/src/replicator/planetreplicator.cc +++ b/src/replicator/planetreplicator.cc @@ -102,7 +102,8 @@ PlanetReplicator::PlanetReplicator(void) {}; std::shared_ptr PlanetReplicator::findRemotePath(const underpassconfig::UnderpassConfig &config, ptime time) { yaml::Yaml yaml; - std::string rep_file = "ETCDIR/replicator/planetreplicator.yaml"; + std::string rep_file = ETCDIR; + rep_file += "replicator/planetreplicator.yaml"; yaml.read(rep_file); std::map hashes; diff --git a/src/stats/statsconfig.cc b/src/stats/statsconfig.cc index 0e1203a0..782dd830 100644 --- a/src/stats/statsconfig.cc +++ b/src/stats/statsconfig.cc @@ -51,7 +51,8 @@ namespace statsconfig { StatsConfig::StatsConfig() { if (path.empty()) { - path = "ETCDIR/stats/statistics.yaml"; + path = ETCDIR; + path += "/stats/statistics.yaml"; if (!boost::filesystem::exists(path)) { throw std::runtime_error("Statistics file not found: " + path); } diff --git a/src/testsuite/libunderpass.all/Makefile.am b/src/testsuite/libunderpass.all/Makefile.am index 216e26dd..30c0ddbe 100644 --- a/src/testsuite/libunderpass.all/Makefile.am +++ b/src/testsuite/libunderpass.all/Makefile.am @@ -19,6 +19,8 @@ AUTOMAKE_OPTIONS = dejagnu +ETCDIR = $(subst lib,etc,$(pkglibdir)) + check_PROGRAMS = \ pq-test \ change-test \ @@ -55,6 +57,7 @@ AM_CXXFLAGS = \ -DPKGLIBDIR=\"$(pkglibdir)\" \ -DTOPSRCDIR=\"$(TOPSRC)\" \ -DSRCDIR=\"$(srcdir)\" \ + -DETCDIR=\"$(ETCDIR)\" \ -DBOOST_LOCALE_HIDE_AUTO_PTR \ -Wno-deprecated-declarations diff --git a/src/testsuite/libunderpass.all/geo-test.cc b/src/testsuite/libunderpass.all/geo-test.cc index 40051273..41060e6b 100644 --- a/src/testsuite/libunderpass.all/geo-test.cc +++ b/src/testsuite/libunderpass.all/geo-test.cc @@ -61,7 +61,9 @@ main(int argc, char* argv[]) return 1; } - if (tgu.readFile("ETCDIR/priority.geojson")) { + std::string filespec = ETCDIR; + filespec += "/priority.geojson"; + if (tgu.readFile(filespec)) { runtest.pass("Read file with absolute path"); } else { runtest.fail("Read file with absolute path"); diff --git a/src/underpass.cc b/src/underpass.cc index 3a38f6b1..689bd91f 100644 --- a/src/underpass.cc +++ b/src/underpass.cc @@ -85,7 +85,8 @@ main(int argc, char *argv[]) { std::string datadir = "replication/"; - std::string boundary = "ETCDIR/priority.geojson"; + std::string boundary = ETCDIR; + boundary += "/priority.geojson"; UnderpassConfig config;