<NME> build.sh
<BEF> #!/bin/bash

basedir=$(dirname $0)/../
workdir=.

# 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

echo "Building package for $os $release"

destdir=build/
prefix=/opt/logstash

if [ "$destdir/$prefix" != "/" -a -d "$destdir/$prefix" ] ; then

os=$1
osver=$2

_fpm() {
  target=$1
  fpm -s dir -n logstash-kafka \
    -a noarch --url "https://github.com/joekiller/logstash-kafka.git" \
    --description "Logstash Kafka" \
    --vendor "na" \
    --license "Apache 2.0" \
    "$@"
}

case $os in
  centos|fedora|redhat|sl)
        _fpm -s dir -t rpm -n "logstash-kafka" -a all -v 1.2.1 --prefix /opt/logstash lib/ vendor/
    ;;
  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)
    mkdir -p $destdir/etc/logrotate.d
    mkdir -p $destdir/etc/init
    mkdir -p $destdir/var/log/logstash
    touch $destdir/etc/sysconfig/logstash
    install -m644 logrotate.conf $destdir/etc/logrotate.d/
    install -m755 logstash.upstart.ubuntu $destdir/etc/init/logstash.conf

<MSG> - fix bug where different packages would build from the same directory
causing centos things to leak into ubuntu packages (Reported by Kristian
Glass)

<DFF> @@ -15,7 +15,7 @@ release=$2
 
 echo "Building package for $os $release"
 
-destdir=build/
+destdir=build/$(echo "$os" | tr ' ' '_')
 prefix=/opt/logstash
 
 if [ "$destdir/$prefix" != "/" -a -d "$destdir/$prefix" ] ; then
@@ -52,6 +52,7 @@ case $os@$release in
     mkdir -p $destdir/etc/logrotate.d
     mkdir -p $destdir/etc/init
     mkdir -p $destdir/var/log/logstash
+    mkdir -p $destdir/etc/sysconfig
     touch $destdir/etc/sysconfig/logstash
     install -m644 logrotate.conf $destdir/etc/logrotate.d/
     install -m755 logstash.upstart.ubuntu $destdir/etc/init/logstash.conf

- fix bug where different packages would build from the same directory causing centos things to leak into ubuntu packages (Reported by Kristian Glass)