simplify initialising variables in shell scripts
Signed-off-by: Leah Rowe <leah@libreboot.org>btrfsvols
parent
49b266eb42
commit
0a0defd325
|
@ -4,7 +4,6 @@
|
|||
_ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
|
||||
|
||||
_7ztest="a"
|
||||
_b=""
|
||||
blobdir="blobs"
|
||||
appdir="${blobdir}/app"
|
||||
cbdir="coreboot/default"
|
||||
|
@ -12,7 +11,6 @@ cbcfgsdir="config/coreboot"
|
|||
ifdtool="cbutils/default/ifdtool"
|
||||
cbfstool="cbutils/default/cbfstool"
|
||||
nvmutil="util/nvmutil/nvm"
|
||||
boarddir=""
|
||||
pciromsdir="pciroms"
|
||||
|
||||
mecleaner="$(pwd)/me_cleaner/me_cleaner.py"
|
||||
|
@ -22,28 +20,18 @@ kbc1126_ec_dump="$(pwd)/${cbdir}/util/kbc1126/kbc1126_ec_dump"
|
|||
pfs_extract="$(pwd)/biosutilities/Dell_PFS_Extract.py"
|
||||
uefiextract="$(pwd)/uefitool/uefiextract"
|
||||
|
||||
setvars="EC_url=\"\""
|
||||
for x in EC_url_bkup EC_hash DL_hash DL_url DL_url_bkup E6400_VGA_DL_hash \
|
||||
E6400_VGA_DL_url E6400_VGA_DL_url_bkup E6400_VGA_offset E6400_VGA_romname \
|
||||
SCH5545EC_DL_url SCH5545EC_DL_url_bkup SCH5545EC_DL_hash MRC_url \
|
||||
MRC_url_bkup MRC_hash MRC_board _dest; do
|
||||
setvars="${setvars}; ${x}=\"\""
|
||||
done
|
||||
eval "$(setvars "" EC_url EC_url_bkup EC_hash DL_hash DL_url DL_url_bkup _dest \
|
||||
E6400_VGA_DL_hash E6400_VGA_DL_url E6400_VGA_DL_url_bkup E6400_VGA_offset \
|
||||
E6400_VGA_romname SCH5545EC_DL_url SCH5545EC_DL_url_bkup SCH5545EC_DL_hash \
|
||||
MRC_url MRC_url_bkup MRC_hash MRC_board archive rom board modifygbe _dl \
|
||||
new_mac release releasearchive _b boarddir)"
|
||||
|
||||
for x in archive rom board modifygbe new_mac release releasearchive _dl; do
|
||||
setvars="${setvars}; ${x}=\"\""
|
||||
done
|
||||
|
||||
for x in CONFIG_BOARD_DELL_E6400 CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN \
|
||||
eval "$(setvars "" CONFIG_BOARD_DELL_E6400 CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN \
|
||||
CONFIG_ME_BIN_PATH CONFIG_KBC1126_FIRMWARE CONFIG_KBC1126_FW1 \
|
||||
CONFIG_KBC1126_FW1_OFFSET CONFIG_KBC1126_FW2 CONFIG_KBC1126_FW2_OFFSET \
|
||||
CONFIG_VGA_BIOS_FILE CONFIG_VGA_BIOS_ID CONFIG_GBE_BIN_PATH \
|
||||
CONFIG_INCLUDE_SMSC_SCH5545_EC_FW CONFIG_SMSC_SCH5545_EC_FW_FILE \
|
||||
CONFIG_IFD_BIN_PATH CONFIG_MRC_FILE; do
|
||||
setvars="${setvars}; ${x}=\"\""
|
||||
done
|
||||
|
||||
eval "${setvars}"
|
||||
CONFIG_IFD_BIN_PATH CONFIG_MRC_FILE)"
|
||||
|
||||
check_defconfig()
|
||||
{
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
# SPDX-FileCopyrightText: 2022, 2023 Leah Rowe <leah@libreboot.org>
|
||||
|
||||
setvars()
|
||||
{
|
||||
_setvars=""
|
||||
[ $# -lt 2 ] && err "setvars: too few arguments"
|
||||
val="${1}"
|
||||
shift 1
|
||||
for var in $@; do
|
||||
_setvars="${var}=\"${val}\"; ${_setvars}"
|
||||
done
|
||||
printf "%s\n" "${_setvars% }"
|
||||
}
|
||||
|
||||
err()
|
||||
{
|
||||
printf "ERROR %s: %s\n" "${0}" "${1}" 1>&2
|
||||
|
|
|
@ -14,41 +14,21 @@ set -u -e
|
|||
|
||||
read projectname < projectname
|
||||
|
||||
seavgabiosrom="elf/seabios/default/libgfxinit/vgabios.bin"
|
||||
grub_background="background1280x800.png"
|
||||
grubelf="elf/grub/grub.elf"
|
||||
cfgsdir="config/coreboot"
|
||||
|
||||
blobs_required=""
|
||||
|
||||
ubdir=""
|
||||
kmapdir="config/grub/keymap"
|
||||
|
||||
grub_timeout=""
|
||||
grub_scan_disk="undefined"
|
||||
tree="undefined"
|
||||
arch="undefined"
|
||||
|
||||
# Disable all payloads by default.
|
||||
# target.cfg files have to specifically enable [a] payload(s)
|
||||
payload_grub="n"
|
||||
payload_grub_withseabios="n" # seabios chainloaded from grub
|
||||
payload_seabios="n"
|
||||
payload_seabios_withgrub="n" # i386-coreboot grub from SeaBIOS boot menu
|
||||
payload_memtest="n"
|
||||
payload_uboot="n"
|
||||
uboot_config="undefined"
|
||||
eval "$(setvars "n" payload_grub payload_grub_withseabios payload_seabios \
|
||||
payload_seabios_withgrub payload_memtest payload_uboot)"
|
||||
|
||||
romdir=""
|
||||
cbdir=""
|
||||
cbfstool=""
|
||||
corebootrom=""
|
||||
seavgabiosrom="elf/seabios/default/libgfxinit/vgabios.bin"
|
||||
grub_background="background1280x800.png"
|
||||
eval "$(setvars "" romdir cbdir cbfstool corebootrom initmode displaymode \
|
||||
cbcfg targetdir grub_timeout ubdir blobs_required)"
|
||||
|
||||
initmode=""
|
||||
displaymode=""
|
||||
cbcfg=""
|
||||
targetdir=""
|
||||
|
||||
grubelf="elf/grub/grub.elf"
|
||||
eval "$(setvars "undefined" grub_scan_disk tree arch uboot_config)"
|
||||
|
||||
# main() is in include/boot.sh
|
||||
|
||||
|
@ -120,13 +100,9 @@ configure_target()
|
|||
# Override all payload directives with cmdline args
|
||||
if [ ! -z ${_payload} ]; then
|
||||
printf "setting payload to: %s\n" "${_payload}"
|
||||
payload_grub="n"
|
||||
payload_grub_withseabios="n" # seabios chainloaded from grub
|
||||
payload_seabios="n"
|
||||
payload_seabios_withgrub="n" # i386-coreboot grub from SeaBIOS
|
||||
payload_uboot="n"
|
||||
payload_memtest="n"
|
||||
|
||||
eval "$(setvars "n" payload_grub payload_grub_withseabios \
|
||||
payload_seabios payload_seabios_withgrub payload_uboot \
|
||||
payload_memtest)"
|
||||
eval "payload_${_payload}=y"
|
||||
fi
|
||||
}
|
||||
|
@ -494,10 +470,8 @@ moverom() {
|
|||
|
||||
[ -d "${newrompath%/*}" ] || mkdir -p "${newrompath%/*}/" || \
|
||||
err "moverom: cannot create rom directory: \"${newrompath%/*}\""
|
||||
|
||||
[ "${blobs_required}" = "n" ] && \
|
||||
newrompath="${newrompath%.rom}_noblobs.rom"
|
||||
|
||||
cp "${rompath}" "${newrompath}" || err "moverom: can't copy rom"
|
||||
}
|
||||
|
||||
|
|
|
@ -11,11 +11,8 @@ read projectname < projectname
|
|||
version="version-unknown"
|
||||
versiondate="version-date-unknown"
|
||||
tree="default"
|
||||
target=""
|
||||
CONFIG_HAVE_MRC=""
|
||||
CONFIG_HAVE_ME_BIN=""
|
||||
CONFIG_KBC1126_FIRMWARE=""
|
||||
CONFIG_INCLUDE_SMSC_SCH5545_EC_FW=""
|
||||
eval "$(setvars "" target CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN \
|
||||
CONFIG_KBC1126_FIRMWARE CONFIG_INCLUDE_SMSC_SCH5545_EC_FW)"
|
||||
ifdtool="cbutils/${tree}/ifdtool"
|
||||
cbfstool="cbutils/${tree}/cbfstool"
|
||||
microcode_required="y"
|
||||
|
@ -25,12 +22,10 @@ main()
|
|||
printf "Building ROM image archives for version %s\n" "${version}"
|
||||
|
||||
init_check
|
||||
|
||||
for romdir in bin/*; do
|
||||
[ -d "${romdir}" ] || continue
|
||||
make_archive "${romdir}"
|
||||
done
|
||||
|
||||
printf "\nROM archives available at release/%s/roms/\n\n" "${version}"
|
||||
}
|
||||
|
||||
|
@ -51,7 +46,6 @@ init_check()
|
|||
[ ! -d "release/${version}/roms/" ] || \
|
||||
rm -Rf "release/${version}/roms/" || \
|
||||
err "init_check: !rm -Rf release/${version}/roms/"
|
||||
|
||||
if [ ! -d "release/${version}/roms/" ]; then
|
||||
mkdir -p "release/${version}/roms/" || \
|
||||
err "init_check: !mkdir -p release/${version}/roms/"
|
||||
|
|
|
@ -21,18 +21,14 @@ filelist="${filelist} checkversion"
|
|||
|
||||
version="version-unknown"
|
||||
versiondate="version-date-unknown"
|
||||
reldir=""
|
||||
dirname=""
|
||||
srcdir=""
|
||||
eval "$(setvars "" reldir dirname srcdir)"
|
||||
|
||||
printf "Building source code archive, version %s\n" "${version}"
|
||||
|
||||
main()
|
||||
{
|
||||
[ -f version ] && \
|
||||
read version < version
|
||||
[ -f versiondate ] && \
|
||||
read versiondate < versiondate
|
||||
[ -f version ] && read version < version
|
||||
[ -f versiondate ] && read versiondate < versiondate
|
||||
|
||||
create_release_directory
|
||||
download_modules
|
||||
|
|
|
@ -15,25 +15,10 @@ read our_version < version
|
|||
|
||||
export LOCALVERSION="-${projectname}-${our_version}"
|
||||
|
||||
arch=""
|
||||
cfgsdir=""
|
||||
codedir=""
|
||||
config=""
|
||||
config_name=""
|
||||
crossgcc_ada=""
|
||||
elfdir=""
|
||||
listfile=""
|
||||
mode=""
|
||||
project=""
|
||||
romtype=""
|
||||
target=""
|
||||
target_dir=""
|
||||
targets=""
|
||||
tree=""
|
||||
cbfstool=""
|
||||
eval "$(setvars "" arch cfgsdir codedir config config_name crossgcc_ada mode \
|
||||
elfdir listfile project romtype target target_dir targets tree cbfstool)"
|
||||
|
||||
tmpclean="$(mktemp -d -t makeclean.XXXXXXXXXX)" || \
|
||||
fail "can't make tmpclean dir"
|
||||
tmpclean="$(mktemp -d -t makeclean.XXXXXXXXXX)" || fail "!mkdir tmpclean"
|
||||
|
||||
main()
|
||||
{
|
||||
|
@ -115,8 +100,7 @@ handle_src_tree()
|
|||
mkdir -p "${elfdir}/${target}" || \
|
||||
fail "handle_src_tree: !mkdir -p ${elfdir}/${target}"
|
||||
|
||||
tree="undefined"
|
||||
arch="undefined"
|
||||
eval "$(setvars "undefined" arch tree)"
|
||||
romtype="normal"
|
||||
|
||||
[ ! -f "${target_dir}/target.cfg" ] && \
|
||||
|
@ -218,10 +202,9 @@ check_config()
|
|||
dest_dir="${elfdir}/${target}/${config_name}"
|
||||
# TODO: very hacky check. do it properly (based on build.list)
|
||||
for elftest in "${dest_dir}"/*; do
|
||||
if [ -f "${elftest}" ]; then
|
||||
printf "Build already exists, so skipping build\n" 1>&2
|
||||
return 1
|
||||
fi
|
||||
[ -f "${elftest}" ] || continue
|
||||
printf "Build already exists, so skipping build\n" 1>&2
|
||||
return 1
|
||||
done
|
||||
mkdir -p "${dest_dir}" || \
|
||||
fail "check_config: cannot mkdir: ${dest_dir}"
|
||||
|
@ -255,15 +238,12 @@ run_make_command()
|
|||
|
||||
copy_elf()
|
||||
{
|
||||
if [ "${project}" = "coreboot" ]; then
|
||||
modify_coreboot_rom || \
|
||||
fail "copy_elf: cannot prepare coreboot image"
|
||||
fi
|
||||
[ "${project}" != "coreboot" ] || modify_coreboot_rom || \
|
||||
fail "copy_elf: cannot prepare coreboot image"
|
||||
|
||||
while read f; do
|
||||
[ ! -f "${codedir}/$f" ] || \
|
||||
cp "${codedir}/${f}" "${dest_dir}/" || \
|
||||
fail "copy_elf: cannot copy elf file"
|
||||
[ ! -f "${codedir}/$f" ] || cp "${codedir}/${f}" \
|
||||
"${dest_dir}/" || fail "copy_elf: cannot copy elf file"
|
||||
done < ${listfile}
|
||||
|
||||
./handle make file -c "${codedir}" || \
|
||||
|
|
|
@ -7,8 +7,7 @@ set -u -e
|
|||
|
||||
. "include/err.sh"
|
||||
|
||||
mode=""
|
||||
project=""
|
||||
eval "$(setvars "" mode project)"
|
||||
|
||||
main()
|
||||
{
|
||||
|
|
|
@ -292,12 +292,10 @@ inject_blob_dell_e6400_vgarom_nvidia()
|
|||
inject_blob_smsc_sch5545_ec()
|
||||
{
|
||||
rom="${1}"
|
||||
|
||||
_sch5545ec_location="${CONFIG_SMSC_SCH5545_EC_FW_FILE#../../}"
|
||||
|
||||
if [ ! -f "${_sch5545ec_location}" ]; then
|
||||
[ -f "${_sch5545ec_location}" ] || \
|
||||
err "inject_blob_smsc_sch5545_ec: SCH5545 fw missing"
|
||||
fi
|
||||
|
||||
"${cbfstool}" "${rom}" add -f "${_sch5545ec_location}" \
|
||||
-n sch5545_ecfw.bin -t raw || \
|
||||
|
@ -307,12 +305,10 @@ inject_blob_smsc_sch5545_ec()
|
|||
modify_gbe()
|
||||
{
|
||||
printf "changing mac address in gbe to ${new_mac}\n"
|
||||
|
||||
rom="${1}"
|
||||
|
||||
[ -z ${CONFIG_GBE_BIN_PATH} ] && \
|
||||
err "modify_gbe: ${board}: CONFIG_GBE_BIN_PATH not set"
|
||||
|
||||
rom="${1}"
|
||||
_gbe_location=${CONFIG_GBE_BIN_PATH#../../}
|
||||
|
||||
[ -f "${_gbe_location}" ] || \
|
||||
|
|
|
@ -8,13 +8,8 @@
|
|||
. "include/git.sh"
|
||||
. "include/option.sh"
|
||||
|
||||
name=""
|
||||
rev=""
|
||||
loc=""
|
||||
url=""
|
||||
bkup_url=""
|
||||
eval "$(setvars "" name rev loc url bkup_url depend)"
|
||||
tmp_dir="${PWD}/tmp/gitclone"
|
||||
depend=""
|
||||
|
||||
main()
|
||||
{
|
||||
|
|
|
@ -11,11 +11,7 @@ set -u -e
|
|||
. "include/git.sh"
|
||||
. "include/option.sh"
|
||||
|
||||
_target=""
|
||||
tree=""
|
||||
rev=""
|
||||
project=""
|
||||
cfgsdir=""
|
||||
eval "$(setvars "" _target tree rev project cfgsdir)"
|
||||
|
||||
main()
|
||||
{
|
||||
|
@ -40,7 +36,6 @@ main()
|
|||
download_for_target "${x}" || \
|
||||
err "${project}/${target}: cannot download source tree"
|
||||
done
|
||||
|
||||
rm -f "${cfgsdir}"/*/seen || err_rm_seen "main 3"
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue