From: Ondrej Mosnacek <omosnace(a)redhat.com>
redhat: properly handle binary files in patches
Pass --binary to git diff when generating the patch-*-redhat.patch in
genspec.sh, so that the patch is applicable also when there are diffs in
binary files.
Furthermore, since the `patch` utility doesn't support applying binary
diffs, switch the spec file to use `git apply` instead of `patch`. This
is OK, since the spec already has `BuildRequires: git-core`. In fact,
this means we can now remove `patch` from BuildRequires in favor of
`git-core`.
Signed-off-by: Ondrej Mosnacek <omosnace(a)redhat.com>
diff --git a/redhat/genspec.sh b/redhat/genspec.sh
index blahblah..blahblah 100755
--- a/redhat/genspec.sh
+++ b/redhat/genspec.sh
@@ -180,7 +180,7 @@ if [ "$DISTRO" == "fedora" ]; then
# May need to preserve word splitting in EXCLUDE_FILES
# shellcheck disable=SC2086
- git diff -p --no-renames --stat "$MARKER".. $EXCLUDE_FILES \
+ git diff -p --binary --no-renames --stat "$MARKER".. $EXCLUDE_FILES \
${SOURCES}/patch-${SPECKVERSION}.${SPECKPATCHLEVEL}-redhat.patch
else
# The tarball in the SRPM contains both upstream sources and OS-specifc
diff --git a/redhat/kernel.spec.template b/redhat/kernel.spec.template
index blahblah..blahblah 100755
--- a/redhat/kernel.spec.template
+++ b/redhat/kernel.spec.template
@@ -571,7 +571,7 @@ Requires: kernel-modules-uname-r = %{KVERREL}
#
# List the packages used during the kernel build
#
-BuildRequires: kmod, patch, bash, coreutils, tar, git-core, which
+BuildRequires: kmod, bash, coreutils, tar, git-core, which
BuildRequires: bzip2, xz, findutils, gzip, m4, perl-interpreter, perl-Carp, perl-devel,
perl-generators, make, diffutils, gawk
BuildRequires: gcc, binutils, redhat-rpm-config, hmaccalc, bison, flex, gcc-c++
BuildRequires: net-tools, hostname, bc, elfutils-devel
@@ -1387,7 +1387,7 @@ if [ "%{patches}" != "%%{patches}" ] ; then
done
fi 2>/dev/null
-patch_command='patch -p1 -F1 -s'
+patch_command='git apply'
ApplyPatch()
{
local patch=$1
--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1972