Blame SOURCES/redhat-rpm-config-9.1.0-kmod-brew-build.patch

76c1b9
From: Jiri Benc <jbenc@redhat.com>
76c1b9
Subject: Build correctly with z-stream kernels
76c1b9
76c1b9
In brew, there's usually a newer kernel installed than the one used for
76c1b9
installation. Handle this situation correctly by allowing the spec file to
76c1b9
define kernel_version to be used in rpm dependencies, while building against
76c1b9
a compatible newer (z-stream) kernel.
76c1b9
76c1b9
Signed-off-by: Jiri Benc <jbenc@redhat.com>
76c1b9
76c1b9
---
76c1b9
 kmodtool |   31 ++++++++++++++++++++++++++++---
76c1b9
 macros   |    2 +-
76c1b9
 2 files changed, 29 insertions(+), 4 deletions(-)
76c1b9
76c1b9
--- a/kmodtool
76c1b9
+++ b/kmodtool
76c1b9
@@ -9,6 +9,7 @@
76c1b9
 # Copyright (c) 2003-2010 Ville Skyttä <ville.skytta@iki.fi>,
76c1b9
 #                         Thorsten Leemhuis <fedora@leemhuis.info>
76c1b9
 #                         Jon Masters <jcm@redhat.com>
76c1b9
+# Copyright (c) 2012-2013 Jiri Benc <jbenc@redhat.com>
76c1b9
 #
76c1b9
 # Permission is hereby granted, free of charge, to any person obtaining
76c1b9
 # a copy of this software and associated documentation files (the
76c1b9
@@ -49,9 +50,25 @@ kver=
76c1b9
 verrel=
76c1b9
 variant=
76c1b9
 
76c1b9
+get_kernel_release ()
76c1b9
+{
76c1b9
+  if [[ -z $1 ]]; then
76c1b9
+    uname -r
76c1b9
+    return
76c1b9
+  fi
76c1b9
+  local arch=$(arch)
76c1b9
+  local verrel=${1%.$arch}
76c1b9
+  local verprefix=${verrel%.*}
76c1b9
+  local versuffix=${verrel#$verprefix}
76c1b9
+  verrel=$(ls -Ud /usr/src/kernels/$verprefix*$versuffix.$arch | sort -V | tail -n 1)
76c1b9
+  verrel=${verrel##*/}
76c1b9
+  [[ -z $verrel ]] && verrel=$1.$arch
76c1b9
+  echo "$verrel"
76c1b9
+}
76c1b9
+
76c1b9
 get_verrel ()
76c1b9
 {
76c1b9
-  verrel=${1:-$(uname -r)}
76c1b9
+  verrel=$(get_kernel_release "$1")
76c1b9
   verrel=${verrel/%.$knownvariants/}
76c1b9
 }
76c1b9
 
76c1b9
@@ -61,10 +78,16 @@ print_verrel ()
76c1b9
   echo "${verrel}"
76c1b9
 }
76c1b9
 
76c1b9
+get_verrel_for_deps ()
76c1b9
+{
76c1b9
+  verrel_dep=${1:-$(uname -r)}
76c1b9
+  verrel_dep=${verrel_dep/%.$knownvariants/}
76c1b9
+}
76c1b9
+
76c1b9
 get_variant ()
76c1b9
 {
76c1b9
   get_verrel $@
76c1b9
-  variant=${1:-$(uname -r)}
76c1b9
+  variant=$(get_kernel_release "$1")
76c1b9
   variant=${variant/#$verrel?(.)/}
76c1b9
   variant=${variant:-'""'}
76c1b9
 }
76c1b9
@@ -129,7 +152,7 @@ get_rpmtemplate ()
76c1b9
     echo "%global _use_internal_dependency_generator 0"
76c1b9
 
76c1b9
     cat <
76c1b9
-Provides:         kernel-modules >= ${verrel}${dotvariant}
76c1b9
+Provides:         kernel-modules >= ${verrel_dep}${dotvariant}
76c1b9
 Provides:         ${kmod_name}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
76c1b9
 Requires(post):   /sbin/depmod
76c1b9
 Requires(postun): /sbin/depmod
76c1b9
@@ -206,6 +229,8 @@ print_rpmtemplate ()
76c1b9
   shift
76c1b9
   kver="${1}"
76c1b9
   get_verrel "${1}"
76c1b9
+  get_verrel_for_deps "${1}"
76c1b9
+  [[ -z $kver ]] && kver=$verrel
76c1b9
   shift
76c1b9
   if [ -z "${kmod_name}" ] ; then
76c1b9
     echo "Please provide the kmodule-name as first parameter." >&2
76c1b9
--- a/macros
76c1b9
+++ b/macros
76c1b9
@@ -218,7 +218,7 @@ package or when debugging this package.\
76c1b9
 	then \
76c1b9
 		nobuildreqs="yes" \
76c1b9
 	fi \
76c1b9
-	override_filelist="$filelist" override_preamble="$preamble" nobuildreqs="$nobuildreqs" kmod_version=%kmod_version kmod_release=%kmod_release %{kmodtool} rpmtemplate %{-n*}%{!-n:%name} %{kverrel} $flavors_to_build 2>/dev/null \
76c1b9
+	override_filelist="$filelist" override_preamble="$preamble" nobuildreqs="$nobuildreqs" kmod_version=%kmod_version kmod_release=%kmod_release %{kmodtool} rpmtemplate %{-n*}%{!-n:%name} %{kernel_version} $flavors_to_build 2>/dev/null \
76c1b9
 )}
76c1b9
 
76c1b9
 #==============================================================================