forked from AliyunContainerService/pouch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule
executable file
·99 lines (81 loc) · 2.45 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
function 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
END
fi
grep -q $1 ${volume_build}
if [[ $? -ne "0" ]]
then
echo "import _ \"$1\"" >> ${volume_build}
fi
}
function hook_plugins_module() {
# generate "hook_plugins_build.go" file
if [[ ! -f ${hook_plugins_build} ]]; then
cat << END > ${hook_plugins_build}
// +build linux
// The file is automatically generated, DON'T EDIT.
package main
END
fi
grep -q $1 ${hook_plugins_build}
if [[ $? -ne "0" ]]; then
echo "import _ \"$1\"" >> ${hook_plugins_build}
fi
}
help=
clean=
gcflags=
volume_build=volume_build.go
hook_plugins_build=hook_plugins_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
;;
--add-plugin=*)
hook_plugins_module $value
;;
*)
echo "$0: error: invalid option \"$option\""
exit 1
;;
esac
done
if [[ "${clean}" == "yes" ]]; then
rm -f ${volume_build}
rm -f ${hook_plugins_build}
exit 0
fi
if [[ "${help}" == "yes" ]]; then
echo "usage:"
echo " module [options]"
echo ""
echo "options:"
echo " --help, -h Print help information"
echo " --add-volume= Add a volume driver module to compile"
echo " --add-plugin= Add a hook plugin 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/storage/volume/examples/demo"
echo " A example show how to add a driver module, 'github.com/alibaba/pouch/storage/volume/examples/demo' is a Go's package"
echo " can be found in \$GOPATH"
exit 0
fi