Move service files into repo and clean up OVERLAYS
Upstream request is to have service files in repo now.
Also limit scope of OVERLAYS flag to allow exports to
still work.
Change-Id: I61c8621a648556d277d4faf3dfe38a61343053ce
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c8cce5b..20bd146 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -115,7 +115,16 @@
add_dependencies (fru-device sdbusplus-project)
endif ()
-install (TARGETS fru-device entity-manager DESTINATION bin)
-install (DIRECTORY configurations DESTINATION share)
-install (DIRECTORY overlay_templates DESTINATION share)
-install (DIRECTORY schemas DESTINATION share/configurations)
+set (
+ SERVICE_FILES
+ ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.EntityManager.service
+ ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.FruDevice.service
+)
+
+set (PACKAGE_DIR /usr/share/entity-manager/)
+target_compile_definitions (entity-manager PRIVATE PACKAGE_DIR="${PACKAGE_DIR}")
+install (TARGETS fru-device entity-manager DESTINATION sbin)
+install (DIRECTORY configurations DESTINATION ${PACKAGE_DIR})
+install (DIRECTORY overlay_templates DESTINATION ${PACKAGE_DIR})
+install (DIRECTORY schemas DESTINATION ${PACKAGE_DIR}/configurations)
+install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/)
diff --git a/service_files/xyz.openbmc_project.EntityManager.service b/service_files/xyz.openbmc_project.EntityManager.service
new file mode 100644
index 0000000..aca242a
--- /dev/null
+++ b/service_files/xyz.openbmc_project.EntityManager.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Entity Manager
+Wants=mapper-wait@-xyz-openbmc_project-FruDevice.service
+After=mapper-wait@-xyz-openbmc_project-FruDevice.service
+ConditionFileNotEmpty={bindir}/entity-manager
+
+[Service]
+ExecStartPre=/bin/mkdir -p /var/configuration
+ExecStartPre=/bin/mkdir -p /tmp/overlays
+ExecStart=/usr/sbin/entity-manager
+Restart=always
+Type=simple
+
+[Install]
+WantedBy=basic.target
diff --git a/service_files/xyz.openbmc_project.FruDevice.service b/service_files/xyz.openbmc_project.FruDevice.service
new file mode 100644
index 0000000..7d69c31
--- /dev/null
+++ b/service_files/xyz.openbmc_project.FruDevice.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Fru Device
+ConditionFileNotEmpty={bindir}/fru-device
+StopWhenUnneeded=true
+After=xyz.openbmc_project.CloseMuxes.service dbus.service
+
+[Service]
+ExecStart=/usr/sbin/fru-device
+Type=oneshot
+
+[Install]
+WantedBy=basic.target
diff --git a/src/EntityManager.cpp b/src/EntityManager.cpp
index a0fa904..cd14cc1 100644
--- a/src/EntityManager.cpp
+++ b/src/EntityManager.cpp
@@ -32,8 +32,8 @@
#include <experimental/filesystem>
constexpr const char *OUTPUT_DIR = "/var/configuration/";
-constexpr const char *configurationDirectory = "/usr/share/configurations";
-constexpr const char *schemaDirectory = "/usr/share/configurations/schemas";
+constexpr const char *configurationDirectory = PACKAGE_DIR "configurations";
+constexpr const char *schemaDirectory = PACKAGE_DIR "configurations/schemas";
constexpr const char *globalSchema = "global.json";
constexpr const char *TEMPLATE_CHAR = "$";
constexpr const size_t PROPERTIES_CHANGED_UNTIL_FLUSH_COUNT = 20;
@@ -1428,12 +1428,8 @@
registerCallbacks(io, dbusMatches, systemConfiguration,
objServer);
io.post([&, newConfiguration]() {
-
-#ifdef OVERLAYS
- // todo: for now, only add new configurations,
- // unload to come later unloadOverlays();
loadOverlays(newConfiguration);
-#endif
+
io.post([&]() {
if (!writeJsonFiles(systemConfiguration))
{
@@ -1512,7 +1508,9 @@
inventoryIface->initialize();
io.post([&]() {
+#if OVERLAYS
unloadAllOverlays();
+#endif
propertiesChangedCallback(io, dbusMatches, systemConfiguration,
objServer);
});
diff --git a/src/Overlay.cpp b/src/Overlay.cpp
index f937dbe..0f25eb5 100644
--- a/src/Overlay.cpp
+++ b/src/Overlay.cpp
@@ -30,7 +30,7 @@
constexpr const char *DT_OVERLAY = "/usr/bin/dtoverlay";
constexpr const char *DTC = "/usr/bin/dtc";
constexpr const char *OUTPUT_DIR = "/tmp/overlays";
-constexpr const char *TEMPLATE_DIR = "/usr/share/overlay_templates";
+constexpr const char *TEMPLATE_DIR = PACKAGE_DIR "overlay_templates";
constexpr const char *TEMPLATE_CHAR = "$";
constexpr const char *HEX_FORMAT_STR = "0x";
constexpr const char *PLATFORM = "aspeed,ast2500";
@@ -356,6 +356,8 @@
continue;
}
std::string type = findType.value().get<std::string>();
+#if OVERLAYS
+
std::string typeFile = type + std::string(".template");
for (const auto &path : paths)
{
@@ -366,7 +368,7 @@
createOverlay(path.string(), configuration);
break;
}
-
+#endif
auto device = devices::exportTemplates.find(type.c_str());
if (device != devices::exportTemplates.end())
{