update/project/*: unified patch handling
Handle patches by a function at include/git.sh Signed-off-by: Leah Rowe <leah@libreboot.org>btrfsvols
parent
cd3225d845
commit
3738ec90ec
|
@ -0,0 +1,21 @@
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
|
||||||
|
|
||||||
|
git_am_patches()
|
||||||
|
{
|
||||||
|
sdir="${1}" # assumed to be absolute path
|
||||||
|
patchdir="${2}" # ditto
|
||||||
|
_fail="${3}"
|
||||||
|
(
|
||||||
|
cd "${sdir}" || \
|
||||||
|
"${_fail}" "apply_patches: !cd \"${sdir}\""
|
||||||
|
for patch in "${patchdir}/"*; do
|
||||||
|
[ -L "${patch}" ] && continue
|
||||||
|
[ -f "${patch}" ] || continue
|
||||||
|
if ! git am "${patch}"; then
|
||||||
|
git am --abort || "${_fail}" "${sdir}: !git am --abort"
|
||||||
|
"${_fail}" "!git am ${patch} -> ${sdir}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
)
|
||||||
|
}
|
|
@ -5,13 +5,14 @@
|
||||||
# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
|
# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
|
||||||
|
|
||||||
. "include/err.sh"
|
. "include/err.sh"
|
||||||
|
. "include/git.sh"
|
||||||
|
|
||||||
name=""
|
name=""
|
||||||
revision=""
|
revision=""
|
||||||
location=""
|
location=""
|
||||||
url=""
|
url=""
|
||||||
bkup_url=""
|
bkup_url=""
|
||||||
tmp_dir="tmp/gitclone"
|
tmp_dir="${PWD}/tmp/gitclone"
|
||||||
depend=""
|
depend=""
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
@ -83,7 +84,8 @@ clone_project()
|
||||||
git reset --hard ${revision} || \
|
git reset --hard ${revision} || \
|
||||||
fail "clone_project: Cannot reset 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}" ] || \
|
[ ! -d "${location}" ] || \
|
||||||
rm -Rf "${location}" || \
|
rm -Rf "${location}" || \
|
||||||
|
@ -94,20 +96,6 @@ clone_project()
|
||||||
fail "clone_project: could not copy temp file to destination"
|
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()
|
fail()
|
||||||
{
|
{
|
||||||
for x in "${location}" "${tmp_dir}"; do
|
for x in "${location}" "${tmp_dir}"; do
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
set -u -e
|
set -u -e
|
||||||
|
|
||||||
. "include/err.sh"
|
. "include/err.sh"
|
||||||
|
. "include/git.sh"
|
||||||
|
|
||||||
_target=""
|
_target=""
|
||||||
tree=""
|
tree=""
|
||||||
|
@ -148,16 +149,10 @@ prepare_new_tree()
|
||||||
err "cannot reset ${project} revision for tree, ${tree}"
|
err "cannot reset ${project} revision for tree, ${tree}"
|
||||||
git submodule update --init --checkout || \
|
git submodule update --init --checkout || \
|
||||||
err "cannot update ${project} submodules for tree, ${tree}"
|
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()
|
err_rm_seen()
|
||||||
|
|
Loading…
Reference in New Issue