update/project/trees: general code cleanup

reduced sloccount, without reducing functionality

Signed-off-by: Leah Rowe <leah@libreboot.org>
btrfsvols
Leah Rowe 2023-10-02 04:53:22 +01:00
parent bcbd3734b3
commit cd2caecb73
1 changed files with 10 additions and 18 deletions

View File

@ -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"
}