This repository has been archived by the owner on Oct 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
dev
executable file
·121 lines (102 loc) · 2.56 KB
/
dev
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
#!/bin/bash
set +e
: '
Copyright (C) 2017 IBM Corporation
Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Contributors:
* Rafael Peria de Sene <[email protected]>
'
DIR=$(basename "$PWD")
createVirtEnv(){
virtualenv $DIR
source $DIR/bin/activate
return $TRUE
}
destroyVirtEnv(){
deactivate
clean
return $TRUE
}
clean(){
rm -rf ./$DIR
rm -rf ./*egg*
rm -rf ./build
rm -rf ./dist
}
buildTests(){
createVirtEnv
python ./setup.py test
destroyVirtEnv
clean
return $TRUE
}
buildRun(){
createVirtEnv
python ./setup.py install
sca -h
destroyVirtEnv
clean
return $TRUE
}
buildInstall(){
clean
python ./setup.py sdist
python ./setup.py check -m
sudo pip install --upgrade ./dist/*.tar.gz
return $TRUE
}
buildClean(){
clean
python ./setup.py clean --all
python ./setup.py build
return $TRUE
}
buildCleanAll(){
clean
return $TRUE
}
buildRelease(){
clean
python ./setup.py sdist
python ./setup.py check -m
return $TRUE
}
#read the inputs
if [ $# -ne 1 ]; then
echo "usage: dev [ build | tests | release | run | clean | -h or --help ]"
exit 1
fi
# overwrite timestamp in setup.py file
buildtime=$(date +%Y%m%d%H%M%S)
sed -i -e "s/timestamp/$buildtime/g" setup.py
tool=${PWD##*/}
if [[ "$1" == "build" ]]; then
buildClean
elif [[ "$1" == "tests" ]]; then
buildTests
elif [[ "$1" == "install" ]]; then
buildInstall
elif [[ "$1" == "run" ]]; then
buildRun $tool
elif [[ "$1" == "clean" ]]; then
buildCleanAll
elif [[ "$1" == "release" ]]; then
buildRelease
elif [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
echo "usage: dev [clean | tests | release]"
echo " * clean: excute a new clean build which do not install or allow execute. Useful for integrity verification."
echo " * tests: run all the unit tests inside a virtual environment."
echo " * release: creates all the necessary packages to distribute the application."
echo " * run: creates a virtual environment where the application is installed and executed"
else
echo "Please, enter the correct command."
echo "usage: dev [ build | tests | install | release | run | clean | -h or --help ]"
fi