From 3738ec90ec1728bb805d84cd8b1a68c7c31d06e4 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 25 Sep 2023 11:37:35 +0100 Subject: update/project/*: unified patch handling Handle patches by a function at include/git.sh Signed-off-by: Leah Rowe --- script/update/project/repo | 20 ++++---------------- script/update/project/trees | 13 ++++--------- 2 files changed, 8 insertions(+), 25 deletions(-) (limited to 'script/update') diff --git a/script/update/project/repo b/script/update/project/repo index 20e8d905..d6eb3130 100755 --- a/script/update/project/repo +++ b/script/update/project/repo @@ -5,13 +5,14 @@ # SPDX-FileCopyrightText: 2023 Leah Rowe . "include/err.sh" +. "include/git.sh" name="" revision="" location="" url="" bkup_url="" -tmp_dir="tmp/gitclone" +tmp_dir="${PWD}/tmp/gitclone" depend="" main() @@ -83,7 +84,8 @@ clone_project() git reset --hard ${revision} || \ fail "clone_project: Cannot reset revision" ) - patch_project + git_am_patches "${tmp_dir}" "${PWD}/config/${name}/patches" "fail" || \ + fail "clone_project ${location}/: cannot apply patches" [ ! -d "${location}" ] || \ rm -Rf "${location}" || \ @@ -94,20 +96,6 @@ clone_project() fail "clone_project: could not copy temp file to destination" } -patch_project() -{ - patchdir="config/${name}/patches" - - for patchfile in "${PWD}/${patchdir}"/*.patch ; do - [ -f "${patchfile}" ] || continue - ( - cd "${tmp_dir}" || fail "patch_project: tmpdir unavailable" - git am "${patchfile}" || \ - fail "patch_project: Cannot patch project: $name" - ) - done -} - fail() { for x in "${location}" "${tmp_dir}"; do diff --git a/script/update/project/trees b/script/update/project/trees index 6ce53250..27418f19 100755 --- a/script/update/project/trees +++ b/script/update/project/trees @@ -8,6 +8,7 @@ set -u -e . "include/err.sh" +. "include/git.sh" _target="" tree="" @@ -148,16 +149,10 @@ prepare_new_tree() err "cannot reset ${project} revision for tree, ${tree}" git submodule update --init --checkout || \ err "cannot update ${project} submodules for tree, ${tree}" - - for patch in "../../${cfgsdir}/${tree}/patches/"*.patch; do - [ -f "${patch}" ] || continue - if ! git am "${patch}"; then - git am --abort || \ - err "${project}/${tree}: FAILED: git am --abort" - err "cannot patch: ${project}/${tree}" - fi - done ) + git_am_patches "${PWD}/${project}/${tree}" \ + "${PWD}/${cfgsdir}/${tree}/patches" "err" || \ + err "prepare_new_trees ${project}/${tree}: cannot apply patches" } err_rm_seen() -- cgit v1.2.1