Lines Matching +full:commits +full:-
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 " - Update bpftool's version number based on bpf-next's kernel version and target commit."
12 echo " - Create a new commit with the updated version and checkpoints."
13 echo " - Check consistency."
15 …echo "Set BPF_NEXT_BASELINE to override bpf-next tree commit, otherwise read from <bpftool-repo>/C…
16 …PF_BASELINE to override bpf tree commit, otherwise read from <bpftool-repo>/BPF-CHECKPOINT-COMMIT."
17 …t BPF_NEXT_TIP_COMMIT to override bpf-next tree target commit, otherwise read from <bpftool-repo>/…
18 … override bpf tree target commit, otherwise read from <bpftool-repo>/libbpf/BPF-CHECKPOINT-COMMIT,…
20 echo "Set MANUAL_MODE to 1 to manually control every cherry-picked commit."
24 set -eu
26 BPFTOOL_REPO=${1-""}
27 LINUX_REPO=${2-""}
29 if [ -z "${BPFTOOL_REPO}" ] || [ -z "${LINUX_REPO}" ]; then
34 BASELINE_COMMIT=${BPF_NEXT_BASELINE:-$(cat ${BPFTOOL_REPO}/CHECKPOINT-COMMIT)}
35 BPF_BASELINE_COMMIT=${BPF_BASELINE:-$(cat ${BPFTOOL_REPO}/BPF-CHECKPOINT-COMMIT)}
37 if [ -z "${BASELINE_COMMIT}" ] || [ -z "${BPF_BASELINE_COMMIT}" ]; then
38 echo "Error: bpf or bpf-next baseline commits are not provided"
42 SUFFIX=$(date --utc +%Y-%m-%dT%H-%M-%S.%3NZ)
44 TMP_DIR=$(mktemp -d)
50 declare -A PATH_MAP
53 [${BPFTOOL_SRC_DIR}/bash-completion]=bash-completion \
57 [tools/include/uapi/asm-generic/bitsperlong.h]=include/uapi/asm-generic/bitsperlong.h \
74 # Deal with tools/bpf/bpftool first, because once we've mkdir-ed src/, command
77 BPFTOOL_TREE_FILTER+="git mv -kf ${BPFTOOL_SRC_DIR} __bpftool/${PATH_MAP[${BPFTOOL_SRC_DIR}]} && "$…
79 # Extract bash-completion and Documentation from src/.
80 BPFTOOL_TREE_FILTER+="git mv -kf __bpftool/src/bash-completion __bpftool/bash-completion && "$'\\\n'
81 BPFTOOL_TREE_FILTER+="git mv -kf __bpftool/src/Documentation __bpftool/docs && "$'\\\n'
83 BPFTOOL_TREE_FILTER+="mkdir -p __bpftool/include/uapi/asm-generic __bpftool/include/uapi/linux/tc_a…
89 BPFTOOL_TREE_FILTER+="git mv -kf ${p} __bpftool/${PATH_MAP[${p}]} && "$'\\\n'
98 # Output brief single-line commit description
99 # $1 - commit ref
102 git log -n1 --pretty='%h ("%s")' $1
105 # Create commit single-line signature, which consists of:
106 # - full commit subject
107 # - author date in ISO8601 format
108 # - full commit body with newlines replaced with vertical bars (|)
109 # - shortstat appended at the end
110 # The idea is that this single-line signature is good enough to make final
111 # decision about whether two commits are the same, across different repos.
112 # $1 - commit ref
113 # $2 - paths filter
116 git show --pretty='("%s")|%aI|%b' --shortstat $1 -- ${2-.} | tr '\n' '|'
119 # Cherry-pick commits touching bpftool-related files
120 # $1 - baseline_tag
121 # $2 - tip_tag
124 local manual_mode=${MANUAL_MODE:-0}
135 …new_commits=$(git rev-list --no-merges --topo-order --reverse ${baseline_tag}..${tip_tag} ${BPFTOO…
138 if git merge-base --is-ancestor "${new_commit}" "${BASELINE_COMMIT}"; then
139 echo "Commit ${new_commit::12} from bpf is already in bpf-next branch, skipping."
145 synced_cnt=$(grep -F "${signature}" ${TMP_DIR}/bpftool_commits.txt | wc -l)
151 grep -F "${signature}" ${TMP_DIR}/bpftool_commits.txt | \
152 cut -d'|' -f1 | sed -e 's/^/- /'
158 echo "'${desc} matches multiple commits, please, double-check!"
163 read -p "Do you want to skip '${desc}'? [y/N]: " should_skip
173 if ! git cherry-pick ${new_commit} &>/dev/null; then
174 …echo "Warning! Cherry-picking '${desc} failed, checking if it's non-bpftool files causing problems…
175 bpftool_conflict_cnt=$(git diff --name-only --diff-filter=U -- ${BPFTOOL_PATHS[@]} | wc -l)
176 conflict_cnt=$(git diff --name-only | wc -l)
180 echo "Looks like only non-bpftool files have conflicts, ignoring..."
182 echo "Empty cherry-pick, skipping it..."
183 git cherry-pick --abort
189 if ! GIT_EDITOR=true git cherry-pick --continue &>/dev/null; then
192 echo "Success! All cherry-pick conflicts were resolved for '${desc}'!"
198 …read -p "Error! Cherry-picking '${desc}' failed, please fix manually and press <return> to proceed…
201 # Append signature of just cherry-picked commit to avoid
202 # potentially cherry-picking the same commit twice later when
203 # processing bpf tree commits. At this point we don't know yet
206 echo LINUX_$(git log --pretty='%h' -n1) "${signature}" >> ${TMP_DIR}/bpftool_commits.txt
213 rm -r ${TMP_DIR}
216 git branch -D ${BASELINE_TAG} ${TIP_TAG} ${BPF_BASELINE_TAG} ${BPF_TIP_TAG} \
224 BPFTOOL_SYNC_TAG=bpftool-sync-${SUFFIX}
225 git checkout -b ${BPFTOOL_SYNC_TAG}
228 if [[ "${SKIP_LIBBPF_UPDATE:-0}" -ne 1 ]]; then
231 LIBBPF_VERSION=$(grep -oE '^LIBBPF_([0-9.]+)' src/libbpf.map | sort -rV | head -n1 | cut -d'_' -f2)
232 LIBBPF_COMMIT=$(git rev-parse HEAD)
234 if [[ -n "$(git status --porcelain --untracked-files=no)" ]]; then
236 git commit -m 'sync: Update libbpf submodule' \
237 -m "\
241 -- libbpf
246 TIP_COMMIT=${BPF_NEXT_TIP_COMMIT:-$(cat ${BPFTOOL_REPO}/libbpf/CHECKPOINT-COMMIT)}
247 BPF_TIP_COMMIT=${BPF_TIP_COMMIT:-$(cat ${BPFTOOL_REPO}/libbpf/BPF-CHECKPOINT-COMMIT)}
248 if [ -z "${TIP_COMMIT}" ] || [ -z "${BPF_TIP_COMMIT}" ]; then
249 echo "Error: bpf or bpf-next tip commits are not provided"
256 for h in $(git log --pretty='%h' -n500); do
263 TIP_SYM_REF=$(git symbolic-ref -q --short HEAD || git rev-parse HEAD)
264 BASELINE_TAG=bpftool-baseline-${SUFFIX}
265 TIP_TAG=bpftool-tip-${SUFFIX}
266 BPF_BASELINE_TAG=bpftool-bpf-baseline-${SUFFIX}
267 BPF_TIP_TAG=bpftool-bpf-tip-${SUFFIX}
268 VIEW_TAG=bpftool-view-${SUFFIX}
271 SQUASH_BASE_TAG=bpftool-squash-base-${SUFFIX}
272 SQUASH_TIP_TAG=bpftool-squash-tip-${SUFFIX}
273 SQUASH_COMMIT=$(git commit-tree ${BASELINE_COMMIT}^{tree} -m "BASELINE SQUASH ${BASELINE_COMMIT}")
300 git checkout -b ${SQUASH_TIP_TAG} ${SQUASH_COMMIT}
302 # Cherry-pick new commits onto squashed baseline commit
303 echo "Cherry-pick for bpf-next..."
305 echo "Cherry-pick for bpf..."
309 FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --prune-empty -f --tree-filter "${BPFTOOL_TREE_FI…
311 FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --prune-empty -f --subdirectory-filter __bpftool …
313 # If there are no new commits with bpftool-related changes, bail out
314 COMMIT_CNT=$(git rev-list --count ${SQUASH_BASE_TAG}..${SQUASH_TIP_TAG})
322 git format-patch ${SQUASH_BASE_TAG}..${SQUASH_TIP_TAG} --cover-letter -o ${TMP_DIR}/patches
325 git -c advice.detachedHead=false checkout ${TIP_COMMIT}
328 # Now is time to re-apply bpftool-related linux patches to bpftool repo
331 for patch in $(ls -1 ${TMP_DIR}/patches | tail -n +2); do
332 if ! git am --3way --committer-date-is-author-date "${TMP_DIR}/patches/${patch}"; then
333 …read -p "Applying ${TMP_DIR}/patches/${patch} failed, please resolve manually and press <return> t…
338 sed -i "s/^\(BPFTOOL_VERSION := \).*/\1${BPFTOOL_VERSION}/" src/Makefile
341 # Use generated cover-letter as a template for "sync commit" with
342 # baseline and checkpoint commits from kernel repo (and leave summary
344 echo ${TIP_COMMIT} > CHECKPOINT-COMMIT && \
345 echo ${BPF_TIP_COMMIT} > BPF-CHECKPOINT-COMMIT && \
346 git add CHECKPOINT-COMMIT && \
347 git add BPF-CHECKPOINT-COMMIT && \
348 awk '/\*\*\* BLURB HERE \*\*\*/ {p=1} p' ${TMP_DIR}/patches/0000-cover-letter.patch | \
352 Syncing latest bpftool commits from kernel repository.\n\
353 Baseline bpf-next commit: ${BASELINE_COMMIT}\n\
354 Checkpoint bpf-next commit: ${TIP_COMMIT}\n\
358 git commit --file=-
360 echo "SUCCESS! ${COMMIT_CNT} commits synced."
365 git checkout -b ${VIEW_TAG} ${TIP_COMMIT}
366 FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch -f --tree-filter "${BPFTOOL_TREE_FILTER}" ${VIEW_…
367 FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch -f --subdirectory-filter __bpftool ${VIEW_TAG}^..…
368 git ls-files -- ${BPFTOOL_VIEW_PATHS[@]} | grep -v -E "${LINUX_VIEW_EXCLUDE_REGEX}" > ${TMP_DIR}/li…
371 git ls-files -- ${BPFTOOL_VIEW_PATHS[@]} | grep -v -E "${BPFTOOL_VIEW_EXCLUDE_REGEX}" > ${TMP_DIR}/…
374 diff -u ${TMP_DIR}/linux-view.ls ${TMP_DIR}/github-view.ls
377 for F in $(cat ${TMP_DIR}/linux-view.ls); do
378 if ! diff -u --color "${LINUX_ABS_DIR}/${F}" "${GITHUB_ABS_DIR}/${F}"; then
388 read -p "Does everything look good? [y/N]: " ignore_inconsistency