summaryrefslogtreecommitdiff
path: root/resources/scripts/update
diff options
context:
space:
mode:
Diffstat (limited to 'resources/scripts/update')
-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
4 files changed, 170 insertions, 349 deletions
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}"