From 62f23123cb2a5ef594f405053d0b111c6e01de87 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 21 Aug 2023 19:41:49 +0100 Subject: general code cleanup on lbmk shell scripts in update/blobs/download, i saw instances where appdir was being deleted with rm -r, but the more appropriate command would rm -Rf. this is now fixed. other than that, i've mostly just simplified a bunch of if statements and consolidated some duplicated logic (e.g. if/else block for dependencies in build_dependencies() of update/blobs/download one or two functions and/or variables have been renamed, for greater clarity in the code, also removed a few messages that were redundant used printf instead of echo, in a few places, also fixed up the indentation in a few places Signed-off-by: Leah Rowe --- resources/scripts/build/release/roms | 53 +++++++++++++----------------------- resources/scripts/build/release/src | 21 ++++++-------- 2 files changed, 27 insertions(+), 47 deletions(-) (limited to 'resources/scripts/build/release') 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" ) -- cgit v1.2.1