build: un-hardcode prefix
/usr/share/pldm, /var/lib/pldm, and /etc are hardcoded in many places.
Workflows such as:
meson -Dprefix=$HOME/workspace -Dsysconfdir=$HOME/workspace builddir \
&& ninja -C buildir install
result in pldmd looking for its data in the wrong place. Fix by
properly incorporating the user specified prefix into filesystem paths.
A number of paths remain hardcoded because they (presumably?) are owned
and provided by other packages (phosphor-software-manager) and those
packages do not provide any pkg-config from which we can extract their
installation prefixes.
Change-Id: I140d7a65e85342fd108af41f33010b422a0f77a5
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/common/utils.cpp b/common/utils.cpp
index 97fc1dd..31449dc 100644
--- a/common/utils.cpp
+++ b/common/utils.cpp
@@ -1,3 +1,5 @@
+#include "config.h"
+
#include "utils.hpp"
#include "libpldm/pdr.h"
@@ -24,7 +26,6 @@
constexpr auto mapperBusName = "xyz.openbmc_project.ObjectMapper";
constexpr auto mapperPath = "/xyz/openbmc_project/object_mapper";
constexpr auto mapperInterface = "xyz.openbmc_project.ObjectMapper";
-constexpr auto eidPath = "/usr/share/pldm/host_eid";
std::vector<std::vector<uint8_t>> findStateEffecterPDR(uint8_t /*tid*/,
uint16_t entityID,
@@ -137,7 +138,7 @@
uint8_t readHostEID()
{
uint8_t eid{};
- std::ifstream eidFile{eidPath};
+ std::ifstream eidFile{HOST_EID_PATH};
if (!eidFile.good())
{
std::cerr << "Could not open host EID file"
diff --git a/configurations/meson.build b/configurations/meson.build
index ccb9b62..5c6c605 100644
--- a/configurations/meson.build
+++ b/configurations/meson.build
@@ -1,27 +1,20 @@
-packagedir = join_paths(
- get_option('prefix'),
- get_option('datadir'),
- meson.project_name(),
-)
+install_subdir('pdr', install_dir: package_datadir)
+install_subdir('host', install_dir: package_datadir)
-install_subdir('pdr', install_dir: packagedir)
-
-install_subdir('host', install_dir: packagedir)
-
-install_subdir('events', install_dir: packagedir)
+install_subdir('events', install_dir: package_datadir)
if get_option('oem-ibm').disabled()
-install_data('fru_master.json', install_dir: packagedir)
+install_data('fru_master.json', install_dir: package_datadir)
endif
if get_option('oem-ibm').enabled()
- install_subdir('../oem/ibm/configurations/fru', install_dir: packagedir)
- install_subdir('../oem/ibm/configurations/events', install_dir: packagedir)
- install_subdir('../oem/ibm/configurations/bios', install_dir: packagedir)
- install_data('../oem/ibm/configurations/fru_master.json',install_dir: packagedir)
+ install_subdir('../oem/ibm/configurations/fru', install_dir: package_datadir)
+ install_subdir('../oem/ibm/configurations/events', install_dir: package_datadir)
+ install_subdir('../oem/ibm/configurations/bios', install_dir: package_datadir)
+ install_data('../oem/ibm/configurations/fru_master.json',install_dir: package_datadir)
install_data('../oem/ibm/configurations/fileTable.json',
- install_dir: packagedir)
- install_data('../oem/ibm/configurations/host_eid', install_dir: packagedir)
+ install_dir: package_datadir)
+ install_data('../oem/ibm/configurations/host_eid', install_dir: package_datadir)
endif
diff --git a/meson.build b/meson.build
index 949d889..92315ac 100644
--- a/meson.build
+++ b/meson.build
@@ -21,22 +21,25 @@
message('Disabling FORTIFY_SOURCE as optimization is set to 0')
endif
+package_datadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
+package_localstatedir = join_paths(get_option('prefix'), get_option('localstatedir'), meson.project_name())
+
conf_data = configuration_data()
if get_option('libpldmresponder').enabled()
-conf_data.set_quoted('BIOS_JSONS_DIR', '/usr/share/pldm/bios')
-conf_data.set_quoted('BIOS_TABLES_DIR', '/var/lib/pldm/bios')
-conf_data.set_quoted('PDR_JSONS_DIR', '/usr/share/pldm/pdr')
-conf_data.set_quoted('FRU_JSONS_DIR', '/usr/share/pldm/fru')
-conf_data.set_quoted('FRU_MASTER_JSON', '/usr/share/pldm/fru_master.json')
-conf_data.set_quoted('HOST_JSONS_DIR', '/usr/share/pldm/host')
-conf_data.set_quoted('EVENTS_JSONS_DIR', '/usr/share/pldm/events')
+conf_data.set_quoted('BIOS_JSONS_DIR', join_paths(package_datadir, 'bios'))
+conf_data.set_quoted('BIOS_TABLES_DIR', join_paths(package_localstatedir, 'bios'))
+conf_data.set_quoted('PDR_JSONS_DIR', join_paths(package_datadir, 'pdr'))
+conf_data.set_quoted('FRU_JSONS_DIR', join_paths(package_datadir, 'fru'))
+conf_data.set_quoted('FRU_MASTER_JSON', join_paths(package_datadir, 'fru_master.json'))
+conf_data.set_quoted('HOST_JSONS_DIR', join_paths(package_datadir, 'host'))
+conf_data.set_quoted('EVENTS_JSONS_DIR', join_paths(package_datadir, 'events'))
add_project_arguments('-DLIBPLDMRESPONDER', language : ['c','cpp'])
endif
if get_option('softoff').enabled()
conf_data.set('SOFTOFF_TIMEOUT_SECONDS', get_option('softoff-timeout-seconds'))
endif
if get_option('oem-ibm').enabled()
- conf_data.set_quoted('FILE_TABLE_JSON', '/usr/share/pldm/fileTable.json')
+ conf_data.set_quoted('FILE_TABLE_JSON', join_paths(package_datadir, 'fileTable.json'))
conf_data.set_quoted('LID_RUNNING_DIR', '/var/lib/phosphor-software-manager/hostfw/running')
conf_data.set_quoted('LID_ALTERNATE_DIR', '/var/lib/phosphor-software-manager/hostfw/alternate')
conf_data.set_quoted('LID_STAGING_DIR', '/var/lib/phosphor-software-manager/hostfw/staging')
@@ -51,6 +54,9 @@
conf_data.set('NUMBER_OF_REQUEST_RETRIES', get_option('number-of-request-retries'))
conf_data.set('INSTANCE_ID_EXPIRATION_INTERVAL',get_option('instance-id-expiration-interval'))
conf_data.set('RESPONSE_TIME_OUT',get_option('response-time-out'))
+if get_option('libpldm-only').disabled()
+ conf_data.set_quoted('HOST_EID_PATH', join_paths(package_datadir, 'host_eid'))
+endif
configure_file(output: 'config.h',
configuration: conf_data
)
@@ -208,7 +214,7 @@
output: 'pldm_verbosity',
configuration: conf_data,
install: true,
- install_dir: '/etc/default')
+ install_dir: join_paths(get_option('sysconfdir'), 'default'))
if get_option('oem-ibm').enabled()
subdir('oem/ibm/service_files')