/
create_package.sh
executable file
·85 lines (71 loc) · 1.79 KB
/
create_package.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
#!/bin/sh
mkdir -p build
src_pkg_dir=build/src_pkg
binary_pkg_dir=build/binary_pkg
# $# represents the number of arguments.
if [ $# -gt 0 ]
then
# Concatenate arguments with spaces.
# (ref.) https://unix.stackexchange.com/questions/197792/joining-bash-arguments-into-single-string-with-spaces
ARGS="'$*'"
echo "Specified args: $ARGS"
fi
debug_options=""
case "$ARGS" in
*libsailr-debug*)
debug_options=${debug_options}'--enable-libsailr-debug '
;;
esac
case "$ARGS" in
*datasailr-debug*)
debug_options=${debug_options}'--enable-datasailr-debug '
;;
esac
# Check whether string contains specific substring.
# (ref.) https://www.shellscript.sh/case.html
# If you use bash, there are more ways. But using basic sh, this seems to be the best solution.
case "$ARGS" in
*src*) ;;
*)
case "$ARGS" in
*binary*) ;;
*)
ARGS="${ARGS} src binary"
;;
esac
;;
esac
case "$ARGS" in
*src*)
echo "Building ource package"
mkdir -p ${src_pkg_dir}
cp -R tmp/datasailr_pkg ${src_pkg_dir}/
cd ${src_pkg_dir}
R CMD build datasailr_pkg
case "$ARGS" in
*keep-build*) ;;
*)
rm -R -f datasailr_pkg
;;
esac
cd -
echo "R CMD build finished successfully under src_pkg directory"
;;
esac
case "$ARGS" in
*binary*)
echo "Building binary package for the current platform"
mkdir -p ${binary_pkg_dir}
cp -R tmp/datasailr_pkg ${binary_pkg_dir}/
cd ${binary_pkg_dir}
R CMD INSTALL datasailr_pkg --build --configure-args="${debug_options}"
case "$ARGS" in
*keep-build*) ;;
*)
rm -R -f datasailr_pkg
;;
esac
cd -
echo "R CMD build finished successfully under binary_pkg directory"
;;
esac