Changes to the way user-modifiable config files are installed.

- Duplicates of the distribution's configuration files are now always
  installed with a .example suffix
- Added --binary-package configure option to toggle configure logic
  specific to the creation of binary packages.
- When not in binary packaging mode, `make install` never overwrites
  existing configure files in case they've been modified.  The previous
  behavior (CMake's default) would only avoid overwriting modified files
  if one consistently uses the same build directory and doesn't reconfigure.
- Fixed an issue with Mac package's pre-install script not preserving ACLs
- Minor cleanup/refactor of the make-mac/rpm-packages scripts
This commit is contained in:
Jon Siwek 2011-02-24 22:02:22 -06:00
parent f79a1f6e58
commit dec97ab56d
9 changed files with 100 additions and 48 deletions

@ -1 +1 @@
Subproject commit a1c6b6e59b3087b6b79a37a847c669b61ae2c522 Subproject commit df6b313720923848daa0cc5b047b49b5405799fe

@ -1 +1 @@
Subproject commit fc940bbb72abbaef2e5f10ea4ab616ec9b61fe0a Subproject commit 40261169619b678704b2c91e489499a8bd97aa87

View file

@ -0,0 +1,20 @@
# Determines at `make install` time if a file, typically a configuration
# file placed in $PREFIX/etc, shouldn't be installed to prevent overwrite
# of an existing file.
#
# _srcfile: the file to install
# _dstfile: the absolute file name after installation
macro(InstallClobberImmune _srcfile _dstfile)
install(CODE "
if (EXISTS ${_dstfile})
message(STATUS \"Skipping: ${_dstfile} (already exists)\")
else ()
message(STATUS \"Installing: ${_dstfile}\")
# install() is not scriptable within install(), and
# configure_file() is the next best thing
configure_file(${_srcfile} ${_dstfile} COPY_ONLY)
# TODO: create additional install_manifest files?
endif ()
")
endmacro(InstallClobberImmune)

View file

@ -0,0 +1,39 @@
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
# pre/post install scripts
# - If binary packaging is not enabled:
# Install the script in a way such that it will check at `make install`
# time whether the file does not exist. See InstallClobberImmune.cmake
#
# _srcfile: the absolute path to the file to install
# _dstdir: absolute path to the directory in which to install the file
# _dstfilename: how to (re)name the file inside _dstdir
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
# or native functionality of RPMs will take care of not clobbering it.
install(FILES ${_srcfile} DESTINATION ${_dstdir} RENAME ${_dstfilename})
# This cache variable is what the Mac package pre/post install scripts
# use to avoid clobbering user-modified config files
set(INSTALLED_CONFIG_FILES
"${INSTALLED_CONFIG_FILES} ${_dstfile}" CACHE STRING "" FORCE)
else ()
# Have `make install` check at run time whether the file does not exist
InstallClobberImmune(${_srcfile} ${_dstfile})
endif ()
endmacro(InstallPackageConfigFile)

View file

@ -5,7 +5,7 @@
backupNamesFile=/tmp/bro_install_backups backupNamesFile=/tmp/bro_install_backups
version=@VERSION@ version=@VERSION@
newFiles="" sampleFiles=""
# check whether it's safe to remove backup configuration files that # check whether it's safe to remove backup configuration files that
# the most recent package install created # the most recent package install created
@ -28,10 +28,8 @@ if [ -e ${backupNamesFile} ]; then
# by the user, we should restore it to its original location # by the user, we should restore it to its original location
# and rename the new version appropriately. # and rename the new version appropriately.
newFileName=${origFileName}.${version} sampleFiles="${sampleFiles}\n${origFileName}.example"
newFiles="${newFiles}\n${newFileName}"
mv ${origFileName} ${newFileName}
mv ${backupFile} ${origFileName} mv ${backupFile} ${origFileName}
fi fi
@ -40,12 +38,12 @@ if [ -e ${backupNamesFile} ]; then
rm ${backupNamesFile} rm ${backupNamesFile}
fi fi
if [ -n "${newFiles}" ]; then if [ -n "${sampleFiles}" ]; then
# Use some apple script to display a message to user # Use some apple script to display a message to user
/usr/bin/osascript << EOF /usr/bin/osascript << EOF
tell application "System Events" tell application "System Events"
activate 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." 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${sampleFiles}\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 end tell
EOF EOF
fi fi

View file

@ -20,7 +20,7 @@ backupFile () {
backupFile=${origFile}.${ver} backupFile=${origFile}.${ver}
cp ${origFile} ${backupFile} cp -p ${origFile} ${backupFile}
# the post upgrade script will check whether the installed # the post upgrade script will check whether the installed
# config file actually differs from existing version # config file actually differs from existing version

4
configure vendored
View file

@ -54,6 +54,7 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
--with-swig=PATH path to SWIG executable --with-swig=PATH path to SWIG executable
Packaging Options (for developers): Packaging Options (for developers):
--binary-package toggle special logic for binary packaging
--ignore-dirs=PATHS paths to ignore when creating source package --ignore-dirs=PATHS paths to ignore when creating source package
(semicolon delimited and quoted when multiple) (semicolon delimited and quoted when multiple)
--pkg-name-prefix=NAME use the given name as the package prefix instead --pkg-name-prefix=NAME use the given name as the package prefix instead
@ -195,6 +196,9 @@ while [ $# -ne 0 ]; do
--with-swig=*) --with-swig=*)
append_cache_entry SWIG_EXECUTABLE PATH $optarg append_cache_entry SWIG_EXECUTABLE PATH $optarg
;; ;;
--binary-package)
append_cache_entry BINARY_PACKAGING_MODE BOOL true
;;
--ignore-dirs=*) --ignore-dirs=*)
append_cache_entry CPACK_SOURCE_IGNORE_FILES STRING $optarg append_cache_entry CPACK_SOURCE_IGNORE_FILES STRING $optarg
;; ;;

View file

@ -3,6 +3,8 @@
# This script creates binary packages for Mac OS X. # This script creates binary packages for Mac OS X.
# They can be found in build/ after running. # They can be found in build/ after running.
prefix=/opt/bro
# CMake/CPack versions before 2.8.2 have bugs that can create bad packages # CMake/CPack versions before 2.8.2 have bugs that can create bad packages
CMAKE_PACK_REQ=2.8.3 CMAKE_PACK_REQ=2.8.3
CMAKE_VER=`cmake -version` CMAKE_VER=`cmake -version`
@ -37,31 +39,26 @@ else
fi fi
# Minimum Bro # Minimum Bro
CMAKE_OSX_ARCHITECTURES=${arch} ./configure --prefix=/opt/bro \ CMAKE_OSX_ARCHITECTURES=${arch} ./configure --prefix=${prefix} \
--disable-broccoli --disable-broctl --pkg-name-prefix=Bro --disable-broccoli --disable-broctl --pkg-name-prefix=Bro \
cd build --binary-package
make package ( cd build && make package )
cd ..
# Full Bro package # Full Bro package
CMAKE_OSX_ARCHITECTURES=${arch} ./configure --prefix=/opt/bro \ CMAKE_OSX_ARCHITECTURES=${arch} ./configure --prefix=${prefix} \
--pkg-name-prefix=Bro-all --pkg-name-prefix=Bro-all --binary-package
cd build ( cd build && make package )
make package
cd ..
# Broccoli # Broccoli
cd aux/broccoli cd aux/broccoli
CMAKE_OSX_ARCHITECTURES=${arch} ./configure --prefix=/opt/bro CMAKE_OSX_ARCHITECTURES=${arch} ./configure --prefix=${prefix} \
cd build --binary-package
make package ( cd build && make package && mv Broccoli*.dmg ../../../build/ )
mv Broccoli*.dmg ../../../build/ cd ../..
cd ../../..
# Broctl # Broctl
cd aux/broctl cd aux/broctl
CMAKE_OSX_ARCHITECTURES=${arch} ./configure --prefix=/opt/bro CMAKE_OSX_ARCHITECTURES=${arch} ./configure --prefix=${prefix} \
cd build --binary-package
make package ( cd build && make package && mv Broctl*.dmg ../../../build/ )
mv Broctl*.dmg ../../../build/ cd ../..
cd ../../..

View file

@ -3,6 +3,8 @@
# This script generates binary RPM packages. # This script generates binary RPM packages.
# They can be found in build/ after running. # They can be found in build/ after running.
prefix=/opt/bro
# CMake/CPack versions before 2.8.2 have bugs that can create bad packages # CMake/CPack versions before 2.8.2 have bugs that can create bad packages
CMAKE_PACK_REQ=2.8.2 CMAKE_PACK_REQ=2.8.2
CMAKE_VER=`cmake -version` CMAKE_VER=`cmake -version`
@ -13,30 +15,22 @@ if [ "${CMAKE_VER}" \< "${CMAKE_PACK_REQ}" ]; then
fi fi
# Minimum Bro # Minimum Bro
./configure --prefix=/opt/bro --disable-broccoli --disable-broctl \ ./configure --prefix=${prefix} --disable-broccoli --disable-broctl \
--pkg-name-prefix=Bro --pkg-name-prefix=Bro --binary-package
cd build ( cd build && make package )
make package
cd ..
# Full Bro package # Full Bro package
./configure --prefix=/opt/bro --pkg-name-prefix=Bro-all ./configure --prefix=${prefix} --pkg-name-prefix=Bro-all --binary-package
cd build ( cd build && make package )
make package
cd ..
# Broccoli # Broccoli
cd aux/broccoli cd aux/broccoli
./configure --prefix=/opt/bro ./configure --prefix=${prefix} --binary-package
cd build ( cd build && make package && mv Broccoli*.rpm ../../../build/ )
make package cd ../..
mv Broccoli*.rpm ../../../build/
cd ../../..
# Broctl # Broctl
cd aux/broctl cd aux/broctl
./configure --prefix=/opt/bro ./configure --prefix=${prefix} --binary-package
cd build ( cd build && make package && mv Broctl*.rpm ../../../build/ )
make package cd ../..
mv Broctl*.rpm ../../../build/
cd ../../..