summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2024-01-01 15:02:34 +0000
committerLeah Rowe <leah@libreboot.org>2024-01-01 15:21:46 +0000
commit48551ced3fea58322e996ca78652ceafb4b9a041 (patch)
treec3b56d549120a22e229479c68754917189f0f677
parentce67c99f4070193a0e71906451c61d377601ded6 (diff)
git.sh: unify am/submodule and tree copying
do it all in a single function! Signed-off-by: Leah Rowe <leah@libreboot.org>
-rwxr-xr-xinclude/git.sh42
-rwxr-xr-xinclude/option.sh2
-rwxr-xr-xscript/update/trees2
3 files changed, 24 insertions, 22 deletions
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 \
diff --git a/script/update/trees b/script/update/trees
index fac37ccd..e4db1872 100755
--- a/script/update/trees
+++ b/script/update/trees
@@ -37,7 +37,7 @@ main()
elfdir="elf/${project}"
cfgsdir="config/${project}"
- remkdir "${tmp_git_dir%/*}"
+ remkdir "${tmpgit%/*}"
check_project
_cmd="build_projects"