-
Notifications
You must be signed in to change notification settings - Fork 56
/
SynoInstall
executable file
·157 lines (123 loc) · 2.86 KB
/
SynoInstall
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
#!/bin/bash
# Copyright (c) 2000-2020 Synology Inc. All rights reserved.
LANG=""
LC_ALL=""
. "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"/include/init
CFLAGS=""
LDFLAGS=""
Source include/install
Source include/util
CheckPermission
Usage() {
cat << EOF
Usage
`basename $0` [OPTIONS] project_name+
Synopsis
Install projects.
Options
-p, --platform {platform}
Specify target platform.
-d, --with-debug
Install binaries with debug symbols.
--parallel N
Parallel install projects with N processes
-h, --help
This help message.
EOF
}
ParsePkgInstallArgs() {
while [ -n "$1" ]; do
case "$1" in
"--single")
# for backward compatibility
;;
*)
Error "Unhandled option '$1'"
Usage
exit 1
;;
esac
shift
done
}
InstallProj() {
local ThisProj=$1
local logFile="${LogDir}/${ThisProj}.install"
[ -f "$logFile" ] && mv -f "$logFile" "${logFile}.old"
(
INFO "Start to install ${ThisProj}."
rm -rf "$TmpInstDir"/*
SetupProjInstallEnv $ThisProj
InstallProject $ThisProj && CreateTarball $ThisProj
INFO "Install $ThisProj finished!"
) &> >(tee $logFile)
}
ParallelInstallProjects() {
local projects=$@
local pickle="/tmp/$$.pickle"
local installProjs doneProjs
if [ -z "$projects" ]; then
echo "No projects input."
return 0
fi
echo "${ScriptsDir}/ProjectDepends.py --dump $pickle -p ${PLATFORM_ABBR} $projects"
${ScriptsDir}/ProjectDepends.py --dump $pickle -p "${PLATFORM_ABBR}" $projects
echo "${ScriptsDir}/ParallelProjects.py --init $pickle -x $projects"
${ScriptsDir}/ParallelProjects.py --init $pickle -x $projects
while true; do
installProjs=$(${ScriptsDir}/ParallelProjects.py --next -c "$ProcessCount" $doneProjs)
if [ "NULL" = "$installProjs" ]; then
echo "Done."
break
fi
for ThisProj in $installProjs; do
InstallProj $ThisProj >/dev/null &
echo "[Installing] $ThisProj"
done
wait
doneProjs=
for proj in $installProjs; do
doneProjs="$doneProjs $proj"
if CheckProjectStatus install $proj > /dev/null; then
echo "[Success] $proj"
else
echo "[Failed] $proj"
fi
done
done
${ScriptsDir}/ParallelProjects.py --purge
rm $pickle
}
main() {
local projectList=
if [ -z "$1" ]; then
Usage
fi
ARGS=$(getopt -u -l $DefaultLongArgs,single $DefaultArgs $@)
if [ $? -ne 0 ]; then
echo "You gave me option(s) that I do not know."
Usage
exit 1
fi
set -- $ARGS
local logFile=
local installFailed=N
ParseDefaultInstallArgs $@
ParsePkgInstallArgs $UnHandledOpt
SetupInstallEnv "$IsDebugBuild"
projectList=$(NormalizeInstallProjects $InputProjs)
INFO "projectList=\"$projectList\""
if $Parallel && [ "$(wc -w <<< "$projectList")" -gt 1 ] ; then
ParallelInstallProjects $projectList
else
for ThisProj in $projectList; do
InstallProj "$ThisProj"
done
fi
if ! CheckErrorLog install $projectList; then
return 1;
fi
INFO "Finished SynoInstall script."
return 0
}
main $@