general code cleanup in shell scripts

Signed-off-by: Leah Rowe <leah@libreboot.org>
btrfsvols
Leah Rowe 2023-10-03 12:59:35 +01:00
parent 334aa1f7c9
commit 5de8eda21c
9 changed files with 29 additions and 61 deletions

View File

@ -29,11 +29,8 @@ scan_config()
"${_fail}" "scan_config ${confdir}: Cannot concatenate files"
while read -r line ; do
set ${line} 1>/dev/null 2>/dev/null || :
if [ "${1%:}" = "depend" ]; then
depend="${depend} ${2}"
else
eval "${1%:}=\"${2}\""
fi
[ "${1%:}" = "depend" ] && depend="${depend} ${2}" && continue
eval "${1%:}=\"${2}\""
done << EOF
$(eval "awk '${awkstr}' \"${revfile}\"")
EOF

View File

@ -20,22 +20,21 @@ main()
if [ "${1}" = "rp2040" ]; then
platform="rp2040"
boards_dir=${pico_sdk_dir}/src/boards/include/boards
[ -d "${pico_src_dir}/" ] || fetch_repo rpi-pico-serprog
[ -d "${pico_src_dir}/" ] || \
x_ ./update project repo "rpi-pico-serprog"
elif [ "${1}" = "stm32" ]; then
platform="stm32"
boards_dir=${stm32_src_dir}/boards
[ -d "${stm32_src_dir}/" ] || fetch_repo stm32-vserprog
[ -d "${stm32_src_dir}/" ] || \
x_ ./update project repo "stm32-vserprog"
else
err "${usage}"
fi
x_ mkdir -p "bin/serprog_${platform}"
if [ $# -gt 1 ] ; then
if [ "${2}" = "list" ] ; then
print_boards ${boards_dir}
else
build_${platform}_rom "${2}"
fi
[ "${2}" = "list" ] && print_boards ${boards_dir} && return 0
build_${platform}_rom "${2}"
else
printf "Building all serprog targets\n"
list_boards "${boards_dir}" | while read board; do
@ -44,11 +43,6 @@ main()
fi
}
fetch_repo()
{
x_ ./update project repo "${1}"
}
build_rp2040_rom()
{
board=${1}

View File

@ -31,10 +31,8 @@ main()
init_check()
{
[ -f version ] && \
read version < version
[ -f versiondate ] && \
read versiondate < versiondate
[ -f version ] && read version < version
[ -f versiondate ] && read versiondate < versiondate
[ ! -d "bin/" ] && \
err "init_check: no ROMs built yet (error)"
[ -d "release/" ] || \
@ -106,9 +104,9 @@ make_archive()
strip_archive()
{
romdir=${1}
[ -d "coreboot/${tree}" ] || \
x_ ./update project trees coreboot ${tree}
x_ ./build coreboot utils ${tree}
if [ "${microcode_required}" = "n" ]; then
@ -125,12 +123,10 @@ strip_archive()
# Hash the rom before removing blobs
x_ rm -f "${romdir}/blobhashes"
x_ touch "${romdir}/blobhashes"
(
x_ cd "${romdir}"
x_ sha512sum *.rom >> blobhashes
)
for romfile in "${romdir}"/*.rom; do
[ -f "${romfile}" ] || continue
strip_rom_image "${romfile}"

View File

@ -109,7 +109,7 @@ purge_files()
done
x_ ./handle make file -c bios_extract flashrom grub uefitool \
util-fw/stm32-vserprog util-fw/stm32-vserprog/libopencm3 \
memtest86plus/build* util/* \
memtest86plus/build* util/*
x_ rm -Rf .git* */.git* */*/.git* */*/*/.git* */*/*/*/.git* \
*/*/*/*/*/.git* */*/*/*/*/*/.git* */*/*/*/*/*/*/.git*

View File

@ -227,7 +227,6 @@ run_make_command()
copy_elf()
{
[ "${project}" != "coreboot" ] || xx_ modify_coreboot_rom
while read f; do
[ ! -f "${codedir}/$f" ] || \
xx_ cp "${codedir}/${f}" "${dest_dir}/"

View File

@ -46,12 +46,9 @@ run_make_command()
{
[ -f "${project}/Makefile" ] || [ -f "${project}/makefile" ] || \
[ -f "${project}/GNUmakefile" ] || return 0
if [ -z "${mode}" ]; then
x_ make -C "${project}" -j$(nproc)
else
x_ make -C "${project}" clean
make -C "${project}" distclean 2>/dev/null || :
fi
[ -z "${mode}" ] && x_ make -C "${project}" -j$(nproc) && return 0
x_ make -C "${project}" clean
make -C "${project}" distclean 2>/dev/null || :
}
main $@

View File

@ -147,7 +147,7 @@ extract_e6400vga()
[ -f "${E6400_VGA_romname}" ] || \
err "extract_e6400vga: can't extract vga rom from bios.bin"
)
x_ cp "${appdir}"/"${E6400_VGA_romname}" "${_dest}"
x_ cp "${appdir}/${E6400_VGA_romname}" "${_dest}"
}
extract_sch5545ec()

View File

@ -96,13 +96,10 @@ build_dependencies()
inject_blobs()
{
release_archive="n"
if [ "${release}" = "true" ]; then
printf "patching release file\n"
release_archive="y"
patch_release_roms
else
x_ patch_rom "${rom}"
fi
[ "${release}" != "true" ] && x_ patch_rom "${rom}" && return 0
printf "patching release file\n"
release_archive="y"
patch_release_roms
}
patch_release_roms()
@ -240,11 +237,9 @@ inject_blob_hp_kbc1126_ec()
if [ "${_ec1_offset}" = "" ] || [ "${_ec1_offset}" = "" ]; then
err "inject_blob_hp_kbc1126_ec: ${board}: offset not declared"
fi
if [ "${_ec1_location}" = "" ] || [ "${_ec2_location}" = "" ]; then
elif [ "${_ec1_location}" = "" ] || [ "${_ec2_location}" = "" ]; then
err "inject_blob_hp_kbc1126_ec: ${board}: EC path not declared"
fi
if [ ! -f "${_ec1_location}" ] || [ ! -f "${_ec2_location}" ]; then
elif [ ! -f "${_ec1_location}" ] || [ ! -f "${_ec2_location}" ]; then
err "inject_blob_hp_kbc1126_ec: ${board}: ecfw not downloaded"
fi

View File

@ -18,10 +18,9 @@ main()
printf "Downloading %s and applying patches\n" ${project}
[ -z "${1}" ] && err "project name not specified"
project="${1}"
project="${1}" && shift 1
cfgsdir="config/${project}"
[ -d "${cfgsdir}" ] || err "unsupported project name"
shift 1
targets=$(listitems "${cfgsdir}")
[ $# -gt 0 ] && targets=$@
@ -39,21 +38,16 @@ download_for_target()
tree="undefined"
rev="undefined"
fetch_config "${_target}"
fetch_config
[ -d "${project}/${tree}" ] && printf "download/%s %s (%s): exists\n" \
"${project}" "${tree}" "${_target}" 1>&2 && return 0
if [ -d "${project}/${tree}" ]; then
printf "REMARK: download/%s %s (%s): exists. Skipping.\n" \
"${project}" "${tree}" "${_target}" 1>&2
else
fetch_from_upstream
prepare_new_tree
fi
fetch_from_upstream
prepare_new_tree
}
fetch_config()
{
_target=${1}
while true; do
eval "$(setvars "" rev tree)"
_xm="fetch_config ${project}/${_target}"
@ -64,10 +58,7 @@ fetch_config()
. "${cfgsdir}/${_target}/target.cfg" || \
err "fetch_config: no \"${cfgsdir}/${_target}/target.cfg\""
if [ "${_target}" != "${tree}" ]; then
_target="${tree}"
continue
fi
[ "${_target}" != "${tree}" ] && _target="${tree}" && continue
[ -z ${tree} ] && err "${_xm}: tree undefined"
[ -z ${rev} ] && err "${_xm}: revision undefined"
break
@ -78,7 +69,6 @@ check_config_for_target()
{
[ -f "${cfgsdir}/${1}/target.cfg" ] || \
err "${_xm} check: target.cfg does not exist"
[ -f "${cfgsdir}/${1}/seen" ] && \
err "${_xm} check: infinite loop in tree definitions"