scripts: put quotes around file/directory names

Signed-off-by: Leah Rowe <leah@libreboot.org>
btrfsvols
Leah Rowe 2023-08-27 09:25:50 +01:00
parent 1c8401be25
commit 5a47c01b11
11 changed files with 102 additions and 101 deletions

10
fetch
View File

@ -35,7 +35,7 @@ main()
[ "${depend}" = "" ] || ./fetch ${depend} || \ [ "${depend}" = "" ] || ./fetch ${depend} || \
fail "Cannot fetch dependency, ${depend}, for project, ${name}" fail "Cannot fetch dependency, ${depend}, for project, ${name}"
rm -Rf ${tmp_dir} || fail "cannot remove tmpdir, ${tmp_dir}" rm -Rf "${tmp_dir}" || fail "cannot remove tmpdir, ${tmp_dir}"
} }
read_config() read_config()
@ -71,17 +71,17 @@ clone_project()
{ {
tmp_dir=$(mktemp -dt "${name}_XXXXX") tmp_dir=$(mktemp -dt "${name}_XXXXX")
git clone ${url} ${tmp_dir} || git clone ${bkup_url} ${tmp_dir} || \ git clone ${url} "${tmp_dir}" || git clone ${bkup_url} "${tmp_dir}" || \
fail "clone_project: could not download ${name}" fail "clone_project: could not download ${name}"
( (
cd ${tmp_dir} || fail "clone_project: tmpdir not created" cd "${tmp_dir}" || fail "clone_project: tmpdir not created"
git reset --hard ${revision} || \ git reset --hard ${revision} || \
fail "clone_project: Cannot reset revision" fail "clone_project: Cannot reset revision"
) )
patch_project patch_project
[ ! -d "${location}" ] || \ [ ! -d "${location}" ] || \
rm -Rf ${location} || \ rm -Rf "${location}" || \
fail "clone_project: Can't remove directory '${location}'" fail "clone_project: Can't remove directory '${location}'"
mv "${tmp_dir}" "${location}" || \ mv "${tmp_dir}" "${location}" || \
fail "clone_project: could not copy temp file to destination" fail "clone_project: could not copy temp file to destination"
@ -91,7 +91,7 @@ patch_project()
{ {
patchdir="resources/${name}/patches" patchdir="resources/${name}/patches"
for patchfile in ${PWD}/${patchdir}/*.patch ; do for patchfile in "${PWD}/${patchdir}"/*.patch ; do
[ -f "${patchfile}" ] || continue [ -f "${patchfile}" ] || continue
( (
cd "${tmp_dir}" || fail "patch_project: tmpdir unavailable" cd "${tmp_dir}" || fail "patch_project: tmpdir unavailable"

View File

@ -40,7 +40,7 @@ main()
err "running lbmk as root as not permitted" err "running lbmk as root as not permitted"
fi fi
rm -f ${cfgsdir}/*/seen || err_rm_seen "main 1" rm -f "${cfgsdir}"/*/seen || err_rm_seen "main 1"
printf "Downloading %s and (if available) applying patches\n" \ printf "Downloading %s and (if available) applying patches\n" \
${project} ${project}
@ -68,7 +68,7 @@ main()
err "${project}/${target}: cannot download source tree" err "${project}/${target}: cannot download source tree"
done done
rm -f ${cfgsdir}/*/seen || err_rm_seen "main 3" rm -f "${cfgsdir}"/*/seen || err_rm_seen "main 3"
} }
download_for_target() download_for_target()

View File

@ -189,7 +189,7 @@ if [ "${payload_grub}" = "y" ] || \
printf "Required GRUB payloads not yet built. Building now.\n" \ printf "Required GRUB payloads not yet built. Building now.\n" \
1>&2 1>&2
fi fi
for keymapfile in ${kmapdir}/*; do for keymapfile in "${kmapdir}"/*; do
[ -f "${keymapfile}" ] || continue [ -f "${keymapfile}" ] || continue
keymap="${keymapfile##*/}" keymap="${keymapfile##*/}"
@ -230,11 +230,11 @@ moverom() {
printf "\nCreating new ROM image: %s\n" "${newrompath}" printf "\nCreating new ROM image: %s\n" "${newrompath}"
if [ "${cuttype}" = "4MiB IFD BIOS region" ]; then if [ "${cuttype}" = "4MiB IFD BIOS region" ]; then
dd if=${rompath} of=${newrompath} bs=1 \ dd if="${rompath}" of="${newrompath}" bs=1 \
skip=$(($(stat -c %s ${rompath}) - 0x400000)) \ skip=$(($(stat -c %s "${rompath}") - 0x400000)) \
count=4194304 || err "moverom: cannot cut 4MB section" count=4194304 || err "moverom: cannot cut 4MB section"
else else
cp ${rompath} ${newrompath} || err "moverom: cannot copy rom" cp "${rompath}" "${newrompath}" || err "moverom: can't copy rom"
fi fi
# pike2008 cards cause a system hang when loading option roms in seabios # pike2008 cards cause a system hang when loading option roms in seabios
@ -245,7 +245,7 @@ moverom() {
touch "${emptyrom}" || err "cannot create fake oprom" touch "${emptyrom}" || err "cannot create fake oprom"
for deviceID in "0072" "3050"; do for deviceID in "0072" "3050"; do
"${cbfstool}" "${newrompath}" add -f "${emptyrom}" \ "${cbfstool}" "${newrompath}" add -f "${emptyrom}" \
-n pci1000,${deviceID}.rom -t raw || \ -n "pci1000,${deviceID}.rom" -t raw || \
err "moverom: cannot insert fake pike2008 rom" err "moverom: cannot insert fake pike2008 rom"
done done
rm -f "${emptyrom}" || err "moverom: cannot remove pike2008 rom" rm -f "${emptyrom}" || err "moverom: cannot remove pike2008 rom"
@ -257,7 +257,7 @@ moverom() {
[ -f "${ifdgbe}" ] || \ [ -f "${ifdgbe}" ] || \
./build descriptors ich9m || \ ./build descriptors ich9m || \
err "moverom: cannot create ich9m ifd" err "moverom: cannot create ich9m ifd"
dd if=${ifdgbe} of=${newrompath} bs=1 count=12k \ dd if="${ifdgbe}" of="${newrompath}" bs=1 count=12k \
conv=notrunc || err "moverom: cant insert ich9m ifd" conv=notrunc || err "moverom: cant insert ich9m ifd"
fi fi
cmpstr="${romsize}MiB ICH9 IFD NOGBE NOR flash" cmpstr="${romsize}MiB ICH9 IFD NOGBE NOR flash"
@ -266,18 +266,19 @@ moverom() {
[ -f "${ifdgbe}" ] || \ [ -f "${ifdgbe}" ] || \
./build descriptors ich9m || \ ./build descriptors ich9m || \
err "moverom: cannot create ich9m ifd" err "moverom: cannot create ich9m ifd"
dd if=${ifdgbe} of=${newrompath} bs=1 count=4k \ dd if="${ifdgbe}" of="${newrompath}" bs=1 count=4k \
conv=notrunc || err "moverom: cant insert ich9m ifd" conv=notrunc || err "moverom: cant insert ich9m ifd"
fi fi
done done
if [ "${cuttype}" = "i945 laptop" ]; then if [ "${cuttype}" = "i945 laptop" ]; then
dd if=${newrompath} of=top64k.bin bs=1 \ dd if="${newrompath}" of=top64k.bin bs=1 \
skip=$(($(stat -c %s ${newrompath}) - 0x10000)) count=64k \ skip=$(($(stat -c %s "${newrompath}") - 0x10000)) \
|| err "moverom: cannot copy boot block from i945 rom" count=64k || \
dd if=top64k.bin of=${newrompath} bs=1 \ err "moverom: cannot copy boot block from i945 rom"
seek=$(($(stat -c %s ${newrompath}) - 0x20000)) count=64k \ dd if=top64k.bin of="${newrompath}" bs=1 \
conv=notrunc || \ seek=$(($(stat -c %s "${newrompath}") - 0x20000)) \
count=64k conv=notrunc || \
err "moverom: cannot copy boot block into i945 rom" err "moverom: cannot copy boot block into i945 rom"
rm -f top64k.bin || err "moverom: can't remove top64k.bin" rm -f top64k.bin || err "moverom: can't remove top64k.bin"
fi fi
@ -292,7 +293,7 @@ moverom() {
if [ "${microcode_present}" = "n" ]; then if [ "${microcode_present}" = "n" ]; then
rm -f "${_newrom_b}" || err "cannot remove ${_newrom_b}" rm -f "${_newrom_b}" || err "cannot remove ${_newrom_b}"
printf "REMARK: '%s' already lacks microcode\n" \ printf "REMARK: '%s' already lacks microcode\n" \
${newrompath} "${newrompath}"
printf "Renaming default ROM file instead.\n" printf "Renaming default ROM file instead.\n"
mv "${newrompath}" "${_newrom_b}" || \ mv "${newrompath}" "${_newrom_b}" || \
err "moverom: mv \"${newrompath}\" \"${_newrom_b}\"" err "moverom: mv \"${newrompath}\" \"${_newrom_b}\""
@ -520,7 +521,7 @@ mkRoms()
if [ "${payload_memtest}" = "y" ]; then if [ "${payload_memtest}" = "y" ]; then
"${cbfstool}" "${corebootrom}" add-payload \ "${cbfstool}" "${corebootrom}" add-payload \
-f ${memtest_bin} -n img/memtest -c lzma || \ -f "${memtest_bin}" -n img/memtest -c lzma || \
err "mkRoms: cannot add img/memtest to coreboot rom" err "mkRoms: cannot add img/memtest to coreboot rom"
fi fi

View File

@ -82,22 +82,22 @@ build_grub_elf()
grub/grub-mkstandalone \ grub/grub-mkstandalone \
--grub-mkimage="grub/grub-mkimage" \ --grub-mkimage="grub/grub-mkimage" \
-O i386-coreboot \ -O i386-coreboot \
-o elf/grub/grub_${keymap}.elf \ -o "elf/grub/grub_${keymap}.elf" \
-d grub/grub-core/ \ -d grub/grub-core/ \
--fonts= --themes= --locales= \ --fonts= --themes= --locales= \
--modules="${grub_modules}" \ --modules="${grub_modules}" \
--install-modules="${grub_install_modules}" \ --install-modules="${grub_install_modules}" \
${gcfg} ${grubk} || \ "${gcfg}" "${grubk}" || \
err "build_grub_elf: cannot build grub payload (grub-mkstandalone)" err "build_grub_elf: cannot build grub payload (grub-mkstandalone)"
} }
create_grub_config() create_grub_config()
{ {
sed "s/usqwerty/${keymap}/" < ${grubcfgsdir}/config/grub.cfg \ sed "s/usqwerty/${keymap}/" < "${grubcfgsdir}/config/grub.cfg" \
> elf/grub/grub_${keymap}.cfg || \ > "elf/grub/grub_${keymap}.cfg" || \
err "create_grub_config: sed failed: grub.cfg" err "create_grub_config: sed failed: grub.cfg"
sed "s/grubtest.cfg/grub.cfg/" < elf/grub/grub_${keymap}.cfg \ sed "s/grubtest.cfg/grub.cfg/" < "elf/grub/grub_${keymap}.cfg" \
> elf/grub/grub_${keymap}_test.cfg || \ > "elf/grub/grub_${keymap}_test.cfg" || \
err "create_grub_config: sed failed: grubtest.cfg" err "create_grub_config: sed failed: grubtest.cfg"
} }

View File

@ -125,7 +125,7 @@ strip_archive()
{ {
romdir=${1} romdir=${1}
[ -d coreboot/${tree} ] || \ [ -d "coreboot/${tree}" ] || \
./fetch_trees coreboot ${tree} || \ ./fetch_trees coreboot ${tree} || \
err "strip_archive: coreboot/${tree}: can't fetch source" err "strip_archive: coreboot/${tree}: can't fetch source"
./build coreboot utils ${tree} || \ ./build coreboot utils ${tree} || \
@ -143,7 +143,7 @@ strip_archive()
err "strip_archive: !touch ${blobdir}/blobhashes" err "strip_archive: !touch ${blobdir}/blobhashes"
( (
cd ${romdir} || err "strip_archive: !cd ${romdir}" cd "${romdir}" || err "strip_archive: !cd ${romdir}"
sha1sum *.rom >> blobhashes || \ sha1sum *.rom >> blobhashes || \
err "strip_archive: ${romdir}: !sha1sum *.rom >> blobhashes" err "strip_archive: ${romdir}: !sha1sum *.rom >> blobhashes"
) )
@ -160,7 +160,7 @@ strip_rom_image()
[ -f "${romfile}" ] || return 0 [ -f "${romfile}" ] || return 0
if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then
${ifdtool} --nuke me "${romfile}" || \ "${ifdtool}" --nuke me "${romfile}" || \
err "strip_rom_images: ${romfile}: cannot nuke Intel ME" err "strip_rom_images: ${romfile}: cannot nuke Intel ME"
mv "${romfile}" "${romdir}_tmp" || \ mv "${romfile}" "${romdir}_tmp" || \
err "strip_rom_images: !mv ${romfile} ${romdir}_tmp" err "strip_rom_images: !mv ${romfile} ${romdir}_tmp"
@ -169,25 +169,25 @@ strip_rom_image()
fi fi
if [ "${CONFIG_HAVE_MRC}" = "y" ]; then if [ "${CONFIG_HAVE_MRC}" = "y" ]; then
${cbfstool} "${romfile}" remove -n mrc.bin || \ "${cbfstool}" "${romfile}" remove -n mrc.bin || \
err "strip_rom_images: ${romfile}: cannot nuke mrc.bin" err "strip_rom_images: ${romfile}: cannot nuke mrc.bin"
${cbfstool} "${romfile}" print || : "${cbfstool}" "${romfile}" print || :
fi fi
if [ "${CONFIG_KBC1126_FIRMWARE}" = "y" ]; then if [ "${CONFIG_KBC1126_FIRMWARE}" = "y" ]; then
${cbfstool} "${romfile}" remove -n ecfw1.bin || \ "${cbfstool}" "${romfile}" remove -n ecfw1.bin || \
err "strip_rom_images: ${romfile}: can't nuke ecfw1.bin" err "strip_rom_images: ${romfile}: can't nuke ecfw1.bin"
${cbfstool} "${romfile}" remove -n ecfw2.bin || \ "${cbfstool}" "${romfile}" remove -n ecfw2.bin || \
err "strip_rom_images: ${romfile}: can't nuke ecfw2.bin" err "strip_rom_images: ${romfile}: can't nuke ecfw2.bin"
fi fi
[ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" != "y" ] || \ [ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" != "y" ] || \
${cbfstool} "${romfile}" remove -n sch5545_ecfw.bin || \ "${cbfstool}" "${romfile}" remove -n sch5545_ecfw.bin || \
err "strip_rom_images: ${romfile}: can't nuke sch5545ec fw" err "strip_rom_images: ${romfile}: can't nuke sch5545ec fw"
# TODO: replace this board-specific hack # TODO: replace this board-specific hack
if [ "${target}" = "e6400nvidia_4mb" ]; then if [ "${target}" = "e6400nvidia_4mb" ]; then
${cbfstool} "${romfile}" remove -n "pci10de,06eb.rom" || \ "${cbfstool}" "${romfile}" remove -n "pci10de,06eb.rom" || \
err "strip_rom_images: ${romfile}: can't nuke e6400 vga rom" err "strip_rom_images: ${romfile}: can't nuke e6400 vga rom"
fi fi
} }

View File

@ -125,7 +125,7 @@ copy_blobs()
[ -e "${srcdir}/blobs/${i}" ] || \ [ -e "${srcdir}/blobs/${i}" ] || \
mkdir -p "${srcdir}/blobs/${i}" || \ mkdir -p "${srcdir}/blobs/${i}" || \
err "copy_blobs: ! -d ${srcdir}/blobs/${i}" err "copy_blobs: ! -d ${srcdir}/blobs/${i}"
cp blobs/${i}/${j}.bin "${srcdir}/blobs/${i}" || \ cp "blobs/${i}/${j}.bin" "${srcdir}/blobs/${i}" || \
err "copy_blobs: ! -f ${srcdir}/blobs/${i}" err "copy_blobs: ! -f ${srcdir}/blobs/${i}"
done done
done done

View File

@ -84,7 +84,7 @@ main()
fi fi
[ -d "${elfdir}" ] || [ "${mode}" != "all" ] || \ [ -d "${elfdir}" ] || [ "${mode}" != "all" ] || \
mkdir -p ${elfdir}/ || fail "cannot create directory: ${elfdir}" mkdir -p "${elfdir}/" || fail "can't create directory ${elfdir}"
for x in "$@"; do for x in "$@"; do
target="${x}" target="${x}"

View File

@ -79,7 +79,7 @@ main()
detect_firmware() detect_firmware()
{ {
set -- "${boarddir}/config/"* set -- "${boarddir}/config/"*
. ${1} 2>/dev/null . "${1}"
. "${boarddir}/target.cfg" . "${boarddir}/target.cfg"
[ "${CONFIG_HAVE_MRC}" = "y" ] && needs="${needs} MRC" [ "${CONFIG_HAVE_MRC}" = "y" ] && needs="${needs} MRC"
@ -94,7 +94,7 @@ detect_firmware()
[ -z ${needs+x} ] && \ [ -z ${needs+x} ] && \
printf "No binary blobs needed for this board\n" && \ printf "No binary blobs needed for this board\n" && \
return 1 return 1
printf "Firmware needed for board '%s':\n%s\n" ${board} ${needs} printf "Firmware needed for board '%s':\n%s\n" "${board}" "${needs}"
} }
scan_sources_config() scan_sources_config()
@ -167,8 +167,8 @@ build_dependencies()
[ -f uefitool/uefiextract ] || \ [ -f uefitool/uefiextract ] || \
./build src for -b uefitool || \ ./build src for -b uefitool || \
err "build_dependencies: can't build uefitool" err "build_dependencies: can't build uefitool"
if [ ! -f ${cbdir}/util/kbc1126/kbc1126_ec_dump ]; then if [ ! -f "${cbdir}/util/kbc1126/kbc1126_ec_dump" ]; then
make -BC ${cbdir}/util/kbc1126 || \ make -BC "${cbdir}/util/kbc1126" || \
err "build_dependencies: can't build kbc1126_ec_dump" err "build_dependencies: can't build kbc1126_ec_dump"
fi fi
} }
@ -210,7 +210,7 @@ extract_blob_intel_me()
_me_destination=${CONFIG_ME_BIN_PATH#../../} _me_destination=${CONFIG_ME_BIN_PATH#../../}
[ -d "${_me_destination%/*}" ] || \ [ -d "${_me_destination%/*}" ] || \
mkdir -p ${_me_destination%/*} || \ mkdir -p "${_me_destination%/*}" || \
err "extract_blob_intel_me: mkdir ${_me_destination%/*}" err "extract_blob_intel_me: mkdir ${_me_destination%/*}"
[ ! -d "${appdir}" ] || \ [ ! -d "${appdir}" ] || \
rm -Rf "${appdir}" || \ rm -Rf "${appdir}" || \
@ -222,8 +222,8 @@ extract_blob_intel_me()
printf "Extracting and stripping Intel ME firmware\n" printf "Extracting and stripping Intel ME firmware\n"
innoextract ${dl_path} -d ${appdir} || \ innoextract "${dl_path}" -d "${appdir}" || \
7z x ${dl_path} -o${appdir} || \ 7z x "${dl_path}" -o"${appdir}" || \
unar "${dl_path}" -o "${appdir}" || \ unar "${dl_path}" -o "${appdir}" || \
err "extract_blob_intel_me: could not extract vendor update" err "extract_blob_intel_me: could not extract vendor update"
@ -265,10 +265,10 @@ bruteforce_extract_blob_intel_me()
&& break # (we found me.bin) && break # (we found me.bin)
"${mecleaner}" -r -t -O "${_me_destination}" "${i}" \ "${mecleaner}" -r -t -O "${_me_destination}" "${i}" \
&& break # (we found me.bin) && break # (we found me.bin)
"${me7updateparser}" -O ${_me_destination} "${i}" \ "${me7updateparser}" -O "${_me_destination}" "${i}" \
&& break # (we found me.bin) && break # (we found me.bin)
_7ztest="${_7ztest}a" _7ztest="${_7ztest}a"
7z x "${i}" -o${_7ztest} \ 7z x "${i}" -o"${_7ztest}" \
|| innoextract "${i}" -d "${_7ztest}" \ || innoextract "${i}" -d "${_7ztest}" \
|| unar "${i}" -o "${_7ztest}" \ || unar "${i}" -o "${_7ztest}" \
|| continue || continue
@ -368,10 +368,10 @@ extract_e6400vga()
return 0 return 0
fi fi
[ -d "${_vga_destination%/*}" ] || \ [ -d "${_vga_destination%/*}" ] || \
mkdir -p ${_vga_destination%/*} || \ mkdir -p "${_vga_destination%/*}" || \
err "extract_e6400vga: can't mkdir ${_vga_destination%/*}" err "extract_e6400vga: can't mkdir ${_vga_destination%/*}"
[ ! -d "${appdir}" ] || \ [ ! -d "${appdir}" ] || \
rm -Rf ${appdir} || \ rm -Rf "${appdir}" || \
err "extract_e6400vga: can't rm -Rf ${appdir}" err "extract_e6400vga: can't rm -Rf ${appdir}"
mkdir -p "${appdir}" || \ mkdir -p "${appdir}" || \
@ -482,18 +482,18 @@ fetch_update()
[ -z "${dl_url+x}" ] && [ "${fw_type}" != "e6400vga" ] && \ [ -z "${dl_url+x}" ] && [ "${fw_type}" != "e6400vga" ] && \
err "fetch_update ${fw_type}: dl_url unspecified for: ${board}" err "fetch_update ${fw_type}: dl_url unspecified for: ${board}"
dl_path=${blobdir}/cache/${dlsum} dl_path="${blobdir}/cache/${dlsum}"
mkdir -p ${blobdir}/cache || err "fetch_update: !mkdir ${blobdir}/cache" mkdir -p "${blobdir}/cache" || err "fetch_update: !mkdir ${blobdir}/cache"
dl_fail="y" dl_fail="y"
vendor_checksum ${dlsum} && dl_fail="n" vendor_checksum "${dlsum}" && dl_fail="n"
for x in "${dl}" "${dl_bkup}"; do for x in "${dl}" "${dl_bkup}"; do
[ "${dl_fail}" = "n" ] && break [ "${dl_fail}" = "n" ] && break
[ -z "${x}" ] && continue [ -z "${x}" ] && continue
rm -f "${dl_path}" || \ rm -f "${dl_path}" || \
err "fetch_update ${fw_type}: !rm -f ${dl_path}" err "fetch_update ${fw_type}: !rm -f ${dl_path}"
wget -U "${agent}" ${x} -O ${dl_path} || continue wget -U "${agent}" "${x}" -O "${dl_path}" || continue
vendor_checksum ${dlsum} && dl_fail="n" vendor_checksum "${dlsum}" && dl_fail="n"
done done
if [ "${dl_fail}" = "y" ]; then if [ "${dl_fail}" = "y" ]; then
printf "ERROR: invalid vendor updates for: %s\n" "${board}" 1>&2 printf "ERROR: invalid vendor updates for: %s\n" "${board}" 1>&2
@ -504,10 +504,11 @@ fetch_update()
vendor_checksum() vendor_checksum()
{ {
if [ ! -f "${dl_path}" ]; then if [ ! -f "${dl_path}" ]; then
printf "Vendor update not found on disk for: %s\n" ${board} 1>&2 printf "Vendor update not found on disk for: %s\n" "${board}" \
1>&2
return 1 return 1
elif [ "$(sha1sum ${dl_path} | awk '{print $1}')" != "${1}" ]; then elif [ "$(sha1sum ${dl_path} | awk '{print $1}')" != "${1}" ]; then
printf "Bad checksum on vendor update for: %s\n" ${board} 1>&2 printf "Bad checksum on vendor update for: %s\n" "${board}" 1>&2
return 1 return 1
fi fi
} }

View File

@ -88,28 +88,27 @@ extract_blobs()
# Cleans up other files extracted with ifdtool # Cleans up other files extracted with ifdtool
rm -f flashregion*.bin || err "extract_blobs: !rm -f flashregion*.bin" rm -f flashregion*.bin || err "extract_blobs: !rm -f flashregion*.bin"
[ -f ${_ifd_destination} ] || err "extract_blobs: Could not extract IFD" [ -f "${_ifd_destination}" ] || err "extract_blobs: Cannot extract IFD"
printf "gbe, ifd, and me extracted to %s\n" \ printf "gbe, ifd, and me extracted to %s\n" "${_me_destination%/*}"
"${_me_destination%/*}"
} }
extract_blob_intel_me() extract_blob_intel_me()
{ {
printf "extracting clean ime and modified ifd\n" printf "extracting clean ime and modified ifd\n"
${mecleaner} -D ${_ifd_destination} \ "${mecleaner}" -D "${_ifd_destination}" \
-M ${_me_destination} ${vendor_rom} -t -r -S || \ -M "${_me_destination}" "${vendor_rom}" -t -r -S || \
${me7updateparser} \ "${me7updateparser}" \
-O ${_me_destination} ${vendor_rom} || \ -O "${_me_destination}" "${vendor_rom}" || \
err "extract_blob_intel_me: cannot extract from vendor rom" err "extract_blob_intel_me: cannot extract from vendor rom"
} }
extract_blob_intel_gbe_nvm() extract_blob_intel_gbe_nvm()
{ {
printf "extracting gigabit ethernet firmware" printf "extracting gigabit ethernet firmware"
./${ifdtool} -x ${vendor_rom} || \ ./"${ifdtool}" -x "${vendor_rom}" || \
err "extract_blob_intel_gbe_nvm: cannot extract gbe.bin from rom" err "extract_blob_intel_gbe_nvm: cannot extract gbe.bin from rom"
mv flashregion*gbe.bin ${_gbe_destination} || \ mv flashregion*gbe.bin "${_gbe_destination}" || \
err "extract_blob_intel_gbe_nvm: cannot move gbe.bin" err "extract_blob_intel_gbe_nvm: cannot move gbe.bin"
} }

View File

@ -72,7 +72,7 @@ main()
check_board() check_board()
{ {
if ! check_release ${archive} ; then if ! check_release "${archive}" ; then
[ -f "${rom}" ] || \ [ -f "${rom}" ] || \
err "check_board: \"${rom}\" is not a valid path" err "check_board: \"${rom}\" is not a valid path"
[ -z ${rom+x} ] && \ [ -z ${rom+x} ] && \
@ -102,7 +102,7 @@ check_release()
# It will only succeed if the filename is not changed from the build/download # It will only succeed if the filename is not changed from the build/download
detect_board() detect_board()
{ {
path=${1} path="${1}"
filename=$(basename ${path}) filename=$(basename ${path})
case ${filename} in case ${filename} in
grub_*) grub_*)
@ -146,20 +146,20 @@ patch_release_roms()
tar xf "${releasearchive}" -C "${_tmpdir}" || \ tar xf "${releasearchive}" -C "${_tmpdir}" || \
err "patch_release_roms: could not extract release archive" err "patch_release_roms: could not extract release archive"
for x in ${_tmpdir}/bin/*/*.rom ; do for x in "${_tmpdir}"/bin/*/*.rom ; do
echo "patching rom $x" echo "patching rom $x"
patch_rom ${x} || err "patch_release_roms: could not patch ${x}" patch_rom "${x}" || err "patch_release_roms: could not patch ${x}"
done done
( (
cd ${_tmpdir}/bin/* cd "${_tmpdir}"/bin/*
sha1sum --status -c blobhashes || \ sha1sum --status -c blobhashes || \
err "patch_release_roms: ROMs did not match expected hashes" err "patch_release_roms: ROMs did not match expected hashes"
) )
if [ "${modifygbe}" = "true" ]; then if [ "${modifygbe}" = "true" ]; then
for x in ${_tmpdir}/bin/*/*.rom ; do for x in "${_tmpdir}"/bin/*/*.rom ; do
modify_gbe ${x} modify_gbe "${x}"
done done
fi fi
@ -203,7 +203,7 @@ patch_rom()
[ "${CONFIG_SMSC_SCH5545_EC_FW_FILE}" != "" ] && \ [ "${CONFIG_SMSC_SCH5545_EC_FW_FILE}" != "" ] && \
inject_blob_smsc_sch5545_ec "${rom}" inject_blob_smsc_sch5545_ec "${rom}"
[ "${modifygbe}" = "true" ] && ! [ "${release}" = "true" ] && \ [ "${modifygbe}" = "true" ] && ! [ "${release}" = "true" ] && \
modify_gbe ${rom} modify_gbe "${rom}"
printf "ROM image successfully patched: %s\n" "${rom}" printf "ROM image successfully patched: %s\n" "${rom}"
} }
@ -232,7 +232,7 @@ inject_blob_intel_mrc()
# source code, and it is *always* correct for haswell platform. # source code, and it is *always* correct for haswell platform.
# TODO: this logic should be tweaked to handle more platforms # TODO: this logic should be tweaked to handle more platforms
${cbfstool} ${rom} add -f mrc/haswell/mrc.bin -n mrc.bin -t mrc \ "${cbfstool}" "${rom}" add -f mrc/haswell/mrc.bin -n mrc.bin -t mrc \
-b 0xfffa0000 || err "inject_blob_intel_mrc: cannot insert mrc.bin" -b 0xfffa0000 || err "inject_blob_intel_mrc: cannot insert mrc.bin"
} }
@ -248,7 +248,7 @@ inject_blob_intel_me()
[ ! -f "${_me_location}" ] && \ [ ! -f "${_me_location}" ] && \
err "inject_blob_intel_me: per CONFIG_ME_BIN_PATH: file missing" err "inject_blob_intel_me: per CONFIG_ME_BIN_PATH: file missing"
${ifdtool} -i me:${_me_location} ${rom} -O ${rom} || \ "${ifdtool}" -i me:"${_me_location}" "${rom}" -O "${rom}" || \
err "inject_blob_intel_me: cannot insert me.bin" err "inject_blob_intel_me: cannot insert me.bin"
} }
@ -273,10 +273,10 @@ inject_blob_hp_kbc1126_ec()
err "inject_blob_hp_kbc1126_ec: ${board}: ecfw not downloaded" err "inject_blob_hp_kbc1126_ec: ${board}: ecfw not downloaded"
fi fi
${cbfstool} "${rom}" add -f ${_ec1_location} -n ecfw1.bin \ "${cbfstool}" "${rom}" add -f "${_ec1_location}" -n ecfw1.bin \
-b ${_ec1_offset} -t raw || \ -b ${_ec1_offset} -t raw || \
err "inject_blob_hp_kbc1126_ec: cannot insert ecfw1.bin" err "inject_blob_hp_kbc1126_ec: cannot insert ecfw1.bin"
${cbfstool} "${rom}" add -f ${_ec2_location} -n ecfw2.bin \ "${cbfstool}" "${rom}" add -f "${_ec2_location}" -n ecfw2.bin \
-b ${_ec2_offset} -t raw || \ -b ${_ec2_offset} -t raw || \
err "inject_blob_hp_kbc1126_ec: cannot insert ecfw2.bin" err "inject_blob_hp_kbc1126_ec: cannot insert ecfw2.bin"
} }
@ -298,7 +298,7 @@ inject_blob_dell_e6400_vgarom_nvidia()
err "inject_blob_dell_e6400vga: ${_vga_location} doesn't exist" err "inject_blob_dell_e6400vga: ${_vga_location} doesn't exist"
fi fi
${cbfstool} ${rom} add -f "${_vga_location}" \ "${cbfstool}" "${rom}" add -f "${_vga_location}" \
-n "pci${CONFIG_VGA_BIOS_ID}.rom" -t optionrom || \ -n "pci${CONFIG_VGA_BIOS_ID}.rom" -t optionrom || \
err "inject_blob_dell_e6400vga: cannot insert vga oprom" err "inject_blob_dell_e6400vga: cannot insert vga oprom"
} }
@ -322,7 +322,7 @@ modify_gbe()
{ {
printf "changing mac address in gbe to ${new_mac}\n" printf "changing mac address in gbe to ${new_mac}\n"
rom=${1} rom="${1}"
[ -z ${CONFIG_GBE_BIN_PATH} ] && \ [ -z ${CONFIG_GBE_BIN_PATH} ] && \
err "modify_gbe: ${board}: CONFIG_GBE_BIN_PATH not set" err "modify_gbe: ${board}: CONFIG_GBE_BIN_PATH not set"
@ -331,27 +331,27 @@ modify_gbe()
[ -f "${_gbe_location}" ] || \ [ -f "${_gbe_location}" ] || \
err "modify_gbe: CONFIG_GBE_BIN_PATH points to missing file" err "modify_gbe: CONFIG_GBE_BIN_PATH points to missing file"
[ -f ${nvmutil} ] || \ [ -f "${nvmutil}" ] || \
make -C util/nvmutil || err "modify_gbe: couldn't build nvmutil" make -C util/nvmutil || err "modify_gbe: couldn't build nvmutil"
_gbe_tmp=$(mktemp -t gbeXXXX.bin) _gbe_tmp=$(mktemp -t gbeXXXX.bin)
cp ${_gbe_location} ${_gbe_tmp} cp "${_gbe_location}" "${_gbe_tmp}"
${nvmutil} "${_gbe_tmp}" setmac "${new_mac}" || \ "${nvmutil}" "${_gbe_tmp}" setmac "${new_mac}" || \
err "modify_gbe: ${board}: failed to modify mac address" err "modify_gbe: ${board}: failed to modify mac address"
${ifdtool} -i GbE:${_gbe_tmp} "${rom}" -O "${rom}" || \ "${ifdtool}" -i GbE:"${_gbe_tmp}" "${rom}" -O "${rom}" || \
err "modify_gbe: ${board}: cannot insert modified gbe.bin" err "modify_gbe: ${board}: cannot insert modified gbe.bin"
rm -f ${_gbe_tmp} rm -f "${_gbe_tmp}"
} }
listboards() listboards()
{ {
for boarddir in ${cbcfgsdir}/*; do for boarddir in "${cbcfgsdir}"/*; do
[ -d "${boarddir}" ] || continue [ -d "${boarddir}" ] || continue
board="${boarddir##${cbcfgsdir}/}" board="${boarddir##${cbcfgsdir}/}"
board="${board%/}" board="${board%/}"
printf '%s\n' "${board##*/}" printf "%s\n" "${board##*/}"
done done
} }

View File

@ -60,10 +60,10 @@ main()
check_existing() check_existing()
{ {
[ -f ${_mrc_complete} ] || \ [ -f "${_mrc_complete}" ] || \
return 0 return 0
printf 'found existing mrc.bin\n' printf 'found existing mrc.bin\n'
[ "$(sha1sum ${_mrc_complete} | awk '{print $1}')" \ [ "$(sha1sum "${_mrc_complete}" | awk '{print $1}')" \
= "${_mrc_complete_hash}" ] && \ = "${_mrc_complete_hash}" ] && \
return 1 return 1
printf 'hashes did not match, starting over\n' printf 'hashes did not match, starting over\n'
@ -84,18 +84,18 @@ fetch_mrc()
( (
cd mrc/haswell/ || err "fetch_mrc: !cd mrc/haswell" cd mrc/haswell/ || err "fetch_mrc: !cd mrc/haswell"
download_image ${_url} ${_file} ${_sha1sum} download_image "${_url}" "${_file}" "${_sha1sum}"
[ -f ${_file} ] || \ [ -f ${_file} ] || \
download_image ${_url2} ${_file} ${_sha1sum} download_image "${_url2}" "${_file}" "${_sha1sum}"
[ -f $_file ] || \ [ -f $_file ] || \
err "fetch_mrc: ${_file} not downloaded / verification failed." err "fetch_mrc: ${_file} not downloaded / verification failed."
extract_partition ROOT-A ${_file} root-a.ext2 extract_partition ROOT-A "${_file}" root-a.ext2
extract_shellball root-a.ext2 chromeos-firmwareupdate-${_board} extract_shellball root-a.ext2 chromeos-firmwareupdate-${_board}
extract_coreboot chromeos-firmwareupdate-${_board} extract_coreboot chromeos-firmwareupdate-${_board}
../../${cbfstool} coreboot-*.bin extract -f mrc.bin -n mrc.bin \ ../../"${cbfstool}" coreboot-*.bin extract -f mrc.bin -n mrc.bin \
-r RO_SECTION || err "fetch_mrc: could not fetch mrc.bin" -r RO_SECTION || err "fetch_mrc: could not fetch mrc.bin"
rm -f "chromeos-firmwareupdate-${_board}" coreboot-*.bin \ rm -f "chromeos-firmwareupdate-${_board}" coreboot-*.bin \
"${_file}" "root-a.ext2" || err "fetch_mrc: cannot remove files" "${_file}" "root-a.ext2" || err "fetch_mrc: cannot remove files"
@ -113,7 +113,7 @@ download_image()
printf "Downloading recovery image\n" printf "Downloading recovery image\n"
curl "$url" > "$_file.zip" || err "download_image: curl failed" curl "$url" > "$_file.zip" || err "download_image: curl failed"
printf "Verifying recovery image checksum\n" printf "Verifying recovery image checksum\n"
if [ "$(sha1sum ${_file}.zip | awk '{print $1}')" = "${_sha1sum}" ] if [ "$(sha1sum "${_file}.zip" | awk '{print $1}')" = "${_sha1sum}" ]
then then
unzip -q "${_file}.zip" || err "download_image: cannot unzip" unzip -q "${_file}.zip" || err "download_image: cannot unzip"
rm -f "${_file}.zip" || err "download_image: can't rm zip {1}" rm -f "${_file}.zip" || err "download_image: can't rm zip {1}"
@ -132,12 +132,12 @@ extract_partition()
printf "Extracting ROOT-A partition\n" printf "Extracting ROOT-A partition\n"
ROOTP=$( printf "unit\nB\nprint\nquit\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" ) )) START=$(( $( echo ${ROOTP} | cut -f2 -d\ | tr -d "B" ) ))
SIZE=$(( $( echo ${ROOTP} | cut -f4 -d\ | tr -d "B" ) )) SIZE=$(( $( echo ${ROOTP} | cut -f4 -d\ | tr -d "B" ) ))
dd if=${FILE} of=${ROOTFS} bs=${_bs} skip=$(( ${START} / ${_bs} )) \ dd if="${FILE}" of="${ROOTFS}" bs=${_bs} skip=$(( ${START} / ${_bs} )) \
count=$(( ${SIZE} / ${_bs} )) || \ count=$(( ${SIZE} / ${_bs} )) || \
err "extract_partition: can't extract root file system" err "extract_partition: can't extract root file system"
} }
@ -149,7 +149,7 @@ extract_shellball()
printf "Extracting chromeos-firmwareupdate\n" printf "Extracting chromeos-firmwareupdate\n"
printf "cd /usr/sbin\ndump chromeos-firmwareupdate ${SHELLBALL}\nquit" \ printf "cd /usr/sbin\ndump chromeos-firmwareupdate ${SHELLBALL}\nquit" \
| debugfs ${ROOTFS} || err "extract_shellball: debugfs" | debugfs "${ROOTFS}" || err "extract_shellball: debugfs"
} }
extract_coreboot() extract_coreboot()
@ -162,7 +162,7 @@ extract_coreboot()
[ -f "${_shellball}" ] || \ [ -f "${_shellball}" ] || \
err "extract_coreboot: shellball missing in google peppy image" err "extract_coreboot: shellball missing in google peppy image"
sh ${_shellball} --unpack ${_unpacked} || \ sh "${_shellball}" --unpack "${_unpacked}" || \
err "extract_coreboot: shellball exits with non-zero status" err "extract_coreboot: shellball exits with non-zero status"
# TODO: audit the f* out of that shellball, for each mrc version. # TODO: audit the f* out of that shellball, for each mrc version.
@ -172,10 +172,10 @@ extract_coreboot()
[ -f "${_unpacked}/VERSION" ] || \ [ -f "${_unpacked}/VERSION" ] || \
err "extract_coreboot: VERSION file missing on google coreboot rom" err "extract_coreboot: VERSION file missing on google coreboot rom"
_version=$( cat ${_unpacked}/VERSION | grep BIOS\ version: | \ _version=$( cat "${_unpacked}/VERSION" | grep BIOS\ version: | \
cut -f2 -d: | tr -d \ ) cut -f2 -d: | tr -d \ )
cp ${_unpacked}/bios.bin coreboot-${_version}.bin || \ cp "${_unpacked}/bios.bin" "coreboot-${_version}.bin" || \
err "extract_coreboot: cannot copy google peppy rom" err "extract_coreboot: cannot copy google peppy rom"
rm -Rf "${_unpacked}" || \ rm -Rf "${_unpacked}" || \
err "extract_coreboot: cannot remove extracted google peppy archive" err "extract_coreboot: cannot remove extracted google peppy archive"