PageRenderTime 44ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 1ms

/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. VERSION="0.1"
  23. test_application () {
  24. application=${1}
  25. $application --version &> /dev/null
  26. if [[ $? != 0 ]]; then
  27. echo "Cannot find or execute ${application}!"
  28. exit 1
  29. fi
  30. }
  31. get_latest_tag() {
  32. echo "$(hg tags | awk '{if (NR == 2) print $1}')"
  33. }
  34. make_packages() {
  35. cwd=$(pwd)
  36. hg=$(which hg)
  37. python=$(which ${1})
  38. test_application "$hg"
  39. test_application "$python"
  40. status=$(hg status -0 -m)
  41. if [[ $status ]]; then
  42. echo "Working directory not in a clean state! Aborting..."
  43. exit 2
  44. fi
  45. echo "Building packages for $python ..."
  46. tag=$(get_latest_tag)
  47. $hg update -C ${tag} &> /dev/null
  48. $python setup.py clean &> /dev/null
  49. $python setup.py build &> /dev/null
  50. $python setup.py bdist_egg &> /dev/null
  51. $python setup.py sdist --formats=bztar,gztar,zip &> /dev/null
  52. $hg update -C &> /dev/null
  53. }
  54. print_help() {
  55. echo "usage: $COMMAND [options] machines"
  56. echo "options:"
  57. echo " -p=PYTHON specify python binary to use"
  58. echo " -v print version and exit"
  59. echo " -h print help and exit"
  60. }
  61. parse_options() {
  62. PYTHON="python2.6"
  63. while getopts "p:vh-" OPT ; do
  64. case $OPT in
  65. p)
  66. PYTHON="$OPTARG" ;;
  67. v)
  68. echo "$COMMAND $VERSION"
  69. exit 0 ;;
  70. h)
  71. print_help
  72. exit 0 ;;
  73. esac
  74. done
  75. shift $(($OPTIND - 1))
  76. }
  77. main() {
  78. parse_options "$@"
  79. make_packages "$PYTHON"
  80. }
  81. ### Main
  82. COMMAND=$(basename $0)
  83. main "$@"
  84. #n End of File