1#!/usr/bin/env bash
2# CALL LIKE SO: bash build/debian/build_debs.sh
3# set -x
4
5pushd .
6# This allows us to pass in the Openfire version from the command-line.
7if [ $1 ]; then
8    export OPENFIRE_FULLVERSION=$1
9else
10    export OPENFIRE_FULLVERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
11fi
12export OPENFIRE_VERSION=$(echo "${OPENFIRE_FULLVERSION}" | cut -d'-' -f1)
13export DEBIAN_BUILDDATE="$(date +'%a, %d %b %Y %H:%M:%S %z')"
14export WORKDIR=tmp/debian/openfire-${OPENFIRE_VERSION}
15
16if [ -d "tmp/debian" ]; then
17    echo "Removing previous workdir tmp/debian"
18    rm -rf tmp/debian
19fi
20mkdir -p $WORKDIR
21
22cp -r distribution/target/distribution-base/. $WORKDIR/
23
24mkdir -p $WORKDIR/debian
25cp build/debian/* $WORKDIR/debian/
26# HACK remove out this actual script
27rm -f $WORKDIR/debian/build_debs.sh
28
29# make rules executable
30chmod 755 $WORKDIR/debian/rules
31
32cd $WORKDIR/debian
33# Do some needed replacements
34sed -i.bak s/@version@/${OPENFIRE_VERSION}/g changelog
35sed -i.bak s/@builddate@/"${DEBIAN_BUILDDATE}"/g changelog
36cd ..
37# Disable build-dependencies, because they're often not useful here.
38dpkg-buildpackage -d -rfakeroot -us -uc
39
40pushd
41mkdir -p distribution/target/debian
42mv tmp/debian/openfire*deb distribution/target/debian/
43