summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfetch54
-rwxr-xr-xfetch_trees39
-rwxr-xr-xlbmk19
-rwxr-xr-xresources/scripts/build/boot/roms47
-rwxr-xr-xresources/scripts/build/boot/roms_helper124
-rwxr-xr-xresources/scripts/build/clean/cbutils9
-rwxr-xr-xresources/scripts/build/clean/crossgcc7
-rwxr-xr-xresources/scripts/build/coreboot/utils15
-rwxr-xr-xresources/scripts/build/descriptors/ich9m6
-rwxr-xr-xresources/scripts/build/grub/payload33
-rwxr-xr-xresources/scripts/build/grub/utils15
-rwxr-xr-xresources/scripts/build/release/roms53
-rwxr-xr-xresources/scripts/build/release/src21
-rwxr-xr-xresources/scripts/build/src/for4
-rwxr-xr-xresources/scripts/handle/config/file19
-rwxr-xr-xresources/scripts/misc/versioncheck18
-rwxr-xr-xresources/scripts/update/blobs/download238
-rwxr-xr-xresources/scripts/update/blobs/extract68
-rwxr-xr-xresources/scripts/update/blobs/inject155
-rwxr-xr-xresources/scripts/update/blobs/mrc58
20 files changed, 344 insertions, 658 deletions
diff --git a/fetch b/fetch
index 502c0f76..4466d4ee 100755
--- a/fetch
+++ b/fetch
@@ -15,25 +15,15 @@ depend=""
main()
{
- if [ -z "${1+x}" ]; then
- err 'Error: name not set'
- fi
-
+ [ -z "${1+x}" ] && err 'Error: name not set'
name=${1}
read_config
verify_config
clone_project
+ [ "${depend}" = "" ] || ./fetch ${depend} || exit 1
- # dependencies are downloaded *after*
- # to account for cases like gnulib in grub where
- # the dependency (gnulib) goes inside the main repo (grub)
- if [ "${depend}" != "" ]; then
- ./fetch ${depend} || exit 1
- fi
-
- # clean in case of failure
rm -Rf ${tmp_dir} >/dev/null 2>&1 || exit 1
}
@@ -44,20 +34,15 @@ read_config()
set ${line} >/dev/null 2>&1
case ${line} in
rev:*)
- revision=${2}
- ;;
+ revision=${2} ;;
loc:*)
- location=${2}
- ;;
+ location=${2} ;;
url:*)
- url=${2}
- ;;
+ url=${2} ;;
bkup_url:*)
- bkup_url=${2}
- ;;
+ bkup_url=${2} ;;
depend:*)
- depend=${2}
- ;;
+ depend=${2} ;;
esac
done << EOF
$(eval "awk '${awkstr}' resources/git/revisions")
@@ -66,32 +51,25 @@ EOF
verify_config()
{
- if [ -z "${revision+x}" ]; then
- err 'Error: revision not set'
- elif [ -z "${location+x}" ]; then
- err 'Error: location not set'
- elif [ -z "${url+x}" ]; then
- err 'Error: url not set'
- fi
+ [ -z "${revision+x}" ] && err 'Error: revision not set'
+ [ -z "${location+x}" ] && err 'Error: location not set'
+ [ -z "${url+x}" ] && err 'Error: url not set'
}
clone_project()
{
tmp_dir=$(mktemp -dt "${name}_XXXXX")
- git clone ${url} ${tmp_dir} || git clone ${bkup_url} ${tmp_dir} \
- || err "ERROR: could not download ${name}"
-
+ git clone ${url} ${tmp_dir} || git clone ${bkup_url} ${tmp_dir} || \
+ err "ERROR: could not download ${name}"
(
cd ${tmp_dir} || err "tmpdir not created"
git reset --hard ${revision} || err "Cannot reset revision"
)
-
patch_project
- if [ -d "${location}" ]; then
- rm -Rf ${location} || err "Cannot remove directory '${location}'"
- fi
+ [ ! -d "${location}" ] || \
+ rm -Rf ${location} || err "Can't remove directory '${location}'"
mv ${tmp_dir} ${location} && return 0
printf "ERROR: Could not copy temp file to destination.\n"
@@ -103,9 +81,7 @@ patch_project()
patchdir="resources/${name}/patches"
for patchfile in ${PWD}/${patchdir}/*.patch ; do
- if [ ! -f "${patchfile}" ]; then
- continue
- fi
+ [ -f "${patchfile}" ] || continue
(
cd ${tmp_dir} || err "tmpdir not created"
git am ${patchfile} || err "Cannot patch project: $name"
diff --git a/fetch_trees b/fetch_trees
index 19112a2e..ed15739a 100755
--- a/fetch_trees
+++ b/fetch_trees
@@ -1,7 +1,7 @@
#!/usr/bin/env sh
# helper script: create code trees based on git revision, with patches
-# (currently used for downloading coreboot and u-boot)
+# (currently used for downloading coreboot, seabios and u-boot)
#
# Copyright (C) 2014-2016,2020,2021,2023 Leah Rowe <info@minifree.org>
# Copyright (C) 2022 Alper Nebi Yasak <alpernebiyasak@gmail.com>
@@ -72,16 +72,14 @@ download_for_target()
if [ -d "${project}/${tree}" ]; then
printf "REMARK: download/%s %s: exists. Skipping.\n" \
- ${project} ${tree}
- [ "${tree}" != "${1}" ] && \
- printf "(for target: '%s}')\n" ${1}
+ ${project} ${tree}
+ [ "${tree}" != "${_target}" ] && \
+ printf "(for target: '%s}')\n" ${_target}
return 0
fi
fetch_from_upstream || exit 1
-
- prepare_new_tree "${1}" "${tree}" "${rev}" \
- || exit 1
+ prepare_new_tree "${_target}" "${tree}" "${rev}" || exit 1
}
fetch_config()
@@ -135,14 +133,11 @@ check_config_for_target()
fetch_from_upstream()
{
- [ ! -d "${project}" ] && \
- mkdir -p "${project}"
- [ ! -d "${project}" ] && \
- return 1
- [ -d "${project}/${project}" ] && \
- return 0
- ./fetch ${project} || \
- return 1
+ [ -d "${project}" ] || mkdir -p "${project}"
+ [ -d "${project}" ] || return 1
+ [ -d "${project}/${project}" ] && return 0
+
+ ./fetch ${project} || return 1
}
prepare_new_tree()
@@ -157,16 +152,14 @@ prepare_new_tree()
cp -R "${project}/${project}" "${project}/${tree}" || exit 1
(
- cd "${project}/${tree}" \
- || err "cannot cd to ${project}/${tree}"
- git reset --hard ${rev} \
- || err "cannot reset ${project} revision for tree, ${tree}"
- git submodule update --init --checkout \
- || err "cannot update ${project} submodules for tree, ${tree}"
+ cd "${project}/${tree}" || err "cannot cd to ${project}/${tree}"
+ git reset --hard ${rev} || \
+ err "cannot reset ${project} revision for tree, ${tree}"
+ git submodule update --init --checkout || \
+ err "cannot update ${project} submodules for tree, ${tree}"
for patch in ../../"${cfgsdir}"/"${tree}"/patches/*.patch; do
- [ ! -f "${patch}" ] && \
- continue
+ [ ! -f "${patch}" ] && continue
if ! git am "${patch}"; then
git am --abort
err "cannot patch ${tree}"
diff --git a/lbmk b/lbmk
index d6bac743..f759e461 100755
--- a/lbmk
+++ b/lbmk
@@ -31,23 +31,15 @@ option=""
main()
{
- if [ "${0##*/}" = "lbmk" ]; then
- die "Do not run the lbmk script directly!"
- elif [ $# -lt 1 ]; then
- die "Too few arguments. Try: ${0} help"
- fi
+ [ "${0##*/}" = "lbmk" ] && die "Don't run this script directly."
+ [ $# -lt 1 ] && die "Too few arguments. Try: ${0} help"
buildpath="./resources/scripts/${0##*/}"
mode="${1}"
./.gitcheck
- if [ "${mode}" = help ]; then
- usage $0
- exit 0
- elif [ $# -lt 2 ]; then
- usage $0
- exit 1
- fi
+ [ "${mode}" = "help" ] && usage ${0} && exit 0
+ [ $# -lt 2 ] && usage ${0} && exit 1
if [ "${mode}" = "dependencies" ]; then
install_dependencies $@ || die "Could not install dependencies"
exit 0
@@ -61,8 +53,7 @@ main()
case "${option}" in
list)
printf "Options for mode '%s':\n\n" ${mode}
- listoptions "${mode}"
- ;;
+ listoptions "${mode}" ;;
all)
for option in $(listoptions "${mode}"); do
"${buildpath}/${mode}/${option}" $@
diff --git a/resources/scripts/build/boot/roms b/resources/scripts/build/boot/roms
index 70054fd4..44b7cb8e 100755
--- a/resources/scripts/build/boot/roms
+++ b/resources/scripts/build/boot/roms
@@ -36,20 +36,11 @@ firstoption=""
main()
{
- if [ $# -lt 1 ]; then
- usage
- exit 1
- fi
- firstoption="${1}"
+ [ $# -lt 1 ] && usage && exit 1
- if [ "${firstoption}" = "help" ]; then
- usage
- exit 0
- fi
- if [ "${firstoption}" = "list" ]; then
- listboards
- exit 0
- fi
+ firstoption="${1}"
+ [ "${firstoption}" = "help" ] && usage && exit 0
+ [ "${firstoption}" = "list" ] && listboards && exit 0
while [ $# -gt 0 ]; do
case ${1} in
@@ -68,21 +59,16 @@ main()
shift
done
- if [ -z ${opts+x} ]; then
- opts=""
- fi
-
+ [ -z ${opts+x} ] && opts=""
printf "Building %s ROM images\n" "${projectname}"
if [ "${firstoption}" = "all" ]; then
for boardname in $(listboards); do
- buildrom "${boardname}" \
- || die "build/roms: error"
+ buildrom "${boardname}" || err "build/roms: error"
done
else
for board in ${boards}; do
- buildrom "${board}" \
- || die "build/roms: error"
+ buildrom "${board}" || err "build/roms: error"
done
fi
@@ -116,9 +102,7 @@ usage()
listboards()
{
for boarddir in resources/coreboot/*; do
- if [ ! -d "${boarddir}" ]; then
- continue
- fi
+ [ ! -d "${boarddir}" ] && continue
board="${boarddir##resources/coreboot/}"
board="${board%/}"
printf '%s\n' "${board##*/}"
@@ -127,18 +111,13 @@ listboards()
# Build ROM images for supported boards
buildrom() {
- board="$1"
-
- if [ -d "resources/coreboot/${board}/" ]; then
- ./build boot roms_helper ${board}${opts}
- else
- printf "\nbuild/roms: target not defined: %s\n" ${board}
- die "Run: ./build boot roms list"
- fi
+ [ -d "resources/coreboot/${1}/" ] || \
+ err "build/roms: target not defined: ${1}"
+ ./build boot roms_helper ${1}${opts}
}
-die() {
- printf 'Error: %s\n' "${@}" 1>&2
+err() {
+ printf '%s\n' "${1}" 1>&2
exit 1
}
diff --git a/resources/scripts/build/boot/roms_helper b/resources/scripts/build/boot/roms_helper
index 5e2085d9..8438fffc 100755
--- a/resources/scripts/build/boot/roms_helper
+++ b/resources/scripts/build/boot/roms_helper
@@ -115,8 +115,8 @@ fi
# NOTE: reverse logic must NOT be applied. If SeaBIOS-with-GRUB works, that
# doesn't necessarily mean GRUb-with-SeaBIOS will. For example, the board
# might have an external GPU, where it's recommended to boot SeaBIOS first
-if [ "${payload_grub}" != "y" ] && [ "${payload_seabios}" != "y" ] \
- && [ "${payload_uboot}" != "y" ]; then
+if [ "${payload_grub}" != "y" ] && [ "${payload_seabios}" != "y" ] && \
+ [ "${payload_uboot}" != "y" ]; then
for configfile in "resources/coreboot/${board}/config/"*; do
[ ! -e "${configfile}" ] && continue
printf "ERROR build/roms: Target '%s' defines no payload. " \
@@ -153,7 +153,7 @@ fi
romdir="bin/${board}"
cbdir="coreboot/${board}"
-[ "${board}" != "${tree}" ] && \
+[ "${board}" = "${tree}" ] || \
cbdir="coreboot/${tree}"
cbfstool="cbutils/${tree}/cbfstool"
corebootrom="${cbdir}/build/coreboot.rom"
@@ -191,10 +191,7 @@ if [ "${payload_grub}" = "y" ] \
printf "Required GRUB payloads not yet built. Building now:\n"
fi
for keymapfile in ${kmapdir}/*; do
-
- if [ ! -f "${keymapfile}" ]; then
- continue
- fi
+ [ -f "${keymapfile}" ] || continue
keymap="${keymapfile##*/}"
keymap="${keymap%.gkb}"
@@ -216,7 +213,7 @@ if [ "${payload_uboot}" = "y" ]; then
ubootelf="${ubdir}/u-boot.elf"
[ ! -f "${ubootelf}" ] && [ -f "${ubdir}/u-boot.bin" ] && \
ubootelf="${ubdir}/u-boot.bin"
- [ ! -f "${ubootelf}" ] && \
+ [ -f "${ubootelf}" ] || \
err "Could not find u-boot build for board, ${board}"
fi
@@ -234,8 +231,7 @@ moverom() {
if [ "${cuttype}" = "4MiB IFD BIOS region" ]; then
dd if=${rompath} of=${newrompath} bs=1 \
- skip=$(($(stat -c %s ${rompath}) - 0x400000)) \
- count=4194304
+ skip=$(($(stat -c %s ${rompath}) - 0x400000)) count=4194304
else
cp ${rompath} ${newrompath}
fi
@@ -248,7 +244,7 @@ moverom() {
touch "${emptyrom}"
for deviceID in "0072" "3050"; do
"${cbfstool}" "${newrompath}" add -f "${emptyrom}" \
- -n pci1000,${deviceID}.rom -t raw
+ -n pci1000,${deviceID}.rom -t raw
done
rm -f "${emptyrom}"
fi
@@ -256,30 +252,27 @@ moverom() {
for romsize in 4 8 16; do
ifdgbe="descriptors/ich9m/ich9fdgbe_${romsize}m.bin"
if [ "${cuttype}" = "${romsize}MiB ICH9 IFD NOR flash" ]; then
- if [ ! -f "${ifdgbe}" ]; then
+ [ -f "${ifdgbe}" ] || \
./build descriptors ich9m
- fi
dd if=${ifdgbe} of=${newrompath} bs=1 count=12k \
- conv=notrunc
+ conv=notrunc
fi
cmpstr="${romsize}MiB ICH9 IFD NOGBE NOR flash"
ifdgbe="descriptors/ich9m/ich9fdnogbe_${romsize}m.bin"
if [ "${cuttype}" = "${cmpstr}" ]; then
- if [ ! -f "${ifdgbe}" ]; then
+ [ -f "${ifdgbe}" ] || \
./build descriptors ich9m
- fi
dd if=${ifdgbe} of=${newrompath} bs=1 count=4k \
- conv=notrunc
+ conv=notrunc
fi
done
if [ "${cuttype}" = "i945 laptop" ]; then
dd if=${newrompath} of=top64k.bin bs=1 \
- skip=$(($(stat -c %s ${newrompath}) - 0x10000)) \
- count=64k
+ skip=$(($(stat -c %s ${newrompath}) - 0x10000)) count=64k
dd if=top64k.bin of=${newrompath} bs=1 \
- seek=$(($(stat -c %s ${newrompath}) - 0x20000)) \
- count=64k conv=notrunc
+ seek=$(($(stat -c %s ${newrompath}) - 0x20000)) count=64k \
+ conv=notrunc
rm -f top64k.bin
fi
@@ -288,11 +281,11 @@ moverom() {
cp "${newrompath}" "${_newrom_b}" || exit 1
microcode_present="y"
"${cbfstool}" "${_newrom_b}" remove -n \
- cpu_microcode_blob.bin || microcode_present="n"
+ cpu_microcode_blob.bin || microcode_present="n"
if [ "${microcode_present}" = "n" ]; then
rm -f "${_newrom_b}" || exit 1
printf "REMARK: '%s' already lacks microcode\n" \
- ${newrompath}
+ ${newrompath}
printf "Renaming default ROM file instead.\n"
mv "${newrompath}" "${_newrom_b}" || exit 1
fi
@@ -313,27 +306,26 @@ mkSeabiosRom() {
cp "${target_cbrom}" "${tmprom}"
"${cbfstool}" "${tmprom}" add-payload -f "${target_seabioself}" \
- -n ${target_seabios_cbfs_path} -c lzma || exit 1
+ -n ${target_seabios_cbfs_path} -c lzma || exit 1
"${cbfstool}" "${tmprom}" add-int -i 3000 -n etc/ps2-keyboard-spinup \
- || exit 1
+ || exit 1
- if [ "${target_initmode}" = "normal" ] \
- || [ "${target_initmode}" = "libgfxinit" ]; then
+ if [ "${target_initmode}" = "normal" ] || \
+ [ "${target_initmode}" = "libgfxinit" ]; then
"${cbfstool}" "${tmprom}" add-int -i 2 \
- -n etc/pci-optionrom-exec || exit 1
+ -n etc/pci-optionrom-exec || exit 1
elif [ "${target_initmode}" = "vgarom" ]; then # coreboot executes it
"${cbfstool}" "${tmprom}" add-int -i 0 \
- -n etc/pci-optionrom-exec || exit 1
+ -n etc/pci-optionrom-exec || exit 1
fi # for undefined modes, don't add this integer. use SeaBIOS defaults
- "${cbfstool}" "${tmprom}" add-int -i 0 -n etc/optionroms-checksum \
- || exit 1
+ "${cbfstool}" "${tmprom}" add-int -i 0 -n etc/optionroms-checksum || \
+ exit 1
- if [ "${target_initmode}" = "libgfxinit" ]; then
+ [ "${target_initmode}" != "libgfxinit" ] || \
"${cbfstool}" "${tmprom}" add -f "${seavgabiosrom}" \
- -n vgaroms/seavgabios.bin -t raw || exit 1
- fi
+ -n vgaroms/seavgabios.bin -t raw || exit 1
printf "%s\n" "${tmprom}"
}
@@ -348,16 +340,16 @@ mkUbootRom() {
target_ubdir="elf/u-boot/${board}/${target_uboot_config}"
target_ubootelf="${target_ubdir}/u-boot.elf"
- [ ! -f "${target_ubootelf}" ] && \
+ [ -f "${target_ubootelf}" ] || \
target_ubootelf="${target_ubdir}/u-boot.bin"
- [ ! -f "${target_ubootelf}" ] && \
+ [ -f "${target_ubootelf}" ] || \
err "Could not find u-boot build for board, ${board}"
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
cp "${target_cbrom}" "${tmprom}"
"${cbfstool}" "${tmprom}" add-payload -f "${target_ubootelf}" \
- -n ${target_uboot_cbfs_path} -c lzma || exit 1
+ -n ${target_uboot_cbfs_path} -c lzma || exit 1
printf "%s\n" "${tmprom}"
}
@@ -376,34 +368,34 @@ mkGrubRom() {
cp "${target_cbrom}" "${tmprom}" || exit 1
"${cbfstool}" "${tmprom}" add-payload -f "${grubelf}" \
- -n ${target_grubelf_cbfs_path} -c lzma || exit 1
+ -n ${target_grubelf_cbfs_path} -c lzma || exit 1
tmpgrubcfg=$(mktemp -t grub.cfg.XXXXXXXXXX)
tmpgrubtestcfg=$(mktemp -t grubtest.cfg.XXXXXXXXXX)
if [ "${grub_scan_disk}" = "ahci" ]; then
sed \
's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ahci\"/' \
- "${grubcfg}" > "${tmpgrubcfg}"
+ "${grubcfg}" > "${tmpgrubcfg}"
sed \
's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ahci\"/' \
- "${grubtestcfg}" > "${tmpgrubtestcfg}"
+ "${grubtestcfg}" > "${tmpgrubtestcfg}"
elif [ "${grub_scan_disk}" = "ata" ]; then
sed \
's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ata\"/' \
- "${grubcfg}" > "${tmpgrubcfg}"
+ "${grubcfg}" > "${tmpgrubcfg}"
sed \
's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ata\"/' \
- "${grubtestcfg}" > "${tmpgrubtestcfg}"
+ "${grubtestcfg}" > "${tmpgrubtestcfg}"
else
cp "${grubcfg}" "${tmpgrubcfg}"
cp "${grubtestcfg}" "${tmpgrubtestcfg}"
fi
- "${cbfstool}" "${tmprom}" add -f "${tmpgrubcfg}" -n grub.cfg -t raw \
- || exit 1
+ "${cbfstool}" "${tmprom}" add -f "${tmpgrubcfg}" -n grub.cfg -t raw || \
+ exit 1
"${cbfstool}" "${tmprom}" add -f "${tmpgrubtestcfg}" -n grubtest.cfg \
- -t raw || exit 1
+ -t raw || exit 1
rm -f "${tmpgrubcfg}" "${tmpgrubtestcfg}"
backgroundfile="background1280x800.png"
@@ -413,7 +405,7 @@ mkGrubRom() {
fi
backgroundfile="resources/grub/background/${backgroundfile}"
"${cbfstool}" "${tmprom}" add -f ${backgroundfile} -n background.png \
- -t raw || exit 1
+ -t raw || exit 1
printf "%s\n" "${tmprom}"
}
@@ -427,20 +419,18 @@ mkRomsWithGrub() {
x=${tmprompath}
y=${initmode}
- if [ "${payload_grub_withseabios}" = "y" ] \
- && [ "${firstpayloadname}" = "grub" ]; then
- mv "$(mkSeabiosRom "${x}" "seabios.elf" "${y}")" \
- "${tmprompath}"
- elif [ "${payload_seabios_withgrub}" ] \
- && [ "${firstpayloadname}" != "grub" ]; then
+ if [ "${payload_grub_withseabios}" = "y" ] && \
+ [ "${firstpayloadname}" = "grub" ]; then
+ mv "$(mkSeabiosRom "${x}" "seabios.elf" "${y}")" "${tmprompath}"
+ elif [ "${payload_seabios_withgrub}" ] && \
+ [ "${firstpayloadname}" != "grub" ]; then
mv "$(mkSeabiosRom "${x}" "fallback/payload" "$y")" \
- "${tmprompath}"
+ "${tmprompath}"
fi
keymaps=""
if [ -z ${keyboard_layouts} ]; then
- for kmapfile in "${kmapdir}"/*
- do
+ for kmapfile in "${kmapdir}"/*; do
keymaps="${keymaps} ${kmapfile}"
done
else
@@ -451,17 +441,14 @@ mkRomsWithGrub() {
for keymapfile in ${keymaps}; do
echo "keymaps is $keymaps, keymapfile is $keymapfile"
- if [ ! -f "${keymapfile}" ]; then
- continue
- fi
+ [ -f "${keymapfile}" ] || continue
keymap="${keymapfile##*/}"
keymap="${keymap%.gkb}"
grub_path_in_cbfs="fallback/payload"
- if [ "${firstpayloadname}" != "grub" ]; then
+ [ "${firstpayloadname}" = "grub" ] || \
grub_path_in_cbfs="img/grub2"
- fi
# evil bofh rfc 2646 compliance hack
x=${keymap}
@@ -492,8 +479,7 @@ mkRoms()
if [ ! -f "${cbcfgpath}" ]; then
printf "'%s' does not exist. Skipping build for %s %s %s\n" \
- ${cbcfgpath} ${board} \
- ${displaymode} ${initmode}
+ ${cbcfgpath} ${board} ${displaymode} ${initmode}
return 0
fi
@@ -506,11 +492,10 @@ mkRoms()
corebootrom="$(mktemp -t coreboot_rom.XXXXXXXXXX)"
cp "${_corebootrom}" "${corebootrom}"
- if [ "${displaymode}" = "txtmode" ] \
- && [ "${payload_memtest}" = "y" ]; then
+ if [ "${displaymode}" = "txtmode" ] && \
+ [ "${payload_memtest}" = "y" ]; then
"${cbfstool}" "${corebootrom}" add-payload \
- -f memtest86plus/memtest -n img/memtest \
- -c lzma || exit 1
+ -f memtest86plus/memtest -n img/memtest -c lzma || exit 1
fi
if [ "${payload_seabios}" = "y" ]; then
@@ -533,15 +518,14 @@ mkRoms()
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
cp "${corebootrom}" "${tmprom}"
mkRomsWithGrub "${tmprom}" "${initmode}" \
- "${displaymode}" "seabios_withgrub"
+ "${displaymode}" "seabios_withgrub"
rm -f "${tmprom}"
fi
fi
- if [ "${payload_grub}" = "y" ]; then
+ [ "${payload_grub}" = "y" ] && \
mkRomsWithGrub "${corebootrom}" "${initmode}" \
- "${displaymode}" "grub"
- fi
+ "${displaymode}" "grub"
if [ "${payload_uboot}" = "y" ]; then
x=${corebootrom}
diff --git a/resources/scripts/build/clean/cbutils b/resources/scripts/build/clean/cbutils
index de9a588f..dec8d944 100755
--- a/resources/scripts/build/clean/cbutils
+++ b/resources/scripts/build/clean/cbutils
@@ -33,12 +33,9 @@ rm -Rf cbutils
[ ! -d "coreboot/" ] && exit 0
for tree in coreboot/*; do
- if [ "${tree##*/}" = "coreboot" ]; then
- continue
- fi
- if [ ! -d "${tree}" ]; then
- continue
- fi
+ [ "${tree##*/}" = "coreboot" ] && continue
+ [ -d "${tree}" ] || continue
+
# Clean coreboot, of course
make -C "${tree}/" distclean
diff --git a/resources/scripts/build/clean/crossgcc b/resources/scripts/build/clean/crossgcc
index 6c09c878..8c61dd5f 100755
--- a/resources/scripts/build/clean/crossgcc
+++ b/resources/scripts/build/clean/crossgcc
@@ -25,14 +25,11 @@ set -u -e
main()
{
printf "Cleaning crossgcc builds in all coreboot archives\n"
-
[ ! -d "coreboot/" ] && exit 0
for board in coreboot/*; do
- [ "${board##*/}" = "coreboot" ] && \
- continue
- [ ! -d "${board}" ] && \
- continue
+ [ "${board##*/}" = "coreboot" ] && continue
+ [ ! -d "${board}" ] && continue
make -C "${board}/" crossgcc-clean || err "make-clean"
done
}
diff --git a/resources/scripts/build/coreboot/utils b/resources/scripts/build/coreboot/utils
index 45739e95..a21da691 100755
--- a/resources/scripts/build/coreboot/utils
+++ b/resources/scripts/build/coreboot/utils
@@ -39,10 +39,8 @@ main()
build_for_mainboard() {
board="${1}"
- [ ! -d "resources/coreboot/${board}" ] && \
- continue
- [ ! -f "resources/coreboot/${board}/target.cfg" ] && \
- continue
+ [ -d "resources/coreboot/${board}" ] || continue
+ [ -f "resources/coreboot/${board}/target.cfg" ] || continue
tree="undefined"
. "resources/coreboot/${board}/target.cfg" # source
if [ "${tree}" = "undefined" ]; then
@@ -55,15 +53,12 @@ build_for_mainboard() {
buildutils() {
tree="${1}"
- if [ ! -d "coreboot/${tree}/" ]; then
+ [ -d "coreboot/${tree}/" ] || \
./fetch_trees coreboot $tree || return 1
- fi
for util in cbfstool ifdtool; do
- [ -f "cbutils/${tree}/${util}" ] \
- && continue
- if [ ! -d "cbutils/${tree}" ]; then
+ [ -f "cbutils/${tree}/${util}" ] && continue
+ [ -d "cbutils/${tree}" ] || \
mkdir -p "cbutils/${tree}" || return 1
- fi
utildir="coreboot/${tree}/util/${util}"
make distclean -C "${utildir}" || return 1
diff --git a/resources/scripts/build/descriptors/ich9m b/resources/scripts/build/descriptors/ich9m
index 1623b94b..221131af 100755
--- a/resources/scripts/build/descriptors/ich9m
+++ b/resources/scripts/build/descriptors/ich9m
@@ -23,9 +23,9 @@ ich9gen="util/ich9utils/ich9gen"
main()
{
- [ -f "${ich9gen}" ] || ./build src for -b ich9utils || err "ich9utils make"
- [ ! -f "${ich9gen}" ] && \
- err "ich9gen doesn't exist"
+ [ -f "${ich9gen}" ] || ./build src for -b ich9utils || \
+ err "ich9utils make"
+ [ ! -f "${ich9gen}" ] && err "ich9gen doesn't exist"
[ -d "descriptors/ich9m/" ] || mkdir -p "descriptors/ich9m/"
rm -f descriptors/ich9m/* || err "rm-rf"
diff --git a/resources/scripts/build/grub/payload b/resources/scripts/build/grub/payload
index bf52d2a1..4886a874 100755
--- a/resources/scripts/build/grub/payload
+++ b/resources/scripts/build/grub/payload
@@ -53,18 +53,15 @@ main()
build_grub_payloads()
{
keylayoutfile=${1}
+ [ -f "${keylayoutfile}" ] || continue
- if [ ! -f "${keylayoutfile}" ]; then
- continue
- fi
keymap="${keylayoutfile##${grubcfgsdir}/keymap/}"
keymap="${keymap%.gkb}"
build_grub_elf "${keylayoutfile}"
create_grub_config
- printf "Created 'elf/grub/grub_%s.elf' and configs.'\n" \
- "${keymap}"
+ printf "Created 'elf/grub/grub_%s.elf' and configs.'\n" "${keymap}"
}
build_grub_elf()
@@ -75,24 +72,22 @@ build_grub_elf()
gcfg="${gcfg}/config/grub_memdisk.cfg"
grubk="/boot/grub/layouts/${keymap}.gkb=${keylayoutfile}"
grub/grub-mkstandalone \
- --grub-mkimage="grub/grub-mkimage" \
- -O i386-coreboot \
- -o elf/grub/grub_${keymap}.elf \
- -d grub/grub-core/ \
- --fonts= --themes= --locales= \
- --modules="${grub_modules}" \
- --install-modules="${grub_install_modules}" \
- ${gcfg} ${grubk}
+ --grub-mkimage="grub/grub-mkimage" \
+ -O i386-coreboot \
+ -o elf/grub/grub_${keymap}.elf \
+ -d grub/grub-core/ \
+ --fonts= --themes= --locales= \
+ --modules="${grub_modules}" \
+ --install-modules="${grub_install_modules}" \
+ ${gcfg} ${grubk}
}
create_grub_config()
{
- sed "s/usqwerty/${keymap}/" \
- < ${grubcfgsdir}/config/grub.cfg \
- > elf/grub/grub_${keymap}.cfg
- sed "s/grubtest.cfg/grub.cfg/" \
- < elf/grub/grub_${keymap}.cfg \
- > elf/grub/grub_${keymap}_test.cfg
+ sed "s/usqwerty/${keymap}/" < ${grubcfgsdir}/config/grub.cfg \
+ > elf/grub/grub_${keymap}.cfg
+ sed "s/grubtest.cfg/grub.cfg/" < elf/grub/grub_${keymap}.cfg \
+ > elf/grub/grub_${keymap}_test.cfg
}
main $@
diff --git a/resources/scripts/build/grub/utils b/resources/scripts/build/grub/utils
index edad6b2a..3e379472 100755
--- a/resources/scripts/build/grub/utils
+++ b/resources/scripts/build/grub/utils
@@ -25,11 +25,7 @@ set -u -e
main()
{
printf "Building GRUB\n"
-
- if [ ! -d "grub/" ]; then
- ./fetch grub || exit 1
- fi
-
+ [ -d "grub/" ] || ./fetch grub || exit 1
build_grub
}
@@ -37,15 +33,8 @@ build_grub()
{
(
cd grub/ || err "cd"
-
- # clean up first
- if [ -d Makefile ]; then
- make distclean || err "make-distclean"
- fi
-
+ [ ! -d Makefile ] || make distclean || err "make-distclean"
./bootstrap --gnulib-srcdir=gnulib/ --no-git || err "bootstrap"
-
- # build
./autogen.sh || err "autogen"
./configure --with-platform=coreboot || err "configure"
make -j$(nproc) || err "make"
diff --git a/resources/scripts/build/release/roms b/resources/scripts/build/release/roms
index b9d2487e..ca0e9fe7 100755
--- a/resources/scripts/build/release/roms
+++ b/resources/scripts/build/release/roms
@@ -70,26 +70,22 @@ make_archive()
target="${romdir##*/}"
echo ${target}
- if [ ! -d "${romdir}/" ]; then
- continue
- fi
+ [ -d "${romdir}/" ] || continue
CONFIG_HAVE_MRC="y"
CONFIG_HAVE_ME_BIN="y"
CONFIG_KBC1126_FIRMWARE="y"
CONFIG_INCLUDE_SMSC_SCH5545_EC_FW="y"
- grep "CONFIG_HAVE_ME_BIN=y" \
- "resources/coreboot/${target}/config/"* \
- || CONFIG_HAVE_ME_BIN="n"
- grep "CONFIG_HAVE_MRC=y" \
- "resources/coreboot/${target}/config/"* \
- || CONFIG_HAVE_MRC="n"
+ grep "CONFIG_HAVE_ME_BIN=y" "resources/coreboot/${target}/config/"* || \
+ CONFIG_HAVE_ME_BIN="n"
+ grep "CONFIG_HAVE_MRC=y" "resources/coreboot/${target}/config/"* || \
+ CONFIG_HAVE_MRC="n"
grep "CONFIG_KBC1126_FIRMWARE=y" \
- "resources/coreboot/${target}/config"/* \
- || CONFIG_KBC1126_FIRMWARE="n"
+ "resources/coreboot/${target}/config"/* || \
+ CONFIG_KBC1126_FIRMWARE="n"
grep "CONFIG_INCLUDE_SMSC_SCH5545_EC_FW=y" \
- "resources/coreboot/${target}/config"/* \
- || CONFIG_INCLUDE_SMSC_SCH5545_EC_FW="n"
+ "resources/coreboot/${target}/config"/* || \
+ CONFIG_INCLUDE_SMSC_SCH5545_EC_FW="n"
# remove ME/MRC/EC firmware from ROM images
if [ "${CONFIG_HAVE_ME_BIN}" = "y" ] \
@@ -107,8 +103,7 @@ make_archive()
f="release/${version}/roms/${projectname}-${version}_${target##*/}"
tar -c "${romdir}/" | xz -9e > "${f}.tar.xz"
- if [ -d "${romdir}_tmp" ]
- then
+ if [ -d "${romdir}_tmp" ]; then
rm -Rf "${romdir}"
mv "${romdir}_tmp" "${romdir}"
fi
@@ -118,9 +113,8 @@ strip_archive()
{
romdir=${1}
- if [ ! -d coreboot/${tree} ]; then
+ [ -d coreboot/${tree} ] || \
./fetch_trees coreboot ${tree} || exit 1
- fi
./build coreboot utils ${tree} || exit 1
rm -Rf "${romdir}_tmp" # dirty hack, to reduce disk io later
@@ -128,17 +122,15 @@ strip_archive()
mkdir "${romdir}_tmp"
# Hash the rom before removing blobs
- if [ ! -f "${romdir}/blobhashes" ]; then
+ [ -f "${romdir}/blobhashes" ] || \
printf "ROMs must match these hashes after blob insertion:" \
- > "${romdir}/blobhashes"
- fi
+ > "${romdir}/blobhashes"
(
cd ${romdir} || err "subshell: cd"
sha1sum *.rom >> blobhashes || err "subshell: sha1sum"
)
- for romfile in "${romdir}"/*.rom
- do
+ for romfile in "${romdir}"/*.rom; do
strip_rom_image "${romfile}"
done
}
@@ -147,9 +139,7 @@ strip_rom_image()
{
romfile=${1}
- if [ ! -f "${romfile}" ]; then
- continue
- fi
+ [ -f "${romfile}" ] || continue
if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then
${ifdtool} --nuke me "${romfile}" || exit 1
@@ -157,8 +147,7 @@ strip_rom_image()
mv "${romfile}.new" "${romfile}"
fi
- if [ "${CONFIG_HAVE_MRC}" = "y" ]
- then
+ if [ "${CONFIG_HAVE_MRC}" = "y" ]; then
${cbfstool} "${romfile}" remove -n mrc.bin || exit 1
${cbfstool} "${romfile}" print
fi
@@ -168,16 +157,12 @@ strip_rom_image()
${cbfstool} "${romfile}" remove -n ecfw2.bin || exit 1
fi
- if [ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" = "y" ]; then
+ [ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" != "y" ] || \
${cbfstool} "${romfile}" remove -n sch5545_ecfw.bin || exit 1
- fi
# TODO: replace this board-specific hack
- if [ "${target}" = "e6400nvidia_4mb" ]; then
- ${cbfstool} "${romfile}" remove \
- -n "pci10de,06eb.rom" \
- || exit 1
- fi
+ [ "${target}" != "e6400nvidia_4mb" ] || \
+ ${cbfstool} "${romfile}" remove -n "pci10de,06eb.rom" || exit 1
}
err()
diff --git a/resources/scripts/build/release/src b/resources/scripts/build/release/src
index 9e5e51d7..ba09a3d3 100755
--- a/resources/scripts/build/release/src
+++ b/resources/scripts/build/release/src
@@ -77,12 +77,10 @@ create_release_directory()
download_modules()
{
for modname in ${trees_fetch_list}; do
- [ ! -d "${modname}" ] && \
- ./fetch_trees ${modname}
+ [ ! -d "${modname}" ] && ./fetch_trees ${modname}
done
for modname in ${simple_fetch_list}; do
- [ ! -d "${modname}/" ] && \
- ./fetch ${modname}
+ [ ! -d "${modname}/" ] && ./fetch ${modname}
done
}
@@ -110,12 +108,10 @@ copy_blobs()
for i in t440p xx20 xx30 hp8200sff hp_ivybridge hp_sandybridge \
hp8300usdt t1650; do
for j in ifd gbe 4_ifd 8_ifd 12_ifd 16_ifd; do
- if [ -f "blobs/${i}/${j}.bin" ]; then
- if [ ! -e "${srcdir}/blobs/${i}" ]; then
- mkdir -p "${srcdir}/blobs/${i}"
- fi
- cp blobs/${i}/${j}.bin "${srcdir}/blobs/${i}"
- fi
+ [ -f "blobs/${i}/${j}.bin" ] || continue
+ [ -e "${srcdir}/blobs/${i}" ] || \
+ mkdir -p "${srcdir}/blobs/${i}"
+ cp blobs/${i}/${j}.bin "${srcdir}/blobs/${i}"
done
done
}
@@ -125,8 +121,7 @@ purge_files()
(
cd "${srcdir}/coreboot/" || err "cd1"
for i in *; do
- [ ! -d "${i}" ] && \
- continue
+ [ ! -d "${i}" ] && continue
(
cd "${i}/" || err "cd2"
make distclean || err "make-distclean1"
@@ -148,7 +143,7 @@ purge_files()
rm -Rf coreboot/coreboot/ || err "rm-rf1"
rm -Rf .git .gitignore */.git* coreboot/*/.git* \
- coreboot/*/3rdparty/*/.git* || err "rm-rf2"
+ coreboot/*/3rdparty/*/.git* || err "rm-rf2"
rm -Rf coreboot/*/util/nvidia/cbootimage/.git* || err "rm-rf3"
rm -Rf u-boot/u-boot/ u-boot/*/.git* || err "rm-rf4"
)
diff --git a/resources/scripts/build/src/for b/resources/scripts/build/src/for
index 1b7c7483..032895e2 100755
--- a/resources/scripts/build/src/for
+++ b/resources/scripts/build/src/for
@@ -44,8 +44,8 @@ main()
[ -z "${project}" ] && err "project name not specified"
[ "${project}" = "ich9utils" ] && project="util/ich9utils"
- [ -d "${project}" ] || ./fetch "${project}" \
- || err "Cannot download project, ${project}"
+ [ -d "${project}" ] || ./fetch "${project}" || \
+ err "Cannot download project, ${project}"
[ -d "${project}" ] || err "Project, ${project}, not downloaded"
if [ "${project}" = "uefitool" ]; then
diff --git a/resources/scripts/handle/config/file b/resources/scripts/handle/config/file
index 6c4bd86e..b8f9bea0 100755
--- a/resources/scripts/handle/config/file
+++ b/resources/scripts/handle/config/file
@@ -63,7 +63,7 @@ main()
project="${OPTARG}"
shift
done
- [ -z "${mode}" ] && err "mode not given (-m menuconfig or -u oldconfig)"
+ [ -z "${mode}" ] && err "mode not given (-m, -u or -b)"
elfdir="elf/${project}"
@@ -89,9 +89,8 @@ main()
target="${x}"
printf "Running 'make %s' for project '%s, target '%s''\n" \
"${mode}" "${project}" "${target}"
- if [ "${project}" = "coreboot" ] && [ "${mode}" = "all" ]; then
+ [ "${project}" != "coreboot" ] || [ "${mode}" != "all" ] || \
./update blobs download ${target} || err "blobutil"
- fi
handle_defconfig || exit 1
done
@@ -166,35 +165,29 @@ check_cross_compiler()
err "check_cross_compiler"
if [ "${arch}" = "x86_32" ] || [ "${arch}" = "x86_64" ]; then
- if [ ! -d "${cbdir}/util/crossgcc/xgcc/i386-elf/" ]; then
- # Even for 64-bit machines, coreboot builds 32-bit ROM
- # images, so we only need to worry about i386-elf
+ [ -d "${cbdir}/util/crossgcc/xgcc/i386-elf/" ] || \
make -C "${cbdir}" crossgcc-i386 CPUS=$(nproc) || \
return 1
- fi
case "$(uname -m)" in
x86*|i*86|amd64) : ;;
*) export CROSS_COMPILE=i386-elf- ;;
esac
elif [ "${arch}" = "ARMv7" ]; then
- if [ ! -d "${cbdir}/util/crossgcc/xgcc/arm-eabi/" ]; then
+ [ -d "${cbdir}/util/crossgcc/xgcc/arm-eabi/" ] || \
make -C "${cbdir}" crossgcc-arm CPUS=$(nproc) || \
return 1
- fi
case "$(uname -m)" in
arm|arm32|armv6*|armv7*) : ;;
*) export CROSS_COMPILE=arm-eabi- ;;
esac
elif [ "${arch}" = "AArch64" ]; then
- if [ ! -d "${cbdir}/util/crossgcc/xgcc/aarch64-elf/" ]; then
+ [ -d "${cbdir}/util/crossgcc/xgcc/aarch64-elf/" ] || \
make -C "${cbdir}" crossgcc-aarch64 CPUS=$(nproc) || \
return 1
- fi
# aarch64 also needs armv7 toolchain for arm-trusted-firmware
- if [ ! -d "${cbdir}/util/crossgcc/xgcc/arm-eabi/" ]; then
+ [ -d "${cbdir}/util/crossgcc/xgcc/arm-eabi/" ] || \
make -C "${cbdir}" crossgcc-arm CPUS=$(nproc) || \
return 1
- fi
case "$(uname -m)" in
arm64|aarch64) : ;;
*) export CROSS_COMPILE=aarch64-elf- ;;
diff --git a/resources/scripts/misc/versioncheck b/resources/scripts/misc/versioncheck
index 3118e297..01e69231 100755
--- a/resources/scripts/misc/versioncheck
+++ b/resources/scripts/misc/versioncheck
@@ -20,24 +20,20 @@
set -u -e
version="version-unknown"
-if [ -f version ]; then
- version="$(cat version)"
-fi
+[ -f version ] && version="$(cat version)"
version_="${version}"
if [ -e ".git" ]; then
- version="$(git describe --tags HEAD 2>&1)" \
- || version="git-$(git rev-parse HEAD 2>&1)" \
- || version="${version_}"
+ version="$(git describe --tags HEAD 2>&1)" || \
+ version="git-$(git rev-parse HEAD 2>&1)" || \
+ version="${version_}"
printf "%s\n" "${version}" > version
fi
versiondate="version-date-unknown"
-if [ -f versiondate ]; then
- versiondate="$(cat versiondate)"
-fi
+[ -f versiondate ] && versiondate="$(cat versiondate)"
versiondate_="${versiondate}"
if [ -e ".git" ]; then
- versiondate="$(git show --no-patch --no-notes --pretty='%ct' HEAD)" \
- || versiondate="${versiondate_}"
+ versiondate="$(git show --no-patch --no-notes --pretty='%ct' HEAD)" || \
+ versiondate="${versiondate_}"
printf "%s\n" "${versiondate}" > versiondate
fi
diff --git a/resources/scripts/update/blobs/download b/resources/scripts/update/blobs/download
index bac48786..cad40895 100755
--- a/resources/scripts/update/blobs/download
+++ b/resources/scripts/update/blobs/download
@@ -54,15 +54,13 @@ main()
boarddir="${cbcfgsdir}/${board}"
[ ! -d "${boarddir}" ] && \
- fail "Board target, ${board}, not defined"
+ fail "Board target, ${board}, not defined"
[ ! -f "${boarddir}/target.cfg" ] && \
- fail "Target missing target.cfg"
+ fail "Target missing target.cfg"
no_config="printf \"No config for target, %s\\n\" ${board} 1>&2; exit 0"
for x in "${boarddir}"/config/*; do
- if [ -f "${x}" ]; then
- no_config=""
- fi
+ [ -f "${x}" ] && no_config=""
done
eval "${no_config}"
@@ -79,34 +77,19 @@ detect_firmware()
. ${1} 2>/dev/null
. "${boarddir}/target.cfg"
- if [ "${CONFIG_HAVE_MRC}" = "y" ]; then
- needs="${needs} MRC"
- fi
- if [ "${CONFIG_HAVE_IFD_BIN}" = "y" ]; then
- needs="${needs} IFD"
- fi
- if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then
- needs="${needs} ME"
- fi
- if [ "${CONFIG_HAVE_GBE_BIN}" = "y" ]; then
- needs="${needs} GBE"
- fi
- if [ "${CONFIG_KBC1126_FIRMWARE}" = "y" ]; then
- needs="${needs} EC"
- fi
- if [ "${CONFIG_BOARD_DELL_E6400}" = "y" ] \
- && [ "${CONFIG_VGA_BIOS_FILE}" != "" ]; then
- needs="${needs} E6400VGA"
- fi
- if [ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" = "y" ]; then
- needs="${needs} SCH5545EC"
- fi
- if [ -z ${needs+x} ]; then
- printf 'No binary blobs needed for this board\n'
+ [ "${CONFIG_HAVE_MRC}" = "y" ] && needs="${needs} MRC"
+ [ "${CONFIG_HAVE_IFD_BIN}" = "y" ] && needs="${needs} IFD"
+ [ "${CONFIG_HAVE_ME_BIN}" = "y" ] && needs="${needs} ME"
+ [ "${CONFIG_HAVE_GBE_BIN}" = "y" ] && needs="${needs} GBE"
+ [ "${CONFIG_KBC1126_FIRMWARE}" = "y" ] && needs="${needs} EC"
+ [ "${CONFIG_BOARD_DELL_E6400}" = "y" ] && \
+ [ "${CONFIG_VGA_BIOS_FILE}" != "" ] && needs="${needs} E6400VGA"
+ [ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" = "y" ] && \
+ needs="${needs} SCH5545EC"
+ [ -z ${needs+x} ] && \
+ printf 'No binary blobs needed for this board\n' && \
return 1
- fi
- printf "Firmware needed for board '%s':\n" ${board}
- printf "%s\n" ${needs}
+ printf "Firmware needed for board '%s':\n%s\n" ${board} ${needs}
}
scan_sources_config()
@@ -120,60 +103,46 @@ scan_sources_config()
case ${line} in
EC_url_bkup*)
set ${line}
- ec_url_bkup=${2}
- ;;
+ ec_url_bkup=${2} ;;
EC_url*)
set ${line}
- ec_url=${2}
- ;;
+ ec_url=${2} ;;
EC_hash*)
set ${line}
- ec_hash=${2}
- ;;
+ ec_hash=${2} ;;
DL_hash*)
set ${line}
- dl_hash=${2}
- ;;
+ dl_hash=${2} ;;
DL_url_bkup*)
set ${line}
- dl_url_bkup=${2}
- ;;
+ dl_url_bkup=${2} ;;
DL_url*)
set ${line}
- dl_url=${2}
- ;;
+ dl_url=${2} ;;
E6400_VGA_DL_hash*)
set ${line}
- e6400_vga_dl_hash=${2}
- ;;
+ e6400_vga_dl_hash=${2} ;;
E6400_VGA_DL_url_bkup*)
set ${line}
- e6400_vga_dl_url_bkup=${2}
- ;;
+ e6400_vga_dl_url_bkup=${2} ;;
E6400_VGA_DL_url*)
set ${line}
- e6400_vga_dl_url=${2}
- ;;
+ e6400_vga_dl_url=${2} ;;
E6400_VGA_offset*)
set ${line}
- e6400_vga_offset=${2}
- ;;
+ e6400_vga_offset=${2} ;;
E6400_VGA_romname*)
set ${line}
- e6400_vga_romname=${2}
- ;;
+ e6400_vga_romname=${2} ;;
SCH5545EC_DL_hash*)
set ${line}
- sch5545ec_dl_hash=${2}
- ;;
+ sch5545ec_dl_hash=${2} ;;
SCH5545EC_DL_url_bkup*)
set ${line}
- sch5545ec_dl_url_bkup=${2}
- ;;
+ sch5545ec_dl_url_bkup=${2} ;;
SCH5545EC_DL_url*)
set ${line}
- sch5545ec_dl_url=${2}
- ;;
+ sch5545ec_dl_url=${2} ;;
esac
done << EOF
$(eval "awk '${awkstr}' resources/blobs/sources")
@@ -182,44 +151,18 @@ EOF
build_dependencies()
{
- if [ ! -d me_cleaner ]; then
- printf "downloading me_cleaner\n"
- ./fetch me_cleaner || fail "could not download me_cleaner"
- fi
- if [ ! -d ${cbdir} ]; then
- printf "downloading coreboot\n"
- ./fetch_trees coreboot default \
- || fail "could not download coreboot"
- fi
- if [ ! -d bios_extract ]; then
- printf "downloading bios_extract\n"
- ./fetch bios_extract \
- || fail "could not download bios_extract"
- fi
- if [ ! -d biosutilities ]; then
- printf "downloading biosutilities\n"
- ./fetch biosutilities \
- || fail "could not download biosutilities"
- fi
- if [ ! -d uefitool ]; then
- printf "download uefitool (for UEFIExtract)\n"
- ./fetch uefitool \
- || fail "could not download uefitool"
- fi
- if [ ! -f uefitool/uefiextract ]; then
- ./build src for -b uefitool \
- || fail "could not build uefitool"
- fi
- if [ ! -f ${cbdir}/util/kbc1126/kbc1126_ec_dump ]; then
- printf "Building kbc1126_ec_dump from coreboot\n"
- make -BC ${cbdir}/util/kbc1126 \
- || fail "could not build kbc1126_ec_dump"
- fi
- if [ ! -f "${cbdir}/util/ifdtool/ifdtool" ]; then
- printf "building ifdtool from coreboot\n"
- make -C ${cbdir}/util/ifdtool \
- || fail 'could not build ifdtool'
- fi
+ [ -d ${cbdir} ] || \
+ ./fetch_trees coreboot ${cbdir##*/} || \
+ fail "can't download to ${cbdir}"
+ for d in uefitool biosutilities bios_extract me_cleaner; do
+ [ -d "${d}" ] && continue
+ ./fetch ${d} || fail "can't download ${d}"
+ done
+ [ -f uefitool/uefiextract ] || \
+ ./build src for -b uefitool || fail "can't build uefitool"
+ [ -f ${cbdir}/util/kbc1126/kbc1126_ec_dump ] || \
+ make -BC ${cbdir}/util/kbc1126 || \
+ fail "can't build kbc1126_ec_dump"
}
download_blobs()
@@ -227,26 +170,20 @@ download_blobs()
for need in ${needs}; do
case ${need} in
*ME*)
- download_blob_intel_me || _failed="${_failed} me"
- ;;
+ download_blob_intel_me || _failed="${_failed} me" ;;
*SCH5545EC*)
- download_sch5545ec || failed="${_failed} sch5545ec"
- ;;
+ download_sch5545ec || failed="${_failed} sch5545ec" ;;
*EC*)
- download_ec || _failed="${_failed} ec"
- ;;
+ download_ec || _failed="${_failed} ec" ;;
*E6400VGA*)
- download_e6400vga || _failed="${_failed} e6400vga"
- ;;
+ download_e6400vga || _failed="${_failed} e6400vga" ;;
*MRC*)
- ./update blobs mrc || _failed="${_failed} mrc"
- ;;
+ ./update blobs mrc || _failed="${_failed} mrc" ;;
esac
done
- if [ ! -z ${_failed+x} ]; then
+ [ -z ${_failed+x} ] || \
fail "failed to obtain ${_failed}\nTry manual extraction?"
- fi
}
download_blob_intel_me()
@@ -263,12 +200,10 @@ extract_blob_intel_me()
_me_destination=${CONFIG_ME_BIN_PATH#../../}
- if [ ! -d "${_me_destination%/*}" ]; then
+ [ -d "${_me_destination%/*}" ] || \
mkdir -p ${_me_destination%/*}
- fi
- if [ -d "${appdir}" ]; then
- rm -r ${appdir}
- fi
+ [ -d "${appdir}" ] && \
+ rm -Rf ${appdir}
if [ -f "${_me_destination}" ]; then
printf 'me already downloaded\n'
return 0
@@ -276,14 +211,13 @@ extract_blob_intel_me()
printf "Extracting and stripping Intel ME firmware\n"
- innoextract ${dl_path} -d ${appdir} \
- || 7z x ${dl_path} -o${appdir} \
- || unar "${dl_path}" -o "${appdir}" \
- || fail 'Could not extract vendor update'
+ innoextract ${dl_path} -d ${appdir} || \
+ 7z x ${dl_path} -o${appdir} || \
+ unar "${dl_path}" -o "${appdir}" || \
+ fail "Could not extract vendor update"
bruteforce_extract_blob_intel_me "$(pwd)/${_me_destination}" \
- "$(pwd)/${appdir}" \
- || fail "Could not extract Intel ME firmware"
+ "$(pwd)/${appdir}" || fail "Could not extract Intel ME firmware"
printf "Truncated and cleaned me output to ${_me_destination}\n"
}
@@ -294,9 +228,7 @@ bruteforce_extract_blob_intel_me()
_me_destination="${1}"
cdir="${2}" # must be an absolute path, not relative
- if [ -f "${_me_destination}" ]; then
- return 0
- fi
+ [ -f "${_me_destination}" ] && return 0
sdir="$(mktemp -d)"
mkdir -p "${sdir}" || return 1
@@ -321,9 +253,9 @@ bruteforce_extract_blob_intel_me()
&& break # (we found me.bin)
_7ztest="${_7ztest}a"
7z x "${i}" -o${_7ztest} \
- || innoextract "${i}" -d "${_7ztest}" \
- || unar "${i}" -o "${_7ztest}" \
- || continue
+ || innoextract "${i}" -d "${_7ztest}" \
+ || unar "${i}" -o "${_7ztest}" \
+ || continue
bruteforce_extract_blob_intel_me "${_me_destination}" \
"${cdir}/${_7ztest}"
elif [ -d "$i" ]; then
@@ -351,21 +283,19 @@ download_ec()
printf "Downloading KBC1126 EC firmware for HP laptop\n"
fetch_update ec || return 1
- extract_ec || return 1
+ extract_blob_kbc1126_ec || return 1
}
-extract_ec()
+extract_blob_kbc1126_ec()
{
printf "Extracting KBC1126 EC firmware for board: %s\n" ${board}
_ec_destination=${CONFIG_KBC1126_FW1#../../}
- if [ ! -d "${_ec_destination%/*}" ]; then
+ [ -d "${_ec_destination%/*}" ] || \
mkdir -p "${_ec_destination%/*}"
- fi
- if [ -d "${appdir}" ]; then
+ [ -d "${appdir}" ] && \
rm -Rf "${appdir}"
- fi
if [ -f "${_ec_destination}" ]; then
printf "ec already downloaded\n"
return 0
@@ -383,23 +313,15 @@ extract_ec()
unar -D 68*.CAB Rom.bin
mv Rom.bin ec.bin
fi
- if [ ! -f ec.bin ]; then
- printf "could not extract ec.bin for board '%s'" ${board} \
- 1>&2
- fail "aborting the build. please audit lbmk carefully."
- fi
+ [ -f ec.bin ] || fail "could not extract ec.bin for board, ${board}"
"${kbc1126_ec_dump}" ec.bin
)
for i in 1 2; do
- if [ -f "${appdir}/${dl_path##*/}/ec.bin.fw${i}" ]; then
- continue
- fi
- printf "Not found: %s/%s/ec.bin.fw%s\n" \
- ${appdir} ${dl_path##*/} ${i}
+ [ -f "${appdir}/${dl_path##*/}/ec.bin.fw${i}" ] && continue
printf "Could not extract EC firmware for: %s\n" \
- ${board}
+ ${board}
return 1
done
@@ -424,12 +346,10 @@ extract_e6400vga()
printf 'vga rom already downloaded\n'
return 0
fi
- if [ ! -d "${_vga_destination%/*}" ]; then
+ [ -d "${_vga_destination%/*}" ] || \
mkdir -p ${_vga_destination%/*}
- fi
- if [ -d "${appdir}" ]; then
- rm -r ${appdir}
- fi
+ [ -d "${appdir}" ] && \
+ rm -Rf ${appdir}
mkdir -p "${appdir}"
mv "${dl_path}" "${appdir}"
@@ -446,13 +366,11 @@ extract_e6400vga()
cd "${appdir}"
tail -c +${e6400_vga_offset} "${dl_path##*/}" \
| gunzip > bios.bin
- if [ ! -f "bios.bin" ]; then
- fail 'Could not extract bios.bin from Dell E6400 update'
- fi
+ [ -f "bios.bin" ] || \
+ fail "Could not extract bios.bin from Dell E6400 update"
"${e6400_unpack}" bios.bin || printf "TODO: fix dell extract util\n"
- if [ ! -f "${e6400_vga_romname}" ]; then
- fail 'Could not extract VGA ROM from Dell E6400 BIOS update'
- fi
+ [ -f "${e6400_vga_romname}" ] || \
+ fail "Could not extract VGA ROM from Dell E6400 BIOS update"
)
cp "${appdir}"/"${e6400_vga_romname}" "${_vga_destination}"
@@ -482,11 +400,9 @@ extract_sch5545ec()
return 0
fi
- if [ -d "${appdir}" ]; then
- rm -Rf "${appdir}"
- fi
- mkdir -p "${appdir}/"
+ [ -d "${appdir}" ] rm -Rf "${appdir}"
+ mkdir -p "${appdir}/"
cp "${dl_path}" "${appdir}/"
python "${pfs_extract}" "${appdir}/${dlsum}" -e || exit 1
@@ -545,9 +461,7 @@ fetch_update()
dl_fail="y"
vendor_checksum ${dlsum} && dl_fail="n"
for x in "${dl}" "${dl_bkup}"; do
- if [ "${dl_fail}" = "n" ]; then
- break
- fi
+ [ "${dl_fail}" = "n" ] && break
rm -f "${dl_path}"
wget -U "${agent}" ${x} -O ${dl_path}
vendor_checksum ${dlsum} && dl_fail="n"
diff --git a/resources/scripts/update/blobs/extract b/resources/scripts/update/blobs/extract
index ad11afb4..6b18e962 100755
--- a/resources/scripts/update/blobs/extract
+++ b/resources/scripts/update/blobs/extract
@@ -29,13 +29,10 @@ _ifd_destination=""
main()
{
sname=${0}
- if [ $# -lt 2 ]; then
- fail "Missing arguments (less than two)."
- fi
+ [ $# -lt 2 ] && fail "Missing arguments (fewer than two)."
board="${1}"
vendor_rom="${2}"
-
boarddir="${cbcfgsdir}/${board}"
check_board
@@ -45,39 +42,22 @@ main()
check_board()
{
- if [ ! -f "${vendor_rom}" ] ; then
+ [ -f "${vendor_rom}" ] || \
fail "file does not exist: ${vendor_rom}"
- elif [ ! -d "${boarddir}" ]; then
+ [ -d "${boarddir}" ] || \
fail "build/roms ${board}: target not defined"
- elif [ ! -f "${boarddir}/target.cfg" ]; then
+ [ -f "${boarddir}/target.cfg" ] || \
fail "build/roms ${board}: missing target.cfg"
- fi
}
build_dependencies()
{
- if [ ! -d me_cleaner ]; then
- printf "downloading me_cleaner\n"
- ./fetch me_cleaner || fail 'could not download me_cleaner'
- else
- printf "me_cleaner already downloaded. Skipping.\n"
- printf "run ./fetch me_cleaner to manually overwrite\n"
- fi
-
- if [ ! -d ${cbdir} ]; then
- printf "downloading coreboot\n"
- ./fetch_trees coreboot default \
- || fail "could not download coreboot"
- else
- printf "coreboot already downloaded. Skipping.\n"
- printf "run ./fetch_trees coreboot to manually overwrite\n"
- fi
-
- if ! [ -f ${ifdtool} ]; then
- printf "building ifdtool from coreboot\n"
- make -C "${ifdtool%/ifdtool}" \
- || fail "could not build ifdtool"
- fi
+ [ -d me_cleaner ] || \
+ ./fetch me_cleaner || fail "can't fetch me_cleaner"
+ [ -d ${cbdir} ] || \
+ ./fetch_trees coreboot default || fail "can't fetch coreboot"
+ [ -f ${ifdtool} ] || \
+ make -C "${ifdtool%/ifdtool}" || fail "can't build ifdtool"
}
extract_blobs()
@@ -88,10 +68,8 @@ extract_blobs()
. ${1} 2>/dev/null
. "${boarddir}/target.cfg"
- if [ "$CONFIG_HAVE_MRC" = "y" ]; then
- printf 'haswell board detected, downloading mrc\n'
+ [ "$CONFIG_HAVE_MRC" != "y" ] || \
./update blobs mrc || fail "could not download mrc"
- fi
_me_destination=${CONFIG_ME_BIN_PATH#../../}
_gbe_destination=${CONFIG_GBE_BIN_PATH#../../}
@@ -103,13 +81,9 @@ extract_blobs()
# Cleans up other files extracted with ifdtool
rm -f flashregion*.bin 2> /dev/null
- if [ -f ${_ifd_destination} ]; then
- printf "gbe, ifd, and me extracted to %s\n" \
- ${_me_destination%/*}
- else
- printf "WARNING: Intel firmware descriptor could not "
- printf "be extracted with modified me\n"
- fi
+ [ -f ${_ifd_destination} ] || fail "Could not extract IFD"
+ printf "gbe, ifd, and me extracted to %s\n" \
+ ${_me_destination%/*}
}
extract_blob_intel_me()
@@ -117,25 +91,23 @@ extract_blob_intel_me()
printf "extracting clean ime and modified ifd\n"
${mecleaner} -D ${_ifd_destination} \
- -M ${_me_destination} ${vendor_rom} -t -r -S \
- || ${me7updateparser} \
- -O ${_me_destination} ${vendor_rom} \
- || fail \
- "me_cleaner failed to extract blobs from rom"
+ -M ${_me_destination} ${vendor_rom} -t -r -S || \
+ ${me7updateparser} \
+ -O ${_me_destination} ${vendor_rom} || \
+ fail "me_cleaner failed to extract blobs from rom"
}
extract_blob_intel_gbe_nvm()
{
printf "extracting gigabit ethernet firmware"
./${ifdtool} -x ${vendor_rom}
- mv flashregion*gbe.bin ${_gbe_destination} \
- || fail 'could not extract gbe'
+ mv flashregion*gbe.bin ${_gbe_destination} || \
+ fail 'could not extract gbe'
}
fail()
{
print_help
-
printf "\n%s: ERROR: %s\n" ${sname} $@
exit 1
}
diff --git a/resources/scripts/update/blobs/inject b/resources/scripts/update/blobs/inject
index 649b865d..696cd74d 100755
--- a/resources/scripts/update/blobs/inject
+++ b/resources/scripts/update/blobs/inject
@@ -41,12 +41,8 @@ main()
{
sname="${0}"
- if [ $# -lt 1 ]; then
- fail "No options specified."
- elif [ "${1}" = "listboards" ]; then
- listboards
- exit 0
- fi
+ [ $# -lt 1 ] && fail "No options specified."
+ [ "${1}" = "listboards" ] && listboards && exit 0
archive="${1}"
@@ -54,15 +50,12 @@ main()
do
case "${option}" in
r)
- rom=${OPTARG}
- ;;
+ rom=${OPTARG} ;;
b)
- board=${OPTARG}
- ;;
+ board=${OPTARG} ;;
m)
modifygbe=true
- new_mac=${OPTARG}
- ;;
+ new_mac=${OPTARG} ;;
esac
done
@@ -78,39 +71,29 @@ main()
check_board()
{
if ! check_release ${archive} ; then
- if [ ! -f "${rom}" ]; then
+ [ -f "${rom}" ] || \
fail "${rom} is not a valid path"
- elif [ -z ${rom+x} ]; then
+ [ -z ${rom+x} ] && \
fail 'no rom specified'
- elif [ -z ${board+x} ]; then
- board=$(detect_board ${rom}) \
- || fail 'no board specified'
- fi
+ [ ! -z ${board+x} ] || \
+ board=$(detect_board ${rom}) || \
+ fail 'no board specified'
else
release=true
releasearchive="${archive}"
- board=$(detect_board ${archive}) \
- || fail 'Could not detect board type'
+ board=$(detect_board ${archive}) || \
+ fail 'Could not detect board type'
fi
boarddir="${cbcfgsdir}/${board}"
- if [ ! -d "${boarddir}" ]; then
- fail "board ${board} not found"
- fi
+ [ -d "${boarddir}" ] || fail "board ${board} not found"
}
check_release()
{
- if [ ! -f "${archive}" ]; then
- return 1
- fi
-
- if [ "${archive##*.}" = "xz" ]; then
- printf "%s\n" "Release archive ${archive} detected"
- return 0
- else
- return 1
- fi
+ [ -f "${archive}" ] || return 1
+ [ "${archive##*.}" = "xz" ] || return 1
+ printf "%s\n" "Release archive ${archive} detected"
}
# This function tries to determine the board from the filename of the rom.
@@ -121,38 +104,25 @@ detect_board()
filename=$(basename ${path})
case ${filename} in
grub_*)
- board=$(echo "${filename}" | cut -d '_' -f2-3)
- ;;
+ board=$(echo "${filename}" | cut -d '_' -f2-3) ;;
seabios_withgrub_*)
- board=$(echo "${filename}" | cut -d '_' -f3-4)
- ;;
+ board=$(echo "${filename}" | cut -d '_' -f3-4) ;;
*.tar.xz)
_stripped_prefix=${filename#*_}
- board="${_stripped_prefix%.tar.xz}"
- ;;
+ board="${_stripped_prefix%.tar.xz}" ;;
*)
return 1
esac
-
- if [ -d "${boarddir}/" ]; then
- printf '%s\n' "${board}"
- return 0
- else
- return 1
- fi
+ [ -d "${boarddir}/" ] || return 1
+ printf '%s\n' "${board}"
}
build_dependencies()
{
- if [ ! -d ${cbdir} ]; then
- printf "downloading coreboot\n"
- ./fetch_trees coreboot default
- fi
-
+ [ -d "${cbdir}" ] || ./fetch_trees coreboot default
./build coreboot utils default || fail "could not build cbutils"
-
./update blobs download ${board} || \
- fail "Could not download blobs for ${board}"
+ fail "Could not download blobs for ${board}"
}
inject_blobs()
@@ -188,12 +158,9 @@ patch_release_roms()
done
fi
- if ! [ -d bin/release ]; then
- mkdir -p bin/release
- fi
-
+ [ -d bin/release ] || mkdir -p bin/release
mv ${_tmpdir}/bin/* bin/release/ && \
- printf '%s\n' 'Success! Your ROMs are in bin/release'
+ printf '%s\n' 'Success! Your ROMs are in bin/release'
rm -r "${_tmpdir}"
}
@@ -206,31 +173,20 @@ patch_rom()
. ${1} 2>/dev/null
. "${boarddir}/target.cfg"
- if [ "$CONFIG_HAVE_MRC" = "y" ]; then
+ [ "$CONFIG_HAVE_MRC" = "y" ] && \
inject_blob_intel_mrc "${rom}"
- fi
-
- if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then
+ [ "${CONFIG_HAVE_ME_BIN}" = "y" ] && \
inject_blob_intel_me "${rom}"
- fi
-
- if [ "${CONFIG_KBC1126_FIRMWARE}" = "y" ]; then
+ [ "${CONFIG_KBC1126_FIRMWARE}" = "y" ] && \
inject_blob_hp_kbc1126_ec "${rom}"
- fi
-
- if [ "${CONFIG_VGA_BIOS_FILE}" != "" ] \
- && [ "${CONFIG_VGA_BIOS_ID}" != "" ]; then
+ [ "${CONFIG_VGA_BIOS_FILE}" != "" ] && \
+ [ "${CONFIG_VGA_BIOS_ID}" != "" ] && \
inject_blob_dell_e6400_vgarom_nvidia
- fi
-
- if [ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" = "y" ] \
- && [ "${CONFIG_SMSC_SCH5545_EC_FW_FILE}" != "" ]; then
+ [ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" = "y" ] && \
+ [ "${CONFIG_SMSC_SCH5545_EC_FW_FILE}" != "" ] && \
inject_blob_smsc_sch5545_ec "${rom}"
- fi
-
- if [ "${modifygbe}" = "true" ] && ! [ "${release}" = "true" ]; then
+ [ "${modifygbe}" = "true" ] && ! [ "${release}" = "true" ] && \
modify_gbe ${rom}
- fi
}
inject_blob_intel_mrc()
@@ -266,16 +222,12 @@ inject_blob_intel_me()
printf 'adding intel management engine\n'
rom="${1}"
-
- if [ -z ${CONFIG_ME_BIN_PATH} ]; then
+ [ -z ${CONFIG_ME_BIN_PATH} ] && \
fail "CONFIG_ME_BIN_PATH not set"
- fi
_me_location=${CONFIG_ME_BIN_PATH#../../}
-
- if [ ! -f "${_me_location}" ]; then
+ [ ! -f "${_me_location}" ] && \
fail "CONFIG_ME_BIN_PATH points to missing file"
- fi
${ifdtool} -i me:${_me_location} ${rom} -O ${rom} || exit 1
}
@@ -293,23 +245,23 @@ inject_blob_hp_kbc1126_ec()
if [ "${_ec1_offset}" = "" ] || [ "${_ec1_offset}" = "" ]; then
printf "EC offsets not declared for board: %s\n" \
- "${board}"
+ "${board}"
exit 1
fi
if [ "${_ec1_location}" = "" ] || [ "${_ec2_location}" = "" ]; then
printf "EC firmware path not declared for board: %s\n" \
- "${board}"
+ "${board}"
fi
if [ ! -f "${_ec1_location}" ] || [ ! -f "${_ec2_location}" ]; then
printf "EC firmware not downloaded for board: %s\n" \
- "${board}"
+ "${board}"
exit 1
fi
${cbfstool} "${rom}" add -f ${_ec1_location} -n ecfw1.bin \
- -b ${_ec1_offset} -t raw || exit 1
+ -b ${_ec1_offset} -t raw || exit 1
${cbfstool} "${rom}" add -f ${_ec2_location} -n ecfw2.bin \
- -b ${_ec2_offset} -t raw || exit 1
+ -b ${_ec2_offset} -t raw || exit 1
}
inject_blob_dell_e6400_vgarom_nvidia()
@@ -332,8 +284,8 @@ inject_blob_dell_e6400_vgarom_nvidia()
fi
${cbfstool} ${rom} add -f "${_vga_location}" \
- -n "pci${CONFIG_VGA_BIOS_ID}.rom" \
- -t optionrom || exit 1
+ -n "pci${CONFIG_VGA_BIOS_ID}.rom" \
+ -t optionrom || exit 1
}
inject_blob_smsc_sch5545_ec()
@@ -357,27 +309,22 @@ modify_gbe()
rom=${1}
- if [ -z ${CONFIG_GBE_BIN_PATH} ]; then
+ [ -z ${CONFIG_GBE_BIN_PATH} ] && \
fail "CONFIG_GBE_BIN_PATH not set"
- fi
_gbe_location=${CONFIG_GBE_BIN_PATH#../../}
- if [ ! -f "${_gbe_location}" ]; then
+ [ -f "${_gbe_location}" ] || \
fail "CONFIG_GBE_BIN_PATH points to missing file"
- fi
-
- if [ ! -f ${nvmutil} ]; then
+ [ -f ${nvmutil} ] || \
make -C util/nvmutil || fail 'failed to build nvmutil'
- fi
_gbe_tmp=$(mktemp -t gbeXXXX.bin)
cp ${_gbe_location} ${_gbe_tmp}
- ${nvmutil} "${_gbe_tmp}" setmac ${new_mac} \
- || fail 'failed to modify mac address'
+ ${nvmutil} "${_gbe_tmp}" setmac ${new_mac} || \
+ fail 'failed to modify mac address'
- ${ifdtool} -i GbE:${_gbe_tmp} "${rom}" \
- -O "${rom}" || exit 1
+ ${ifdtool} -i GbE:${_gbe_tmp} "${rom}" -O "${rom}" || exit 1
rm -f ${_gbe_tmp}
}
@@ -385,7 +332,7 @@ modify_gbe()
listboards()
{
for boarddir in ${cbcfgsdir}/*; do
- if [ ! -d "${boarddir}" ]; then continue; fi
+ [ -d "${boarddir}" ] || continue
board="${boarddir##${cbcfgsdir}/}"
board="${board%/}"
printf '%s\n' "${board##*/}"
@@ -394,10 +341,8 @@ listboards()
fail()
{
- if [ ! -z ${@+x} ]; then
+ [ -z ${@+x} ] || \
printf "\n%s: ERROR: ${@}\n" ${sname}
- fi
-
usage
exit 1
}
diff --git a/resources/scripts/update/blobs/mrc b/resources/scripts/update/blobs/mrc
index 8213e6c1..14a1d2b6 100755
--- a/resources/scripts/update/blobs/mrc
+++ b/resources/scripts/update/blobs/mrc
@@ -57,25 +57,19 @@ main()
check_existing()
{
- if [ ! -f ${_mrc_complete} ]; then
+ [ -f ${_mrc_complete} ] || \
return 1
- fi
- printf 'found existing mrc.bin, checking its hash\n'
- if [ "$(sha1sum ${_mrc_complete} | awk '{print $1}')" \
- = "${_mrc_complete_hash}" ]; then
- printf 'checksums matched, skipping downloading\n'
+ printf 'found existing mrc.bin\n'
+ [ "$(sha1sum ${_mrc_complete} | awk '{print $1}')" \
+ = "${_mrc_complete_hash}" ] && \
return 0
- else
- printf 'hashes did not match, starting over\n'
- return 1
- fi
+ printf 'hashes did not match, starting over\n'
+ return 1
}
build_dependencies()
{
- if [ ! -d "${cbdir}/" ]; then
- ./fetch_trees coreboot default || return 1
- fi
+ [ -d "${cbdir}/" ] || ./fetch_trees coreboot default || return 1
./build coreboot utils default || return 1
return 0
}
@@ -88,23 +82,20 @@ fetch_mrc()
cd mrc/haswell/
download_image ${_url} ${_file} ${_sha1sum}
- if [ ! -f ${_file} ]; then
+ [ -f ${_file} ] || \
download_image ${_url2} ${_file} ${_sha1sum}
- fi
- if [ ! -f $_file ]; then
+ [ -f $_file ] || \
fail "%{_file} not downloaded / verification failed."
- fi
extract_partition ROOT-A ${_file} root-a.ext2
extract_shellball root-a.ext2 chromeos-firmwareupdate-${_board}
extract_coreboot chromeos-firmwareupdate-${_board}
- ../../${cbfstool} coreboot-*.bin extract -f mrc.bin \
- -n mrc.bin -r RO_SECTION \
- || fail "Could not fetch mrc.bin"
+ ../../${cbfstool} coreboot-*.bin extract -f mrc.bin -n mrc.bin \
+ -r RO_SECTION || fail "Could not fetch mrc.bin"
rm -f "chromeos-firmwareupdate-${_board}" coreboot-*.bin \
- "${_file}" "root-a.ext2"
+ "${_file}" "root-a.ext2"
printf "\n\nmrc.bin saved to ${_mrc_complete}\n\n"
)
@@ -118,19 +109,18 @@ download_image()
_file=${2}
_sha1sum=${3}
- echo "Downloading recovery image"
+ printf "Downloading recovery image\n"
curl "$url" > "$_file.zip"
+ printf "Verifying recovery image checksum\n"
if [ "$(sha1sum ${_file}.zip | awk '{print $1}')" = "${_sha1sum}" ]
then
unzip -q "${_file}.zip"
rm "${_file}.zip"
- echo "Checksum verification passed for recovery image."
return 0
- else
- rm "${_file}.zip"
- echo "Bad checksum. Recovery image deleted."
- return 1
fi
+ rm "${_file}.zip"
+ printf "Bad checksum. Recovery image deleted.\n"
+ return 1
}
extract_partition()
@@ -140,15 +130,15 @@ extract_partition()
ROOTFS=${3}
_bs=1024
- echo "Extracting ROOT-A partition"
+ printf "Extracting ROOT-A partition\n"
ROOTP=$( printf "unit\nB\nprint\nquit\n" | \
- parted ${FILE} 2>/dev/null | grep ${NAME} )
+ parted ${FILE} 2>/dev/null | grep ${NAME} )
START=$(( $( echo ${ROOTP} | cut -f2 -d\ | tr -d "B" ) ))
SIZE=$(( $( echo ${ROOTP} | cut -f4 -d\ | tr -d "B" ) ))
dd if=${FILE} of=${ROOTFS} bs=${_bs} skip=$(( ${START} / ${_bs} )) \
- count=$(( ${SIZE} / ${_bs} )) > /dev/null
+ count=$(( ${SIZE} / ${_bs} )) > /dev/null
}
extract_shellball()
@@ -156,9 +146,9 @@ extract_shellball()
ROOTFS=${1}
SHELLBALL=${2}
- echo "Extracting chromeos-firmwareupdate"
+ printf "Extracting chromeos-firmwareupdate\n"
printf "cd /usr/sbin\ndump chromeos-firmwareupdate ${SHELLBALL}\nquit" \
- | debugfs ${ROOTFS} > /dev/null 2>&1
+ | debugfs ${ROOTFS} > /dev/null 2>&1
}
extract_coreboot()
@@ -166,11 +156,11 @@ extract_coreboot()
_shellball=${1}
_unpacked=$( mktemp -d )
- echo "Extracting coreboot image"
+ printf "Extracting coreboot image\n"
sh ${_shellball} --unpack ${_unpacked} > /dev/null
_version=$( cat ${_unpacked}/VERSION | grep BIOS\ version: | \
- cut -f2 -d: | tr -d \ )
+ cut -f2 -d: | tr -d \ )
cp ${_unpacked}/bios.bin coreboot-${_version}.bin
rm -r "${_unpacked}"