Skip to content

Commit

Permalink
Extract packaging project version from cassandra.h
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenick committed Nov 23, 2015
1 parent ad9e02f commit 62df4f8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
18 changes: 17 additions & 1 deletion packaging/build_deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 17 additions & 1 deletion packaging/build_rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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"
Expand Down

0 comments on commit 62df4f8

Please sign in to comment.