-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathrelease_rootfs.sh
executable file
·48 lines (37 loc) · 1.11 KB
/
release_rootfs.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
#!/bin/bash
set -x
set -e
CHECK_COUNT=0
MAX_RETRY=3
test -d ${TARGET_DIR} || mkdir -p ${TARGET_DIR}
urlencode() {
# urlencode <string>
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
*) printf '%%%02X' "'$c"
esac
done
}
ROOTFS_TAG=$(urlencode "$ROOTFS_TAG")
ROOTFS_FILE=$(urlencode "$ROOTFS_FILE")
if [ ! -f $PREBUILT_DIR/$ROOTFS_FILE ]; then
echo "Not found rootfs. Download it"
wget https://github.com/SamsungARTIK/fedora-spin-kickstarts/releases/download/${ROOTFS_TAG}/${ROOTFS_FILE} -O $PREBUILT_DIR/$ROOTFS_FILE
fi
while :
do
MD5_SUM=$(md5sum $PREBUILT_DIR/$ROOTFS_FILE | awk '{print $1}')
if [ "$ROOTFS_FILE_MD5" == "$MD5_SUM" ]; then
break
fi
echo "Mismatch MD5 hash. Just download again"
wget https://github.com/SamsungARTIK/fedora-spin-kickstarts/releases/download/${ROOTFS_TAG}/${ROOTFS_FILE} -O $PREBUILT_DIR/$ROOTFS_FILE
CHECK_COUNT=$((CHECK_COUNT + 1))
if [ $CHECK_COUNT -ge $MAX_RETRY ]; then
exit -1
fi
done
cp $PREBUILT_DIR/$ROOTFS_FILE $TARGET_DIR/rootfs.tar.gz