Pārlūkot izejas kodu

support/download/git: properly catch failures

Since commit b7efb43e86da (download/git: try to recover from
utterly-broken repositories), we catch errors through an ERR
trap, so we can try and recover from a broken repository. In
that commit, we switched from using "set -e" to "set -E", so
that trap is inherited in functions, command substitutions,
and subshells.

However, the trap is not defined until we have parsed the
options, created the cache directory, and eventually chdir()ed
into it. Athough improbable, it is possible for the git helper
to fail in any of those steps, and that would not get caught.

Fix that

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
(cherry picked from commit daa341cb9bc82d8bcb175c46da1ba80fd9203a98)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Yann E. MORIN 1 gadu atpakaļ
vecāks
revīzija
6c11a91e2a
1 mainītis faili ar 3 papildinājumiem un 2 dzēšanām
  1. 3 2
      support/download/git

+ 3 - 2
support/download/git

@@ -5,8 +5,8 @@
 # (e.g. tar options, compression ratio or method)), we MUST update the format
 # (e.g. tar options, compression ratio or method)), we MUST update the format
 # version in the variable BR_FMT_VERSION_git, in package/pkg-download.mk.
 # version in the variable BR_FMT_VERSION_git, in package/pkg-download.mk.
 
 
-# We want to catch any unexpected failure, and exit immediately
-set -E
+# We want to catch any unexpected failure
+set -e
 
 
 # Download helper for git, to be called from the download wrapper script
 # Download helper for git, to be called from the download wrapper script
 #
 #
@@ -77,6 +77,7 @@ pushd "${git_cache}" >/dev/null
 
 
 # Any error now should try to recover
 # Any error now should try to recover
 trap _on_error ERR
 trap _on_error ERR
+set -E
 
 
 # Caller needs to single-quote its arguments to prevent them from
 # Caller needs to single-quote its arguments to prevent them from
 # being expanded a second time (in case there are spaces in them)
 # being expanded a second time (in case there are spaces in them)