forked from elastic/logstash-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild2.sh
93 lines (78 loc) · 2.44 KB
/
build2.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
basedir=$(dirname $0)/../
# Get version details
[ ! -f "$basedir/.VERSION.mk" ] && make -C $basedir .VERSION.mk
. $basedir/.VERSION.mk
if [ "$#" -ne 2 ] ; then
echo "Usage: $0 os release"
echo
echo "Example: $0 ubuntu 12.10"
fi
silent() {
"$@" > /dev/null 2>&1
}
log() {
echo "$@" >&2
}
os=$1
osver=$2
logstash="$basedir/../logstash/"
logstashtar="$basedir/../logstash/build/logstash-${VERSION}.tar.gz"
contribtar="$basedir/build/logstash-contrib-${VERSION}.tar.gz"
workdir=build/$os/$osver
silent mkdir -p $workdir
if [ ! -d "$logstash" ] ; then
echo "Missing logstash git repo? Expected to find it here: $logstash"
exit 1
fi
if [ ! -f "$logstashtar" ] ; then
echo "Missing $logstashtar"
exit 1
fi
if [ ! -f "$contribtar" ] ; then
echo "Building $contribtar"
make -C $basedir $contribtar || exit 1
fi
# Find files that only contrib contains.
tarfiles() {
log "Listing files in $1"
tar -ztf "$1" | grep -v '/$' | sed -re 's@^[^/]+/@@' | sort
}
tarfiles $contribtar > $workdir/files.contrib
tarfiles $logstashtar > $workdir/files.logstash
# Find all files in contrib but not logstash core
grep -Fvxf $workdir/files.logstash $workdir/files.contrib > $workdir/files
set -x
set -e
# Unpack the contrib tarball.
silent mkdir -p $workdir/tarball || true
tar -C $workdir/tarball -zxf $contribtar --strip-components 1
_fpm() {
target=$1
fpm -s dir -n logstash-contrib \
-a noarch --url "https://github.com/elasticsearch/logstash-contrib" \
--description "Community supported plugins for Logstash" \
--vendor "Elasticsearch" \
--license "Apache 2.0" \
"$@"
}
case $os in
centos|fedora|redhat|sl)
_fpm -t rpm --rpm-use-file-permissions --rpm-user root --rpm-group root \
--iteration "1_$REVISION" --rpm-ignore-iteration-in-dependencies \
-d "logstash = $RELEASE" -v "$RELEASE" \
-f -C $workdir/tarball --prefix /opt/logstash $(cat $workdir/files)
;;
ubuntu|debian)
if ! echo $RELEASE | grep -q '\.(dev\|rc.*)'; then
# This is a dev or RC version... So change the upstream version
# example: 1.2.2.dev => 1.2.2~dev
# This ensures a clean upgrade path.
RELEASE="$(echo $RELEASE | sed 's/\.\(dev\|rc.*\)/~\1/')"
fi
_fpm -t deb --deb-user root --deb-group root \
--iteration "1-$REVISION" --deb-ignore-iteration-in-dependencies \
-d "logstash = $RELEASE" -v "$RELEASE" \
-f -C $workdir/tarball --prefix /opt/logstash $(cat $workdir/files)
;;
esac