forked from friendlyarm/sd-fuse_s5p6818
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mk-emmc-image.sh
executable file
·95 lines (83 loc) · 2.86 KB
/
mk-emmc-image.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
#!/bin/bash
set -eu
# Copyright (C) Guangzhou FriendlyARM Computer Tech. Co., Ltd.
# (http://www.friendlyarm.com)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, you can access it online at
# http://www.gnu.org/licenses/gpl-2.0.html.
function usage() {
echo "Usage: $0 <friendlycore-arm64|friendlycore|friendlycore-arm64|friendlycore-lite-focal|friendlycore-lite-focal-arm64|friendlywrt|lubuntu|android|android7>"
exit 0
}
if [ $# -eq 0 ]; then
usage
fi
. tools/util.sh
check_and_install_package
# ----------------------------------------------------------
# Get platform, target OS
true ${SOC:=s5p6818}
true ${TARGET_OS:=$(echo ${1,,}|sed 's/\///g')}
case ${TARGET_OS} in
friendlycore* | lubuntu* | android | android7 | friendlywrt)
;;
*)
echo "Error: Unsupported target OS: ${TARGET_OS}"
exit 0
esac
download_img() {
local PARTMAP=$(dirname $0)/${1}/partmap.txt
if [ ! -f "${PARTMAP}" ]; then
ROMFILE=`./tools/get_pkg_filename.sh ${1}`
cat << EOF
Warn: Image not found for ${1}
----------------
you may download it from the netdisk (dl.friendlyarm.com) to get a higher downloading speed,
the image files are stored in a directory called "03_Partition image files", for example:
tar xvzf /path/to/NetDrive/03_Partition\ image\ files/${ROMFILE}
----------------
Do you want to download it now via http? (Y/N):
EOF
while read -r -n 1 -t 3600 -s USER_REPLY; do
if [[ ${USER_REPLY} = [Nn] ]]; then
echo ${USER_REPLY}
exit 1
elif [[ ${USER_REPLY} = [Yy] ]]; then
echo ${USER_REPLY}
break;
fi
done
if [ -z ${USER_REPLY} ]; then
echo "Cancelled."
exit 1
fi
./tools/get_rom.sh ${1} || exit 1
fi
}
download_img ${TARGET_OS}
download_img eflasher
# Automatically re-run script under sudo if not root
if [ $(id -u) -ne 0 ]; then
echo "Re-running script under sudo..."
sudo --preserve-env "$0" "$@"
exit
fi
true ${RAW_SIZE_MB:=0}
RAW_SIZE_MB=${RAW_SIZE_MB} ./mk-sd-image.sh eflasher && \
./tools/fill_img_to_eflasher out/${SOC}-eflasher-$(date +%Y%m%d).img ${SOC} $@ && {
rm -f out/${SOC}-eflasher-$(date +%Y%m%d).img
mkdir -p out/images-for-eflasher
tar czf out/images-for-eflasher/${TARGET_OS}-images.tgz ${TARGET_OS}
echo "all done."
}