summaryrefslogtreecommitdiffstats
path: root/kernel.spec
diff options
context:
space:
mode:
authorLaura Abbott <labbott@redhat.com>2019-10-31 17:01:08 -0400
committerLaura Abbott <labbott@redhat.com>2019-11-01 16:18:24 -0400
commitb8d58e29083fa8374b4b37e0b5e032ec29104869 (patch)
treeb07d875c55e65ef1a0842c81954a789fa340700e /kernel.spec
parent22f43b4c88e8a9d0f5f5f5dffac481c650dd3d52 (diff)
downloadkernel-b8d58e29083fa8374b4b37e0b5e032ec29104869.tar.gz
kernel-b8d58e29083fa8374b4b37e0b5e032ec29104869.tar.xz
kernel-b8d58e29083fa8374b4b37e0b5e032ec29104869.zip
Bring back ApplyPatch and ApplyOptionalPatch macros
These are not used directly in Fedora but for easy of syncing let's keep them around.
Diffstat (limited to 'kernel.spec')
-rw-r--r--kernel.spec36
1 files changed, 36 insertions, 0 deletions
diff --git a/kernel.spec b/kernel.spec
index 929d7eb0c..d2b44e420 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -1057,6 +1057,42 @@ if [ "%{patches}" != "%%{patches}" ] ; then
done
fi 2>/dev/null
+patch_command='patch -p1 -F1 -s'
+ApplyPatch()
+{
+ local patch=$1
+ shift
+ if [ ! -f $RPM_SOURCE_DIR/$patch ]; then
+ exit 1
+ fi
+ if ! grep -E "^Patch[0-9]+: $patch\$" %{_specdir}/${RPM_PACKAGE_NAME%%%%%{?variant}}.spec ; then
+ if [ "${patch:0:8}" != "patch-5." ] ; then
+ echo "ERROR: Patch $patch not listed as a source patch in specfile"
+ exit 1
+ fi
+ fi 2>/dev/null
+ case "$patch" in
+ *.bz2) bunzip2 < "$RPM_SOURCE_DIR/$patch" | $patch_command ${1+"$@"} ;;
+ *.gz) gunzip < "$RPM_SOURCE_DIR/$patch" | $patch_command ${1+"$@"} ;;
+ *.xz) unxz < "$RPM_SOURCE_DIR/$patch" | $patch_command ${1+"$@"} ;;
+ *) $patch_command ${1+"$@"} < "$RPM_SOURCE_DIR/$patch" ;;
+ esac
+}
+
+# don't apply patch if it's empty
+ApplyOptionalPatch()
+{
+ local patch=$1
+ shift
+ if [ ! -f $RPM_SOURCE_DIR/$patch ]; then
+ exit 1
+ fi
+ local C=$(wc -l $RPM_SOURCE_DIR/$patch | awk '{print $1}')
+ if [ "$C" -gt 9 ]; then
+ ApplyPatch $patch ${1+"$@"}
+ fi
+}
+
# First we unpack the kernel tarball.
# If this isn't the first make prep, we use links to the existing clean tarball
# which speeds things up quite a bit.