Skip to content
Browse files

Handle errors from a git update by cloning a fresh repo.

Remove old backup directory before creating a new one. Avoids recursive backup when removing .rpi-firmware
  • Loading branch information...
1 parent 0609fa4 commit 214184a62fa790c26705e2b3d516255e592accb2 @popcornmix popcornmix committed Jan 8, 2013
Showing with 18 additions and 12 deletions.
  1. +18 −12 rpi-update
View
30 rpi-update
@@ -123,8 +123,10 @@ function finalise {
function download_repo {
echo " *** Setting up firmware (this may take a few minutes)"
mkdir -p "${FW_REPOLOCAL}"
+ set +e
git clone "${FW_REPO}" "${FW_REPOLOCAL}" --depth=1
RETVAL=$?
+ set -e
if [[ ${RETVAL} -ne 0 ]]; then
echo " !!! Failed to download new firmware files"
exit 1
@@ -133,26 +135,34 @@ function download_repo {
function update_repo {
echo " *** Updating firmware (this may take a few minutes)"
+ set +e
eval ${GITCMD} fetch --depth=1
RETVAL=$?
+ set -e
if [[ ${RETVAL} -ne 0 ]]; then
- echo " !!! Failed to download updated firmware files"
- exit 1
+ echo " !!! Failed to fetch updated firmware files, trying a fresh checkout"
+ rm -rf ${FW_REPOLOCAL}
+ download_repo
+ return
fi
- eval ${GITCMD} reset --hard
- eval ${GITCMD} clean -f -d
- eval ${GITCMD} merge origin/master -m "automerge"
+ set +e
+ eval ${GITCMD} reset --hard && eval ${GITCMD} clean -f -d && eval ${GITCMD} merge origin/master -m "automerge"
RETVAL=$?
+ set -e
if [[ ${RETVAL} -ne 0 ]]; then
- echo " !!! Failed to download updated firmware files"
- exit 1
+ echo " !!! Failed to merge updated firmware files, trying a fresh checkout"
+ rm -rf ${FW_REPOLOCAL}
+ download_repo
+ return
fi
}
function do_backup {
echo " *** Backing up files"
+ rm -rf "${FW_PATH}.bak"
cp -va "${FW_PATH}" "${FW_PATH}.bak"
- cp -va "${FW_MODPATH}" "${FW_MODPATH}.bak"
+ rm -rf "${FW_MODPATH}.bak"
+ cp -va "${FW_MODPATH}" ""
}
function do_update {
@@ -189,10 +199,6 @@ if [[ ! -d "${FW_PATH}" ]]; then
echo " !!! ${FW_PATH} doesn't exist"
exit 1
fi
-if [[ ! -f "${FW_PATH}/start.elf" ]]; then
- echo " !!! ${FW_PATH}/start.elf doesn't exist."
- exit 1
-fi
if [[ ! -d "${FW_MODPATH}" ]]; then
echo " !!! ${FW_MODPATH} doesn't exist"
exit 1

0 comments on commit 214184a

Please sign in to comment.
Something went wrong with that request. Please try again.