Changes for packaging

- Added 'dist' target to top-level Makefile for doing source packages
- Added 'make-*-packages' scripts for generating binary packages
- Fixes for the ConfigurePackaging CMake script
  - No longer fails when package version doesn't include a patch-level
  - Now considers the case when a package doesn't install any
    config files and the INSTALLED_CONFIG_FILES var is empty
This commit is contained in:
Jon Siwek 2011-01-14 22:25:10 -06:00
parent 8d4f487add
commit 1d8ad8e946
8 changed files with 185 additions and 23 deletions

View file

@ -70,12 +70,18 @@ build/, using default build options. It then installs the Bro binary
into /usr/local/bro/bin. Depending on the Bro package you into /usr/local/bro/bin. Depending on the Bro package you
downloaded, there may be auxiliary tools and libraries available in downloaded, there may be auxiliary tools and libraries available in
the aux/ directory. If so, they will be installed by default as well the aux/ directory. If so, they will be installed by default as well
if not explicitly disabled via configure options. if not explicitly disabled via configure options and may also have
additional installation/configuration instructions that you can
find in their source directories.
You can specify a different installation directory with You can specify a different installation directory with
> ./configure --prefix=<dir> > ./configure --prefix=<dir>
Note that "/usr" and "/opt/bro" are standard prefixes for binary
packages to be installed, so those are typically not good choices
unless you are creating such a package.
Run "./configure --help" for more options. Run "./configure --help" for more options.
Running Bro Running Bro

View file

@ -6,6 +6,14 @@
# #
BUILD=build BUILD=build
BROCCOLI=aux/broccoli
BROCTL=aux/broctl
# CMake/CPack versions before 2.8.2 have bugs that can create bad packages
CMAKE_PACK_REQ=2.8.2
CMAKE_VER=`cmake -version`
OSX_VER_CMD=sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2
all: configured all: configured
( cd $(BUILD) && make ) ( cd $(BUILD) && make )
@ -16,13 +24,48 @@ install: configured
clean: configured clean: configured
( cd $(BUILD) && make clean ) ( cd $(BUILD) && make clean )
dist: configured dist: cmake_version
( cd $(BUILD) && make package_source ) # Minimum Bro source package
( \
./configure --ignore-dirs='aux/broctl;aux/broccoli' --pkg-name-prefix=Bro && \
cd $(BUILD) && \
make package_source \
)
# Full Bro source package
( \
./configure --pkg-name-prefix=Bro-all && \
cd $(BUILD) && \
make package_source \
)
# Broccoli source package
( \
cd $(BROCCOLI) && \
./configure && \
cd $(BUILD) && \
make package_source && \
mv Broccoli*.tar.gz ../../../$(BUILD)/ && \
cd .. && \
rm -r $(BUILD) \
)
# Broctl source package
( \
cd $(BROCTL) && \
./configure && \
cd $(BUILD) && \
make package_source && \
mv Broctl*.tar.gz ../../../$(BUILD)/ && \
cd .. && \
rm -r $(BUILD) \
)
distclean: distclean:
rm -rf $(BUILD) rm -rf $(BUILD)
.PHONY : configured
configured: configured:
@test -d $(BUILD) || ( echo "Error: No build/ directory found. Did you run configure?" && exit 1 ) @test -d $(BUILD) || ( echo "Error: No build/ directory found. Did you run configure?" && exit 1 )
@test -e $(BUILD)/Makefile || ( echo "Error: No build/Makefile found. Did you run configure?" && exit 1 ) @test -e $(BUILD)/Makefile || ( echo "Error: No build/Makefile found. Did you run configure?" && exit 1 )
cmake_version:
@test "$(CMAKE_VER)" \> "cmake version $(CMAKE_PACK_REQ)" || ( echo "Error: please use a CMake version greater than $(CMAKE_PACK_REQ)" && exit 1 )
.PHONY : all install clean distclean configured cmake_version

@ -1 +1 @@
Subproject commit b1336188695fb900ac30c48164fea831c2aae2f4 Subproject commit c2769d9cd826ecaa08431d6af329db75a7d43583

@ -1 +1 @@
Subproject commit a6ebc3ee2fc986a62244e03a3d7c7162aa33838b Subproject commit 13986eb50729f45834eb050be4a6233c83f9295d

View file

@ -4,7 +4,9 @@
# Sets CPack version variables by splitting the first macro argument # Sets CPack version variables by splitting the first macro argument
# using "." as a delimiter. If the length of the split list is # using "." as a delimiter. If the length of the split list is
# greater than 2, all remaining elements are tacked on to the patch # greater than 2, all remaining elements are tacked on to the patch
# level version. # level version. Not that the version set by the macro is internal
# to binary packaging, the file name of our package will reflect the
# exact version number.
macro(SetPackageVersion _version) macro(SetPackageVersion _version)
string(REPLACE "." " " version_numbers ${_version}) string(REPLACE "." " " version_numbers ${_version})
separate_arguments(version_numbers) separate_arguments(version_numbers)
@ -33,8 +35,10 @@ macro(SetPackageVersion _version)
${CPACK_PACKAGE_VERSION_MAJOR}) ${CPACK_PACKAGE_VERSION_MAJOR})
string(REGEX REPLACE "[_a-zA-Z-]" "" CPACK_PACKAGE_VERSION_MINOR string(REGEX REPLACE "[_a-zA-Z-]" "" CPACK_PACKAGE_VERSION_MINOR
${CPACK_PACKAGE_VERSION_MINOR}) ${CPACK_PACKAGE_VERSION_MINOR})
string(REGEX REPLACE "[_a-zA-Z-]" "" CPACK_PACKAGE_VERSION_PATCH if (CPACK_PACKAGE_VERSION_PATCH)
${CPACK_PACKAGE_VERSION_PATCH}) string(REGEX REPLACE "[_a-zA-Z-]" "" CPACK_PACKAGE_VERSION_PATCH
${CPACK_PACKAGE_VERSION_PATCH})
endif ()
endif () endif ()
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
@ -43,8 +47,10 @@ macro(SetPackageVersion _version)
${CPACK_PACKAGE_VERSION_MAJOR}) ${CPACK_PACKAGE_VERSION_MAJOR})
string(REGEX REPLACE "[-]" "" CPACK_PACKAGE_VERSION_MINOR string(REGEX REPLACE "[-]" "" CPACK_PACKAGE_VERSION_MINOR
${CPACK_PACKAGE_VERSION_MINOR}) ${CPACK_PACKAGE_VERSION_MINOR})
string(REGEX REPLACE "[-]" "" CPACK_PACKAGE_VERSION_PATCH if (CPACK_PACKAGE_VERSION_PATCH)
${CPACK_PACKAGE_VERSION_PATCH}) string(REGEX REPLACE "[-]" "" CPACK_PACKAGE_VERSION_PATCH
${CPACK_PACKAGE_VERSION_PATCH})
endif ()
endif () endif ()
# Minimum supported OS X version # Minimum supported OS X version
@ -143,14 +149,16 @@ endmacro(SetPackageMetadata)
# See also: http://public.kitware.com/Bug/view.php?id=10294 # See also: http://public.kitware.com/Bug/view.php?id=10294
macro(SetPackageInstallScripts) macro(SetPackageInstallScripts)
# Remove duplicates from the list of installed config files if (INSTALLED_CONFIG_FILES)
separate_arguments(INSTALLED_CONFIG_FILES) # Remove duplicates from the list of installed config files
list(REMOVE_DUPLICATES INSTALLED_CONFIG_FILES) separate_arguments(INSTALLED_CONFIG_FILES)
# Space delimit the list again list(REMOVE_DUPLICATES INSTALLED_CONFIG_FILES)
foreach (_file ${INSTALLED_CONFIG_FILES}) # Space delimit the list again
set(_tmp "${_tmp} ${_file}") foreach (_file ${INSTALLED_CONFIG_FILES})
endforeach () set(_tmp "${_tmp} ${_file}")
set(INSTALLED_CONFIG_FILES "${_tmp}" CACHE STRING "" FORCE) endforeach ()
set(INSTALLED_CONFIG_FILES "${_tmp}" CACHE STRING "" FORCE)
endif ()
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/package_preinstall.sh.in) if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/package_preinstall.sh.in)
configure_file( configure_file(

4
configure vendored
View file

@ -45,7 +45,6 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
--with-perftools=PATH path to Google Perftools install root --with-perftools=PATH path to Google Perftools install root
Packaging Options (for developers): Packaging Options (for developers):
--package toggles special build 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
@ -165,9 +164,6 @@ while [ $# -ne 0 ]; do
--with-perftools=*) --with-perftools=*)
append_cache_entry GooglePerftools_ROOT_DIR PATH $optarg append_cache_entry GooglePerftools_ROOT_DIR PATH $optarg
;; ;;
--package)
append_cache_entry 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
;; ;;

67
make-mac-packages Executable file
View file

@ -0,0 +1,67 @@
#!/bin/sh
# This script creates binary packages for Mac OS X.
# They can be found in build/ after running.
# CMake/CPack versions before 2.8.2 have bugs that can create bad packages
CMAKE_PACK_REQ=2.8.3
CMAKE_VER=`cmake -version`
if [ "${CMAKE_VER}" \< "${CMAKE_PACK_REQ}" ]; then
echo "Package creation requires CMake > 2.8.2" >&2
exit 1
fi
type sw_vers > /dev/null 2>&1 || {
echo "Unable to get Mac OS X version" >&2;
exit 1;
}
# Get the OS X minor version
# 5 = Leopard, 6 = Snow Leopard, 7 = Lion ...
osx_ver=`sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2`
if [ ${osx_ver} -lt 5 ]; then
echo "Packages for OS X < 10.5 are not supported" >&2
exit 1
elif [ ${osx_ver} -eq 5 ]; then
# On OS X 10.5, the x86_64 version of libresolv is broken,
# so we build for i386 as the easiest solution
arch=i386
else
# Currently it's just easiest to build the 10.5 package on
# on 10.5, but if it weren't for the libresolv issue, we could
# potentially build packages for older OS X version by using the
# --osx-sysroot and --osx-min-version options
arch=x86_64
fi
# Minimum Bro
CMAKE_OSX_ARCHITECTURES=${arch} ./configure --prefix=/opt/bro \
--disable-broccoli --disable-broctl --pkg-name-prefix=Bro
cd build
make package
cd ..
# Full Bro package
CMAKE_OSX_ARCHITECTURES=${arch} ./configure --prefix=/opt/bro \
--pkg-name-prefix=Bro-all
cd build
make package
cd ..
# Broccoli
cd aux/broccoli
CMAKE_OSX_ARCHITECTURES=${arch} ./configure --prefix=/opt/bro
cd build
make package
mv Broccoli*.dmg ../../../build/
cd ../../..
# Broctl
cd aux/broctl
CMAKE_OSX_ARCHITECTURES=${arch} ./configure --prefix=/opt/bro
cd build
make package
mv Broctl*.dmg ../../../build/
cd ../../..

42
make-rpm-packages Executable file
View file

@ -0,0 +1,42 @@
#!/bin/sh
# This script generates binary RPM packages.
# They can be found in build/ after running.
# CMake/CPack versions before 2.8.2 have bugs that can create bad packages
CMAKE_PACK_REQ=2.8.2
CMAKE_VER=`cmake -version`
if [ "${CMAKE_VER}" \< "${CMAKE_PACK_REQ}" ]; then
echo "Package creation requires CMake > 2.8.2" >&2
exit 1
fi
# Minimum Bro
./configure --prefix=/opt/bro --disable-broccoli --disable-broctl \
--pkg-name-prefix=Bro
cd build
make package
cd ..
# Full Bro package
./configure --prefix=/opt/bro --pkg-name-prefix=Bro-all
cd build
make package
cd ..
# Broccoli
cd aux/broccoli
./configure --prefix=/opt/bro
cd build
make package
mv Broccoli*.rpm ../../../build/
cd ../../..
# Broctl
cd aux/broctl
./configure --prefix=/opt/bro
cd build
make package
mv Broctl*.rpm ../../../build/
cd ../../..