From c2b1f8842abf191b39e2c663f1d55815d0c71fcf Mon Sep 17 00:00:00 2001 From: Denis <146707790+dnzbk@users.noreply.github.com> Date: Wed, 9 Oct 2024 17:37:02 +0300 Subject: [PATCH] Fix: nzbget.conf.template installation path (#405) --- cmake/install.cmake | 48 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/cmake/install.cmake b/cmake/install.cmake index 91c48b31a..090fd4c85 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -1,15 +1,19 @@ -set(DOC_FILES - ${CMAKE_SOURCE_DIR}/ChangeLog.md - ${CMAKE_SOURCE_DIR}/COPYING -) -set(SHARE_DIR ${CMAKE_INSTALL_PREFIX}/share/${PACKAGE}) -set(CONF_FILE ${CMAKE_SOURCE_DIR}/nzbget.conf) -set(WEBUI_DIR ${CMAKE_SOURCE_DIR}/webui) -set(DOC_FILES_DEST ${SHARE_DIR}/doc) -set(CONF_TEMPLATE_FILE_DEST ${SHARE_DIR}) -set(WEBUI_DIR_DEST ${SHARE_DIR}) +set(CONF_FILE nzbget.conf) +set(SHARE_DIR_DEST ${CMAKE_INSTALL_PREFIX}/share/${PACKAGE}) +set(DOC_FILES_SRC ${CMAKE_SOURCE_DIR}/ChangeLog.md ${CMAKE_SOURCE_DIR}/COPYING) +set(CONF_FILE_SRC ${CMAKE_SOURCE_DIR}/${CONF_FILE}) +set(WEBUI_DIR_SRC ${CMAKE_SOURCE_DIR}/webui) +set(DOC_FILES_DEST ${SHARE_DIR_DEST}/doc) +set(WEBUI_DIR_DEST ${SHARE_DIR_DEST}) +set(TEMPLATE_CONF_FILE_DEST ${SHARE_DIR_DEST}) +set(CONF_FILE_DEST ${CMAKE_INSTALL_PREFIX}/etc) set(BIN_FILE_DEST ${CMAKE_INSTALL_PREFIX}/bin) +file(READ ${CONF_FILE_SRC} CONFIG_CONTENT) +string(REPLACE "WebDir=" "WebDir=${WEBUI_DIR_DEST}/webui" MODIFIED_CONFIG_CONTENT "${CONFIG_CONTENT}") +string(REPLACE "ConfigTemplate=" "ConfigTemplate=${TEMPLATE_CONF_FILE_DEST}/${CONF_FILE}" MODIFIED_CONFIG_CONTENT "${MODIFIED_CONFIG_CONTENT}") +file(WRITE ${CMAKE_BINARY_DIR}/${CONF_FILE} ${MODIFIED_CONFIG_CONTENT}) + install(TARGETS ${PACKAGE} PERMISSIONS OWNER_EXECUTE OWNER_WRITE @@ -18,32 +22,26 @@ install(TARGETS ${PACKAGE} PERMISSIONS GROUP_EXECUTE WORLD_READ WORLD_EXECUTE - DESTINATION ${BIN_FILE_DEST}) -install(FILES ${DOC_FILES} DESTINATION ${DOC_FILES_DEST}) -install(DIRECTORY ${WEBUI_DIR} DESTINATION ${WEBUI_DIR_DEST}) - -file(READ ${CONF_FILE} CONFIG_CONTENT) -string(REPLACE "WebDir=" "WebDir=${WEBUI_DIR_DEST}/webui" MODIFIED_CONFIG_CONTENT "${CONFIG_CONTENT}") -string(REPLACE "ConfigTemplate=" "ConfigTemplate=${CONF_TEMPLATE_FILE_DEST}/nzbget.conf" MODIFIED_CONFIG_CONTENT "${MODIFIED_CONFIG_CONTENT}") -file(WRITE ${CMAKE_BINARY_DIR}/nzbget.conf "${MODIFIED_CONFIG_CONTENT}") + DESTINATION ${BIN_FILE_DEST} +) +install(DIRECTORY ${WEBUI_DIR_SRC} DESTINATION ${WEBUI_DIR_DEST}) +install(FILES ${DOC_FILES_SRC} DESTINATION ${DOC_FILES_DEST}) +install(FILES ${CMAKE_BINARY_DIR}/${CONF_FILE} DESTINATION ${TEMPLATE_CONF_FILE_DEST}) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -E remove_directory ${DOC_FILES_DEST} - COMMAND ${CMAKE_COMMAND} -E remove_directory ${SHARE_DIR} + COMMAND ${CMAKE_COMMAND} -E remove_directory ${SHARE_DIR_DEST} COMMAND ${CMAKE_COMMAND} -E remove ${BIN_FILE_DEST}/${PACKAGE} COMMENT "Uninstalling" ${PACKAGE} ) add_custom_target(install-conf - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_INSTALL_PREFIX}/etc - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/nzbget.conf ${CMAKE_INSTALL_PREFIX}/etc/nzbget.conf - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/nzbget.conf ${CONF_TEMPLATE_FILE_DEST}/nzbget.conf + COMMAND ${CMAKE_COMMAND} -E make_directory ${CONF_FILE_DEST} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/${CONF_FILE} ${CONF_FILE_DEST}/${CONF_FILE} COMMENT "Installing nzbget.conf" ) add_custom_target(uninstall-conf - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_INSTALL_PREFIX}/etc - COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_INSTALL_PREFIX}/etc/nzbget.conf - COMMAND ${CMAKE_COMMAND} -E remove ${CONF_TEMPLATE_FILE_DEST}/nzbget.conf + COMMAND ${CMAKE_COMMAND} -E remove ${CONF_FILE_DEST}/${CONF_FILE} COMMENT "Unstalling nzbget.conf" )