This repository has been archived by the owner on May 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
bootstrap-dev-env.sh
160 lines (140 loc) · 3.34 KB
/
bootstrap-dev-env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/sh
#set -x
USAGE="Usage: `basename $0` [-hv] [-s] [-e] [-l logfile.txt] [-c git-url] [-n] app"
VERSION="0.0"
NEWAPP=0
GIT="0"
SYSTEMSITEPACKAGES=0
INSTALLEXT=0
LOGFILE=/dev/null
# URLS
BRABBEL=https://github.com/ringo-framework/brabbel.git
FORMBAR=https://github.com/ringo-framework/formbar.git
RINGO=https://github.com/ringo-framework/ringo.git
PYTESTRINGO=https://github.com/ringo-framework/pytest-ringo.git
# EXTENSIONS
PRINTTEMPLATES=https://github.com/ringo-framework/ringo_printtemplates.git
COMMENT=https://github.com/ringo-framework/ringo_comment.git
EVALUATION=https://github.com/ringo-framework/ringo_evaluation.git
DIAGRAM=https://github.com/ringo-framework/ringo_diagram.git
FILE=https://github.com/ringo-framework/ringo_file.git
NEWS=https://github.com/ringo-framework/ringo_news.git
TAG=https://github.com/ringo-framework/ringo_tag.git
EXTENSIONS="$PRINTTEMPLATES $COMMENT $EVALUATION $DIAGRAM $FILE $NEWS $TAG"
# Parse command line options.
while getopts hvsnec:l: OPT; do
case "$OPT" in
h)
echo $USAGE
exit 0
;;
v)
echo "`basename $0` version $VERSION"
exit 0
;;
s)
SYSTEMSITEPACKAGES=1
;;
n)
NEWAPP=1
;;
e)
INSTALLEXT=1
;;
c)
GIT=$OPTARG
;;
l)
LOGFILE=$OPTARG
;;
\?)
# getopts issues an error message
echo $USAGE >&2
exit 1
;;
esac
done
# Remove the switches we parsed above.
shift `expr $OPTIND - 1`
# We want at least one non-option argument.
# Remove this block if you don't need it.
if [ $# -eq 0 ]; then
echo $USAGE >&2
exit 1
fi
# Check if clone and new option is provided
if [ $NEWAPP -eq 1 ] && [ $GIT != "0" ]; then
echo "Error: -c and -n option are not allowed together"
echo $USAGE >&2
exit 1
fi
# Set name of the application
APP=$1
if ! [ -d $APP ]; then
mkdir $APP
fi
cd $APP
if ! [ -d "env" ]; then
printf "Installing virtualenv... "
if [ $SYSTEMSITEPACKAGES -eq 1 ]; then
virtualenv --system-site-packages env > $LOGFILE 2>&1
else
virtualenv env > $LOGFILE 2>&1
fi
printf "OK\n"
fi
. env/bin/activate
pip install setuptools --upgrade > $LOGFILE 2>&1
Deploy() {
DIR=`echo $1 | awk -F \/ '{split($NF, P, "."); print P[1]}'`
if ! [ -d $DIR ]; then
printf "Installing $DIR... "
git clone $path $DIR > $LOGFILE 2>&1
cd $DIR
python setup.py develop > $LOGFILE 2>&1
printf "OK\n"
cd ..
fi
}
if ! [ -d lib ]; then
mkdir lib
fi
cd lib
# Install base libs
for path in $BRABBEL $FORMBAR $RINGO; do
Deploy $path
done
# Install extensions
if [ $INSTALLEXT -eq 1 ]; then
for path in $EXTENSIONS; do
Deploy $path
done
fi
cd ..
if [ $NEWAPP -eq 1 ]; then
printf "Creating new app $APP... "
pcreate -t ringo $APP
mv $APP src
cd src
python setup.py develop > $LOGFILE 2>&1
printf "OK\n"
cd ..
fi
if [ $GIT != "0" ]; then
printf "Cloning app $APP... "
git clone $GIT $APP
mv $APP src
cd src
if [ -f "requirements.txt" ]; then
pip install -r requirements.txt > $LOGFILE 2>&1
else
python setup.py develop > $LOGFILE 2>&1
fi
printf "OK\n"
cd ..
fi
echo "Ringo Setup Ready. Next steps:"
echo ""
echo "cd $APP"
echo "source env/bin/activate"
exit 0