forked from askeing/B2G-flash-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_system_fonts.sh
executable file
·104 lines (87 loc) · 2.57 KB
/
update_system_fonts.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
#==========================================================================
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#==========================================================================
# Description:
# Update the system fonts of B2G v2.1 (Bug 1032874).
# https://bugzilla.mozilla.org/show_bug.cgi?id=1032874
#
# Author: Askeing [email protected]
# History:
# 2014/07/07 Askeing: v1.0 First release.
#
#==========================================================================
## URL
FONTS_URL="https://people.mozilla.org/~mwu/fira-font-update.zip"
## Show usage
function helper(){
echo -e "Update the system fonts of B2G v2.1 (Bug 1032874).\n"
exit 0
}
## wget with flags
function run_wget() {
wget -P $@
}
#########################
# Processing Parameters #
#########################
## distinguish platform
case `uname` in
"Linux")
## add getopt argument parsing
TEMP=`getopt -o h --long help \
-n 'invalid option' -- "$@"`
if [ $? != 0 ]; then echo "Try '--help' for more information." >&2; exit 1; fi
eval set -- "$TEMP";;
"Darwin");;
esac
while true
do
case "$1" in
-h|--help) helper; exit 0;;
--) shift;break;;
"") shift;break;;
*) shift;break;;
esac
done
echo
#########################
# Create TEMP Folder #
#########################
if ! which mktemp > /dev/null; then
echo "Package \"mktemp\" not found!"
rm -rf ./fonts_temp
mkdir fonts_temp
cd fonts_temp
TMP_DIR=`pwd`
cd ..
else
rm -rf /tmp/fonts_temp.*
TMP_DIR=`mktemp -d -t fonts_temp.XXXXXXXXXXXX`
fi
#########################
# Download and Unzip #
#########################
run_wget ${TMP_DIR} ${FONTS_URL}
FONTS_BASENAME=`basename ${FONTS_URL}`
unzip -d ${TMP_DIR} ${TMP_DIR}/${FONTS_BASENAME}
echo -e "\n### Please make sure:\n1) your phone is unlocked,\n2) the adb is enabled,\n3) and the adb is running as root."
read -p "### (Press Return to continue...)" is_continue
#########################
# Flash System Fonts #
#########################
CURRENT_DIR=`pwd`
TARGET_DIR=`ls -d ${TMP_DIR}/*/`
echo "${TMP_DIR} ${TARGET_DIR}"
cd ${TARGET_DIR}
bash ./flash.sh
ret=$?
if ! [ ${ret} == 0 ]; then
echo "Flash System Fonts failed."
exit -1
fi
cd ${CURRENT_DIR}
#rm -rf ${TMP_DIR}
echo -e "\n### The following command can update fonts without download again:\n cd ${TARGET_DIR} && ./flash.sh && cd ${CURRENT_DIR}\n"