forked from apache/cassandra-cpp-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_deb.sh
More file actions
executable file
·76 lines (65 loc) · 1.92 KB
/
build_deb.sh
File metadata and controls
executable file
·76 lines (65 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
function check_command {
command=$1
package=$2
if ! type "$command" > /dev/null 2>&1; then
echo "Missing command '$command', run: apt-get install $package"
exit 1
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 }
/CASS_VERSION_SUFFIX/ { suffix=$3; gsub(/"/, "", suffix) }
END {
if (length(suffix) > 0)
printf "%s.%s.%s~%s", major, minor, patch, suffix
else
printf "%s.%s.%s", major, minor, patch
}
EOF
version=$(grep '#define[ \t]\+CASS_VERSION_\(MAJOR\|MINOR\|PATCH\|SUFFIX\)' $1 | awk "$version_script")
if [[ ! $version =~ ^[0-9]+\.[0-9]+\.[0-9]+(~[a-zA-Z0-9_\-]+)?$ ]]; then
echo "Unable to extract version from $1"
exit 1
fi
echo "$version"
}
check_command "dch" "devscripts"
check_command "lsb_release" "lsb-release"
version=$(header_version "../include/cassandra.h")
release=1
dist=$(lsb_release -s -c)
base="cassandra-cpp-driver-$version"
archive="$base.tar.gz"
files="CMakeLists.txt cmake cmake_uninstall.cmake.in driver_config.hpp.in include src"
echo "Building version $version"
libuv_version=$(dpkg -s libuv1 | grep 'Version' | awk '{ print $2 }')
if [[ -e $libuv_version ]]; then
echo "'libuv' required, but not installed"
exit 1
fi
echo "Using libuv version $libuv_version"
if [[ -d build ]]; then
read -p "Build directory exists, remove? [y|n] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -rf build
fi
fi
mkdir -p "build/$base"
echo "Copying files"
for file in $files; do
cp -r "../$file" "build/$base"
done
cp -r debian "build/$base"
pushd "build/$base"
echo "Updating changlog"
dch -m -v "$version-$release" -D $dist "Version $version"
echo "Building package:"
nprocs=$(grep -e '^processor' -c /proc/cpuinfo)
DEB_BUILD_OPTIONS="parallel=$nprocs" debuild -i -b -uc -us
popd