summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-12-28 16:34:45 +0000
committerLeah Rowe <leah@libreboot.org>2023-12-28 16:34:45 +0000
commit34ded35fa616a323f582d3e942d7b49ac9beeef4 (patch)
tree54e988545c63c5e029da54e30d6a8dce272a90e5 /script
parent4e06779948744b3d7c09b3749ddc06e0b9e73732 (diff)
lbmk scripts: general code cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'script')
-rwxr-xr-xscript/build/roms6
-rwxr-xr-xscript/update/release3
-rwxr-xr-xscript/update/trees10
-rwxr-xr-xscript/vendor/inject39
4 files changed, 17 insertions, 41 deletions
diff --git a/script/build/roms b/script/build/roms
index aa32ff35..95b697ec 100755
--- a/script/build/roms
+++ b/script/build/roms
@@ -165,8 +165,7 @@ build_dependency_grub()
rebuild_grub="y"
done
[ -n "${_keyboard}" ] && keymaps="${kmapdir}/${_keyboard}.gkb"
- [ "${rebuild_grub}" = "y" ] || return 0
- x_ ./build grub
+ [ "${rebuild_grub}" = "y" ] && x_ ./build grub; return 0
}
build_dependency_uboot()
@@ -179,7 +178,7 @@ build_dependency_uboot()
[ ! -f "${ubootelf}" ] && [ -f "${ubdir}/u-boot" ] && \
ubootelf="${ubdir}/u-boot"
[ -f "${ubootelf}" ] && return 0
- err "Could not find u-boot build for board, ${board}"
+ err "Can't find u-boot build for board, $board";
}
build_target()
@@ -365,7 +364,6 @@ mkSeabiosGrubonlyRom()
x_ rm -f "${tmpbootorder}"
x_ "${cbfstool}" "${_grubrom}" add-int -i 0 -n etc/show-boot-menu
-
x_ moverom "${_grubrom}" "${_newrom%.rom}_grubonly.rom"
}
diff --git a/script/update/release b/script/update/release
index e47aef80..7e0492f4 100755
--- a/script/update/release
+++ b/script/update/release
@@ -128,8 +128,7 @@ handle_rom_archive()
insert_version_files "${romdir}" || \
err "mkrom_tarball ${romdir}: versionfile"
- insert_copying_files "$romdir" || \
- err "!insert copy, handle 2, $romdir"
+ insert_copying_files "$romdir" || err "!insert copy, handle 2, $romdir"
mkrom_tarball
}
diff --git a/script/update/trees b/script/update/trees
index da42d200..556181ed 100755
--- a/script/update/trees
+++ b/script/update/trees
@@ -98,8 +98,7 @@ handle_targets()
done
[ "$target1" = "utils" ] && [ "$project" = "coreboot" ] && return 0
- [ -z "${mode}" ] || return 0
- printf "Done! The files are stored under %s/\n\n" "$elfdir"
+ [ -z "${mode}" ] && printf "Done! Check %s/\n\n" "$elfdir"; return 0
}
handle_defconfig()
@@ -149,8 +148,7 @@ handle_src_tree()
fi
[ "$target1" = "utils" ] && [ "$project" = "coreboot" ] && return 0
- [ -z "$mode" ] || return 0
- check_cross_compiler
+ [ -z "$mode" ] && check_cross_compiler; return 0
}
check_cross_compiler()
@@ -172,8 +170,7 @@ check_cross_compiler()
check_config()
{
- [ -f "$config" ] || \
- err "check_config: ${project}/${target}: configs missing"
+ [ -f "$config" ] || err "check_config: ${project}/${target}: no config"
dest_dir="${elfdir}/${target}/${config_name}"
# TODO: very hacky check. do it properly (based on build.list)
@@ -214,7 +211,6 @@ run_make_command()
> "${codedir}/.coreboot-version"
x_ make $mode -j$(nproc) -C "$codedir"
-
[ "$mode" != "clean" ] && return 0
make -C "$codedir" distclean 2>/dev/null || :
}
diff --git a/script/vendor/inject b/script/vendor/inject
index cec19b2e..5734b599 100755
--- a/script/vendor/inject
+++ b/script/vendor/inject
@@ -14,10 +14,7 @@ eval "$(setvars "" archive rom modifygbe nukemode release new_mac)"
main()
{
[ $# -lt 1 ] && err "No options specified."
- if [ "${1}" = "listboards" ]; then
- items config/coreboot || :
- exit 0
- fi
+ [ "${1}" = "listboards" ] && eval "items config/coreboot || :; exit 0"
archive="${1}"
@@ -45,20 +42,16 @@ check_board()
failcheck="n"
check_release "${archive}" || failcheck="y"
if [ "${failcheck}" = "y" ]; then
- [ -f "${rom}" ] || \
- err "check_board: \"${rom}\" is not a valid path"
- [ -z "${rom+x}" ] && \
- err "check_board: no rom specified"
- [ -n "${board+x}" ] || \
- board=$(detect_board "${rom}")
+ [ -f "$rom" ] || err "check_board \"$rom\": invalid path"
+ [ -z "${rom+x}" ] && err "check_board: no rom specified"
+ [ -n "${board+x}" ] || board=$(detect_board "${rom}")
else
release="y"
board=$(detect_board "${archive}")
fi
boarddir="${cbcfgsdir}/${board}"
- [ -d "${boarddir}" ] && return 0
- err "check_board: board ${board} not found"
+ [ -d "$boarddir" ] || err "check_board: board $board missing"; return 0
}
check_release()
@@ -85,8 +78,7 @@ detect_board()
*)
err "detect_board $filename: could not detect board type"
esac
- [ -d "${boarddir}/" ] || \
- err "detect_board: dir, ${boarddir}, doesn't exist"
+ [ -d "$boarddir" ] || err "detect_board: dir \"$boarddir\" missing"
printf "%s\n" "${board}"
}
@@ -97,17 +89,12 @@ build_dependencies()
x_ ./update trees -b coreboot utils default
fi
[ -z "$new_mac" ] || [ -f "$nvmutil" ] || x_ make -C util/nvmutil
- [ "${nukemode}" = "nuke" ] && return 0
- x_ ./vendor download ${board}
+ [ "$nukemode" = "nuke" ] || x_ ./vendor download $board; return 0
}
inject_vendorfiles()
{
- if [ "${release}" != "y" ]; then
- patch_rom "${rom}"
- return 0
- fi
- printf "patching release images\n"
+ [ "${release}" != "y" ] && eval "patch_rom \"$rom\"; return 0"
patch_release_roms
}
@@ -134,18 +121,16 @@ patch_release_roms()
err "patch_release_roms: ROMs did not match expected hashes"
) || err "can't verify vendor hashes"
- if [ "${modifygbe}" = "true" ]; then
+ [ "${modifygbe}" = "true" ] && \
for x in "${_tmpdir}"/bin/*/*.rom ; do
modify_gbe "${x}"
done
- fi
[ -d bin/release ] || x_ mkdir -p bin/release
x_ mv "${_tmpdir}"/bin/* bin/release/
+ x_ rm -Rf "${_tmpdir}"
printf "Success! Your ROMs are in bin/release\n"
-
- x_ rm -Rf "${_tmpdir}"
}
patch_rom()
@@ -195,8 +180,7 @@ inject()
err "inject_${dl_type}: file missing, ${_dest}"
[ "$nukemode" = "nuke" ] || \
- printf "Inserting %s/%s into file: %s\n" \
- "${cbfsname}" "${_t}" "$rom"
+ printf "Inserting %s/%s in file: %s\n" "$cbfsname" "$_t" "$rom"
if [ "${_t}" = "GbE" ]; then
x_ mkdir -p tmp
@@ -223,7 +207,6 @@ inject()
"$cbfstool" "$rom" remove -n "$cbfsname" || \
err "inject $rom: can't remove $cbfsname"
fi
-
fi
}