From cd2caecb739bb2c20f25780c17813bc70cd2b29a Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 2 Oct 2023 04:53:22 +0100 Subject: update/project/trees: general code cleanup reduced sloccount, without reducing functionality Signed-off-by: Leah Rowe --- script/update/project/trees | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'script') diff --git a/script/update/project/trees b/script/update/project/trees index de01a942..c5b40dc0 100755 --- a/script/update/project/trees +++ b/script/update/project/trees @@ -42,16 +42,12 @@ download_for_target() x_ fetch_config "${_target}" if [ -d "${project}/${tree}" ]; then - printf "REMARK: download/%s %s: exists. Skipping.\n" \ - "${project}" "${tree}" 1>&2 - [ "${tree}" != "${_target}" ] && \ - printf "(for target: '%s}')\n" "${_target}" 1>&2 - return 0 + printf "REMARK: download/%s %s (%s): exists. Skipping.\n" \ + "${project}" "${tree}" "${_target}" 1>&2 + else + x_ fetch_from_upstream "${project}" + x_ prepare_new_tree "${_target}" "${tree}" "${rev}" fi - - fetch_from_upstream || \ - err "download_for_target: cannot fetch: ${project}" - x_ prepare_new_tree "${_target}" "${tree}" "${rev}" } fetch_config() @@ -111,11 +107,11 @@ check_config_for_target() fetch_from_upstream() { - [ -d "${project}" ] || mkdir -p "${project}" || return 1 - [ -d "${project}" ] || return 1 - [ -d "${project}/${project}" ] && return 0 + [ -d "${1}" ] || mkdir -p "${1}" || return 1 + [ -d "${1}" ] || return 1 + [ -d "${1}/${1}" ] && return 0 - ./update project repo ${project} || return 1 + ./update project repo ${1} || return 1 } prepare_new_tree() @@ -124,19 +120,15 @@ prepare_new_tree() tree=${2} rev=${3} - printf "Preparing %s tree: %s\n" ${project} ${tree} - [ "${tree}" != "${target}" ] && \ - printf "(for target, %s)\n" "${target}" + printf "Preparing %s tree %s (%s)\n" "${project}" "${tree}" "${target}" x_ cp -R "${project}/${project}" "${project}/${tree}" x_ git_reset_rev "${project}/${tree}" "${rev}" "err" - ( x_ cd "${project}/${tree}" git submodule update --init --checkout || \ err "prepare_new_tree ${project}/${tree}: can't update git modules" ) - x_ git_am_patches "${PWD}/${project}/${tree}" \ "${PWD}/${cfgsdir}/${tree}/patches" "err" } -- cgit v1.2.1