redhat: Use the right path to depmod
[openafs.git] / src / packaging / RedHat / openafs-kmodtool
index b136e25..88d10b2 100644 (file)
@@ -40,10 +40,12 @@ get_verrel ()
   verrel=${1:-$(uname -r)}
   verrel=${verrel%%$knownvariants}
   case "$verrel" in
-    *.el6.elrepo*) verrel="`echo ${verrel} | sed -e 's/^\(.*.el6.elrepo[^\.]*\)\.[^\.]\+.\?$/\1/'`" ;;
-    *.el6*)        verrel="`echo ${verrel} | sed -e 's/^\(.*.el6[^\.]*\)\.[^\.]\+.\?$/\1/'`" ;;
+    *.el[6-9].elrepo*)
+                   verrel="`echo ${verrel} | sed -e 's/^\(.*.el[6-9].elrepo[^\.]*\)\.[^\.]\+.\?$/\1/'`" ;;
+    *.el[6-9]*)    verrel="`echo ${verrel} | sed -e 's/^\(.*.el[6-9][^\.]*\)\.[^\.]\+.\?$/\1/'`" ;;
+    *.fc[1-9][0-9]*)
+                   verrel="`echo ${verrel} | sed -e 's/^\(.*.fc[1-9][0-9][^\.]*\)\.[^\.]\+.\?$/\1/'`" ;;
     *.fc9*)        verrel="`echo ${verrel} | sed -e 's/^\(.*.fc9[^\.]*\)\.[^\.]\+.\?$/\1/'`" ;;
-    *.fc1?*)       verrel="`echo ${verrel} | sed -e 's/^\(.*.fc1[0-9][^\.]*\)\.[^\.]\+.\?$/\1/'`" ;;
   esac
 }
 
@@ -73,14 +75,19 @@ get_rpmtemplate ()
     local variant="${1}"
     local dashvariant="${variant:+-${variant}}"
     case "$verrel" in
-        *.el6*) kdep="kernel-%{_target_cpu} = ${verrel}${variant}"     ;;
+        *.el[6-9]*)
+              kdep="kernel-%{_target_cpu} = ${verrel}${variant}"     ;;
         *.EL*) kdep="kernel${dashvariant}-%{_target_cpu} = ${verrel}" ;;
         *)     kdep="kernel-%{_target_cpu} = ${verrel}${variant}"     ;;
     esac
     case "$verrel" in
-        *.el6*)   kname="${verrel}.%{_target_cpu}${variant:+.${variant}}" ;;
+        *.el[6-9]*)
+                 kname="${verrel}.%{_target_cpu}${variant:+.${variant}}" ;;
+        *.fc[2-9][0-9]*)
+                 kname="${verrel}.%{_target_cpu}${variant:++${variant}}" ;;
+        *.fc1[0-9]*)
+                 kname="${verrel}.%{_target_cpu}${variant:+.${variant}}" ;;
         *.fc9*)   kname="${verrel}.%{_target_cpu}${variant:+.${variant}}" ;;
-        *.fc1?*)  kname="${verrel}.%{_target_cpu}${variant:+.${variant}}" ;;
         *)        kname="${verrel}${variant}"                             ;;
     esac
 
@@ -93,17 +100,17 @@ Provides:         ${kmod_name}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
 Provides:         openafs-kernel = %{PACKAGE_VERSION}
 Requires:         ${kdep}
 Requires:         ${kmod_name}-kmod-common >= %{?epoch:%{epoch}:}%{version}
-Requires(post):   /sbin/depmod
-Requires(postun): /sbin/depmod
+Requires(post):   ${depmod}
+Requires(postun): ${depmod}
 Release:          %{pkgrel}.%(echo ${verrel} | tr - _)
 BuildRequires:    kernel${dashvariant}-devel-%{_target_cpu} = ${verrel}
 %description   -n kmod-${kmod_name}${dashvariant}
 This package provides the ${kmod_name} kernel modules built for the Linux
 kernel ${kname} for the %{_target_cpu} family of processors.
 %post          -n kmod-${kmod_name}${dashvariant}
-/sbin/depmod -aeF /boot/System.map-${kname} ${kname} > /dev/null || :
+${depmod} -aeF /boot/System.map-${kname} ${kname} > /dev/null || :
 %postun        -n kmod-${kmod_name}${dashvariant}
-/sbin/depmod -aF /boot/System.map-${kname} ${kname} &> /dev/null || :
+${depmod} -aF /boot/System.map-${kname} ${kname} &> /dev/null || :
 %files         -n kmod-${kmod_name}${dashvariant}
 %defattr(644,root,root,755)
 /lib/modules/${kname}/extra/${kmod_name}/
@@ -118,12 +125,17 @@ print_rpmtemplate ()
   kver="${1}"
   get_verrel "${1}"
   shift
+  depmod="${1}"
+  shift
   if [ -z "${kmod_name}" ] ; then
     echo "Please provide the kmodule-name as first parameter." >&2
     exit 2
   elif [ -z "${kver}" ] ; then
     echo "Please provide the kver as second parameter." >&2
     exit 2
+  elif [ -z "${depmod}" ] ; then
+    echo "Please provide the full path to depmod as third parameter." >&2
+    exit 2
   elif [ -z "${verrel}" ] ; then
     echo "Couldn't find out the verrel." >&2
     exit 2
@@ -145,7 +157,7 @@ Usage: ${myprog} <command> <option>+
     - Get "base" version-release.
   variant <uname>                               
     - Get variant from uname.
-  rpmtemplate <mainpgkname> <uname> <variants> 
+  rpmtemplate <mainpgkname> <uname> </path/to/depmod> <variants> 
     - Return a template for
   version  
     - Output version number and exit.