summaryrefslogtreecommitdiff
path: root/script/update/project/repo
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-10-01 06:33:43 +0100
committerLeah Rowe <leah@libreboot.org>2023-10-01 22:47:02 +0100
commit8c03b886c4d4b9bcfb1cb30b3704b8af561c2f45 (patch)
tree828eb1ad589300517e9a41581eee4b5d9605d3e8 /script/update/project/repo
parent5f914a4d00da5ab9324c55eaecc40aa2ee000f63 (diff)
Greatly simplify error handling in shell scripts
Instead of having detailed error messages, run most commands through a function that calls err() under fault conditions. Where detail is still required, err() is still called manually. Where it isn't, the error message is simply whatever command was executed to cause the error. This results in a massive sloccount reduction for lbmk; specifically, 178 sloc reduction, or a 8.1% reduction. The total sloccount is now 2022, for shell scripts. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'script/update/project/repo')
-rwxr-xr-xscript/update/project/repo19
1 files changed, 7 insertions, 12 deletions
diff --git a/script/update/project/repo b/script/update/project/repo
index c0cec1b6..71c3940c 100755
--- a/script/update/project/repo
+++ b/script/update/project/repo
@@ -23,11 +23,9 @@ main()
clone_project
[ "${depend}" = "" ] || for d in ${depend} ; do
- ./update project repo ${d} || \
- fail "Cannot fetch dependency, ${d}, for project, ${name}"
+ xx_ ./update project repo ${d}
done
-
- rm -Rf "${tmp_dir}" || fail "cannot remove tmpdir, ${tmp_dir}"
+ xx_ rm -Rf "${tmp_dir}"
}
verify_config()
@@ -39,8 +37,8 @@ verify_config()
clone_project()
{
- rm -Rf "${tmp_dir}" || fail "clone_project: cannot remove old tmpdir"
- mkdir -p "${tmp_dir%/*}" || fail "clone_project: can't mkdir"
+ xx_ rm -Rf "${tmp_dir}"
+ xx_ mkdir -p "${tmp_dir%/*}"
git clone ${url} "${tmp_dir}" || git clone ${bkup_url} "${tmp_dir}" || \
fail "clone_project: could not download ${name}"
@@ -50,12 +48,9 @@ clone_project()
fail "clone_project ${loc}/: cannot apply patches"
[ ! -d "${loc}" ] || \
- rm -Rf "${loc}" || \
- fail "clone_project: Can't remove directory '${loc}'"
- [ "${loc}" = "${loc%/*}" ] || mkdir -p ${loc%/*} || \
- fail "clone_project: cannot make directory for ${name}"
- mv "${tmp_dir}" "${loc}" || \
- fail "clone_project: could not copy temp file to destination"
+ xx_ rm -Rf "${loc}"
+ [ "${loc}" = "${loc%/*}" ] || xx_ mkdir -p ${loc%/*}
+ xx_ mv "${tmp_dir}" "${loc}"
}
fail()