-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakepipe.sh
More file actions
executable file
·229 lines (213 loc) · 5.47 KB
/
makepipe.sh
File metadata and controls
executable file
·229 lines (213 loc) · 5.47 KB
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/bin/bash
# Init & Create the makepipe in local directory
# Where is located the $MAKEPIPE_REPOSITORY if not defined from env
if [ $GITREPOSITORY ]
then
if [ -d $GITREPOSITORY/makepipe ]
then
MAKEPIPE_REPOSITORY=$GITREPOSITORY/makepipe
fi
elif [ -d /data/share/repository/makepipe ]
then
# define a local
MAKEPIPE_REPOSITORY=/data/share/repository/makepipe
fi
if [ ! -d $MAKEPIPE_REPOSITORY ]
then
echo "There no repository at $MAKEPIPE_REPOSITORY"
echo "Check the environmental variable GITREPPOSITORY"
echo "or do makepipe init makepipe_repository"
exit 1
fi
# current patch
pwd=$(pwd)
###########
# Functions
#----------
# show help for all command
function usage() {
echo "
Makepipe commands :
* help: display a command's help screen
* build: yaml: generate a Makefile from a YAML pipeline
* brick: list all bricks available
* brick name: display a brick's help
* init: init a new project with makepipe in current folder
* update: update makepipe submodule from repository
"
}
# do init makepipe
init() {
# Where to take the repository for makepipe
repository="$1"
# Check git not present in current folder
if [ -d .git ]
then
echo "You have already a git repository in this directory"
echo "You can add makepipe as submodule by doing:"
echo "git submodule add $repository makepipe"
exit 0
fi
# init git repository for this projects
git init
git submodule add $repository makepipe
$(cd makepipe && git checkout -b local)
# Ignore bam, fastq
cp makepipe/.gitignore .gitignore
git add makepipe .gitignore
git commit -m 'Initial release on local branch'
version=$(git --git-dir=makepipe/.git tag | grep makepipe | tail -1)
if [ $version ]
then
git tag $version
fi
cat <<END
[info] Makepipe installed
[info] Git Repository initialized
# Configure your yml file, ckeck makepipee/pipeline.yml as sample configuration file.
For more information, read makepipe/README.md
* The original bricks are managed in the submodule "makepipe/bricks".
* If you modify a brick, you should commit inside the submodule "makepipe" on
the local branch.
* If you add a new brick, you can add to your current git repository (inside the bricks folder)
* or put it in the bricks folder of the submodule "makepipe" and index it in the local
branch.
END
}
#----------
upgradev0.03info() {
cat <<END
----
Something went wrong & Do it by yourself:
# Files NOT in bricks or makepipe.module
* You have files to commit or files to index/commit"
* Do 'git add & git commit'
* or git commit -am 'your message'
# Files IN bricks or makepipe.module
* If new file in bricks/*, move them in makepipe.module/bricks/
* cd makepipe.module
* create a local branch in makepipe.module:
git checkout -b local
git commit -am 'your message'
git chekckout master
git pull origin master
git rebase local
git checkout local
* cd ..
* git commit -a -m "Makepipe ready for upgrade from v0.03"
* makepipe update
# More info on submodule
* see https://git-scm.com/book/en/v2/Git-Tools-Submodules
END
exit 1
}
# do update makepipe
update() {
# check if current project repository is clean
gitstatus=$(git status -s | grep -v '?')
if [ "$(git status -s | grep -v '?')" != "" ]
then
echo '<-------'
echo $gitstatus
echo '------->'
upgradev0.03info
exit 0
fi
# update current git module repository for this projects
echo "[info] Doing update of makepipe"
# update from v0.03
if [ -d makepipe.module ]
then
[ -L makepipe ] && rm makepipe
for f in bricks/*; do [ -L $f ] && rm $f; done
rmdir bricks && mv makepipe.module makepipe
[ $? -gt 0 ] && upgradev0.03info
# update path for git module
mv .git/modules/makepipe.module .git/modules/makepipe
for f in .git/config .git/modules/makepipe/config makepipe/.git
do
sed -i 's/makepipe.module/makepipe/' $f
done
(cd makepipe && git commit -a -m 'Updated Makepipe from version 0.03')
echo "Updated from version 0.03"
fi
git submodule update --remote --rebase
git commit -am 'Upgraded to makepipe 0.04'
echo "[info] Makepipe updated"
}
############
if [ -d makepipe.module ]
then
echo "You HAVE to upgrade to makepipe v0.04, by doing:"
echo "makepipe update"
makepipe="./makepipe.offline"
fi
if [ -x "$pwd/makepipe/makepipe" ]
then
makepipe="./makepipe/makepipe"
else
echo -e "[Warning] Makepipe not initialised\n"
fi
# Manage help commands
if [ "$1" == "help" ]
then
case "$2" in
"init")
echo -e "Create git repository, add makepipe as submodule.\nmakepipe init [$MAKEPIPE_REPOSITORY]"
;;
"update")
echo -e "Update local branch of submodule makepipe. Do \nmakepipe update [$MAKEPIPE_REPOSITORY]"
;;
"build" | "brick")
if [ $makepipe ]
then
$makepipe help $2
else
echo "To get the help on "$2", you have to init makepipe"
fi
;;
*)
usage
;;
esac
exit 0
fi
# Test if makepipe is already here
if [ $makepipe ]
then
# if we don't have an argument, default is to send to local makepipe
case $1 in
"init")
echo "You have already initialized this repository,"
echo -e "you should do \nmakepipe update"
;;
"update")
# we do update
if [ "$2" ]
then
MAKEPIPE_REPOSITORY=$2
fi
update $MAKEPIPE_REPOSITORY
;;
"list")
usage
;;
*)
$makepipe $*
#makepipe build *.yml > Makefile
;;
esac
else
# we have nothing yet, do init()
if [ "$1" == "init" ]
then
shift
if [ $1 ]
then
MAKEPIPE_REPOSITORY=$1
fi
init $MAKEPIPE_REPOSITORY
else
usage
fi
fi