diff --git a/aux/broccoli b/aux/broccoli index c2769d9cd8..ab273570c2 160000 --- a/aux/broccoli +++ b/aux/broccoli @@ -1 +1 @@ -Subproject commit c2769d9cd826ecaa08431d6af329db75a7d43583 +Subproject commit ab273570c22b04f977877a2eb707c982319fd9c7 diff --git a/aux/broctl b/aux/broctl index 13986eb507..1fe790706f 160000 --- a/aux/broctl +++ b/aux/broctl @@ -1 +1 @@ -Subproject commit 13986eb50729f45834eb050be4a6233c83f9295d +Subproject commit 1fe790706fcf3d9338b8fb073956c02a55686bb0 diff --git a/cmake/ConfigurePackaging.cmake b/cmake/ConfigurePackaging.cmake index 51f1c04d96..f77dcc0fae 100644 --- a/cmake/ConfigurePackaging.cmake +++ b/cmake/ConfigurePackaging.cmake @@ -140,14 +140,12 @@ macro(SetPackageMetadata) set(CPACK_RPM_PACKAGE_LICENSE "BSD") endmacro(SetPackageMetadata) -# Sets pre and post install scripts for PackageMaker and RPM packages. +# Sets pre and post install scripts for PackageMaker packages. # The main functionality that such scripts offer is a way to make backups # of "configuration" files that a user may have modified. -# A better way to prevent an RPM from not overwriting config files is -# with the %config(noreplace) .spec attribute, but CPack does not have any -# good hooks into using that yet, so we re-use the pre/post install scripts -# See also: http://public.kitware.com/Bug/view.php?id=10294 -macro(SetPackageInstallScripts) +# Note that RPMs already have a robust mechanism for dealing with +# user-modified files, so we do not need this additional functionality +macro(SetPackageInstallScripts VERSION) if (INSTALLED_CONFIG_FILES) # Remove duplicates from the list of installed config files @@ -160,6 +158,14 @@ macro(SetPackageInstallScripts) set(INSTALLED_CONFIG_FILES "${_tmp}" CACHE STRING "" FORCE) endif () + if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + # Leaving the set of installed config files empty will just + # bypass the logic in the pre/post install scripts and let + # the RPM do their own thing (regarding backups, etc.) + # when upgrading packages. + set (INSTALLED_CONFIG_FILES "") + endif () + if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/package_preinstall.sh.in) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/package_preinstall.sh.in @@ -189,7 +195,7 @@ macro(ConfigurePackaging _version) SetPackageGenerators() SetPackageFileName(${_version}) SetPackageMetadata() - SetPackageInstallScripts() + SetPackageInstallScripts(${_version}) set(CPACK_SET_DESTDIR true) set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) diff --git a/cmake/MAC_PACKAGE_INTRO b/cmake/MAC_PACKAGE_INTRO index b1fc25891b..ef37e62a1a 100644 --- a/cmake/MAC_PACKAGE_INTRO +++ b/cmake/MAC_PACKAGE_INTRO @@ -15,10 +15,6 @@ destination as the one that contains the root filesystem. If you have existing configuration files that are modified or otherwise different from the version included in the package, -this installer will attempt to prevent clobbering them by -backing them up like: - - @CMAKE_INSTALL_PREFIX@/etc/. - +this installer will attempt to prevent overwirting them, but its also advisable to make your own backups of important files before proceeding. diff --git a/cmake/package_postupgrade.sh.in b/cmake/package_postupgrade.sh.in index 6cae58dc9f..7ae35185f6 100755 --- a/cmake/package_postupgrade.sh.in +++ b/cmake/package_postupgrade.sh.in @@ -3,8 +3,9 @@ # This script is meant to be used by binary packages post-installation. # Variables between @ symbols are replaced by CMake at configure time. -backupDesc="# Backup made by install of @CMAKE_PROJECT_NAME@ version @VERSION@" backupNamesFile=/tmp/bro_install_backups +version=@VERSION@ +newFiles="" # check whether it's safe to remove backup configuration files that # the most recent package install created @@ -13,22 +14,25 @@ if [ -e ${backupNamesFile} ]; then backupFileList=`cat ${backupNamesFile}` for backupFile in ${backupFileList}; do - origFile=`echo ${backupFile} | sed 's/\(.*\)\..*/\1/'` + origFileName=`echo ${backupFile} | sed 's/\(.*\)\..*/\1/'` - diff ${origFile} ${backupFile} > /dev/null 2>&1 + diff ${origFileName} ${backupFile} > /dev/null 2>&1 if [ $? -eq 0 ]; then # if the installed version and the backup version don't differ # then we can remove the backup version rm ${backupFile} else - # keep the backup, prepend text explaining what created it - tmpfile=/tmp/bro_install_tmp$$ - echo ${backupDesc} > ${tmpfile} - echo "" >> ${tmpfile} - cat ${backupFile} >> ${tmpfile} - cp ${tmpfile} ${backupFile} - rm ${tmpfile} + # The backup file differs from the newly installed version, + # since we can't tell if the backup version has been modified + # by the user, we should restore it to its original location + # and rename the new version appropriately. + + newFileName=${origFileName}.${version} + newFiles="${newFiles}\n${newFileName}" + + mv ${origFileName} ${newFileName} + mv ${backupFile} ${origFileName} fi done @@ -36,6 +40,16 @@ if [ -e ${backupNamesFile} ]; then rm ${backupNamesFile} fi +if [ -n "${newFiles}" ]; then +# Use some apple script to display a message to user +/usr/bin/osascript << EOF + tell application "System Events" + activate + display alert "Existing configuration files differ from the ones that would be installed by this package. To avoid overwriting configuration which you may have modified, the following new config files have been installed:\n${newFiles}\n\nIf you have previously modified configuration files, please make sure that they are still compatible, else you should update your config files to the new versions." + end tell +EOF +fi + # make sure that world-writeable dirs have the sticky bit set # so that unprivileged can't rename/remove files within