Skip to content

Commit

Permalink
cmake: install: do not overwrite bconsole.conf if already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorz committed Jul 14, 2020
1 parent 9473471 commit 8ee705a
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions core/src/console/CMakeLists.txt
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2017-2019 Bareos GmbH & Co. KG
# Copyright (C) 2017-2020 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -45,10 +45,30 @@ endif()

target_link_libraries(bconsole ${CONSOLE_LINK_LIBRARIES})

install(TARGETS bconsole DESTINATION "${bindir}" COMPONENT bconsole)
install(TARGETS bconsole DESTINATION "${sbindir}" COMPONENT bconsole)
install(
FILES bconsole.conf
DESTINATION "${configtemplatedir}"
TARGETS bconsole
DESTINATION "${bindir}"
COMPONENT bconsole
)
install(
TARGETS bconsole
DESTINATION "${sbindir}"
COMPONENT bconsole
)

install(
CODE "
message(STATUS \"DESTDIR is \$ENV{DESTDIR}\")
set(DESTDIR \$ENV{DESTDIR})
#if(EXISTS \$ENV{DESTDIR}${configtemplatedir} AND NOT EXISTS \$ENV{DESTDIR}${configtemplatedir}/bconsole.conf)
if(NOT EXISTS \$ENV{DESTDIR}${configtemplatedir}/bconsole.conf)
message(STATUS \"Installing: \$ENV{DESTDIR}${configtemplatedir}/bconsole.conf\")
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/bconsole.conf DESTINATION \$ENV{DESTDIR}${configtemplatedir})
else()
message(STATUS \"Installing: \$ENV{DESTDIR}${configtemplatedir}/bconsole.conf.new\")
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/bconsole.conf ${CMAKE_CURRENT_SOURCE_DIR}/bconsole.conf.new)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/bconsole.conf.new DESTINATION \$ENV{DESTDIR}${configtemplatedir})
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/bconsole.conf.new ${CMAKE_CURRENT_SOURCE_DIR}/bconsole.conf)
endif()
"
)

0 comments on commit 8ee705a

Please sign in to comment.