martinrusev
2/9/2015 - 9:47 AM

gistfile1.sh

#! /usr/bin/env bash
set -xe

export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export DEBIAN_FRONTEND=noninteractive
export ITERATION=`date +%s`
export PACKAGE=circus
export DESCRIPTION='circus, A Process & Socket Manager built with zmq'
export VERSION=0.9.2
export WEB_VERSION=0.4.1
export PACKAGE_NAME="${PACKAGE}_${VERSION}-${ITERATION}-all.deb"

source /etc/lsb-release

echo "-> Updating deb repository"
sudo apt-get update > /dev/null

echo "-> Get build dependencies"
sudo apt-get install -qq -y --force-yes libreadline-dev libncurses5-dev libpcre3-dev libssl-dev libxml2-dev libxslt1-dev perl git-core > /dev/null

echo "-> Installing python build tools"
sudo apt-get install -qq -y --force-yes python python-dev > /dev/null

echo "-> Installing ${PACKAGE} dependencies"
sudo apt-get install -qq -y --force-yes libzmq-dev python-setuptools python-zmq python-iowait python-psutil > /dev/null
sudo apt-get install -qq -y --force-yes python-setuptools python-support python-mock python-configobj > /dev/null

echo "-> Setting up the virtualenv"
sudo pip install virtualenv-tools > /dev/null
rm -rf build/usr/share/python/${PACKAGE}
mkdir -p build/usr/share/python > /dev/null
virtualenv build/usr/share/python/${PACKAGE} > /dev/null

echo "-> Installing distribute"
build/usr/share/python/${PACKAGE}/bin/pip install -U pip distribute > /dev/null
build/usr/share/python/${PACKAGE}/bin/pip uninstall -y distribute > /dev/null

echo "-> Installing ${PACKAGE}"
build/usr/share/python/${PACKAGE}/bin/pip install ${PACKAGE}==${VERSION} > /dev/null
build/usr/share/python/${PACKAGE}/bin/pip install circus-web==${WEB_VERSION} > /dev/null
build/usr/share/python/${PACKAGE}/bin/pip install circus-logstash > /dev/null
build/usr/share/python/${PACKAGE}/bin/pip install psutil==1.2.1 > /dev/null

echo "-> Cleaning ${PACKAGE}"
find build ! -perm -a+r -exec chmod a+r {} \;
cd build/usr/share/python/${PACKAGE}
virtualenv-tools --update-path /usr/share/python/${PACKAGE} > /dev/null
cd -

echo "-> Removing compiled files"
find build -iname *.pyc -exec rm {} \;
find build -iname *.pyo -exec rm {} \;

echo "-> Copying conf files"
test -d conf/etc && cp -a conf/etc build

echo "-> Creating ${PACKAGE}"
sudo fpm \
    -t deb -s dir -C build -n ${PACKAGE} -v ${VERSION} \
    --iteration ${ITERATION} \
    -a all \
    -p ${PACKAGE_NAME} \
    --deb-init conf/etc/init/circus.conf \
    --config-files /etc/init/circus.conf \
    --config-files /etc/circus/circus.ini \
    --after-install conf/post-install \
    --before-remove conf/pre-remove \
    --after-remove conf/post-remove \
    --url https://github.com/circus-tent/circus \
    --description "${DESCRIPTION}" \
    --license 'Apache 2.0' \
    .
echo "-> Done"