-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathinstall.sh
executable file
·122 lines (107 loc) · 3.89 KB
/
install.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
# Part of the SEALs project
# https://github.com/kaiwan/seals
# (c) kaiwanTECH
# Set Bash unofficial 'strict mode'; _really_ helps catch bugs
# ref: http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
name=$(basename $0)
# Fetch the SEALs env
source ./build.config || {
echo "${name}: ./build.config file missing or invalid? using defaults if they exist..."
if [ -d ./images ]; then
STG=./
else
echo "No ./images/ dir, aborting..."
exit 1
fi
}
source ./common.sh || {
echo "${name}: source failed! ./common.sh missing or invalid?"
exit 1
}
ShowTitle "SEALS :: Install Script"
[[ -z "${STG}" ]] && {
aecho "${name}: SEALS staging folder isn't defined? You Must correct this and retry..."
aecho "Tip: read the docs (wiki pages), recheck / edit the build.config file"
color_reset
exit 1
}
[[ -d "${STG}" ]] && {
wecho "The staging directory already exists (${STG}).
OVERWRITE it ? Doing so will DESTROY it's content, you can't recover it:
(As a safety measure, you'll again be prompted before wiping Busybox and the kernel source trees)
y/N ? "
get_yn_reply "" n
[ $? -eq 1 ] && exit 0
}
aecho "Creating the staging dir..."
mkdir -p ${STG} || FatalError "Creating the staging dir failed (permission issues?). Aborting..."
#-------------------- Busybox
#BB_INSTALLED=0
echo
set +e # work-around for bash strict mode
get_yn_reply "Pl confirm: Install (and possibly overwrite) busybox source tree (to ${BB_FOLDER}) now? Y/n" y
ans=$?
set -e
#set -x
if [[ ${ans} -eq 0 ]] ; then # ans 'y'
aecho "Installing the busybox source tree"
[[ -d ${BB_FOLDER} ]] && {
aecho "Deleting old content..."
rm -rf ${BB_FOLDER} "$(dirname ${BB_FOLDER})/busybox"
}
mkdir -p ${BB_FOLDER} # abs pathname #|| FatalError "Creating the staging dir failed (permission issues?). Aborting..."
cd ${STG}
runcmd "git clone --depth=1 https://github.com/mirror/busybox"
rmdir ${BB_FOLDER} || true
#BB_INSTALLED=1
aecho "[+] Busybox source tree installed"
fi
#-------------------- Linux kernel
#KSRC_INSTALLED=0
echo
set +e # work-around for bash strict mode
get_yn_reply "Pl confirm: Install (and possibly overwrite) kernel source tree (to ${KERNEL_FOLDER}) now? Y/n" y
ans=$?
set -e
if [[ ${ans} -eq 0 ]] ; then # ans 'y'
aecho "Installing the Linux kernel source tree"
cd ${STG} # abs pathname
# have to figure the URL based on kernel ver...
# f.e. if kver is 3.16.68:
# https://mirrors.edge.kernel.org/pub/linux/kernel/v3.x/linux-3.16.68.tar.xz
# support only >=3.x
K_MJ=$(echo ${KERNELVER} | cut -d'.' -f1)
[[ ${K_MJ} -lt 3 ]] && FatalError "Your specified kernel ver (${KERNELVER}) is too old!
SEALS supports only kernel ver >= 3.x.
Pl change the kernel ver (in the build.config) and rerun"
mkdir -p ${KERNEL_FOLDER} #|| FatalError "Creating the staging dir failed (permission issues?). Aborting..."
#K_MN=$(echo ${KERNELVER} | cut -d'.' -f2)
#K_PL=$(echo ${KERNELVER} | cut -d'.' -f3)
K_URL_BASE=https://mirrors.edge.kernel.org/pub/linux/kernel
K_URL_TARXZ=${K_URL_BASE}/v${K_MJ}.x/linux-${KERNELVER}.tar.xz
# TODO / FIXME : if the tar.xz file exists, don't wget it...
[[ -d ${KERNEL_FOLDER} ]] && {
aecho "Deleting old content..."
rm -f "$(basename ${K_URL_TARXZ})"*
rm -rf ${KERNEL_FOLDER}
}
echo "wget ${K_URL_TARXZ}"
wget ${K_URL_TARXZ} || FatalError "Failed to fetch kernel source."
# TODO - verify integrity
# Uncompress
echo "tar xf $(basename ${K_URL_TARXZ})"
tar xf "$(basename ${K_URL_TARXZ})" || FatalError "Failed to extract kernel source."
#KSRC_INSTALLED=1
aecho "[+] Kernel source tree linux-${KERNELVER} installed"
fi
# TODO - toolchain install
echo "To install the toolchain (Linux x86_64 host to AArch32 or AArch64 target), pl see:
https://github.com/kaiwan/seals/wiki/SEALs-HOWTO
It has detailed instructions.
"
aecho "${name}: all done.
You can now run the build_SEALS.sh script."
color_reset
exit 0