mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
Install example config files dynamically.
They'll only get installed when the distribution version differs from existing version on disk.
This commit is contained in:
parent
0e5bc16a60
commit
ca95ad9618
3 changed files with 16 additions and 6 deletions
|
@ -9,6 +9,12 @@ macro(InstallClobberImmune _srcfile _dstfile)
|
|||
install(CODE "
|
||||
if (EXISTS ${_dstfile})
|
||||
message(STATUS \"Skipping: ${_dstfile} (already exists)\")
|
||||
execute_process(COMMAND \"${CMAKE_COMMAND}\" -E compare_files
|
||||
${_srcfile} ${_dstfile} RESULT_VARIABLE _diff)
|
||||
if (NOT \"\${_diff}\" STREQUAL \"0\")
|
||||
message(STATUS \"Installing: ${_dstfile}.example\")
|
||||
configure_file(${_srcfile} ${_dstfile}.example COPY_ONLY)
|
||||
endif ()
|
||||
else ()
|
||||
message(STATUS \"Installing: ${_dstfile}\")
|
||||
# install() is not scriptable within install(), and
|
||||
|
|
|
@ -3,7 +3,6 @@ include(InstallClobberImmune)
|
|||
# This macro can be used to install configuration files which
|
||||
# users are expected to modify after installation. It will:
|
||||
#
|
||||
# - Always install one version of the file with a .example suffix
|
||||
# - If binary packaging is enabled:
|
||||
# Install the file in the typical CMake fashion, but append to the
|
||||
# INSTALLED_CONFIG_FILES cache variable for use with the Mac package's
|
||||
|
@ -19,10 +18,6 @@ include(InstallClobberImmune)
|
|||
macro(InstallPackageConfigFile _srcfile _dstdir _dstfilename)
|
||||
set(_dstfile ${_dstdir}/${_dstfilename})
|
||||
|
||||
# Always install the latest version of the file renamed as an example
|
||||
install(FILES ${_srcfile} DESTINATION ${_dstdir}
|
||||
RENAME ${_dstfilename}.example)
|
||||
|
||||
if (BINARY_PACKAGING_MODE)
|
||||
# If packaging mode is enabled, always install the distribution's
|
||||
# version of the file. The Mac package's pre/post install scripts
|
||||
|
@ -32,6 +27,14 @@ macro(InstallPackageConfigFile _srcfile _dstdir _dstfilename)
|
|||
# use to avoid clobbering user-modified config files
|
||||
set(INSTALLED_CONFIG_FILES
|
||||
"${INSTALLED_CONFIG_FILES} ${_dstfile}" CACHE STRING "" FORCE)
|
||||
|
||||
# Additionally, the Mac PackageMaker packages don't have any automatic
|
||||
# handling of configuration file conflicts so install an example file
|
||||
# that the post install script will cleanup in the case it's extraneous
|
||||
if (APPLE)
|
||||
install(FILES ${_srcfile} DESTINATION ${_dstdir}
|
||||
RENAME ${_dstfilename}.example)
|
||||
endif ()
|
||||
else ()
|
||||
# Have `make install` check at run time whether the file does not exist
|
||||
InstallClobberImmune(${_srcfile} ${_dstfile})
|
||||
|
|
|
@ -20,8 +20,9 @@ if [ -e ${backupNamesFile} ]; then
|
|||
|
||||
if [ $? -eq 0 ]; then
|
||||
# if the installed version and the backup version don't differ
|
||||
# then we can remove the backup version
|
||||
# then we can remove the backup version and the example file
|
||||
rm ${backupFile}
|
||||
rm ${origFileName}.example
|
||||
else
|
||||
# The backup file differs from the newly installed version,
|
||||
# since we can't tell if the backup version has been modified
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue