From 2c179dd84f4c0ef886a5099199112af283297f2c Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Tue, 5 Jun 2018 11:34:01 +0200 Subject: [PATCH] add config install helper --- CMakeLists.txt | 7 ++++ cmake/modules/SRSLTE_install_configs.sh.in | 39 ++++++++++++++++++++++ srsenb/CMakeLists.txt | 8 ++--- srsepc/CMakeLists.txt | 8 ++--- srsue/CMakeLists.txt | 2 +- 5 files changed, 55 insertions(+), 9 deletions(-) create mode 100755 cmake/modules/SRSLTE_install_configs.sh.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 146c061d3..30986ece9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,6 +224,13 @@ set(INCLUDE_DIR include) set(DOC_DIR "share/doc/${CPACK_PACKAGE_NAME}") set(DATA_DIR share/${CPACK_PACKAGE_NAME}) +# Auto-generate config install helper and mark for installation +configure_file( + ${CMAKE_SOURCE_DIR}/cmake/modules/SRSLTE_install_configs.sh.in + ${CMAKE_BINARY_DIR}/srslte_install_configs.sh +) +install(PROGRAMS ${CMAKE_BINARY_DIR}/srslte_install_configs.sh DESTINATION ${RUNTIME_DIR}) + ######################################################################## # Compiler specific setup ######################################################################## diff --git a/cmake/modules/SRSLTE_install_configs.sh.in b/cmake/modules/SRSLTE_install_configs.sh.in new file mode 100755 index 000000000..8e143f74f --- /dev/null +++ b/cmake/modules/SRSLTE_install_configs.sh.in @@ -0,0 +1,39 @@ +#!/bin/bash + +# Auto-updated by CMake with actual install path +SRSLTE_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${DATA_DIR}" + +install_file(){ + source_path="$SRSLTE_INSTALL_DIR/$1" + dest_path="$HOME/.srs/${1%.example}" # Strip .example from it + + # Check if config file already exists in location + if [ -f $dest_path ]; then + echo "$dest_path already exists. Skipping it." + return + fi + + # Check if config file exists in source location + if [ -f $source_path ]; then + echo "Installing $1 in $dest_path" + cp $source_path $dest_path + else + echo "$source_path doesn't exist. Skipping it." + fi + + return +} + +# Install all srsLTE config files +echo "Installing srsLTE configuration files .." + +install_file "ue.conf.example" +install_file "enb.conf.example" +install_file "sib.conf.example" +install_file "rr.conf.example" +install_file "drb.conf.example" +install_file "epc.conf.example" +install_file "mbms.conf.example" +install_file "user_db.csv.example" + +echo "Done." diff --git a/srsenb/CMakeLists.txt b/srsenb/CMakeLists.txt index 4bcb12545..8a9f085d3 100644 --- a/srsenb/CMakeLists.txt +++ b/srsenb/CMakeLists.txt @@ -52,7 +52,7 @@ add_subdirectory(test) ######################################################################## # Default configuration files ######################################################################## -install(FILES enb.conf.example RENAME enb.conf DESTINATION etc/srs) -install(FILES drb.conf.example RENAME drb.conf DESTINATION etc/srs) -install(FILES rr.conf.example RENAME rr.conf DESTINATION etc/srs) -install(FILES sib.conf.example RENAME sib.conf DESTINATION etc/srs) \ No newline at end of file +install(FILES enb.conf.example DESTINATION ${DATA_DIR}) +install(FILES drb.conf.example DESTINATION ${DATA_DIR}) +install(FILES rr.conf.example DESTINATION ${DATA_DIR}) +install(FILES sib.conf.example DESTINATION ${DATA_DIR}) \ No newline at end of file diff --git a/srsepc/CMakeLists.txt b/srsepc/CMakeLists.txt index c51d17e23..0405fd958 100644 --- a/srsepc/CMakeLists.txt +++ b/srsepc/CMakeLists.txt @@ -51,7 +51,7 @@ add_subdirectory(src) ######################################################################## # Default configuration files ######################################################################## -install(FILES epc.conf.example RENAME epc.conf DESTINATION etc/srs) -install(FILES mbms.conf.example RENAME mbms.conf DESTINATION etc/srs) -install(FILES user_db.csv.example RENAME user_db.csv DESTINATION etc/srs) -install(FILES srsepc_if_masq.sh DESTINATION ${RUNTIME_DIR}) \ No newline at end of file +install(FILES epc.conf.example DESTINATION ${DATA_DIR}) +install(FILES mbms.conf.example DESTINATION ${DATA_DIR}) +install(FILES user_db.csv.example DESTINATION ${DATA_DIR}) +install(PROGRAMS srsepc_if_masq.sh DESTINATION ${RUNTIME_DIR}) \ No newline at end of file diff --git a/srsue/CMakeLists.txt b/srsue/CMakeLists.txt index 456c07523..2f9106827 100644 --- a/srsue/CMakeLists.txt +++ b/srsue/CMakeLists.txt @@ -48,4 +48,4 @@ add_subdirectory(test) ######################################################################## # Default configuration files ######################################################################## -install(FILES ue.conf.example RENAME ue.conf DESTINATION etc/srs) \ No newline at end of file +install(FILES ue.conf.example DESTINATION ${DATA_DIR}) \ No newline at end of file