| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | SVNURI="http://helpim.tilanus.com/subversion/HelpIM3/" |
|---|
| 4 | HTMLPATH="/usr/local/share/HelpIM" |
|---|
| 5 | |
|---|
| 6 | if [ $# -ne 0 ]; then |
|---|
| 7 | cat << EOF |
|---|
| 8 | This script updates the current installation of HelpIM from subversion at the uri: |
|---|
| 9 | $SVNURI |
|---|
| 10 | If HelpIM is not in the python-path, then this script will use the current directory. If in the current directory is no 'HelpIM' directory, a new one will be created. |
|---|
| 11 | The html-resources will be copied to: |
|---|
| 12 | $HTMLPATH |
|---|
| 13 | If it doesn't exist, it will be created. |
|---|
| 14 | EOF |
|---|
| 15 | exit 0 |
|---|
| 16 | fi |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | SVN=`which svn` |
|---|
| 20 | if [ -z $SVN ]; then |
|---|
| 21 | echo "svn not found, please install the subversion client and make sure it is in your path" |
|---|
| 22 | exit 1 |
|---|
| 23 | fi |
|---|
| 24 | |
|---|
| 25 | LOCALPATH=`python -c "import HelpIM; print HelpIM.__file__.split('HelpIM/__init__.py')[0]"` |
|---|
| 26 | |
|---|
| 27 | if [ $? -eq 1 ]; then |
|---|
| 28 | echo "No HelpIM found, placing it in current directory" |
|---|
| 29 | LOCALPATH='.' |
|---|
| 30 | else |
|---|
| 31 | if [ -z $LOCALPATH ]; then |
|---|
| 32 | echo "HelpIM found in current directory" |
|---|
| 33 | LOCALPATH='.' |
|---|
| 34 | else |
|---|
| 35 | echo "Found HelpIM in $LOCALPATH" |
|---|
| 36 | fi |
|---|
| 37 | fi |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | echo "Updating $HTMLPATH/htdocs" |
|---|
| 41 | if [ ! -d "$HTMLPATH" ]; then |
|---|
| 42 | mkdir "$HTMLPATH" |
|---|
| 43 | if [ $? -ne 0 ]; then |
|---|
| 44 | echo "Can't find or create $HTMLPATH, aborting" |
|---|
| 45 | exit 1 |
|---|
| 46 | fi |
|---|
| 47 | fi |
|---|
| 48 | RESULT=`$SVN export --force "$SVNURI/htdocs" "$HTMLPATH/htdocs"` |
|---|
| 49 | if [ $? -ne 0 ]; then |
|---|
| 50 | echo "Error while updating, aborting" |
|---|
| 51 | exit 1 |
|---|
| 52 | fi |
|---|
| 53 | |
|---|
| 54 | echo "Updating $LOCALPATH""HelpIM" |
|---|
| 55 | RESULT=`$SVN export --force "$SVNURI/HelpIM" "$LOCALPATH""HelpIM"` |
|---|
| 56 | if [ $? -ne 0 ]; then |
|---|
| 57 | echo "Error while updating, aborting" |
|---|
| 58 | exit 1 |
|---|
| 59 | fi |
|---|
| 60 | REVISION=`echo $RESULT | awk '{print $NF}' | sed "s/\.//g"` |
|---|
| 61 | sed -i "s/^__version__ = \"\([0-9.]*\)\"$/__version__ = \"\1r$REVISION\"/" "$LOCALPATH""HelpIM/__init__.py" |
|---|
| 62 | echo "Precompiling $LOCALPATH""HelpIM" |
|---|
| 63 | python -c "import compileall; compileall.compile_dir('$LOCALPATH''HelpIM', force=True, quiet=True)" |
|---|
| 64 | if [ $? -ne 0 ]; then |
|---|
| 65 | echo "Error while compiling, aborting" |
|---|
| 66 | exit 1 |
|---|
| 67 | fi |
|---|
| 68 | |
|---|
| 69 | if ! chmod +x "$LOCALPATH"'HelpIM/bot/bot.py'; then |
|---|
| 70 | echo "Error while making HelpIM bot executable, aborting" |
|---|
| 71 | exit 1 |
|---|
| 72 | fi |
|---|
| 73 | exit 0 |
|---|