Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 339 lines (300 sloc) 9.823 kb
9805f8f @Hexxeh Added initial version of update tool
authored
1 #!/bin/bash
2
80c9961 @Hexxeh Added self-updater
authored
3 set -o nounset
4 set -o errexit
5
ec1ef11 @popcornmix Allow REPO_URI to be overridden.
popcornmix authored
6 REPO_URI=${REPO_URI:-"https://github.com/Hexxeh/rpi-firmware"}
16c2061 @Hexxeh Added support for installing a specific firmware revision
authored
7
1361c8f @nylen Add option to disable self-updating
nylen authored
8 UPDATE_SELF=${UPDATE_SELF:-1}
e05cd7a @popcornmix Update url to githubusercontent
popcornmix authored
9 UPDATE_URI="https://raw.githubusercontent.com/Hexxeh/rpi-update/master/rpi-update"
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
10
faad48b @adammw Test if BOOT_PATH and ROOT_PATH are unset rather than their default valu...
adammw authored
11 if [[ ${BOOT_PATH:-"unset"} == "unset" && ${ROOT_PATH:-"unset"} != "unset" ]] ||
12 [[ ${BOOT_PATH:-"unset"} != "unset" && ${ROOT_PATH:-"unset"} == "unset" ]]; then
4652f64 @nylen Further improve progress messages
nylen authored
13 echo " *** You need to specify both ROOT_PATH and BOOT_PATH, or neither"
faad48b @adammw Test if BOOT_PATH and ROOT_PATH are unset rather than their default valu...
adammw authored
14 exit 1
15 fi
16
ba094ca @XECDesign Check for NOOBS files in /boot
XECDesign authored
17 if [[ ${BOOT_PATH:-"unset"} == "unset" ]]; then
18 NOOBS_CHECK=${NOOBS_CHECK:-1}
19 else
20 NOOBS_CHECK=${NOOBS_CHECK:-0}
21 fi
22
a933ec6 @rm-hull BRANCH env variable allows alternate branch to be specified
rm-hull authored
23 BRANCH=${BRANCH:-"master"}
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
24 ROOT_PATH=${ROOT_PATH:-"/"}
25 BOOT_PATH=${BOOT_PATH:-"/boot"}
87044fb @lurch Added a new $WORK_PATH variable
lurch authored
26 WORK_PATH=${WORK_PATH:-"${ROOT_PATH}/root"}
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
27 SKIP_KERNEL=${SKIP_KERNEL:-0}
a1fb550 @lurch Separate updating of vc_libs and sdk, allow sdk to be skipped
lurch authored
28 SKIP_SDK=${SKIP_SDK:-0}
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
29 SKIP_REPODELETE=${SKIP_REPODELETE:-0}
30 SKIP_BACKUP=${SKIP_BACKUP:-0}
f7baa38 @popcornmix Support install from local repo.
popcornmix authored
31 SKIP_DOWNLOAD=${SKIP_DOWNLOAD:-0}
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
32 WANT_SYMVERS=${WANT_SYMVERS:-0}
3a3fa3b @samnazarko Ensure that rpi-update will not update unsupported distributions
samnazarko authored
33 RPI_UPDATE_UNSUPPORTED=${RPI_UPDATE_UNSUPPORTED:-0}
e346828 @popcornmix Add a JUST_CHECK=1 option which just reports if a firmware update is nee...
popcornmix authored
34 JUST_CHECK=${JUST_CHECK:-0}
5e8344a @Hexxeh Fix incorrect repo path
authored
35 FW_REPO="${REPO_URI}.git"
f7baa38 @popcornmix Support install from local repo.
popcornmix authored
36 FW_REPOLOCAL=${FW_REPOLOCAL:-"${WORK_PATH}/.rpi-firmware"}
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
37 FW_PATH="${BOOT_PATH}"
38 FW_MODPATH="${ROOT_PATH}/lib/modules"
da74cb3 @Hexxeh Added support for new gpu_mem
authored
39 FW_REV=${1:-""}
b7d3dba @lurch Replace usages of $FW_PATH/.firmware_revision with a $FW_REVFILE variabl...
lurch authored
40 FW_REVFILE="${FW_PATH}/.firmware_revision"
522a20f @lurch Ensure all string variables are fully quoted
lurch authored
41 [ "${RPI_UPDATE_UNSUPPORTED}" -ne 0 ] && echo -e "You appear to be trying to update firmware on an incompatible distribution. To force update, run the following:\nsudo -E RPI_UPDATE_UNSUPPORTED=0 rpi-update" && exit 1
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
42
80c9961 @Hexxeh Added self-updater
authored
43 function update_self() {
4652f64 @nylen Further improve progress messages
nylen authored
44 echo " *** Performing self-update"
80c9961 @Hexxeh Added self-updater
authored
45 _tempFileName="$0.tmp"
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
46
dd495b8 @popcornmix Switch from wget to curl for downloads
popcornmix authored
47 if ! curl -L --output "${_tempFileName}" "${UPDATE_URI}"; then
4652f64 @nylen Further improve progress messages
nylen authored
48 echo " !!! Failed to download update for rpi-update!"
49 echo " !!! Make sure you have ca-certificates installed and that the time is set correctly"
80c9961 @Hexxeh Added self-updater
authored
50 exit 1
51 fi
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
52
53 OCTAL_MODE=$(stat -c '%a' "$0")
54 if ! chmod ${OCTAL_MODE} "${_tempFileName}" ; then
4652f64 @nylen Further improve progress messages
nylen authored
55 echo " !!! Failed: Error while trying to set mode on ${_tempFileName}"
80c9961 @Hexxeh Added self-updater
authored
56 exit 1
57 fi
58
87044fb @lurch Added a new $WORK_PATH variable
lurch authored
59 cat > "${WORK_PATH}/.updateScript.sh" << EOF
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
60 if mv "${_tempFileName}" "$0"; then
61 rm -- "\$0"
1361c8f @nylen Add option to disable self-updating
nylen authored
62 exec env UPDATE_SELF=0 /bin/bash "$0" "${FW_REV}"
80c9961 @Hexxeh Added self-updater
authored
63 else
4652f64 @nylen Further improve progress messages
nylen authored
64 echo " !!! Failed!"
80c9961 @Hexxeh Added self-updater
authored
65 fi
66 EOF
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
67
4652f64 @nylen Further improve progress messages
nylen authored
68 echo " *** Relaunching after update"
87044fb @lurch Added a new $WORK_PATH variable
lurch authored
69 exec /bin/bash "${WORK_PATH}/.updateScript.sh"
80c9961 @Hexxeh Added self-updater
authored
70 }
71
76d8634 @Hexxeh Added VC libs update support and tidied the script up a little
authored
72 function update_modules {
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
73 if [[ ${SKIP_KERNEL} -eq 0 ]]; then
b514610 @lurch Status message updates
lurch authored
74 echo " *** Updating kernel modules"
fb5babd @popcornmix Remove old modules before installing new ones
popcornmix authored
75 find "${FW_REPOLOCAL}/modules" -mindepth 1 -maxdepth 1 -type d | while read DIR; do
f1ce518 @popcornmix Remove old modules before installing new ones: Avoid removing extra modu...
popcornmix authored
76 BASEDIR=$(basename "${DIR}")
77 rm -rf "${FW_MODPATH}/${BASEDIR}/kernel"
fb5babd @popcornmix Remove old modules before installing new ones
popcornmix authored
78 done
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
79 cp -R "${FW_REPOLOCAL}/modules/"* "${FW_MODPATH}/"
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
80 find "${FW_REPOLOCAL}/modules" -mindepth 1 -maxdepth 1 -type d | while read DIR; do
522a20f @lurch Ensure all string variables are fully quoted
lurch authored
81 BASEDIR=$(basename "${DIR}")
82 echo " *** depmod ${BASEDIR}"
83 depmod -b "${ROOT_PATH}" -a "${BASEDIR}"
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
84 done
4652f64 @nylen Further improve progress messages
nylen authored
85 else
b514610 @lurch Status message updates
lurch authored
86 echo " *** As requested, not updating kernel modules"
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
87 fi
80c9961 @Hexxeh Added self-updater
authored
88 }
48b6de4 @Hexxeh Add check for root
authored
89
a1fb550 @lurch Separate updating of vc_libs and sdk, allow sdk to be skipped
lurch authored
90 function update_vc_libs {
91 echo " *** Updating VideoCore libraries"
4652f64 @nylen Further improve progress messages
nylen authored
92
82ca97b @popcornmix Use /bin/sh rather than /bin/bash for determining hard/soft float
popcornmix authored
93 ELFOUTPUT=$(readelf -a "${ROOT_PATH}/bin/sh")
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
94 if [ "${ELFOUTPUT}" != "${ELFOUTPUT/VFP_args/}" ]; then
4652f64 @nylen Further improve progress messages
nylen authored
95 echo " *** Using HardFP libraries"
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
96 cp -R "${FW_REPOLOCAL}/vc/hardfp/"* "${ROOT_PATH}/"
76d8634 @Hexxeh Added VC libs update support and tidied the script up a little
authored
97 else
4652f64 @nylen Further improve progress messages
nylen authored
98 echo " *** Using SoftFP libraries"
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
99 cp -R "${FW_REPOLOCAL}/vc/softfp/"* "${ROOT_PATH}/"
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
100 fi
a1fb550 @lurch Separate updating of vc_libs and sdk, allow sdk to be skipped
lurch authored
101 }
102
103 function update_sdk {
104 if [[ ${SKIP_SDK} -eq 0 ]]; then
105 echo " *** Updating SDK"
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
106 cp -R "${FW_REPOLOCAL}/vc/sdk/"* "${ROOT_PATH}/"
a1fb550 @lurch Separate updating of vc_libs and sdk, allow sdk to be skipped
lurch authored
107 else
108 echo " *** As requested, not updating SDK"
109 fi
76d8634 @Hexxeh Added VC libs update support and tidied the script up a little
authored
110 }
111
6bb57b7 @XECDesign Print NOTICE.md
XECDesign authored
112 function show_notice {
113 local NOTICE=`curl -Lfs https://raw.githubusercontent.com/hexxeh/rpi-firmware/${FW_REV}/NOTICE.md`
114 if [ -z "$NOTICE" ]; then
115 return
116 fi
117 echo "$NOTICE"
118 if ! echo "$NOTICE" | grep -q WARNING; then
119 return
120 fi
121 read -p "Would you like to proceed? (y/N)" -n 1 -r -s
122 echo ""
123 if ! [[ $REPLY =~ ^[Yy]$ ]]; then
124 exit 1;
125 fi
126 }
127
ecf2897 @Hexxeh Updated to store repo on root partition
authored
128 function update_firmware {
4652f64 @nylen Further improve progress messages
nylen authored
129 echo " *** Updating firmware"
522a20f @lurch Ensure all string variables are fully quoted
lurch authored
130 rm -rf "${FW_PATH}/"*.elf
59b09e6 @ghollingworth Stop rpi-update deleting dt-blob.bin
ghollingworth authored
131 rm -rf "${FW_PATH}/"bootcode.bin
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
132 cp "${FW_REPOLOCAL}/"*.elf "${FW_PATH}/"
133 cp "${FW_REPOLOCAL}/"*.bin "${FW_PATH}/"
134 cp "${FW_REPOLOCAL}/"*.dat "${FW_PATH}/"
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
135 if [[ ${SKIP_KERNEL} -eq 0 ]]; then
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
136 cp "${FW_REPOLOCAL}/"*.img "${FW_PATH}/"
127f4ce @notro Add support for pre/post install scripts and Device Tree Blobs
notro authored
137 if [[ -n $(shopt -s nullglob; echo "${FW_REPOLOCAL}/"*.dtb) ]]; then
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
138 cp "${FW_REPOLOCAL}/"*.dtb "${FW_PATH}/"
127f4ce @notro Add support for pre/post install scripts and Device Tree Blobs
notro authored
139 fi
a7513b5 @popcornmix Also copy device tree overlays if present
popcornmix authored
140 if [[ -n $(shopt -s nullglob; echo "${FW_REPOLOCAL}/overlays/"*.dtb) ]]; then
aba0d5f @lurch Also copy the overlays README file
lurch authored
141 mkdir -p "${FW_PATH}/overlays"
142 cp "${FW_REPOLOCAL}/overlays/"*.dtb "${FW_PATH}/overlays/"
143 if [[ -f "${FW_REPOLOCAL}/overlays/README" ]]; then
144 cp "${FW_REPOLOCAL}/overlays/README" "${FW_PATH}/overlays/"
145 fi
a7513b5 @popcornmix Also copy device tree overlays if present
popcornmix authored
146 fi
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
147 else
4652f64 @nylen Further improve progress messages
nylen authored
148 echo " *** As requested, not updating kernel"
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
149 fi
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
150 if [[ ${WANT_SYMVERS} -ne 0 ]]; then
8c76703 @lurch Minor consistency fixes
lurch authored
151 if [[ -f "${FW_REPOLOCAL}/Module.symvers" ]]; then
152 cp "${FW_REPOLOCAL}/Module.symvers" "${FW_PATH}/"
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
153 fi
8c76703 @lurch Minor consistency fixes
lurch authored
154 if [[ -f "${FW_REPOLOCAL}/git_hash" ]]; then
155 cp "${FW_REPOLOCAL}/git_hash" "${FW_PATH}/"
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
156 fi
157 fi
76d8634 @Hexxeh Added VC libs update support and tidied the script up a little
authored
158 }
159
bd0e2dd @Hexxeh Fixed readelf package names, added ldconfig call
authored
160 function finalise {
062fbdf @Hexxeh Copy start.elf when installing an older firmware
authored
161 if [[ -f "${FW_PATH}/arm192_start.elf" ]]; then
4652f64 @nylen Further improve progress messages
nylen authored
162 echo " *** Setting 192M ARM split"
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
163 cp "${FW_PATH}/arm192_start.elf" "${FW_PATH}/start.elf"
062fbdf @Hexxeh Copy start.elf when installing an older firmware
authored
164 fi
4652f64 @nylen Further improve progress messages
nylen authored
165 echo " *** Running ldconfig"
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
166 ldconfig -r "${ROOT_PATH}"
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
167 echo " *** Storing current firmware revision"
168 echo "${FW_REV}" > "${FW_REVFILE}"
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
169 }
170
171 function do_backup {
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
172 if [[ ${SKIP_BACKUP} -eq 0 ]]; then
173 echo " *** Backing up files (this will take a few minutes)"
1f02f85 @popcornmix Fix existence checks for backup directories.
popcornmix authored
174 if [[ -d "${FW_PATH}.bak" ]]; then
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
175 echo " *** Remove old firmware backup"
176 rm -rf "${FW_PATH}.bak"
177 fi
178 echo " *** Backing up firmware"
179 cp -a "${FW_PATH}" "${FW_PATH}.bak"
180 if [[ ${SKIP_KERNEL} -eq 0 ]]; then
1f02f85 @popcornmix Fix existence checks for backup directories.
popcornmix authored
181 if [[ -d "${FW_MODPATH}.bak" ]]; then
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
182 echo " *** Remove old modules backup"
183 rm -rf "${FW_MODPATH}.bak"
184 fi
185 echo " *** Backing up modules $(uname -r)"
1f02f85 @popcornmix Fix existence checks for backup directories.
popcornmix authored
186 if [[ -d "${FW_MODPATH}/$(uname -r)" ]]; then
4b4f910 @popcornmix Skip modules backup if path doesn't exist
popcornmix authored
187 mkdir -p "${FW_MODPATH}.bak" && cp -a "${FW_MODPATH}/$(uname -r)" "${FW_MODPATH}.bak"
188 fi
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
189 fi
e92f4b3 @popcornmix Don't require /lib/modules when SKIP_KERNEL is requested pt 2
popcornmix authored
190 fi
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
191 }
192
193 function do_update {
6bb57b7 @XECDesign Print NOTICE.md
XECDesign authored
194 show_notice
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
195 download_rev
127f4ce @notro Add support for pre/post install scripts and Device Tree Blobs
notro authored
196 if [[ -f "${FW_REPOLOCAL}/pre-install" ]]; then
197 echo " *** Running pre-install script"
198 source "${FW_REPOLOCAL}/pre-install"
199 fi
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
200 update_firmware
201 update_modules
a1fb550 @lurch Separate updating of vc_libs and sdk, allow sdk to be skipped
lurch authored
202 update_vc_libs
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
203 update_sdk
204 finalise
127f4ce @notro Add support for pre/post install scripts and Device Tree Blobs
notro authored
205 if [[ -f "${FW_REPOLOCAL}/post-install" ]]; then
206 echo " *** Running post-install script"
207 source "${FW_REPOLOCAL}/post-install"
208 fi
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
209 remove_rev
210 echo " *** Syncing changes to disk"
211 sync
212 echo " *** If no errors appeared, your firmware was successfully updated to ${FW_REV}"
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
213 if [[ "${ROOT_PATH}" == "/" ]]; then
4652f64 @nylen Further improve progress messages
nylen authored
214 echo " *** A reboot is needed to activate the new firmware"
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
215 fi
216 }
217
16c2061 @Hexxeh Added support for installing a specific firmware revision
authored
218 function download_rev {
f7baa38 @popcornmix Support install from local repo.
popcornmix authored
219 if [[ ${SKIP_DOWNLOAD} -eq 0 ]]; then
220 echo " *** Downloading specific firmware revision (this will take a few minutes)"
221 rm -rf "${FW_REPOLOCAL}"
222 mkdir -p "${FW_REPOLOCAL}"
223 curl -L "${REPO_URI}/tarball/${FW_REV}" | tar xzf - -C "${FW_REPOLOCAL}" --strip-components=1
224 fi
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
225 }
226
227 function remove_rev {
228 echo " *** Deleting downloaded files"
229 if [[ ${SKIP_REPODELETE} -eq 0 ]]; then
230 rm -rf "${FW_REPOLOCAL}"
231 fi
16c2061 @Hexxeh Added support for installing a specific firmware revision
authored
232 }
233
ba094ca @XECDesign Check for NOOBS files in /boot
XECDesign authored
234 function noobs_fix {
235 echo " !!! $BOOT_PATH appears to contain NOOBS files"
236 echo " This may occur if fstab contains incorrect entries."
237 echo " rpi-update will attempt to correct fstab."
238 read -p "Would you like to proceed? (y/N)" -n 1 -r -s
239 echo
240 if ! [[ $REPLY =~ ^[Yy]$ ]]; then
241 exit 1;
242 fi
243
244 if ! grep -qE "/dev/mmcblk0p1\s+/boot" ${ROOT_PATH}/etc/fstab; then
245 echo "Unexpected fstab entry"
246 exit 1
247 fi
248
249 local ROOTNUM=`cat /proc/cmdline | sed -n 's|.*root=/dev/mmcblk0p\([0-9]*\).*|\1|p'`
250 if [ ! "$ROOTNUM" ];then
251 echo "Could not determine root partition."
252 exit 1
253 fi
254 local BOOT_DEV="/dev/mmcblk0p$((ROOTNUM-1))"
255 local ROOT_DEV="/dev/mmcblk0p${ROOTNUM}"
256 sed ${ROOT_PATH}/etc/fstab -e "s|^.*[^#].* / |${ROOT_DEV} / |;s|^.*[^#].* /boot |${BOOT_DEV} /boot |"
257 read -p "Does this look correct? (y/N)" -n 1 -r -s
258 echo
259 if ! [[ $REPLY =~ ^[Yy]$ ]]; then
260 exit 1;
261 fi
262 sed ${ROOT_PATH}/etc/fstab -i -e "s|^.*[^#].* / |${ROOT_DEV} / |;s|^.*[^#].* /boot |${BOOT_DEV} /boot |"
263
264 umount /boot
265 if [ $? -ne 0 ]; then
266 echo "Failed to umount /boot. Remount manually and try again."
267 exit 1
268 else
269 mount /boot
270 fi
271
272 }
273
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
274 if [[ ${EUID} -ne 0 ]]; then
4652f64 @nylen Further improve progress messages
nylen authored
275 echo " !!! This tool must be run as root"
48b6de4 @Hexxeh Add check for root
authored
276 exit 1
277 fi
278
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
279 echo " *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom"
1361c8f @nylen Add option to disable self-updating
nylen authored
280
281 if [[ ${UPDATE_SELF} -ne 0 ]]; then
80c9961 @Hexxeh Added self-updater
authored
282 update_self
283 fi
284
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
285 if [[ ! -d "${FW_PATH}" ]]; then
4652f64 @nylen Further improve progress messages
nylen authored
286 echo " !!! ${FW_PATH} doesn't exist"
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
287 exit 1
288 fi
ee7802a @popcornmix Don't require /lib/modules when SKIP_KERNEL is requested
popcornmix authored
289
290 if [[ ${SKIP_KERNEL} -eq 0 ]] && [[ ! -d "${FW_MODPATH}" ]]; then
4652f64 @nylen Further improve progress messages
nylen authored
291 echo " !!! ${FW_MODPATH} doesn't exist"
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
292 exit 1
293 fi
294
ba094ca @XECDesign Check for NOOBS files in /boot
XECDesign authored
295 if [[ ${NOOBS_CHECK} -eq 1 ]] && [[ -f ${BOOT_PATH}/recovery.elf ]]; then
296 noobs_fix
297 fi
298
76d8634 @Hexxeh Added VC libs update support and tidied the script up a little
authored
299 command -v readelf >/dev/null 2>&1 || {
4652f64 @nylen Further improve progress messages
nylen authored
300 echo " !!! This tool requires you have readelf installed, please install it first"
301 echo " In Debian, try: sudo apt-get install binutils"
302 echo " In Arch, try: pacman -S binutils"
76d8634 @Hexxeh Added VC libs update support and tidied the script up a little
authored
303 exit 1
304 }
305
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
306 # ask github for latest version hash
307 REPO_API=${REPO_URI/github.com/api.github.com\/repos}/git/refs/heads/${BRANCH}
5ff5b10 @popcornmix cosmetic: Make use the REPO_API variable
popcornmix authored
308 GITREV=$(curl -s ${REPO_API} | awk '{ if ($1 == "\"sha\":") { print substr($2, 2, 40) } }')
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
309 FW_REV=${FW_REV:-${GITREV}}
310
311 if [[ "${FW_REV}" == "" ]]; then
312 echo " *** No hash received from github: ${REPO_API}"
8c76703 @lurch Minor consistency fixes
lurch authored
313 # run again with errors not suppressed
314 curl ${REPO_API}
315 exit 1
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
316 fi
317
318 if [[ ! -f "${FW_REVFILE}" ]]; then
4652f64 @nylen Further improve progress messages
nylen authored
319 echo " *** We're running for the first time"
e346828 @popcornmix Add a JUST_CHECK=1 option which just reports if a firmware update is nee...
popcornmix authored
320 if [[ ${JUST_CHECK} -ne 0 ]]; then
321 exit 2
322 fi
e9c85cd @Hexxeh Added RAM split detection, added offline mode, added option to skip kern...
authored
323 do_backup
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
324 else
8c76703 @lurch Minor consistency fixes
lurch authored
325 if [[ $(cat "${FW_REVFILE}") == "${FW_REV}" ]]; then
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
326 echo " *** Your firmware is already up to date"
327 exit 0
328 fi
e346828 @popcornmix Add a JUST_CHECK=1 option which just reports if a firmware update is nee...
popcornmix authored
329 if [[ ${JUST_CHECK} -ne 0 ]]; then
330 echo " *** Firmware update required. New commits available:"
331 DIFF_API=${REPO_URI/github.com/api.github.com\/repos}/compare/$(cat "${FW_REVFILE}")...${BRANCH}
332 SEPARATOR="======================================================"
6bb57b7 @XECDesign Print NOTICE.md
XECDesign authored
333 curl -Ls ${DIFF_API} | awk -v SEPARATOR="${SEPARATOR}" -F\" ' { if ($2 == "commits") {commits=1} if (commits && $2 == "message") {print SEPARATOR "\n" $4} }' | sed 's/\\n/\n/g'
e346828 @popcornmix Add a JUST_CHECK=1 option which just reports if a firmware update is nee...
popcornmix authored
334 exit 2
335 fi
9805f8f @Hexxeh Added initial version of update tool
authored
336 fi
41e23a0 @popcornmix Download firmware without using git
popcornmix authored
337
338 do_update
Something went wrong with that request. Please try again.