Lines Matching +full:cherry +full:- +full:pick
4 echo "USAGE: ./sync-kernel.sh <bpftool-repo> <kernel-repo>"
8 …echo " - Update the libbpf submodule, commit, and use its new checkpoints as target commits for b…
9 echo " - Cherry-pick commits from the bpf-next branch, up to the bpf-next target commit."
10 echo " - Cherry-pick commits from the bpf branch, up to the bpf target commit."
11 echo " - Create a new commit with the updated version and checkpoints."
12 echo " - Check consistency."
14 …echo "Set BPF_NEXT_BASELINE to override bpf-next tree commit, otherwise read from <bpftool-repo>/C…
15 …PF_BASELINE to override bpf tree commit, otherwise read from <bpftool-repo>/BPF-CHECKPOINT-COMMIT."
16 …t BPF_NEXT_TIP_COMMIT to override bpf-next tree target commit, otherwise read from <bpftool-repo>/…
17 … override bpf tree target commit, otherwise read from <bpftool-repo>/libbpf/BPF-CHECKPOINT-COMMIT,…
19 echo "Set MANUAL_MODE to 1 to manually control every cherry-picked commit."
23 set -eu
25 BPFTOOL_REPO=${1-""}
26 LINUX_REPO=${2-""}
28 if [ -z "${BPFTOOL_REPO}" ] || [ -z "${LINUX_REPO}" ]; then
33 BASELINE_COMMIT=${BPF_NEXT_BASELINE:-$(cat "${BPFTOOL_REPO}"/CHECKPOINT-COMMIT)}
34 BPF_BASELINE_COMMIT=${BPF_BASELINE:-$(cat "${BPFTOOL_REPO}"/BPF-CHECKPOINT-COMMIT)}
36 if [ -z "${BASELINE_COMMIT}" ] || [ -z "${BPF_BASELINE_COMMIT}" ]; then
37 echo "Error: bpf or bpf-next baseline commits are not provided"
41 SUFFIX=$(date --utc +%Y-%m-%dT%H-%M-%S.%3NZ)
43 TMP_DIR=$(mktemp -d)
50 declare -A PATH_MAP
53 [${BPFTOOL_SRC_DIR}/bash-completion]=bash-completion \
57 [tools/include/tools/dis-asm-compat.h]=include/tools/dis-asm-compat.h \
58 [tools/include/uapi/asm-generic/bitsperlong.h]=include/uapi/asm-generic/bitsperlong.h \
76 # Deal with tools/bpf/bpftool first, because once we've mkdir-ed src/, command
79 BPFTOOL_TREE_FILTER+="git mv -kf ${BPFTOOL_SRC_DIR} __bpftool/${PATH_MAP[${BPFTOOL_SRC_DIR}]} && "$…
81 # Extract bash-completion and Documentation from src/.
82 BPFTOOL_TREE_FILTER+="git mv -kf __bpftool/src/bash-completion __bpftool/bash-completion && "$'\\\n'
83 BPFTOOL_TREE_FILTER+="git mv -kf __bpftool/src/Documentation __bpftool/docs && "$'\\\n'
85 BPFTOOL_TREE_FILTER+="mkdir -p __bpftool/include/tools __bpftool/include/uapi/asm-generic __bpftool…
91 BPFTOOL_TREE_FILTER+="git mv -kf ${p} __bpftool/${PATH_MAP[${p}]} && "$'\\\n'
100 # Output brief single-line commit description
101 # $1 - commit ref
104 git log -n1 --pretty='%h ("%s")' "$1"
107 # Create commit single-line signature, which consists of:
108 # - full commit subject
109 # - author date in ISO8601 format
110 # - full commit body with newlines replaced with vertical bars (|)
111 # - shortstat appended at the end
112 # The idea is that this single-line signature is good enough to make final
114 # $1 - commit ref
115 # $2 - paths filter
119 git show --pretty='("%s")|%aI|%b' --shortstat "$1" -- ${2-.} | tr '\n' '|'
122 # Cherry-pick commits touching bpftool-related files
123 # $1 - baseline_tag
124 # $2 - tip_tag
127 local manual_mode=${MANUAL_MODE:-0}
139 …new_commits=$(git rev-list --no-merges --topo-order --reverse "${baseline_tag}".."${tip_tag}" ${BP…
142 if git merge-base --is-ancestor "${new_commit}" "${BASELINE_COMMIT}"; then
143 echo "Commit ${new_commit::12} from bpf is already in bpf-next branch, skipping."
150 synced_cnt=$(grep -F "${signature}" "${TMP_DIR}"/bpftool_commits.txt | wc -l)
156 grep -F "${signature}" "${TMP_DIR}"/bpftool_commits.txt | \
157 cut -d'|' -f1 | sed -e 's/^/- /'
163 echo "'${desc} matches multiple commits, please, double-check!"
168 read -rp "Do you want to skip '${desc}'? [y/N]: " should_skip
178 if ! git cherry-pick "${new_commit}" &>/dev/null; then
179 …echo "Warning! Cherry-picking '${desc} failed, checking if it's non-bpftool files causing problems…
181 bpftool_conflict_cnt=$(git diff --name-only --diff-filter=U -- ${BPFTOOL_PATHS[@]} | wc -l)
182 conflict_cnt=$(git diff --name-only | wc -l)
186 echo "Looks like only non-bpftool files have conflicts, ignoring..."
188 echo "Empty cherry-pick, skipping it..."
189 git cherry-pick --abort
195 if ! GIT_EDITOR=true git cherry-pick --continue &>/dev/null; then
198 echo "Success! All cherry-pick conflicts were resolved for '${desc}'!"
204 …read -rp "Error! Cherry-picking '${desc}' failed, please fix manually and press <return> to procee…
207 # Append signature of just cherry-picked commit to avoid
208 # potentially cherry-picking the same commit twice later when
212 echo "LINUX_$(git log --pretty='%h' -n1) ${signature}" >> "${TMP_DIR}"/bpftool_commits.txt
219 rm -r -- "${TMP_DIR}"
222 git branch -D "${BASELINE_TAG}" "${TIP_TAG}" "${BPF_BASELINE_TAG}" "${BPF_TIP_TAG}" \
225 git show-ref --verify --quiet refs/heads/"${VIEW_TAG}" && \
226 git branch -D "${VIEW_TAG}" || true
233 BPFTOOL_SYNC_TAG="bpftool-sync-${SUFFIX}"
234 git checkout -b "${BPFTOOL_SYNC_TAG}"
237 if [[ "${SKIP_LIBBPF_UPDATE:-0}" -ne 1 ]]; then
240 LIBBPF_VERSION=$(grep -oE '^LIBBPF_([0-9.]+)' src/libbpf.map | sort -rV | head -n1 | cut -d'_' -f2)
241 LIBBPF_COMMIT=$(git rev-parse HEAD)
243 if [[ -n "$(git status --porcelain --untracked-files=no)" ]]; then
245 git commit --signoff -m 'sync: Update libbpf submodule' \
246 -m "\
250 -- libbpf
255 TIP_COMMIT=${BPF_NEXT_TIP_COMMIT:-$(cat "${BPFTOOL_REPO}"/libbpf/CHECKPOINT-COMMIT)}
256 BPF_TIP_COMMIT=${BPF_TIP_COMMIT:-$(cat "${BPFTOOL_REPO}"/libbpf/BPF-CHECKPOINT-COMMIT)}
257 if [ -z "${TIP_COMMIT}" ] || [ -z "${BPF_TIP_COMMIT}" ]; then
258 echo "Error: bpf or bpf-next tip commits are not provided"
265 for h in $(git log --pretty='%h' -n500); do
272 TIP_SYM_REF=$(git symbolic-ref -q --short HEAD || git rev-parse HEAD)
273 BASELINE_TAG="bpftool-baseline-${SUFFIX}"
274 TIP_TAG="bpftool-tip-${SUFFIX}"
275 BPF_BASELINE_TAG="bpftool-bpf-baseline-${SUFFIX}"
276 BPF_TIP_TAG="bpftool-bpf-tip-${SUFFIX}"
277 VIEW_TAG="bpftool-view-${SUFFIX}"
280 SQUASH_BASE_TAG="bpftool-squash-base-${SUFFIX}"
281 SQUASH_TIP_TAG="bpftool-squash-tip-${SUFFIX}"
282 SQUASH_COMMIT=$(git commit-tree "${BASELINE_COMMIT}^{tree}" -m "BASELINE SQUASH ${BASELINE_COMMIT}")
309 git checkout -b "${SQUASH_TIP_TAG}" "${SQUASH_COMMIT}"
311 # Cherry-pick new commits onto squashed baseline commit
312 echo "Cherry-pick for bpf-next..."
314 echo "Cherry-pick for bpf..."
318 FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --prune-empty -f --tree-filter "${BPFTOOL_TREE_FI…
320 FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --prune-empty -f --subdirectory-filter __bpftool …
322 # If there are no new commits with bpftool-related changes, bail out
323 COMMIT_CNT=$(git rev-list --count "${SQUASH_BASE_TAG}".."${SQUASH_TIP_TAG}")
331 git format-patch --no-signature "${SQUASH_BASE_TAG}".."${SQUASH_TIP_TAG}" --cover-letter -o "${TMP_…
333 # Now is time to re-apply bpftool-related linux patches to bpftool repo
337 for patch in $(ls -1 "${TMP_DIR}"/patches | tail -n +2); do
338 if ! git am --3way --committer-date-is-author-date "${TMP_DIR}/patches/${patch}"; then
339 …read -rp "Applying ${TMP_DIR}/patches/${patch} failed, please resolve manually and press <return> …
343 # Use generated cover-letter as a template for "sync commit" with
346 echo "${TIP_COMMIT}" > CHECKPOINT-COMMIT && \
347 echo "${BPF_TIP_COMMIT}" > BPF-CHECKPOINT-COMMIT && \
348 git add CHECKPOINT-COMMIT && \
349 git add BPF-CHECKPOINT-COMMIT && \
350 awk '/\*\*\* BLURB HERE \*\*\*/ {p=1} p' "${TMP_DIR}"/patches/0000-cover-letter.patch | \
355 Baseline bpf-next commit: ${BASELINE_COMMIT}\n\
356 Checkpoint bpf-next commit: ${TIP_COMMIT}\n\
359 git commit --signoff --file=-
366 git checkout -b "${VIEW_TAG}" "${TIP_COMMIT}"
367 FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch -f --tree-filter "${BPFTOOL_TREE_FILTER}" "${VIEW…
368 FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch -f --subdirectory-filter __bpftool "${VIEW_TAG}"^…
370 git ls-files -- ${BPFTOOL_VIEW_PATHS[@]} | grep -v -E "${LINUX_VIEW_EXCLUDE_REGEX}" > "${TMP_DIR}"/…
376 patch -d "${LINUX_ABS_DIR}" -p0 -f --reject-file=- --no-backup-if-mismatch < "${GITHUB_ABS_DIR}/scr…
377 git add -u
378 git commit -m 'tmp: apply expected differences to compare github/kernel repos' || true
382 git ls-files -- ${BPFTOOL_VIEW_PATHS[@]} | grep -v -E "${BPFTOOL_VIEW_EXCLUDE_REGEX}" > "${TMP_DIR}…
385 diff -u "${TMP_DIR}"/linux-view.ls "${TMP_DIR}"/github-view.ls
388 while IFS= read -r F; do
389 if ! diff -u --color "${LINUX_ABS_DIR}/${F}" "${GITHUB_ABS_DIR}/${F}"; then
393 done < "${TMP_DIR}"/linux-view.ls
400 echo "Some of them may come from patches in bpf tree but absent from bpf-next."
401 echo "Note: I applied scripts/sync-kernel-expected-diff.patch before checking,"
404 echo "------"
405 echo " (cd \"${LINUX_ABS_DIR}\" && git -c advice.detachedHead=false checkout HEAD~)"
406 echo " for f in \$(cat \"${TMP_DIR}/linux-view.ls\"); do"
407 echo " diff -u --label \"\${f}\" --label \"\${f}\" \\"
410 echo " done > \"${GITHUB_ABS_DIR}/scripts/sync-kernel-expected-diff.patch\""
411 echo "------"
412 read -rp "Does everything look good? [y/N]: " ignore_inconsistency