diff options
Diffstat (limited to 'include')
-rwxr-xr-x | include/git.sh | 50 | ||||
-rwxr-xr-x | include/mrc.sh | 26 | ||||
-rwxr-xr-x | include/option.sh | 11 |
3 files changed, 37 insertions, 50 deletions
diff --git a/include/git.sh b/include/git.sh index 7f926c28..ce7a2625 100755 --- a/include/git.sh +++ b/include/git.sh @@ -4,8 +4,7 @@ # This file is only used by update/project/trees -eval "$(setvars "" _target rev _xm)" -eval "$(setvars "" loc url bkup_url depend)" +eval "$(setvars "" _target rev _xm loc url bkup_url depend)" tmp_git_dir="${PWD}/tmp/gitclone" fetch_project_trees() @@ -16,8 +15,7 @@ fetch_project_trees() [ -z "${rev}" ] && err "fetch_project_trees $target: undefined rev" [ -d "src/${project}/${tree}" ] && \ printf "download/%s %s (%s): exists\n" \ - "${project}" "${tree}" "${_target}" 1>&2 && \ - return 1 + "${project}" "${tree}" "${_target}" 1>&2 && return 0 prepare_new_tree } @@ -26,12 +24,12 @@ fetch_from_upstream() [ -d "src/${project}/${project}" ] && return 0 x_ mkdir -p "src/${project}" - x_ fetch_project_repo "${project}" + fetch_project_repo "${project}" } fetch_config() { - x_ rm -f "${cfgsdir}/"*/seen + rm -f "${cfgsdir}/"*/seen || err "fetch_config ${cfgsdir}: !rm seen" while true; do eval "$(setvars "" rev tree)" _xm="fetch_config ${project}/${_target}" @@ -51,7 +49,7 @@ load_target_config() . "${cfgsdir}/${1}/target.cfg" || \ err "load_target_config ${cfgsdir}/${1}: cannot load config" - x_ touch "${cfgsdir}/${1}/seen" + touch "${cfgsdir}/${1}/seen" || err "load_config $cfgsdir/$1: !mk seen" } prepare_new_tree() @@ -59,14 +57,13 @@ prepare_new_tree() printf "Creating %s tree %s (%s)\n" "${project}" "${tree}" "${_target}" x_ cp -R "src/${project}/${project}" "src/${project}/${tree}" - x_ git_reset_rev "src/${project}/${tree}" "${rev}" + git_reset_rev "src/${project}/${tree}" "${rev}" ( x_ cd "src/${project}/${tree}" git submodule update --init --checkout || \ err "prepare_new_tree ${project}/${tree}: can't update git modules" ) - git_am_patches "${PWD}/src/${project}/${tree}" \ - "${PWD}/${cfgsdir}/${tree}/patches" + git_am_patches "$PWD/src/$project/$tree" "$PWD/$cfgsdir/$tree/patches" } fetch_project_repo() @@ -75,10 +72,10 @@ fetch_project_repo() verify_config clone_project - [ "${depend}" = "" ] || for d in ${depend} ; do - x_ ./update project trees -f ${d} + [ -z "${depend}" ] || for d in ${depend} ; do + x_ ./update trees -f ${d} done - x_ rm -Rf "${tmp_git_dir}" + rm -Rf "${tmp_git_dir}" || err "fetch_repo: !rm -Rf ${tmp_git_dir}" } verify_config() @@ -91,8 +88,9 @@ verify_config() clone_project() { - x_ rm -Rf "${tmp_git_dir}" - x_ mkdir -p "${tmp_git_dir%/*}" + rm -Rf "${tmp_git_dir}" || err "clone_project: !rm -Rf ${tmp_git_dir}" + mkdir -p "${tmp_git_dir%/*}" || \ + err "clone_project: !mkdir -p ${tmp_git_dir%/*}" loc="${loc#src/}" loc="src/${loc}" @@ -100,24 +98,20 @@ clone_project() git clone ${url} "${tmp_git_dir}" || \ git clone ${bkup_url} "${tmp_git_dir}" || \ err "clone_project: could not download ${project}" - git_reset_rev "${tmp_git_dir}" "${rev}" || \ - err "clone_project ${loc}/: cannot reset <- ${rev}" - git_am_patches "${tmp_git_dir}" "${PWD}/config/${project}/patches" || \ - err "clone_project ${loc}/: cannot apply patches" + git_reset_rev "${tmp_git_dir}" "${rev}" + git_am_patches "${tmp_git_dir}" "${PWD}/config/${project}/patches" x_ rm -Rf "${loc}" [ "${loc}" = "${loc%/*}" ] || x_ mkdir -p ${loc%/*} - x_ mv "${tmp_git_dir}" "${loc}" + mv "${tmp_git_dir}" "${loc}" || \ + err "clone_project: !mv ${tmp_git_dir} ${loc}" } git_reset_rev() { - sdir="${1}" - _rev="${2}" ( - x_ cd "${sdir}" - git reset --hard ${_rev} || \ - err "cannot git reset ${sdir} <- ${rev}" + cd "${1}" || err "git_reset_rev: !cd ${1}" + git reset --hard ${2} || err "!git reset ${1} <- ${2}" ) } @@ -126,7 +120,7 @@ git_am_patches() sdir="${1}" # assumed to be absolute path patchdir="${2}" # ditto ( - x_ cd "${sdir}" + cd "${sdir}" || err "git_am_patches: !cd ${sdir}" for patch in "${patchdir}/"*; do [ -L "${patch}" ] && continue [ -f "${patch}" ] || continue @@ -138,8 +132,6 @@ git_am_patches() ) for patches in "${patchdir}/"*; do [ -L "${patches}" ] && continue - [ ! -d "${patches}" ] || \ - git_am_patches "${sdir}" "${patches}" err || \ - err "apply_patches: !${sdir}/ ${patches}/" + [ -d "${patches}" ] && git_am_patches "${sdir}" "${patches}" done } diff --git a/include/mrc.sh b/include/mrc.sh index 4ff067a9..3c6ac24e 100755 --- a/include/mrc.sh +++ b/include/mrc.sh @@ -4,7 +4,7 @@ # Modifications in this version are Copyright 2021 and 2023 Leah Rowe. # Original copyright detailed in repo: https://review.coreboot.org/coreboot/ -eval "$(setvars "" MRC_url MRC_url_bkup MRC_hash MRC_board)" +eval "$(setvars "" MRC_url MRC_url_bkup MRC_hash MRC_board ROOTFS SHELLBALL)" extract_mrc() { @@ -12,14 +12,14 @@ extract_mrc() [ -z "${CONFIG_MRC_FILE}" ] && \ err "extract_mrc $MRC_hash: CONFIG_MRC_FILE not set" - _file="${MRC_url##*/}" - _file="${_file%.zip}" + ROOTFS="root-a.ext2" + SHELLBALL="chromeos-firmwareupdate-${MRC_board}" ( x_ cd "${appdir}" - extract_partition ROOT-A "${_file}" root-a.ext2 - extract_shellball root-a.ext2 chromeos-firmwareupdate-${MRC_board} - extract_coreboot chromeos-firmwareupdate-${MRC_board} + extract_partition + extract_shellball + extract_coreboot ) x_ "${cbfstool}" "${appdir}/"coreboot-*.bin extract -n mrc.bin \ @@ -28,9 +28,9 @@ extract_mrc() extract_partition() { - NAME=${1} - FILE=${2} - ROOTFS=${3} + NAME="ROOT-A" + FILE="${MRC_url##*/}" + FILE="${FILE%.zip}" _bs=1024 printf "Extracting ROOT-A partition\n" @@ -46,9 +46,6 @@ extract_partition() extract_shellball() { - ROOTFS=${1} - SHELLBALL=${2} - printf "Extracting chromeos-firmwareupdate\n" printf "cd /usr/sbin\ndump chromeos-firmwareupdate ${SHELLBALL}\nquit" \ | debugfs "${ROOTFS}" || err "extract_shellball: debugfs" @@ -56,13 +53,12 @@ extract_shellball() extract_coreboot() { - _shellball=${1} _unpacked=$( mktemp -d ) printf "Extracting coreboot image\n" - [ -f "${_shellball}" ] || \ + [ -f "${SHELLBALL}" ] || \ err "extract_coreboot: shellball missing in google cros image" - x_ sh "${_shellball}" --unpack "${_unpacked}" + x_ sh "${SHELLBALL}" --unpack "${_unpacked}" # TODO: audit the f* out of that shellball, for each mrc version. # it has to be updated for each mrc update. we should ideally diff --git a/include/option.sh b/include/option.sh index 991ec0dc..13137104 100755 --- a/include/option.sh +++ b/include/option.sh @@ -3,7 +3,7 @@ # SPDX-FileCopyrightText: 2022 Ferass El Hafidi <vitali64pmemail@protonmail.com> # SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org> -vendir="vendor" +vendir="vendorfiles" appdir="${vendir}/app" cbdir="src/coreboot/default" cbcfgsdir="config/coreboot" @@ -17,11 +17,11 @@ eval "$(setvars "" CONFIG_BOARD_DELL_E6400 CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN \ CONFIG_INCLUDE_SMSC_SCH5545_EC_FW CONFIG_SMSC_SCH5545_EC_FW_FILE \ CONFIG_IFD_BIN_PATH CONFIG_MRC_FILE _dest board boarddir)" -listitems() +items() { rval=1 [ ! -d "${1}" ] && \ - printf "listitems: directory '%s' doesn't exist" "${1}" && \ + printf "items: directory '%s' doesn't exist" "${1}" && \ return 1 for x in "${1}/"*; do # -e used because this is for files *or* directories @@ -62,13 +62,12 @@ check_defconfig() handle_coreboot_utils() { for util in cbfstool ifdtool; do - x_ ./update project trees ${_f} "src/coreboot/${1}/util/${util}" + x_ ./update trees ${_f} "src/coreboot/${1}/util/${util}" [ -z "${mode}" ] && [ ! -f "cbutils/${1}/${util}" ] && \ x_ mkdir -p "cbutils/${1}" && \ x_ cp "src/coreboot/${1}/util/${util}/${util}" \ "cbutils/${1}" - [ -z "${mode}" ] || \ - x_ rm -Rf "cbutils/${1}" + [ -z "${mode}" ] || x_ rm -Rf "cbutils/${1}" done } |