]> kaliko git repositories - mpd-sima.git/blob - vinstall.sh
Add virtualenv generator
[mpd-sima.git] / vinstall.sh
1 #!/bin/sh
2 #
3 #   SCRIPT NAME
4 #
5 #   version: 0.0 : Date: 1970/01/01 00:0:00
6 #
7 #   TODO:
8 #           *
9 DEBUG=${DEBUG:-"0"}     #  Set to 1 in order to enable DEBUG message.
10                         ## Use "export DEBUG=1" in the calling script to enable it
11                         ##  or run:
12                         #           >$ DEBUG=1 script_name.sh
13                         ## Only error message will be printed with DEBUG="0"
14
15
16 PY3=${PY3:-$(which python3.3)}
17 MUSICPD="http://media.kaliko.me/src/musicpd/dist/python-musicpd-0.3.1.tar.bz2"
18
19 # Test virtualenv presence
20 [ -x "$(which virtualenv)" ] || { echo "Cannot find virtualenv executable!"; exit 1; }
21 [ -x "$(which ${PY3})"  ] || { echo "Cannot find a python3.3 interpreter!"; exit 1; }
22 [ "$DEBUG" != "0" ] && echo "python: $PY3"
23
24 INSTALL_DIR=${INSTALL_DIR:-$(dirname $0)}
25 # canonicalize path
26 INSTALL_DIR=$(readlink -f ${INSTALL_DIR})
27 [ "$DEBUG" != "0" ] && echo "install dir: $INSTALL_DIR"
28
29 VENV_OPTIONS="--python=$PY3 --prompt="sima_venv" --no-site-packages --clear"
30 [ "$DEBUG" = "0" ] && VENV_OPTIONS="$VENV_OPTIONS --quiet"
31
32 virtualenv $VENV_OPTIONS $INSTALL_DIR/venv || { echo "something went wrong generating virtualenv"; exit 1; }
33
34 . $INSTALL_DIR/venv/bin/activate
35
36 PIP_OPTIONS=""
37 [ "$DEBUG" = "0" ] && PIP_OPTIONS="$PIP_OPTIONS --quiet"
38
39 pip $PIP_OPTIONS install $MUSICPD
40
41 deactivate
42
43 SIMA_LAUNCHER=$(readlink -f $(dirname $0))/launch
44 SIMA_VLAUNCHER=$(readlink -f $(dirname $0))/vlaunch
45 [ -x "$SIMA_LAUNCHER" ] || { echo "$SIMA_LAUNCHER not available"; exit 1; }
46
47 cat << EOF > $SIMA_VLAUNCHER
48 #!/bin/sh
49 . $INSTALL_DIR/venv/bin/activate
50 python $SIMA_LAUNCHER $@
51 EOF
52 chmod +x $SIMA_VLAUNCHER
53
54 echo 
55
56 # vim: fileencoding=utf8