PageRenderTime 18ms CodeModel.GetById 14ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tools/mkpkgs

https://bitbucket.org/prologic/circuits/
#! | 105 lines | 84 code | 21 blank | 0 comment | 0 complexity | 76a43f2db0b811fa72a4860dffc633ee MD5 | raw file
  1#!/bin/bash
  2#
  3#  mkpkgs
  4# 
  5#  Copyright (C) 2010 James Mills
  6# 
  7#  This program is free software; you can redistribute it and/or modify
  8#  it under the terms of the GNU General Public License as published by
  9#  the Free Software Foundation; either version 2 of the License, or
 10#  (at your option) any later version.
 11#
 12#  This program is distributed in the hope that it will be useful,
 13#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 14#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15#  GNU General Public License for more details.
 16#
 17#  You should have received a copy of the GNU General Public License
 18#  along with this program; if not, write to the Free Software
 19#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
 20#  USA.
 21#
 22
 23VERSION="0.1"
 24
 25test_application () {
 26    application=${1}
 27    $application --version &> /dev/null
 28    if [[ $? != 0 ]]; then
 29        echo "Cannot find or execute ${application}!"
 30        exit 1
 31    fi
 32}
 33
 34get_latest_tag() {
 35    echo "$(hg tags | awk '{if (NR == 2) print $1}')"
 36}
 37
 38make_packages() {
 39    cwd=$(pwd)
 40    hg=$(which hg)
 41	python=$(which ${1})
 42
 43    test_application "$hg"
 44    test_application "$python"
 45
 46    status=$(hg status -0 -m)
 47    if [[ $status ]]; then
 48        echo "Working directory not in a clean state! Aborting..."
 49        exit 2
 50    fi
 51
 52    echo "Building packages for $python ..."
 53
 54    tag=$(get_latest_tag)
 55
 56    $hg update -C ${tag} &> /dev/null
 57
 58    $python setup.py clean &> /dev/null
 59    $python setup.py build &> /dev/null
 60    $python setup.py bdist_egg &> /dev/null
 61    $python setup.py sdist --formats=bztar,gztar,zip &> /dev/null
 62
 63    $hg update -C &> /dev/null
 64}
 65
 66print_help() {
 67	echo "usage: $COMMAND [options] machines"
 68	echo "options:"
 69	echo "   -p=PYTHON  specify python binary to use"
 70	echo "   -v         print version and exit"
 71	echo "   -h         print help and exit"
 72}
 73
 74parse_options() {
 75	PYTHON="python2.6"
 76
 77	while getopts "p:vh-" OPT ; do
 78		case $OPT in
 79			p)
 80				PYTHON="$OPTARG" ;;
 81			v)
 82				echo "$COMMAND $VERSION"
 83				exit 0 ;;
 84			h)
 85				print_help
 86				exit 0 ;;
 87		esac
 88	done
 89
 90	shift $(($OPTIND - 1))
 91}
 92
 93main() {
 94	parse_options "$@"
 95
 96    make_packages "$PYTHON"
 97}
 98
 99### Main
100
101COMMAND=$(basename $0)
102
103main "$@"
104
105#n End of File