From 48551ced3fea58322e996ca78652ceafb4b9a041 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 1 Jan 2024 15:02:34 +0000 Subject: git.sh: unify am/submodule and tree copying do it all in a single function! Signed-off-by: Leah Rowe --- include/git.sh | 42 ++++++++++++++++++++++-------------------- include/option.sh | 2 +- 2 files changed, 23 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/include/git.sh b/include/git.sh index 5c238718..7e677939 100755 --- a/include/git.sh +++ b/include/git.sh @@ -58,13 +58,9 @@ prepare_new_tree() { printf "Creating %s tree %s (%s)\n" "$project" "$tree" "$_target" - cp -R "src/${project}/${project}" "${tmp_git_dir}" || \ + cp -R "src/${project}/${project}" "${tmpgit}" || \ err "prepare_new_tree ${project}/${tree}: can't make tmpclone" - git_patch "$tmp_git_dir" "$PWD/$cfgsdir/$tree/patches" - git_submodule_update "${tmp_git_dir}" - - mv "${tmp_git_dir}" "src/${project}/${tree}" || \ - err "prepare_new_tree ${project}/${tree}: can't copy tmpclone" + git_prep "$PWD/$cfgsdir/$tree/patches" "src/$project/$tree" "update" } fetch_project_repo() @@ -76,7 +72,7 @@ fetch_project_repo() [ -z "${depend}" ] || for d in ${depend} ; do x_ ./update trees -f ${d} done - rm -Rf "${tmp_git_dir}" || err "fetch_repo: !rm -Rf ${tmp_git_dir}" + rm -Rf "${tmpgit}" || err "fetch_repo: !rm -Rf ${tmpgit}" } verify_config() @@ -95,23 +91,29 @@ clone_project() return 0 fi - git clone ${url} "${tmp_git_dir}" || \ - git clone ${bkup_url} "${tmp_git_dir}" || \ - err "clone_project: could not download ${project}" - git_patch "${tmp_git_dir}" "${PWD}/config/${project}/patches" - - x_ rm -Rf "${loc}" - [ "${loc}" = "${loc%/*}" ] || x_ mkdir -p "${loc%/*}" - mv "${tmp_git_dir}" "${loc}" || \ - err "clone_project: !mv ${tmp_git_dir} ${loc}" + git clone $url "$tmpgit" || git clone $bkup_url "$tmpgit" \ + || err "clone_project: could not download ${project}" + git_prep "$PWD/config/$project/patches" "$loc" } -git_patch() +git_prep() { - git -C "${1}" reset --hard ${rev} || err "!git reset ${1} <- ${rev}" - git_am_patches "$1" "$2" || err "git_patch $project $1 $2: patch fail" + _patchdir="$1" + _loc="$2" + + git -C "$tmpgit" reset --hard $rev || \ + err "!git -C $_patchdir reset $rev" + git_am_patches "$tmpgit" "$_patchdir" || \ + err "git_prep $project $_patchdir: patchfail" + [ "$project" != "coreboot" ] && [ "$project" != "u-boot" ] && \ - git_submodule_update "${1}"; return 0 + git_submodule_update "$tmpgit" + [ $# -gt 2 ] && git_submodule_update "$tmpgit" + + rm -Rf "$_loc" || err "git_prep: !rm -Rf $_loc" + [ "$_loc" = "${_loc%/*}" ] || x_ mkdir -p "${_loc%/*}" + mv "$tmpgit" "$_loc" || \ + err "git_prep $project $_patchdir: !mv $tmpgit $_loc" } git_submodule_update() diff --git a/include/option.sh b/include/option.sh index 66b89d4c..2136cf4d 100755 --- a/include/option.sh +++ b/include/option.sh @@ -12,7 +12,7 @@ cbfstool="cbutils/default/cbfstool" grubcfgsdir="config/grub" layoutdir="/boot/grub/layouts" . "${grubcfgsdir}/modules.list" -tmp_git_dir="${PWD}/tmp/gitclone" +tmpgit="${PWD}/tmp/gitclone" eval "$(setvars "" CONFIG_BOARD_DELL_E6400 CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN \ CONFIG_ME_BIN_PATH CONFIG_KBC1126_FIRMWARE CONFIG_KBC1126_FW1 \ -- cgit v1.2.1