lbmk scripts: shorter code lines

while seemingly pedantic, this does actually make code
easier to read. mostly just switching to shorthand for
variable names, where no expansions or patterns are used

Signed-off-by: Leah Rowe <leah@libreboot.org>
9020vga
Leah Rowe 2023-12-24 09:04:36 +00:00
parent 575332f221
commit 0aca6332ee
11 changed files with 128 additions and 128 deletions

12
build
View File

@ -38,7 +38,7 @@ main()
xx_ id -u 1>/dev/null 2>/dev/null
[ $# -lt 1 ] && fail "Too few arguments. Try: ${0} help"
[ "${1}" = "dependencies" ] && xx_ install_packages $@ && lbmk_exit 0
[ "$1" = "dependencies" ] && xx_ install_packages $@ && lbmk_exit 0
for cmd in initcmd check_git check_project git_init excmd; do
eval "${cmd} \$@"
@ -78,7 +78,7 @@ install_packages()
xx_ ${pkg_add} ${pkglist}
[ -z "${aur_notice}" ] && return 0
printf "You must install AUR packages: %s\n" "${aur_notice}" 1>&2
printf "You must install AUR packages: %s\n" "$aur_notice" 1>&2
}
# release archives contain .gitignore, but not .git.
@ -93,7 +93,7 @@ git_init()
git add -A . || fail "${PWD}: cannot add files to Git repository"
git commit -m "${projectname} ${version}" --date "${cdate}" \
--author="lbmk <lbmk@libreboot.org>" || \
fail "${PWD}: can't commit ${projectname}/${version}, date ${cdate}"
fail "$PWD: can't commit ${projectname}/${version}, date $cdate"
git tag -a "${version}" -m "${projectname} ${version}" || \
fail "${PWD}: cannot git-tag ${projectname}/${version}"
}
@ -125,19 +125,19 @@ usage()
mkversion()
{
printf "revision: %s %s\n" "${projectname}" "${version}"
printf "revision: %s %s\n" "$projectname" "$version"
printf "revision date: %s\n" "$(date -Rud @${versiondate})"
}
lbmk_exit()
{
tmp_cleanup || err "lbmk_exit: can't rm tmpdir upon exit $1: ${tmpdir}"
tmp_cleanup || err "lbmk_exit: can't rm tmpdir upon exit $1: $tmpdir"
exit $1
}
fail()
{
tmp_cleanup || printf "WARNING: can't rm tmpdir: %s\n" "${tmpdir}" 1>&2
tmp_cleanup || printf "WARNING: can't rm tmpdir: %s\n" "$tmpdir" 1>&2
err "${1}"
}

View File

@ -29,7 +29,7 @@ check_git()
git_err()
{
printf "You need to set git name/email, like so:\n%s\n\n" "${1}" 1>&2
printf "You need to set git name/email, like so:\n%s\n\n" "$1" 1>&2
fail "Git name/email not configured" || \
err "Git name/email not configured"
}

View File

@ -51,12 +51,13 @@ load_target_config()
. "${cfgsdir}/${1}/target.cfg" || \
err "load_target_config ${cfgsdir}/${1}: cannot load config"
touch "${cfgsdir}/${1}/seen" || err "load_config $cfgsdir/$1: !mk seen"
touch "${cfgsdir}/${1}/seen" || \
err "load_config $cfgsdir/$1: !mk seen"
}
prepare_new_tree()
{
printf "Creating %s tree %s (%s)\n" "${project}" "${tree}" "${_target}"
printf "Creating %s tree %s (%s)\n" "$project" "$tree" "$_target"
remkdir "${tmp_git_dir%/*}"
cp -R "src/${project}/${project}" "${tmp_git_dir}" || \
@ -121,7 +122,7 @@ clone_project()
git_reset_rev()
{
git -C "${1}" reset --hard ${2} || err "!git reset ${1} <- ${2}"
if [ "${project}" != "coreboot" ] && [ "${project}" != "u-boot" ] && \
if [ "$project" != "coreboot" ] && [ "$project" != "u-boot" ] && \
[ -f "${1}/.gitmodules" ]; then
git -C "${1}" submodule update --init --checkout || \
err "git_reset_rev ${1}: can't download submodules"
@ -137,7 +138,7 @@ git_am_patches()
[ -f "${patch}" ] || continue
git -C "${sdir}" am "${patch}" || patchfail="y"
[ "${patchfail}" != "y" ] && continue
git -C "${sdir}" am --abort || err "${sdir}: !git am --abort"
git -C "$sdir" am --abort || err "$sdir: !git am --abort"
err "!git am ${patch} -> ${sdir}"
done
for patches in "${patchdir}/"*; do

View File

@ -8,7 +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 "$MRC_board" ] && err "extract_mrc $MRC_hash: MRC_board not set"
[ -z "${CONFIG_MRC_FILE}" ] && \
err "extract_mrc $MRC_hash: CONFIG_MRC_FILE not set"
@ -21,7 +21,7 @@ extract_mrc()
) || err "mrc download/extract failure"
"${cbfstool}" "${appdir}/"bios.bin extract -n mrc.bin \
-f "${_dest}" -r RO_SECTION || err "extract_mrc: cbfstool ${_dest}"
-f "$_dest" -r RO_SECTION || err "extract_mrc: cbfstool $_dest"
}
extract_partition()
@ -38,5 +38,5 @@ extract_partition()
err "extract_partition, dd ${1%.zip}, root-a.ext2"
printf "cd /usr/sbin\ndump chromeos-firmwareupdate ${SHELLBALL}\nquit" \
| debugfs "root-a.ext2" || err "extract_mrc: can't extract shellball"
| debugfs "root-a.ext2" || err "can't extract shellball"
}

View File

@ -52,7 +52,7 @@ scan_config()
done << EOF
$(eval "awk '${awkstr}' \"${revfile}\"")
EOF
rm -f "${revfile}" || "${_fail}" "scan_config: Cannot remove tmpfile"
rm -f "$revfile" || "$_fail" "scan_config: Cannot remove tmpfile"
}
check_defconfig()

View File

@ -67,7 +67,7 @@ main()
eval "printf \"${targets}\""
printf "^^ ROM images available in these directories.\n\n"
printf "DO NOT flash ROM images from elf/ - please use bin/ instead.\n"
printf "DO NOT flash images from elf/ - please use bin/ instead.\n"
}
configure_target()
@ -80,7 +80,7 @@ configure_target()
. "${targetdir}/target.cfg"
[ -z "${grub_scan_disk}" ] && grub_scan_disk="both"
[ "${grub_scan_disk}" != "both" ] && [ "${grub_scan_disk}" != "ata" ] \
[ "$grub_scan_disk" != "both" ] && [ "$grub_scan_disk" != "ata" ] \
&& [ "${grub_scan_disk}" != "ahci" ] && \
grub_scan_disk="both"
@ -98,16 +98,16 @@ configure_target()
# The reverse logic must not be applied. If SeaBIOS-with-GRUB works,
# that doesn't mean GRUB-withSeaBIOS will. For example, the board
# might have a graphics card whose vga rom coreboot doesn't execute
[ "${payload_grub}" != "y" ] && [ "${payload_seabios}" != "y" ] && \
[ "$payload_grub" != "y" ] && [ "$payload_seabios" != "y" ] && \
[ "${payload_uboot}" != "y" ] && \
for configfile in "${targetdir}/config/"*; do
[ -e "${configfile}" ] || continue
err "target '${board}' defines no payload"
done
[ "${payload_uboot}" != "n" ] && [ "${payload_uboot}" != "y" ] && \
[ "$payload_uboot" != "n" ] && [ "$payload_uboot" != "y" ] && \
payload_uboot="n"
[ "${payload_uboot}" = "y" ] && [ -z "${uboot_config}" ] && \
[ "$payload_uboot" = "y" ] && [ -z "$uboot_config" ] && \
uboot_config="default"
# Override all payload directives with cmdline args
@ -127,7 +127,7 @@ configure_dependencies()
cbfstool="cbutils/${tree}/cbfstool"
cbrom="${cbdir}/build/coreboot.rom"
[ -f "${cbfstool}" ] || x_ ./update trees -b coreboot utils ${tree}
[ -f "$cbfstool" ] || x_ ./update trees -b coreboot utils $tree
memtest_bin="memtest86plus/build64/memtest.bin"
[ "${payload_memtest}" != "y" ] || [ -f "src/${memtest_bin}" ] || \
@ -228,7 +228,7 @@ build_roms()
x_ "${cbfstool}" "${cbrom}" add-payload \
-f "src/${memtest_bin}" -n img/memtest -c lzma
[ "${payload_seabios}" = "y" ] && build_seabios_roms
[ "${payload_grub}" != "y" ] || x_ build_grub_roms "${cbrom}" "grub"
[ "$payload_grub" != "y" ] || x_ build_grub_roms "$cbrom" "grub"
[ "${payload_uboot}" = "y" ] || return 0
x_ cp "${_cbrom}" "${cbrom}"
build_uboot_roms
@ -337,15 +337,15 @@ mkSeabiosRom() {
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
x_ cp "${_cbrom}" "${tmprom}"
x_ "${cbfstool}" "${tmprom}" add-payload -f "${_seabioself}" \
x_ "$cbfstool" "$tmprom" add-payload -f "$_seabioself" \
-n "${_seabios_cbfs_path}" -c lzma
x_ "$cbfstool" "$tmprom" add-int -i 3000 -n etc/ps2-keyboard-spinup
z="2"; [ "${initmode}" = "vgarom" ] && z="0"
x_ "${cbfstool}" "${tmprom}" add-int -i $z -n etc/pci-optionrom-exec
x_ "${cbfstool}" "${tmprom}" add-int -i 0 -n etc/optionroms-checksum
[ "${initmode}" != "libgfxinit" ] || \
x_ "${cbfstool}" "${tmprom}" add -f "${seavgabiosrom}" \
z="2"; [ "$initmode" = "vgarom" ] && z="0"
x_ "$cbfstool" "$tmprom" add-int -i $z -n etc/pci-optionrom-exec
x_ "$cbfstool" "$tmprom" add-int -i 0 -n etc/optionroms-checksum
[ "$initmode" != "libgfxinit" ] || \
x_ "$cbfstool" "$tmprom" add -f "$seavgabiosrom" \
-n vgaroms/seavgabios.bin -t raw
printf "%s\n" "${tmprom}"
@ -387,12 +387,12 @@ mkUbootRom() {
_ubdir="elf/u-boot/${board}/${uboot_config}"
_ubootelf="${_ubdir}/u-boot.elf"
[ -f "${_ubootelf}" ] || _ubootelf="${_ubdir}/u-boot"
[ -f "${_ubootelf}" ] || err "mkUbootRom: ${board}: cant find u-boot"
[ -f "$_ubootelf" ] || err "mkUbootRom: $board: cant find u-boot"
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
x_ cp "${_cbrom}" "${tmprom}"
x_ "${cbfstool}" "${tmprom}" add-payload -f "${_ubootelf}" \
x_ "$cbfstool" "$tmprom" add-payload -f "$_ubootelf" \
-n "${_uboot_cbfs_path}" -c lzma
printf "%s\n" "${tmprom}"

View File

@ -18,7 +18,7 @@ usage="usage: ./build firmware serprog <rp2040|stm32> [board]"
main()
{
[ -z "${1+x}" ] && err "${usage}"
[ "${1}" != "rp2040" ] && [ "${1}" != "stm32" ] && err "${usage}"
[ "$1" != "rp2040" ] && [ "$1" != "stm32" ] && err "$usage"
if [ "${1}" = "rp2040" ]; then
boards_dir=${pico_sdk_dir}/src/boards/include/boards
[ -d "$pico_src_dir" ] || x_ ./update trees -f "pico-serprog"
@ -44,23 +44,23 @@ build_rp2040_rom()
{
board=${1}
printf "Building pico-serprog for %s\n" "${board}"
x_ cmake -DPICO_BOARD="${board}" -DPICO_SDK_PATH="${pico_sdk_dir}" \
x_ cmake -DPICO_BOARD="$board" -DPICO_SDK_PATH="$pico_sdk_dir" \
-B "${pico_src_dir}/build" "${pico_src_dir}"
x_ cmake --build "${pico_src_dir}/build"
x_ mv ${pico_src_dir}/build/pico_serprog.uf2 \
bin/serprog_rp2040/serprog_${board}.uf2
printf "output to bin/serprog_rp2040/serprog_%s.uf2\n" "${board}"
printf "output to bin/serprog_rp2040/serprog_%s.uf2\n" "$board"
}
build_stm32_rom()
{
board=${1}
printf "Building stm32-vserprog for %s\n" "${board}"
x_ make -C ${stm32_src_dir} libopencm3-just-make BOARD=${board}
x_ make -C $stm32_src_dir libopencm3-just-make BOARD=$board
x_ make -C ${stm32_src_dir} BOARD=${board}
x_ mv ${stm32_src_dir}/stm32-vserprog.hex \
bin/serprog_stm32/serprog_${board}.hex
printf "output to bin/serprog_stm32/serprog_%s.hex\n" "${board}"
printf "output to bin/serprog_stm32/serprog_%s.hex\n" "$board"
}
print_boards()

View File

@ -149,7 +149,7 @@ nukerom()
for romfile in "${romdir}"/*.rom; do
[ -f "${romfile}" ] || continue
./vendor inject -r "${romfile}" -b "${target}" -n nuke || \
./vendor inject -r "$romfile" -b "$target" -n nuke || \
err "!vendor inject (nuke) ${romfile}, nukerom"
done
}

View File

@ -31,8 +31,8 @@ main()
esac
shift; project="${OPTARG#src/}"; shift
done
[ -z "${_f}" ] && err "missing flag (-m/-u/-b/-c/-x/-f/-s/-l/-n)"
[ -z "${project}" ] && err "project name not specified"
[ -z "$_f" ] && err "missing flag (-m/-u/-b/-c/-x/-f/-s/-l/-n)"
[ -z "$project" ] && err "project name not specified"
check_project
@ -43,7 +43,7 @@ main()
build_projects()
{
[ $# -gt 0 ] && x_ ./update trees ${_f} ${@}
[ $# -gt 0 ] && x_ ./update trees $_f $@
if [ "${mode}" = "fetch" ]; then
fetch_project_repo
@ -51,9 +51,9 @@ build_projects()
fi
codedir="src/${project}"
[ -d "${codedir}" ] || x_ ./update trees -f "${project}"
[ -d "$codedir" ] || x_ ./update trees -f "$project"
if [ "${project}" = "uefitool" ]; then
if [ "$project" = "uefitool" ]; then
(
x_ cd src/uefitool
cmake UEFIExtract/ || [ -f Makefile ] || \
@ -61,72 +61,72 @@ build_projects()
) || err "can't build cmake on uefiextract"
fi
[ "${mode}" = "distclean" ] && mode="clean"
[ "$mode" = "distclean" ] && mode="clean"
run_make_command || return 0
}
build_targets()
{
elfdir="elf/${project}"
[ "${elfdir}" = "elf/coreboot" ] && \
[ "$elfdir" = "elf/coreboot" ] && \
elfdir="elf/coreboot_nopayload_DO_NOT_FLASH"
cfgsdir="config/${project}"
[ -d "${cfgsdir}" ] || err "directory, ${cfgsdir}, does not exist"
[ -d "$cfgsdir" ] || err "directory, $cfgsdir, does not exist"
listfile="${cfgsdir}/build.list"
[ -f "${listfile}" ] || err "list file, ${listfile}, does not exist"
[ -f "$listfile" ] || err "list file, $listfile, does not exist"
# Build for all targets if no argument is given
[ $# -gt 0 ] && target1="${1}"
[ "${target1}" = "utils" ] && [ "${project}" = "coreboot" ] && \
[ $# -gt 0 ] && target1="$1"
[ "$target1" = "utils" ] && [ "$project" = "coreboot" ] && \
shift 1
targets=$(items "${cfgsdir}") || \
err "Cannot get options for ${cfgsdir}"
targets=$(items "$cfgsdir") || \
err "Cannot get options for $cfgsdir"
[ $# -gt 0 ] && targets=$@
[ -z "${mode}" ] && x_ mkdir -p "${elfdir}/"
[ -z "$mode" ] && x_ mkdir -p "$elfdir"
handle_targets
}
handle_targets()
{
for x in ${targets}; do
for x in $targets; do
target="${x}"
printf "Running 'make %s' for project '%s, target '%s''\n" \
"${mode}" "${project}" "${target}"
[ "${project}" != "coreboot" ] || [ -n "${mode}" ] || \
[ "${target1}" = "utils" ] || \
x_ ./vendor download ${target}
"$mode" "$project" "$target"
[ "$project" != "coreboot" ] || [ -n "$mode" ] || \
[ "$target1" = "utils" ] || \
x_ ./vendor download $target
x_ handle_defconfig
done
[ "$target1" = "utils" ] && [ "$project" = "coreboot" ] && return 0
[ -z "${mode}" ] || return 0
printf "Done! The files are stored under %s/\n\n" "${elfdir}"
printf "Done! The files are stored under %s/\n\n" "$elfdir"
}
handle_defconfig()
{
handle_src_tree "${target}" || return 0
handle_src_tree "$target" || return 0
if [ "${target1}" = "utils" ] && [ "${project}" = "coreboot" ]; then
handle_coreboot_utils "${tree}"
if [ "$target1" = "utils" ] && [ "$project" = "coreboot" ]; then
handle_coreboot_utils "$tree"
return 0
fi
for y in "${target_dir}/config"/*; do
[ -f "${y}" ] || continue
config="${y}"
[ -f "$y" ] || continue
config="$y"
config_name="${config#"${target_dir}/config/"}"
printf "handle/make/config %s %s: handling config %s\n" \
"${project}" "${target}" "${config_name}"
"$project" "$target" "$config_name"
[ -n "${mode}" ] || check_config || continue
[ -n "$mode" ] || check_config || continue
handle_makefile
[ -n "${mode}" ] || copy_elf
[ -n "$mode" ] || copy_elf
done
}
@ -134,7 +134,7 @@ handle_src_tree()
{
target_dir="${cfgsdir}/${target}"
if [ "${mode}" = "fetch" ]; then
if [ "$mode" = "fetch" ]; then
fetch_project_trees
return 1
fi
@ -145,23 +145,23 @@ handle_src_tree()
. "${target_dir}/target.cfg" || \
err "handle_src_tree ${target_dir}: cannot load target.cfg"
[ -z "${arch}" ] && err "handle_src_tree $project/$tree: arch unset"
[ -z "${tree}" ] && err "handle_src_tree $project/$tree: tree unset"
[ -z "$arch" ] && err "handle_src_tree $project/$tree: arch unset"
[ -z "$tree" ] && err "handle_src_tree $project/$tree: tree unset"
codedir="src/${project}/${tree}"
if [ ! -d "${codedir}" ]; then
if [ "${mode}" = "distclean" ] || \
[ "${mode}" = "crossgcc-clean" ]; then
if [ ! -d "$codedir" ]; then
if [ "$mode" = "distclean" ] || \
[ "$mode" = "crossgcc-clean" ]; then
printf "Directory %s missing; skipping clean\n" \
"${codedir}" 1>&2
"$codedir" 1>&2
return 1
fi
x_ ./update trees -f "${project}" "${target}"
x_ ./update trees -f "$project" "$target"
fi
[ "$target1" = "utils" ] && [ "$project" = "coreboot" ] && return 0
[ -z "${mode}" ] || return 0
[ -z "$mode" ] || return 0
check_cross_compiler
}
@ -170,22 +170,21 @@ handle_src_tree()
check_cross_compiler()
{
[ "$project" = "u-boot" ] || [ "$project" = "coreboot" ] || return 0
[ -z "${arch}" ] && err "${project}/${tree}: arch isn't set"
[ -z "$arch" ] && err "${project}/${tree}: arch isn't set"
_arch="${arch}"
[ "${arch}" = "aarch64-elf" ] && _arch="aarch64-elf arm-eabi"
_arch="$arch"
[ "$arch" = "aarch64-elf" ] && _arch="aarch64-elf arm-eabi"
[ "${crossgcc_ada}" = "y" ] || [ "${crossgcc_ada}" = "n" ] || \
crossgcc_ada="y"
[ "${crossgcc_ada}" = "y" ] || export BUILD_LANGUAGES=c
[ "$crossgcc_ada" = "y" ] || [ "$crossgcc_ada" = "n" ] || crossgcc_ada=y
[ "$crossgcc_ada" = "y" ] || export BUILD_LANGUAGES=c
cbdir="src/coreboot/${tree}"
[ "${project}" != "coreboot" ] && cbdir="src/coreboot/default"
[ "$project" != "coreboot" ] && cbdir="src/coreboot/default"
x_ ./update trees -f coreboot ${cbdir#src/coreboot/}
for xarch in ${_arch}; do
for xarch in $_arch; do
[ -d "${cbdir}/util/crossgcc/xgcc/${xarch}/" ] && continue
x_ make -C "${cbdir}" crossgcc-${xarch%-*} CPUS=$(nproc)
x_ make -C "$cbdir" crossgcc-${xarch%-*} CPUS=$(nproc)
done
# we *must* ensure that u-boot's build system uses crossgcc first
@ -195,36 +194,36 @@ check_cross_compiler()
check_config()
{
[ -f "${config}" ] || \
[ -f "$config" ] || \
err "check_config: ${project}/${target}: configs missing"
dest_dir="${elfdir}/${target}/${config_name}"
# TODO: very hacky check. do it properly (based on build.list)
for elftest in "${dest_dir}"/*; do
[ -f "${elftest}" ] || continue
[ -f "$elftest" ] || continue
printf "Build already exists, so skipping build\n" 1>&2
return 1
done
x_ mkdir -p "${dest_dir}"
x_ mkdir -p "$dest_dir"
}
handle_makefile()
{
x_ make clean -C "${codedir}"
x_ cp "${config}" "${codedir}/.config"
[ -n "${mode}" ] || make -C "${codedir}" silentoldconfig || \
make -C "${codedir}" oldconfig || :
x_ make clean -C "$codedir"
x_ cp "$config" "${codedir}/.config"
[ -n "$mode" ] || make -C "$codedir" silentoldconfig || \
make -C "$codedir" oldconfig || :
run_make_command || err "handle_makefile ${codedir}: no makefile!"
run_make_command || err "handle_makefile $codedir: no makefile!"
if [ -e "${codedir}/.git" ] && [ "${project}" = "u-boot" ] && \
[ "${mode}" = "distclean" ]; then
x_ git -C "${codedir}" clean -fdx
if [ -e "${codedir}/.git" ] && [ "$project" = "u-boot" ] && \
[ "$mode" = "distclean" ]; then
x_ git -C "$codedir" clean -fdx
elif [ "$mode" = "oldconfig" ] || [ "$mode" = "olddefconfig" ] || \
[ "$mode" = "menuconfig" ] || [ "$mode" = "nconfig" ]; then
x_ cp "${codedir}/.config" "${config}"
elif [ "${mode}" = "savedefconfig" ]; then
x_ cp "${codedir}/defconfig" "${config}"
x_ cp "${codedir}/.config" "$config"
elif [ "$mode" = "savedefconfig" ]; then
x_ cp "${codedir}/defconfig" "$config"
fi
}
@ -232,24 +231,24 @@ run_make_command()
{
[ -f "${codedir}/Makefile" ] || [ -f "${codedir}/makefile" ] || \
[ -f "${codedir}/GNUmakefile" ] || return 1
[ "${project}" = "coreboot" ] && [ -z "${mode}" ] && \
[ "$project" = "coreboot" ] && [ -z "$mode" ] && \
x_ printf "%s\n" "${version%%-*}" \
> "${codedir}/.coreboot-version"
x_ make ${mode} -j$(nproc) -C "${codedir}"
x_ make $mode -j$(nproc) -C "$codedir"
[ "${mode}" != "clean" ] && return 0
make -C "${codedir}" distclean 2>/dev/null || :
[ "$mode" != "clean" ] && return 0
make -C "$codedir" distclean 2>/dev/null || :
}
copy_elf()
{
while read -r f; do
[ ! -f "${codedir}/$f" ] || \
x_ cp "${codedir}/${f}" "${dest_dir}/"
done < "${listfile}"
x_ cp "${codedir}/${f}" "$dest_dir"
done < "$listfile"
x_ make clean -C "${codedir}"
x_ make clean -C "$codedir"
}
main $@

View File

@ -30,7 +30,7 @@ main()
[ $# -gt 0 ] || err "No argument given"
board="${1}"
boarddir="${cbcfgsdir}/${board}"
_b="${board%%_*mb}" # shorthand (avoid duplicating config per rom size)
_b="${board%%_*mb}" # shorthand (no duplication per rom size)
check_defconfig "${boarddir}" && exit 0
detect_firmware && exit 0
@ -162,28 +162,28 @@ extract_intel_me()
[ -f "${_me}" ] && return 0
sdir="$(mktemp -d)"
mkdir -p "${sdir}" || err "extract_intel_me: !mkdir -p \"${sdir}\""
mkdir -p "$sdir" || err "extract_intel_me: !mkdir -p \"$sdir\""
(
[ "${cdir#/a}" != "${cdir}" ] && cdir="${cdir#/}"
cd "${cdir}" || err "extract_intel_me: !cd \"${cdir}\""
[ "${cdir#/a}" != "$cdir" ] && cdir="${cdir#/}"
cd "$cdir" || err "extract_intel_me: !cd \"$cdir\""
for i in *; do
[ -f "${_me}" ] && break
[ -L "${i}" ] && continue
if [ -f "${i}" ]; then
"${mecleaner}" -r -t -O "${sdir}/vendorfile" \
-M "${_me}" "${i}" && break
"${mecleaner}" -r -t -O "${_me}" "${i}" && break
"${me7updateparser}" -O "${_me}" "${i}" && break
[ -f "$_me" ] && break
[ -L "$i" ] && continue
if [ -f "$i" ]; then
"$mecleaner" -r -t -O "${sdir}/vendorfile" \
-M "$_me" "$i" && break
"$mecleaner" -r -t -O "$_me" "$i" && break
"$me7updateparser" -O "$_me" "$i" && break
_7ztest="${_7ztest}a"
extract_archive "${i}" "${_7ztest}" || continue
extract_intel_me "${_me}" "${cdir}/${_7ztest}"
extract_archive "$i" "$_7ztest" || continue
extract_intel_me "$_me" "${cdir}/${_7ztest}"
elif [ -d "$i" ]; then
extract_intel_me "${_me}" "${cdir}/${i}"
extract_intel_me "$_me" "${cdir}/${i}"
else
continue
fi
cdir="${1}"
[ "${cdir#/a}" != "${cdir}" ] && cdir="${cdir#/}"
[ "${cdir#/a}" != "$cdir" ] && cdir="${cdir#/}"
cd "${cdir}" || :
done
)

20
script/vendor/inject vendored
View File

@ -37,7 +37,7 @@ main()
inject_vendorfiles
[ "${nukemode}" = "nuke" ] && return 0
printf "Friendly reminder (this is *not* an error message):\n"
printf "Please always ensure that the files were inserted correctly.\n"
printf "Please ensure that the files were inserted correctly.\n"
}
check_board()
@ -96,7 +96,7 @@ build_dependencies()
if [ ! -f "${cbfstool}" ] || [ ! -f "${ifdtool}" ]; then
x_ ./update trees -b coreboot utils default
fi
[ -z "${new_mac}" ] || [ -f "${nvmutil}" ] || x_ make -C util/nvmutil
[ -z "$new_mac" ] || [ -f "$nvmutil" ] || x_ make -C util/nvmutil
[ "${nukemode}" = "nuke" ] && return 0
x_ ./vendor download ${board}
}
@ -116,7 +116,7 @@ patch_release_roms()
_tmpdir="tmp/romdir"
remkdir "${_tmpdir}"
tar -xf "${archive}" -C "${_tmpdir}" || \
err "patch_release_roms: !tar -xf \"${archive}\" -C \"${_tmpdir}\""
err "patch_release_roms: !tar -xf \"$archive\" -C \"$_tmpdir\""
for x in "${_tmpdir}"/bin/*/*.rom ; do
printf "patching rom: %s\n" "$x"
@ -208,20 +208,20 @@ inject()
fi
if [ "${cbfsname}" = "IFD" ]; then
if [ "${nukemode}" != "nuke" ]; then
"${ifdtool}" -i ${_t}:${_dest} "${rom}" -O "$rom" || \
"$ifdtool" -i ${_t}:${_dest} "$rom" -O "$rom" || \
err "inject: can't insert $_t ($dest) into $rom"
else
"${ifdtool}" --nuke ${_t} "${rom}" -O "${rom}" || \
err "inject ${rom}: can't nuke ${_t} in IFD"
"$ifdtool" --nuke $_t "$rom" -O "$rom" || \
err "inject $rom: can't nuke $_t in IFD"
fi
else
if [ "${nukemode}" != "nuke" ]; then
"${cbfstool}" "${rom}" add -f "${_dest}" \
-n "${cbfsname}" -t ${_t} ${_offset} || \
"$cbfstool" "$rom" add -f "$_dest" \
-n "$cbfsname" -t $_t $_offset || \
err "inject $rom: can't insert $_t file $_dest"
else
"${cbfstool}" "${rom}" remove -n "${cbfsname}" || \
err "inject $rom: can't remove ${cbfsname}"
"$cbfstool" "$rom" remove -n "$cbfsname" || \
err "inject $rom: can't remove $cbfsname"
fi
fi