-
Notifications
You must be signed in to change notification settings - Fork 6
/
build-packages.sh
executable file
·61 lines (51 loc) · 1.57 KB
/
build-packages.sh
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
#!/bin/bash
VERSION="2.0.7"
BUILD="1"
JAR="./dist/jrrd2-api-$VERSION.jar"
LIB="./dist/libjrrd2.so"
if [ ! -e build-packages.sh ]; then
echo "build-packages.sh must be ran from the root of the project."
fi
# Make sure fpm is installed before proceeding
which fpm >/dev/null
if [ $? -ne 0 ]; then
echo "The fpm command is not available. See https://github.com/jordansissel/fpm for installation instructions."
fi
set -e
# Cleanup
rm -f ./dist/*.rpm
rm -f ./dist/*.deb
rm -rf ./tmp && mkdir ./tmp
mkdir -p ./dist
function createPackage() {
TYPE="$1"
EXTRA_ARGUMENTS="$2"
fpm -s dir \
--name jrrd2 \
--description "A native interface to rrdtool for Java" \
--vendor "OpenNMS" \
--license "GPLv2" \
--maintainer "opennms@opennms.org" \
--url "https://github.com/OpenNMS/jrrd2" \
--version $VERSION \
-t $TYPE \
-C ./tmp/$TYPE \
-d "rrdtool > 1.5.0" \
-p ./dist $EXTRA_ARGUMENTS
}
# Build the tree for the .rpm package
mkdir -p ./tmp/rpm/usr/lib64
mkdir -p ./tmp/rpm/usr/share/java
cp $LIB ./tmp/rpm/usr/lib64/libjrrd2.so
chmod 755 ./tmp/rpm/usr/lib64/libjrrd2.so
cp $JAR ./tmp/rpm/usr/share/java/jrrd2.jar
chmod 644 ./tmp/rpm/usr/share/java/jrrd2.jar
createPackage "rpm" "--epoch $BUILD" || exit 1
# Build the tree for the .deb package
mkdir -p ./tmp/deb/usr/lib/jni
mkdir -p ./tmp/deb/usr/share/java
cp $LIB ./tmp/deb/usr/lib/jni/libjrrd2.so
chmod 755 ./tmp/deb/usr/lib/jni/libjrrd2.so
cp $JAR ./tmp/deb/usr/share/java/jrrd2.jar
chmod 644 ./tmp/deb/usr/share/java/jrrd2.jar
createPackage "deb" "--iteration $BUILD" || exit 1