2024-10-29 05:12:06 +03:00
|
|
|
#!/bin/sh
|
|
|
|
set -ef
|
|
|
|
|
|
|
|
export GIT_OPTIONAL_LOCKS=0
|
|
|
|
|
|
|
|
w=$(git rev-parse --path-format=absolute --show-toplevel) ; : "${w:?}" ; cd "$w"
|
|
|
|
|
2024-11-15 10:44:41 +03:00
|
|
|
dst='debian/patches/pf-tmp'
|
2024-10-29 05:12:06 +03:00
|
|
|
src='../linux-extras'
|
2024-12-10 00:17:37 +03:00
|
|
|
branches='amd-pstate amd-rapl cpuidle crypto fixes kbuild pksm xfs zstd'
|
2024-10-29 05:12:06 +03:00
|
|
|
|
2024-11-15 10:44:41 +03:00
|
|
|
if [ -d "${dst}" ] ; then rm -rf "${dst}" ; fi
|
|
|
|
mkdir -p "${dst}"
|
2024-10-29 05:12:06 +03:00
|
|
|
|
|
|
|
kver=
|
|
|
|
if [ -n "$1" ] ; then
|
|
|
|
kver="$1"
|
|
|
|
else
|
|
|
|
kver=$(dpkg-parsechangelog --show-field=Version | sed -E 's/^[0-9]+://;s/-[^-]*$//' | cut -d. -f1-2)
|
|
|
|
fi
|
|
|
|
from="upstream/linux-${kver}.y"
|
|
|
|
|
|
|
|
t=$(mktemp -d) ; : "${t:?}"
|
|
|
|
|
|
|
|
cp -ar "${src}" "$t/"
|
|
|
|
cd "$t/${src##*/}"
|
|
|
|
|
|
|
|
git config advice.skippedCherryPicks false
|
|
|
|
|
|
|
|
for b in ${branches} ; do
|
|
|
|
ref="pf/$b-${kver}"
|
|
|
|
r="tmp-rebase-$b"
|
|
|
|
|
|
|
|
git switch --detach "${ref}"
|
|
|
|
git switch -C "$r"
|
|
|
|
|
|
|
|
if git rebase "${from}" ; then
|
|
|
|
[ -d "$w/${dst}/$b/" ] || mkdir -p "$w/${dst}/$b"
|
|
|
|
|
|
|
|
set +e
|
|
|
|
env -C "$w" git ls-files -z | grep -zF "${dst}/$b/" | grep -zFv '/.' | env -C "$w" -u GIT_OPTIONAL_LOCKS xargs -r -0 git rm -f
|
|
|
|
find "$w/${dst}/$b/" -name '*.patch' -type f -exec rm -f {} +
|
|
|
|
set -e
|
|
|
|
|
|
|
|
git format-patch -N --subject-prefix='' --output-directory "$w/${dst}/$b" "${from}..$r"
|
|
|
|
else
|
|
|
|
echo >&2
|
|
|
|
git rebase --abort
|
|
|
|
echo >&2
|
|
|
|
fi
|
|
|
|
|
|
|
|
git switch -q --detach "${ref}"
|
|
|
|
git branch -D "$r"
|
|
|
|
echo >&2
|
|
|
|
done
|
|
|
|
|
|
|
|
cd "$w" ; rm -rf "$t"
|
|
|
|
|
|
|
|
echo >&2
|
|
|
|
echo 'put in debian/patches/series' >&2
|
|
|
|
echo >&2
|
|
|
|
find "${dst}/" -type f -name '*.patch' | sed -E 's#^debian/patches/##' | sort -V
|