-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathget_source.sh
58 lines (52 loc) · 1.9 KB
/
get_source.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
#!/bin/bash
function check_md5() {
file=$1
md5=$2
if [ $(md5sum ${file} | cut -d' ' -f1) != ${md5} ]; then
echo "[Error]: MD5 checksum failed for ${file}"
rm -f ${file}
exit 1
fi
}
function get_source() {
name=$1
url=$2
if [ ! -f "${name}" ]; then
echo "[Info]: Downloading ${name}..."
wget --no-check-certificate -qO ${name} ${url} || {
echo "[Error]: Failed to download ${name}"
rm -f ${name}
exit 1
}
fi
}
for app in ./*; do
if [ -d "${app}" ]; then
if [ -f "${app}/build.yml" ]; then
app_name=$(cat ${app}/setup.yml | grep "source" | cut -d' ' -f2)
source_url=$(cat ${app}/build.yml | grep "source_url" | cut -d' ' -f2)
source_md5=$(cat ${app}/build.yml | grep "source_md5" | cut -d' ' -f2)
if [ -n "${source_url}" ] && [ -n "${source_md5}" ]; then
if [ ! -f "${app}/${app_name}" ]; then
get_source ${app}/${app_name} ${source_url}
check_md5 ${app}/${app_name} ${source_md5}
else
check_md5 ${app}/${app_name} ${source_md5}
fi
fi
if [ -f "${app}/patch.yml" ]; then
patch_name=$(cat ${app}/patch.yml | grep "patch" | cut -d' ' -f2)
patch_url=$(cat ${app}/build.yml | grep "patch_url" | cut -d' ' -f2)
patch_md5=$(cat ${app}/build.yml | grep "patch_md5" | cut -d' ' -f2)
fi
if [ -n "${patch_url}" ] && [ -n "${patch_md5}" ]; then
if [ ! -f "${app}/${patch_name}" ]; then
get_source ${app}/${patch_name} ${patch_url}
check_md5 ${app}/${patch_name} ${patch_md5}
else
check_md5 ${app}/${patch_name} ${patch_md5}
fi
fi
fi
fi
done