forked from AliyunContainerService/pouch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
module
executable file
·78 lines (63 loc) · 1.89 KB
/
module
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
#!/bin/bash
volume_module() {
# generate 'volume_build.go' file
if [ ! -f $volume_build ]; then
cat << END > $volume_build
// +build linux
// The file is automatically generated, DON'T EDIT.
package main
// import default package.
import _ "github.com/alibaba/pouch/volume/store/boltdb"
END
fi
grep -q $1 $volume_build
if [ $? -ne "0" ]
then
echo "import _ \"$1\"" >> $volume_build
fi
}
help=
clean=
gcflags=
volume_build=volume_build.go
opt=
for option
do
opt="$opt `echo $option | sed -e \"s/\(--[^=]*=\)\(.* .*\)/\1'\2'/\"`"
case "$option" in
-*=*) value=`echo "$option" | sed -e 's/[-_a-zA-Z0-9]*=//'` ;;
*) value="" ;;
esac
case "$option" in
--help) help=yes ;;
-h) help=yes ;;
--clean) clean=yes ;;
--add-volume=*)
volume_module $value
;;
*)
echo "$0: error: invalid option \"$option\""
exit 1
;;
esac
done
if [ "$clean" = "yes" ]; then
rm -f $volume_build
exit 0
fi
if [ "$help" = "yes" ]; then
echo "usage:"
echo " module [options]"
echo ""
echo "options:"
echo " --help, -h Print help infomation"
echo " --add-volume= Add a volume driver module to compile"
echo " --clean Remove temporary codes, the 'build.go'"
echo ""
echo " ./module To comiple directly on current codes, include added modules"
echo ""
echo " ./module --add-volume=github.com/alibaba/pouch/volume/examples/demo"
echo " A example show how to add a driver module, 'github.com/alibaba/pouch/volume/examples/demo' is a Go's package"
echo " can be found in \$GOPATH"
exit 0
fi