From bf8480124980401052ee54f8121d6701ff043c3f Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Fri, 20 May 2011 17:08:59 -0500 Subject: [PATCH] Packaging tweaks and rewrite of 'dist' target. - Move binary packaging scripts out of source root into pkg/ subdir - A consistent CMake version (2.8.4) is now enforced for binary packaging - Added a 'bindist' target to top Makefile as a convenience - The 'dist' target has been rewritten to depend on standard system command/utils rather than CMake and the full dependency chain of Bro, addressing #398 (but the CMake 'package_source' target is still available in the generated build/Makefile and can be used if desired) --- Makefile | 72 ++++++++-------------- pkg/check-cmake | 14 +++++ make-deb-packages => pkg/make-deb-packages | 19 +++--- make-mac-packages => pkg/make-mac-packages | 17 ++--- make-rpm-packages => pkg/make-rpm-packages | 22 ++++--- 5 files changed, 66 insertions(+), 78 deletions(-) create mode 100755 pkg/check-cmake rename make-deb-packages => pkg/make-deb-packages (77%) rename make-mac-packages => pkg/make-mac-packages (84%) rename make-rpm-packages => pkg/make-rpm-packages (65%) diff --git a/Makefile b/Makefile index 77f0626cdc..863440661e 100644 --- a/Makefile +++ b/Makefile @@ -5,15 +5,12 @@ # to offer. For more, execute that one directly. # -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 +SOURCE=$(PWD) +BUILD=$(SOURCE)/build +TMP=/tmp/bro-dist.$(UID) +BRO_V=`cat $(SOURCE)/VERSION` +BROCCOLI_V=`cat $(SOURCE)/aux/broccoli/VERSION` +BROCTL_V=`cat $(SOURCE)/aux/broctl/VERSION` all: configured ( cd $(BUILD) && make ) @@ -31,39 +28,25 @@ doc: configured docclean: configured ( cd $(BUILD) && make docclean && make restclean ) -dist: cmake_version - # 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) \ - ) +dist: + @( mkdir -p $(BUILD) && rm -rf $(TMP) && mkdir $(TMP) ) + @cp -R $(SOURCE) $(TMP)/Bro-$(BRO_V) + @( cd $(TMP) && find . -name .git\* | xargs rm -rf ) + @( cd $(TMP) && find . -name \*.swp | xargs rm -rf ) + @( cd $(TMP) && find . -type d -name build | xargs rm -rf ) + @( cd $(TMP) && tar -czf $(BUILD)/Bro-all-$(BRO_V).tar.gz Bro-$(BRO_V) ) + @( cd $(TMP)/Bro-$(BRO_V)/aux && mv broccoli Broccoli-$(BROCCOLI_V) && \ + tar -czf $(BUILD)/Broccoli-$(BROCCOLI_V).tar.gz Broccoli-$(BROCCOLI_V) ) + @( cd $(TMP)/Bro-$(BRO_V)/aux && mv broctl Broctl-$(BROCTL_V) && \ + tar -czf $(BUILD)/Broctl-$(BROCTL_V).tar.gz Broctl-$(BROCTL_V) ) + @( cd $(TMP)/Bro-$(BRO_V)/aux && rm -rf Broctl* Broccoli* ) + @( cd $(TMP) && tar -czf $(BUILD)/Bro-$(BRO_V).tar.gz Bro-$(BRO_V) ) + @rm -rf $(TMP) + @echo "Distribution source tarballs have been compiled in $(BUILD)" + +bindist: + @( cd pkg && ( ./make-deb-packages || ./make-mac-packages || \ + ./make-rpm-packages ) ) distclean: rm -rf $(BUILD) @@ -72,7 +55,4 @@ configured: @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 ) -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 +.PHONY : all install clean doc docclean dist bindist distclean configured diff --git a/pkg/check-cmake b/pkg/check-cmake new file mode 100755 index 0000000000..2c3ed765a6 --- /dev/null +++ b/pkg/check-cmake @@ -0,0 +1,14 @@ +#!/bin/sh + +# CMake/CPack versions before 2.8.3 have bugs that can create bad packages +# Since packages will be built on several different systems, a single +# version of CMake is required to obtain consistency, but can be increased +# as new versions of CMake come out that also produce working packages. + +CMAKE_PACK_REQ="cmake version 2.8.4" +CMAKE_VER=`cmake -version` + +if [ "${CMAKE_VER}" != "${CMAKE_PACK_REQ}" ]; then + echo "Package creation requires ${CMAKE_PACK_REQ}" >&2 + exit 1 +fi diff --git a/make-deb-packages b/pkg/make-deb-packages similarity index 77% rename from make-deb-packages rename to pkg/make-deb-packages index c8d501198b..a9de210e52 100755 --- a/make-deb-packages +++ b/pkg/make-deb-packages @@ -1,35 +1,30 @@ #!/bin/sh # This script generates binary DEB 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_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 +./check-cmake || { exit 1; } # The DEB CPack generator depends on `dpkg-shlibdeps` to automatically # determine what dependencies to set for the packages type dpkg-shlibdeps > /dev/null 2>&1 || { echo "\ -Creating DEB packages requires the `dpkg-shlibs` command, usually provided by +Creating DEB packages requires the "dpkg-shlibs" command, usually provided by the 'dpkg-dev' package, please install it first. " >&2; exit 1; } +prefix=/opt/bro + # During the packaging process, `dpkg-shlibs` will fail if used on a library # that links to other internal/project libraries unless an RPATH is used or # we set LD_LIBRARY_PATH such that it can find the internal/project library # in the temporary packaging tree. export LD_LIBRARY_PATH=./${prefix}/lib +cd .. + # Minimum Bro ./configure --prefix=${prefix} --disable-broccoli --disable-broctl \ --pkg-name-prefix=Bro --binary-package diff --git a/make-mac-packages b/pkg/make-mac-packages similarity index 84% rename from make-mac-packages rename to pkg/make-mac-packages index c3b6736d20..a8f7f965c8 100755 --- a/make-mac-packages +++ b/pkg/make-mac-packages @@ -1,18 +1,9 @@ #!/bin/sh # 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_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 +./check-cmake || { exit 1; } type sw_vers > /dev/null 2>&1 || { echo "Unable to get Mac OS X version" >&2; @@ -38,6 +29,10 @@ else arch=x86_64 fi +prefix=/opt/bro + +cd .. + # Minimum Bro CMAKE_OSX_ARCHITECTURES=${arch} ./configure --prefix=${prefix} \ --disable-broccoli --disable-broctl --pkg-name-prefix=Bro \ diff --git a/make-rpm-packages b/pkg/make-rpm-packages similarity index 65% rename from make-rpm-packages rename to pkg/make-rpm-packages index 503d80ef4e..ac8dfa97b4 100755 --- a/make-rpm-packages +++ b/pkg/make-rpm-packages @@ -1,18 +1,22 @@ #!/bin/sh # This script generates binary RPM packages. -# They can be found in build/ after running. +# They can be found in ../build/ after running. + +./check-cmake || { exit 1; } + +# The RPM CPack generator depends on `rpmbuild` to create packages +type rpmbuild > /dev/null 2>&1 || { + echo "\ +Creating RPM packages requires the "rpmbuild" command, usually provided by +the 'rpm-build' package, please install it first. +" >&2; + exit 1; +} prefix=/opt/bro -# 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 +cd .. # Minimum Bro ./configure --prefix=${prefix} --disable-broccoli --disable-broctl \