From 90b4455dbab96a0dae5a7e4b269dc9979cd861fc Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 26 May 2020 12:38:29 +0200 Subject: build-initramfs.sh: more error handling --- build-initramfs.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'build-initramfs.sh') diff --git a/build-initramfs.sh b/build-initramfs.sh index 4966d0d4..303e3186 100755 --- a/build-initramfs.sh +++ b/build-initramfs.sh @@ -131,6 +131,7 @@ bootstrap() { echo " Commit: ${_ref[commit]}" echo " Path: ${_ref[path]}" + # handlers deal with errors on their own handler_${_ref[handler]} \ "${_ref[path]}" \ "${_ref[url]}" \ @@ -141,13 +142,19 @@ bootstrap() { shopt -s nullglob pushd "${_ref[path]}" for patch in "${_repo_dir}/patches/${_ref[path]##*/}/"*.patch; do - patch -p1 < "$patch" + if ! patch -p1 < "$patch"; then + echo "Applying '$patch' failed, expecting errors. Continuing..." + fi done popd done } handler_git() { + if ! hash git 2>/dev/null; then + echo "'git' binary not found, please install it and try again." + exit 1 + fi local path="$1" local url="$2" local branch="$3" @@ -190,11 +197,16 @@ handler_git() { } handler_http() { + if ! hash curl tar 2>/dev/null; then + echo "'curl'/'tar' binaries not found, please install them and try again." + exit 1 + fi local path="$1" local url="$2" mkdir --parents "$path" + set -o pipefail curl \ --location \ --max-redirs 5 \ @@ -208,6 +220,10 @@ handler_http() { --gzip \ --directory "$path" \ --strip-components 1 + if [ $? -ne 0 ]; then + echo "Failed to download/extract '$url' to '$path'." + exit 1 + fi } -- cgit v1.2.3-55-g7522