diff --git a/packaging/build_deb.sh b/packaging/build_deb.sh index 44ecbb347..12625fe16 100755 --- a/packaging/build_deb.sh +++ b/packaging/build_deb.sh @@ -9,10 +9,26 @@ function check_command { fi } +function header_version { + read -d '' version_script << 'EOF' + BEGIN { major="?"; minor="?"; patch="?" } + /CASS_VERSION_MAJOR/ { major=$3 } + /CASS_VERSION_MINOR/ { minor=$3 } + /CASS_VERSION_PATCH/ { patch=$3 } + END { printf "%s.%s.%s", major, minor, patch } +EOF + version=$(grep '#define[ \t]\+CASS_VERSION_\(MAJOR\|MINOR\|PATCH\)' $1 | awk "$version_script") + if [[ ! $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Unable to extract version from $1" + exit 1 + fi + echo "$version" +} + check_command "dch" "debhelper" check_command "lsb_release" "lsb-release" -version="2.2.1" +version=$(header_version "../include/cassandra.h") release=1 dist=$(lsb_release -s -c) base="cassandra-cpp-driver-$version" diff --git a/packaging/build_rpm.sh b/packaging/build_rpm.sh index a5911bfb2..65907eb68 100755 --- a/packaging/build_rpm.sh +++ b/packaging/build_rpm.sh @@ -9,6 +9,22 @@ function check_command { fi } +function header_version { + read -d '' version_script << 'EOF' + BEGIN { major="?"; minor="?"; patch="?" } + /CASS_VERSION_MAJOR/ { major=$3 } + /CASS_VERSION_MINOR/ { minor=$3 } + /CASS_VERSION_PATCH/ { patch=$3 } + END { printf "%s.%s.%s", major, minor, patch } +EOF + version=$(grep '#define[ \t]\+CASS_VERSION_\(MAJOR\|MINOR\|PATCH\)' $1 | awk "$version_script") + if [[ ! $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Unable to extract version from $1" + exit 1 + fi + echo "$version" +} + # 'redhat-rpm-config' needs to be installed for the 'debuginfo' package check_command "rpmbuild" "rpm-build" @@ -17,7 +33,7 @@ if [[ ! -z $1 ]]; then arch=$1 fi -version="2.2.1" +version=$(header_version "../include/cassandra.h") base="cassandra-cpp-driver-$version" archive="$base.tar.gz" files="CMakeLists.txt cmake_uninstall.cmake.in include src README.md LICENSE.txt"