summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xinclude/git.sh9
-rwxr-xr-xinclude/lib.sh8
-rwxr-xr-xinclude/mrc.sh6
-rwxr-xr-xscript/trees5
4 files changed, 14 insertions, 14 deletions
diff --git a/include/git.sh b/include/git.sh
index 46b63014..c1e7b4ba 100755
--- a/include/git.sh
+++ b/include/git.sh
@@ -52,8 +52,7 @@ fetch_project_repo()
eval "$(setvars "" xtree tree_depend)"
scan_config "$project" "config/git"
- [ -z "${loc+x}" ] && $err "fetch_project_repo $project: loc not set"
- [ -z "${url+x}" ] && $err "fetch_project_repo $project: url not set"
+ chkvars loc url
[ -n "$xtree" ] && [ ! -d "src/coreboot/$xtree" ] && \
x_ ./update trees -f coreboot "$xtree"
@@ -87,7 +86,7 @@ git_prep()
_patchdir="$3" # $1 and $2 are gitrepo and gitrepo_backup
_loc="$4"
- [ -z "${rev+x}" ] && $err "git_prep $_loc: rev not set"
+ chkvars rev
tmpclone "$1" "$2" "$tmpgit" "$rev" "$_patchdir"
if singletree "$project" || [ $# -gt 4 ]; then
@@ -130,9 +129,7 @@ fetch_submodule()
[ -z "$st" ] && return 0 # subrepo/subfile not defined
- for mvar in "sub${st}" "sub${st}_bkup" "subhash"; do
- eval "[ -n \"\$$mvar\" ] || $err \"$1, $mdir: $mvar unset\""
- done
+ chkvars "sub${st}" "sub${st}_bkup" "subhash"
if [ "$st" = "repo" ]; then
rm -Rf "$tmpgit/$1" || $err "!rm '$mdir' '$1'"
diff --git a/include/lib.sh b/include/lib.sh
index a329fa3f..3de05c24 100755
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -41,6 +41,12 @@ setvars()
done
printf "%s\n" "${_setvars% }"
}
+chkvars()
+{
+ for var in $@; do
+ eval "[ -n "\${$var+x}" ] || \$err \"$var unset\""
+ done
+}
eval "$(setvars "" xbmk_release tmpdir _nogit version board boarddir relname \
versiondate threads projectname projectsite aur_notice cfgsdir datadir)"
@@ -112,7 +118,7 @@ versiondate_="$versiondate"
[ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \
--pretty='%ct' HEAD)" || versiondate="$versiondate_"
for p in projectname version versiondate projectsite; do
- eval "[ -n \"\$$p\" ] || $err \"$p unset\""
+ chkvars "$p"
eval "x_ printf \"%s\\n\" \"\$$p\" > $p"
done
relname="$projectname-$version"
diff --git a/include/mrc.sh b/include/mrc.sh
index caf893a7..fddaef5d 100755
--- a/include/mrc.sh
+++ b/include/mrc.sh
@@ -8,9 +8,7 @@ eval "$(setvars "" MRC_url MRC_url_bkup MRC_hash MRC_board SHELLBALL)"
extract_mrc()
{
- [ -z "$MRC_board" ] && $err "extract_mrc $MRC_hash: MRC_board not set"
- [ -z "$CONFIG_MRC_FILE" ] && $err "$MRC_hash: CONFIG_MRC_FILE unset"
-
+ chkvars "MRC_board" "CONFIG_MRC_FILE"
SHELLBALL="chromeos-firmwareupdate-$MRC_board"
(
@@ -49,7 +47,7 @@ extract_refcode()
# cbfstool changed the attributes scheme for stage files,
# incompatible with older versions before coreboot 4.14,
# so we need coreboot 4.13 cbfstool for certain refcode files
- [ -n "$cbfstoolref" ] || $err "$board: MRC_refcode_cbtree not set"
+ chkvars cbfstoolref
mkdir -p "${_refdest%/*}" || $err "ref: !mkdir -p ${_refdest%/*}"
"$cbfstoolref" "$appdir/bios.bin" extract \
diff --git a/script/trees b/script/trees
index f090f539..a773f03c 100755
--- a/script/trees
+++ b/script/trees
@@ -131,7 +131,7 @@ handle_src_tree()
load_project_config "$target_dir"
x_ mkdir -p "$elfdir/$target"
- [ -z "$tree" ] && $err "handle_src_tree $project/$tree: tree unset"
+ chkvars tree
cdir="src/$project/$tree"
if [ ! -d "$cdir" ]; then
@@ -279,8 +279,7 @@ mkpayload_grub()
. "$grubdata/module/$tree" || $err "$tree: !source grub modules"
- [ -z "$grub_install_modules" ] && $err "$tree: install modules unset"
- [ -z "$grub_modules" ] && $err "$tree: modules unset"
+ chkvars "grub_install_modules" "grub_modules"
"${cdir}/grub-mkstandalone" --grub-mkimage="${cdir}/grub-mkimage" \
-O i386-coreboot -o "${cdir}/grub.elf" -d "${cdir}/grub-core/" \