mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-08 17:49:07 +08:00
sync: add manual cherry-picking mode
This is sometimes necessary when we did ad-hoc urgent bug fixes, which are not identical to the ones in kernel. Signed-off-by: Andrii Nakryiko <andriin@fb.com>
This commit is contained in:
committed by
Andrii Nakryiko
parent
00ad180d07
commit
6227c6f8dd
@@ -3,7 +3,8 @@
|
|||||||
usage () {
|
usage () {
|
||||||
echo "USAGE: ./sync-kernel.sh <kernel-repo> <libbpf-repo> [<baseline-commit>]"
|
echo "USAGE: ./sync-kernel.sh <kernel-repo> <libbpf-repo> [<baseline-commit>]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "If <baseline-commit> is not specified, it's read from <libbpf-repo>/CHECKPOINT-COMMIT"
|
echo "If <baseline-commit> is not specified, it's read from <libbpf-repo>/CHECKPOINT-COMMIT."
|
||||||
|
echo "Set MANUAL_MODE envvar to 1 to manually control every cherry-picked commita."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,12 +96,14 @@ validate_merges()
|
|||||||
# $2 - tip_tag
|
# $2 - tip_tag
|
||||||
cherry_pick_commits()
|
cherry_pick_commits()
|
||||||
{
|
{
|
||||||
|
local manual_mode=${MANUAL_MODE:-0}
|
||||||
local baseline_tag=$1
|
local baseline_tag=$1
|
||||||
local tip_tag=$2
|
local tip_tag=$2
|
||||||
local new_commits
|
local new_commits
|
||||||
local signature
|
local signature
|
||||||
local should_skip
|
local should_skip
|
||||||
local synced_cnt
|
local synced_cnt
|
||||||
|
local manual_check
|
||||||
local desc
|
local desc
|
||||||
|
|
||||||
new_commits=$(git rev-list --no-merges --topo-order --reverse ${baseline_tag}..${tip_tag} ${LIBBPF_PATHS[@]})
|
new_commits=$(git rev-list --no-merges --topo-order --reverse ${baseline_tag}..${tip_tag} ${LIBBPF_PATHS[@]})
|
||||||
@@ -108,18 +111,24 @@ cherry_pick_commits()
|
|||||||
desc="$(commit_desc ${new_commit})"
|
desc="$(commit_desc ${new_commit})"
|
||||||
signature="$(commit_signature ${new_commit})"
|
signature="$(commit_signature ${new_commit})"
|
||||||
synced_cnt=$(grep -F "${signature}" ${TMP_DIR}/libbpf_commits.txt | wc -l)
|
synced_cnt=$(grep -F "${signature}" ${TMP_DIR}/libbpf_commits.txt | wc -l)
|
||||||
|
manual_check=0
|
||||||
if ((${synced_cnt} > 0)); then
|
if ((${synced_cnt} > 0)); then
|
||||||
# commit with the same subject is already in libbpf, but it's
|
# commit with the same subject is already in libbpf, but it's
|
||||||
# not 100% the same commit, so check with user
|
# not 100% the same commit, so check with user
|
||||||
echo "Commit '${desc}' is synced into libbpf as:"
|
echo "Commit '${desc}' is synced into libbpf as:"
|
||||||
grep -F "${signature}" ${TMP_DIR}/libbpf_commits.txt | \
|
grep -F "${signature}" ${TMP_DIR}/libbpf_commits.txt | \
|
||||||
cut -d'|' -f1 | sed -e 's/^/- /'
|
cut -d'|' -f1 | sed -e 's/^/- /'
|
||||||
if ((${synced_cnt} == 1)); then
|
if ((${manual_mode} != 1 && ${synced_cnt} == 1)); then
|
||||||
echo "Skipping '${desc}' due to unique match..."
|
echo "Skipping '${desc}' due to unique match..."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "'${desc} matches multiple commits, please, double-check!"
|
if ((${synced_cnt} > 1)); then
|
||||||
read -p "Do you want to skip it? [y/N]: " should_skip
|
echo "'${desc} matches multiple commits, please, double-check!"
|
||||||
|
manual_check=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if ((${manual_mode} == 1 || ${manual_check} == 1)); then
|
||||||
|
read -p "Do you want to skip '${desc}'? [y/N]: " should_skip
|
||||||
case "${should_skip}" in
|
case "${should_skip}" in
|
||||||
"y" | "Y")
|
"y" | "Y")
|
||||||
echo "Skipping '${desc}'..."
|
echo "Skipping '${desc}'..."
|
||||||
@@ -129,9 +138,8 @@ cherry_pick_commits()
|
|||||||
fi
|
fi
|
||||||
# commit hasn't been synced into libbpf yet
|
# commit hasn't been synced into libbpf yet
|
||||||
echo "Picking '${desc}'..."
|
echo "Picking '${desc}'..."
|
||||||
if ! git cherry-pick ${new_commit}; then
|
if ! git cherry-pick ${new_commit} &>/dev/null; then
|
||||||
read -p "Cherry-picking '${desc}' failed, \
|
read -p "Error! Cherry-picking '${desc}' failed, please fix manually and press <return> to proceed..."
|
||||||
please fix manually and press <return> to proceed..."
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user