From 61419aae264069ed1f8bce34ad3a5cf7d26fcbae Mon Sep 17 00:00:00 2001 From: Andrii Nakryiko Date: Thu, 18 Apr 2019 15:24:21 -0700 Subject: [PATCH] sync-kernel.sh: detect synced commits, interactively resolve conflicts 1. There is one commit ("libbpf: fix btf_dedup equivalence check handling of different kinds"), which was originally committed into bpf tree and manually synced into libbpf (it was a critical bug fix). Now that bpf and bpf-next trees were merged, this causes duplicate commits in libbpf. To address this, check is added to see if libbpf repo already has a commit with the same subject and allow to skip it. 2. Just checking by subject is not good enough, as we currently have few different commits with the same subject "bpf: Sync bpf.h to tools/". To address this, script now will ask user whether to skip or cherry-pick commit. This allows for human to double-check the commit and make informed devision. 3. There is a commit ('bfb35c27c65f bpf: fix whitespace for ENCAP_L2 defines in bpf.h'), which modifies both include/uapi/linux/bpf.h and tools/include/uapi/linux/bpf.h in the same commit. This break the sync script, as it doesn't cherry-pick commits that hasn't modified libbpf files. So at the time that commit bfb35c27c65f is applied, linux repo is missing some preceding changes to include/uapi/linux/bpf.h. They would normally be ignored later during repo filtering, but to do cherry-pick they are necessary. It's hard to fix it automatically, so script will wait for user to resolve the issue and continue. Signed-off-by: Andrii Nakryiko --- scripts/sync-kernel.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/scripts/sync-kernel.sh b/scripts/sync-kernel.sh index 74d3342..68cec4a 100755 --- a/scripts/sync-kernel.sh +++ b/scripts/sync-kernel.sh @@ -77,9 +77,31 @@ for LIBBPF_NEW_MERGE in ${LIBBPF_NEW_MERGES}; do fi done +cd ${WORKDIR} && cd ${LIBBPF_REPO} +git log --oneline -n500 > ${TMP_DIR}/libbpf_commits.txt +cd ${WORKDIR} && cd ${LINUX_REPO} + LIBBPF_NEW_COMMITS=$(git rev-list --no-merges --topo-order --reverse ${BASELINE_TAG}..${TIP_TAG} ${LIBBPF_PATHS[@]}) for LIBBPF_NEW_COMMIT in ${LIBBPF_NEW_COMMITS}; do - git cherry-pick ${LIBBPF_NEW_COMMIT} + echo "Checking commit '${LIBBPF_NEW_COMMIT}'" + SYNCED_COMMITS=$(grep -F "$(git log -n1 --pretty=format:%s ${LIBBPF_NEW_COMMIT})" ${TMP_DIR}/libbpf_commits.txt || echo "") + if [ -n "${SYNCED_COMMITS}" ]; then + # commit with the same subject is already in libbpf, but it's not 100% the same commit, so check with user + echo "Commit '$(git log -n1 --oneline ${LIBBPF_NEW_COMMIT})' appears to be already synced into libbpf..." + echo "Corresponding libbpf commit(s):" + echo "${SYNCED_COMMITS}" + read -p "Do you want to skip it? [y/N]: " SHOULD_SKIP + case "${SHOULD_SKIP}" in + "y" | "Y") + echo "Skipping '$(git log -n1 --oneline ${LIBBPF_NEW_COMMIT})'..." + continue + ;; + esac + fi + # commit hasn't been synced into libbpf yet + if ! git cherry-pick ${LIBBPF_NEW_COMMIT}; then + read -p "Cherry-picking '$(git log --oneline -n1 ${LIBBPF_NEW_COMMIT})' failed, please fix manually and press to proceed..." + fi done LIBBPF_TREE_FILTER=' \