diff options
Diffstat (limited to 'script/update')
-rwxr-xr-x | script/update/blobs/download | 30 | ||||
-rwxr-xr-x | script/update/blobs/inject | 89 | ||||
-rwxr-xr-x | script/update/project/repo | 19 | ||||
-rwxr-xr-x | script/update/project/trees | 50 |
4 files changed, 71 insertions, 117 deletions
diff --git a/script/update/blobs/download b/script/update/blobs/download index 9e017cc4..9d52dfb7 100755 --- a/script/update/blobs/download +++ b/script/update/blobs/download @@ -41,21 +41,16 @@ detect_firmware() build_dependencies() { [ -d ${cbdir} ] || \ - ./update project trees coreboot ${cbdir##*/} || \ - err "build_dependencies: can't fetch ${cbdir}" + x_ ./update project trees coreboot ${cbdir##*/} for d in uefitool biosutilities bios_extract me_cleaner; do [ -d "${d}" ] && continue - ./update project repo "${d}" || \ - err "build_dependencies: can't fetch ${d}" + x_ ./update project repo "${d}" done [ -f uefitool/uefiextract ] || \ - ./handle make file -b uefitool || \ - err "build_dependencies: can't build uefitool" + x_ ./handle make file -b uefitool [ -f "${cbdir}/util/kbc1126/kbc1126_ec_dump" ] || \ - make -C "${cbdir}/util/kbc1126" || \ - err "build_dependencies: can't build kbc1126_ec_dump" - ./build coreboot utils default || \ - err "build_dependencies: cannot build utils in cbutils/default/" + x_ make -C "${cbdir}/util/kbc1126" + x_ ./build coreboot utils default } download_blobs() @@ -117,13 +112,12 @@ extract_intel_me() extract_kbc1126ec() { ( - cd "${appdir}/" || \ - err "extract_kbc1126_ec: !cd \"${appdir}/\"" + x_ cd "${appdir}/" mv Rompaq/68*.BIN ec.bin || : if [ ! -f ec.bin ]; then unar -D ROM.CAB Rom.bin || unar -D Rom.CAB Rom.bin || \ - unar -D 68*.CAB Rom.bin || err "extract_kbc1126_ec !extract" - mv Rom.bin ec.bin || err "extract_kbc1126_ec: *didn't* extract" + x_ unar -D 68*.CAB Rom.bin + x_ mv Rom.bin ec.bin fi [ -f ec.bin ] || err "extract_kbc1126_ec ${board}: can't extract" "${kbc1126_ec_dump}" ec.bin || \ @@ -135,8 +129,7 @@ extract_kbc1126ec() done [ "${ec_ex}" = "y" ] || \ err "extract_kbc1126_ec ${board}: didn't extract ecfw1/2.bin" - cp "${appdir}/"ec.bin.fw* "${_dest%/*}/" || \ - err "extract_kbc1126_ec: cant mv ecfw1/2 ${_dest%/*}" + x_ cp "${appdir}/"ec.bin.fw* "${_dest%/*}/" } extract_e6400vga() @@ -148,14 +141,13 @@ extract_e6400vga() tail -c +${E6400_VGA_offset} "${_dl}" | \ gunzip >"${appdir}/bios.bin" || : ( - cd "${appdir}" || err "extract_e6400vga: can't cd ${appdir}" + x_ cd "${appdir}" [ -f "bios.bin" ] || err "extract_e6400vga: can't extract bios.bin" "${e6400_unpack}" bios.bin || printf "TODO: fix dell extract util\n" [ -f "${E6400_VGA_romname}" ] || \ err "extract_e6400vga: can't extract vga rom from bios.bin" ) - cp "${appdir}"/"${E6400_VGA_romname}" "${_dest}" || \ - err "extract_e6400vga: can't copy vga rom to ${_dest}" + x_ cp "${appdir}"/"${E6400_VGA_romname}" "${_dest}" } # TODO: this code is cancer. hardcoded is bad, and stupid. diff --git a/script/update/blobs/inject b/script/update/blobs/inject index 5e75d6c4..99eb9d5b 100755 --- a/script/update/blobs/inject +++ b/script/update/blobs/inject @@ -82,18 +82,15 @@ detect_board() err "detect_board: could not detect board type" esac [ -d "${boarddir}/" ] || \ - err "detect_board: dir, ${boarddir}, doesn't exist" + err "detect_board: dir, ${boarddir}, doesn't exist" printf "%s\n" "${board}" } build_dependencies() { - [ -d "${cbdir}" ] || ./update project trees coreboot default || \ - err "build_dependencies: could not download coreboot/default" - ./build coreboot utils default || \ - err "build_dependencies: could not build cbutils" - ./update blobs download ${board} || \ - err "build_dependencies: Could not download blobs for ${board}" + [ -d "${cbdir}" ] || x_ ./update project trees coreboot default + x_ ./build coreboot utils default + x_ ./update blobs download ${board} } inject_blobs() @@ -104,35 +101,31 @@ inject_blobs() release_archive="y" patch_release_roms else - patch_rom "${rom}" || \ - err "inject_blobs: could not patch ${x}" + x_ patch_rom "${rom}" fi } patch_release_roms() { _tmpdir="tmp/romdir" - rm -Rf "${_tmpdir}" || err "patch_release_roms 1: can't prepare tmpdir" - mkdir -p "${_tmpdir}" || err "patch_release_roms: can't make tmpdir" - tar -xf "${releasearchive}" -C "${_tmpdir}" || \ - err "patch_release_roms: could not extract release archive" + x_ rm -Rf "${_tmpdir}" + x_ mkdir -p "${_tmpdir}" + x_ tar -xf "${releasearchive}" -C "${_tmpdir}" for x in "${_tmpdir}"/bin/*/*.rom ; do printf "patching rom: %s\n" "$x" - patch_rom "${x}" || err "patch_release_roms: could not patch ${x}" + x_ patch_rom "${x}" done for x in "${_tmpdir}"/bin/*/*_nomicrocode.rom ; do [ -f "${x}" ] || continue [ -f "${x%_nomicrocode.rom}.rom" ] || continue - cp "${x%_nomicrocode.rom}.rom" "${x}" || \ - err "patch_release_roms: ${x}: can't overwrite no-ucode rom" - "${cbfstool}" "${x}" remove -n cpu_microcode_blob.bin || \ - err "patch_release_roms: ${x}: cannot remove u-code" + x_ cp "${x%_nomicrocode.rom}.rom" "${x}" + x_ "${cbfstool}" "${x}" remove -n cpu_microcode_blob.bin done ( - cd "${_tmpdir}"/bin/* + x_ cd "${_tmpdir}/bin/"* # NOTE: For compatibility with older rom releases, defer to sha1 sha512sum --status -c blobhashes || \ @@ -146,14 +139,12 @@ patch_release_roms() done fi - [ -d bin/release ] || mkdir -p bin/release || \ - err "patch_release_roms: !mkdir -p bin/release" - mv "${_tmpdir}"/bin/* bin/release/ || \ - err "patch_release_roms: !mv ${_tmpdir}/bin/* bin/release/" + [ -d bin/release ] || x_ mkdir -p bin/release + x_ mv "${_tmpdir}"/bin/* bin/release/ printf "Success! Your ROMs are in bin/release\n" - rm -Rf "${_tmpdir}" || err "patch_release_roms: !rm -Rf ${_tmpdir}" + x_ rm -Rf "${_tmpdir}" } patch_rom() @@ -170,7 +161,7 @@ patch_rom() [ -f "${rom%_nomicrocode.rom}.rom" ] && \ [ "${release_archive}" = "y" ] && return 0 - check_defconfig "${boarddir}" || err "patch_rom ${rom}: no defconfig" + x_ check_defconfig "${boarddir}" set -- "${boarddir}/config/"* . "${1}" 2>/dev/null @@ -217,8 +208,8 @@ inject_blob_intel_mrc() # source code, and it is *always* correct for haswell platform. # TODO: this logic should be tweaked to handle more platforms - "${cbfstool}" "${rom}" add -f mrc/haswell/mrc.bin -n mrc.bin -t mrc \ - -b 0xfffa0000 || err "inject_blob_intel_mrc: cannot insert mrc.bin" + x_ "${cbfstool}" "${rom}" add -f mrc/haswell/mrc.bin -n mrc.bin \ + -t mrc -b 0xfffa0000 } inject_blob_intel_me() @@ -233,8 +224,7 @@ inject_blob_intel_me() [ ! -f "${_me_location}" ] && \ err "inject_blob_intel_me: per CONFIG_ME_BIN_PATH: file missing" - "${ifdtool}" -i me:"${_me_location}" "${rom}" -O "${rom}" || \ - err "inject_blob_intel_me: cannot insert me.bin" + x_ "${ifdtool}" -i me:"${_me_location}" "${rom}" -O "${rom}" } inject_blob_hp_kbc1126_ec() @@ -258,12 +248,10 @@ inject_blob_hp_kbc1126_ec() err "inject_blob_hp_kbc1126_ec: ${board}: ecfw not downloaded" fi - "${cbfstool}" "${rom}" add -f "${_ec1_location}" -n ecfw1.bin \ - -b ${_ec1_offset} -t raw || \ - err "inject_blob_hp_kbc1126_ec: cannot insert ecfw1.bin" - "${cbfstool}" "${rom}" add -f "${_ec2_location}" -n ecfw2.bin \ - -b ${_ec2_offset} -t raw || \ - err "inject_blob_hp_kbc1126_ec: cannot insert ecfw2.bin" + x_ "${cbfstool}" "${rom}" add -f "${_ec1_location}" -n ecfw1.bin \ + -b ${_ec1_offset} -t raw + x_ "${cbfstool}" "${rom}" add -f "${_ec2_location}" -n ecfw2.bin \ + -b ${_ec2_offset} -t raw } inject_blob_dell_e6400_vgarom_nvidia() @@ -276,29 +264,24 @@ inject_blob_dell_e6400_vgarom_nvidia() printf "adding pci option rom\n" - if [ "${_vga_dir}" != "${pciromsdir}" ]; then + [ "${_vga_dir}" = "${pciromsdir}" ] || \ err "inject_blob_dell_e6400vga: invalid pcirom dir: ${_vga_dir}" - fi - if [ ! -f "${_vga_location}" ]; then + [ -f "${_vga_location}" ] || \ err "inject_blob_dell_e6400vga: ${_vga_location} doesn't exist" - fi - "${cbfstool}" "${rom}" add -f "${_vga_location}" \ - -n "pci${CONFIG_VGA_BIOS_ID}.rom" -t optionrom || \ - err "inject_blob_dell_e6400vga: cannot insert vga oprom" + x_ "${cbfstool}" "${rom}" add -f "${_vga_location}" \ + -n "pci${CONFIG_VGA_BIOS_ID}.rom" -t optionrom } inject_blob_smsc_sch5545_ec() { rom="${1}" _sch5545ec_location="${CONFIG_SMSC_SCH5545_EC_FW_FILE#../../}" - [ -f "${_sch5545ec_location}" ] || \ err "inject_blob_smsc_sch5545_ec: SCH5545 fw missing" - "${cbfstool}" "${rom}" add -f "${_sch5545ec_location}" \ - -n sch5545_ecfw.bin -t raw || \ - err "inject_blob_smsc_sch5545_ec: can't insert sch5545_ecfw.bin" + x_ "${cbfstool}" "${rom}" add -f "${_sch5545ec_location}" \ + -n sch5545_ecfw.bin -t raw } modify_gbe() @@ -309,21 +292,17 @@ modify_gbe() rom="${1}" _gbe_location=${CONFIG_GBE_BIN_PATH#../../} - [ -f "${_gbe_location}" ] || \ err "modify_gbe: CONFIG_GBE_BIN_PATH points to missing file" [ -f "${nvmutil}" ] || \ - make -C util/nvmutil || err "modify_gbe: couldn't build nvmutil" + x_ make -C util/nvmutil _gbe_tmp=$(mktemp -t gbeXXXX.bin) - cp "${_gbe_location}" "${_gbe_tmp}" - "${nvmutil}" "${_gbe_tmp}" setmac "${new_mac}" || \ - err "modify_gbe: ${board}: failed to modify mac address" - - "${ifdtool}" -i GbE:"${_gbe_tmp}" "${rom}" -O "${rom}" || \ - err "modify_gbe: ${board}: cannot insert modified gbe.bin" + x_ cp "${_gbe_location}" "${_gbe_tmp}" + x_ "${nvmutil}" "${_gbe_tmp}" setmac "${new_mac}" + x_ "${ifdtool}" -i GbE:"${_gbe_tmp}" "${rom}" -O "${rom}" - rm -f "${_gbe_tmp}" || err "modify_gbe: can't remove ${_gbe_tmp}" + x_ rm -f "${_gbe_tmp}" } usage() diff --git a/script/update/project/repo b/script/update/project/repo index c0cec1b6..71c3940c 100755 --- a/script/update/project/repo +++ b/script/update/project/repo @@ -23,11 +23,9 @@ main() clone_project [ "${depend}" = "" ] || for d in ${depend} ; do - ./update project repo ${d} || \ - fail "Cannot fetch dependency, ${d}, for project, ${name}" + xx_ ./update project repo ${d} done - - rm -Rf "${tmp_dir}" || fail "cannot remove tmpdir, ${tmp_dir}" + xx_ rm -Rf "${tmp_dir}" } verify_config() @@ -39,8 +37,8 @@ verify_config() clone_project() { - rm -Rf "${tmp_dir}" || fail "clone_project: cannot remove old tmpdir" - mkdir -p "${tmp_dir%/*}" || fail "clone_project: can't mkdir" + xx_ rm -Rf "${tmp_dir}" + xx_ mkdir -p "${tmp_dir%/*}" git clone ${url} "${tmp_dir}" || git clone ${bkup_url} "${tmp_dir}" || \ fail "clone_project: could not download ${name}" @@ -50,12 +48,9 @@ clone_project() fail "clone_project ${loc}/: cannot apply patches" [ ! -d "${loc}" ] || \ - rm -Rf "${loc}" || \ - fail "clone_project: Can't remove directory '${loc}'" - [ "${loc}" = "${loc%/*}" ] || mkdir -p ${loc%/*} || \ - fail "clone_project: cannot make directory for ${name}" - mv "${tmp_dir}" "${loc}" || \ - fail "clone_project: could not copy temp file to destination" + xx_ rm -Rf "${loc}" + [ "${loc}" = "${loc%/*}" ] || xx_ mkdir -p ${loc%/*} + xx_ mv "${tmp_dir}" "${loc}" } fail() diff --git a/script/update/project/trees b/script/update/project/trees index 1214ab21..d5d631b6 100755 --- a/script/update/project/trees +++ b/script/update/project/trees @@ -15,7 +15,7 @@ eval "$(setvars "" _target tree rev project cfgsdir)" main() { - rm -f "${cfgsdir}"/*/seen || err_rm_seen "main 1" + x_ rm -f "${cfgsdir}"/*/seen printf "Downloading %s and (if available) applying patches\n" \ ${project} @@ -32,11 +32,10 @@ main() err "No targets available for project: ${project}" for x in ${targets}; do - rm -f "${cfgsdir}"/*/seen || err_rm_seen "main 2" - download_for_target "${x}" || \ - err "${project}/${target}: cannot download source tree" + x_ rm -f "${cfgsdir}"/*/seen + x_ download_for_target "${x}" done - rm -f "${cfgsdir}"/*/seen || err_rm_seen "main 3" + x_ rm -f "${cfgsdir}"/*/seen } download_for_target() @@ -45,10 +44,8 @@ download_for_target() tree="undefined" rev="undefined" - fetch_config "${_target}" || \ - err "download_for_target: ${project}/${_target}: bad target.cfg" - - rm -f "${cfgsdir}"/*/seen || err_rm_seen "download_for_target" + x_ fetch_config "${_target}" + x_ rm -f "${cfgsdir}"/*/seen if [ -d "${project}/${tree}" ]; then printf "REMARK: download/%s %s: exists. Skipping.\n" \ @@ -60,8 +57,7 @@ download_for_target() fetch_from_upstream || \ err "download_for_target: cannot fetch: ${project}" - prepare_new_tree "${_target}" "${tree}" "${rev}" || \ - err "download_for_target: cannot create tree: ${project}/${tree}" + x_ prepare_new_tree "${_target}" "${tree}" "${rev}" } fetch_config() @@ -82,14 +78,16 @@ fetch_config() _target="${tree}" continue elif [ "${tree}" = "undefined" ]; then - printf "ERROR (fetch_config): download/%s:" 1>&2 + printf "ERROR (fetch_config): download/%s:" \ + "${project}" 1>&2 printf " tree name undefined for '%s\n'" \ - "${project}" "${_target}" 1>&2 + "${_target}" 1>&2 return 1 elif [ "${rev}" = "undefined" ]; then - printf "ERROR (fetch_config): download/%s:" 1>&2 + printf "ERROR (fetch_config): download/%s:" \ + "${project}" 1>&2 printf " commit ID undefined for '%s'\n" \ - "${project}" "${_target}" 1>&2 + "${_target}" 1>&2 return 1 else break @@ -114,8 +112,7 @@ check_config_for_target() 1>&2 return 1 fi - touch "${cfgsdir}/${_target}/seen" || \ - err "${project}/${_target}: touch \"${cfgsdir}/${_target}/seen\"" + x_ touch "${cfgsdir}/${_target}/seen" } fetch_from_upstream() @@ -137,26 +134,17 @@ prepare_new_tree() [ "${tree}" != "${target}" ] && \ printf "(for target, %s)\n" "${target}" - cp -R "${project}/${project}" "${project}/${tree}" || \ - err "${project}/${tree}: cannot copy source tree" - git_reset_rev "${project}/${tree}" "${rev}" "err" || \ - err "prepare_new_trees ${project}/${tree}: cannot reset <- ${rev}" + x_ cp -R "${project}/${project}" "${project}/${tree}" + x_ git_reset_rev "${project}/${tree}" "${rev}" "err" ( - cd "${project}/${tree}" || \ - err "prepare_new_tree: !cd \"${project}/${tree}\"" + x_ cd "${project}/${tree}" git submodule update --init --checkout || \ err "prepare_new_tree ${project}/${tree}: can't update git modules" ) - git_am_patches "${PWD}/${project}/${tree}" \ - "${PWD}/${cfgsdir}/${tree}/patches" "err" || \ - err "prepare_new_trees ${project}/${tree}: cannot apply patches" -} - -err_rm_seen() -{ - err "${1}: ${project}/${target}: cannot rm: \"${cfgsdir}/*/seen\"" + x_ git_am_patches "${PWD}/${project}/${tree}" \ + "${PWD}/${cfgsdir}/${tree}/patches" "err" } main $@ |