mirror of
https://github.com/raspberrypi/rpi-update.git
synced 2026-01-20 21:13:38 +08:00
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
This commit is contained in:
30
rpi-update
30
rpi-update
@@ -123,8 +123,10 @@ function finalise {
|
|||||||
function download_repo {
|
function download_repo {
|
||||||
echo " *** Setting up firmware (this may take a few minutes)"
|
echo " *** Setting up firmware (this may take a few minutes)"
|
||||||
mkdir -p "${FW_REPOLOCAL}"
|
mkdir -p "${FW_REPOLOCAL}"
|
||||||
|
set +e
|
||||||
git clone "${FW_REPO}" "${FW_REPOLOCAL}" --depth=1
|
git clone "${FW_REPO}" "${FW_REPOLOCAL}" --depth=1
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
|
set -e
|
||||||
if [[ ${RETVAL} -ne 0 ]]; then
|
if [[ ${RETVAL} -ne 0 ]]; then
|
||||||
echo " !!! Failed to download new firmware files"
|
echo " !!! Failed to download new firmware files"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -133,26 +135,34 @@ function download_repo {
|
|||||||
|
|
||||||
function update_repo {
|
function update_repo {
|
||||||
echo " *** Updating firmware (this may take a few minutes)"
|
echo " *** Updating firmware (this may take a few minutes)"
|
||||||
|
set +e
|
||||||
eval ${GITCMD} fetch --depth=1
|
eval ${GITCMD} fetch --depth=1
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
|
set -e
|
||||||
if [[ ${RETVAL} -ne 0 ]]; then
|
if [[ ${RETVAL} -ne 0 ]]; then
|
||||||
echo " !!! Failed to download updated firmware files"
|
echo " !!! Failed to fetch updated firmware files, trying a fresh checkout"
|
||||||
exit 1
|
rm -rf ${FW_REPOLOCAL}
|
||||||
|
download_repo
|
||||||
|
return
|
||||||
fi
|
fi
|
||||||
eval ${GITCMD} reset --hard
|
set +e
|
||||||
eval ${GITCMD} clean -f -d
|
eval ${GITCMD} reset --hard && eval ${GITCMD} clean -f -d && eval ${GITCMD} merge origin/master -m "automerge"
|
||||||
eval ${GITCMD} merge origin/master -m "automerge"
|
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
|
set -e
|
||||||
if [[ ${RETVAL} -ne 0 ]]; then
|
if [[ ${RETVAL} -ne 0 ]]; then
|
||||||
echo " !!! Failed to download updated firmware files"
|
echo " !!! Failed to merge updated firmware files, trying a fresh checkout"
|
||||||
exit 1
|
rm -rf ${FW_REPOLOCAL}
|
||||||
|
download_repo
|
||||||
|
return
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_backup {
|
function do_backup {
|
||||||
echo " *** Backing up files"
|
echo " *** Backing up files"
|
||||||
|
rm -rf "${FW_PATH}.bak"
|
||||||
cp -va "${FW_PATH}" "${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 {
|
function do_update {
|
||||||
@@ -189,10 +199,6 @@ if [[ ! -d "${FW_PATH}" ]]; then
|
|||||||
echo " !!! ${FW_PATH} doesn't exist"
|
echo " !!! ${FW_PATH} doesn't exist"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ ! -f "${FW_PATH}/start.elf" ]]; then
|
|
||||||
echo " !!! ${FW_PATH}/start.elf doesn't exist."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [[ ! -d "${FW_MODPATH}" ]]; then
|
if [[ ! -d "${FW_MODPATH}" ]]; then
|
||||||
echo " !!! ${FW_MODPATH} doesn't exist"
|
echo " !!! ${FW_MODPATH} doesn't exist"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user