From: Ondrej Mosnacek <omosnace@xxxxxxxxxx> When generating the patches under $SINGLE_TARBALL == 0, cherry-pick each commit on top of $MARKER before generating the patch from it. This partly solves the problem of patches generated from old commits not applying on the current tree any more. To avoid polluting the current working copy, this is done in a temporary worktree inside a temporary directory, which is automatically deleted when the script exits. Signed-off-by: Ondrej Mosnacek <omosnace@xxxxxxxxxx> --- redhat/genspec.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/redhat/genspec.sh b/redhat/genspec.sh index b72dffe14729..c8f3b5fec698 100755 --- a/redhat/genspec.sh +++ b/redhat/genspec.sh @@ -23,7 +23,6 @@ TARFILE_RELEASE=${16} SNAPSHOT=${17} BUILDID=${18} RPMVERSION=${KVERSION}.${KPATCHLEVEL}.${KSUBLEVEL} -clogf="$SOURCES/changelog" # hide [redhat] entries from changelog HIDE_REDHAT=1; # hide entries for unsupported arches @@ -36,6 +35,20 @@ LC_TIME= STAMP=$(echo $MARKER | cut -f 1 -d '-' | sed -e "s/v//"); RPM_VERSION="$RPMVERSION-$PKGRELEASE"; +function cleanup() { + set +ex + [ -n "$tmpwt" ] && git worktree remove -f "$tmpwt" + [ -n "$tmpdir" ] && rm -rf "$tmpdir" + return 0 +} + +trap cleanup EXIT + +tmpdir="$(mktemp -d)" +clogf="$tmpdir/changelog" + +trap 'rm -rf $tmpdir' EXIT + echo >$clogf lasttag=$(git rev-list --first-parent --grep="^\[redhat\] kernel-${RPMVERSION}" --max-count=1 HEAD) @@ -255,7 +268,12 @@ if [ "$SINGLE_TARBALL" = 0 ]; then ":(exclude,top)makefile" \ ":(exclude,top)Makefile.rhelver" \ ":(exclude,top)redhat") - for c in $COMMITS; do + git worktree add --detach "$tmpdir/work" "$MARKER" + tmpwt="$tmpdir/work" + for origc in $COMMITS; do + git -C "$tmpwt" cherry-pick --allow-empty --keep-redundant-commits \ + "$origc" || exit 1 + c="$(git -C "$tmpwt" rev-parse --verify HEAD)" patch=$(git format-patch --zero-commit -1 "$c") echo "$patch" >> $plistf mv $patch $SOURCES/ @@ -274,5 +292,3 @@ for opt in $BUILDOPTS; do [ -z "${opt##-*}" ] && add_opt="_without_${opt#?}" [ -n "$add_opt" ] && sed -i "s/^\\(# The following build options\\)/%define $add_opt 1\\n\\1/" $SPECFILE done - -rm -f $clogf{,.rev,.stripped}; -- GitLab _______________________________________________ kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx