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