linux-fedora9-packaging-updates-20080422
[openafs.git] / src / packaging / RedHat / openafs.spec.in
index 13d3b8a..b0dfa2e 100644 (file)
 %define upvar ""
 %{!?kvariants: %define kvariants %{?upvar}}
 
-%{!?ksrcdir: %define ksrcdir %{_usrsrc}/kernels/%{kverrel}-%{_target_cpu}}
+%if %{?ksrcdir:1}%{!?ksrcdir:0}
+  if ( -d %{_usrsrc}/kernels/%{kverrel}-%{_target_cpu}) ; then
+    %define ksrcdir %{_usrsrc}/kernels/%{kverrel}-%{_target_cpu}}
+  else
+    %define ksrcdir %{_usrsrc}/kernels/%{kverrel}.%{_target_cpu}}
+  fi
+%endif
 
 %else # Legacy kernel build stuff 
 
@@ -821,7 +827,11 @@ ksrc=""
 %if %{fedorakmod} 
   for kvariant in %{kvariants} ; do
     if [ -z "${kvariant}" -o -z "$ksrc" ] ; then
-      ksrc=%{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu}
+      if [ -d %{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu} ] ; then
+        ksrc=%{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu}
+      else
+        ksrc=%{_usrsrc}/kernels/%{kverrel}.%{_target_cpu}${kvariant:+.$kvariant}
+      fi
     fi
   done
 %endif
@@ -854,6 +864,12 @@ make only_libafs_tree || exit 1
 %if %{fedorakmod} && %{build_modules}
 for kvariant in %{kvariants} ; do
   if [ -n "${kvariant}" ] ; then
+    if [ -d %{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu} ] ; then
+      ksrc=%{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu}
+    else
+      ksrc=%{_usrsrc}/kernels/%{kverrel}.%{_target_cpu}${kvariant:+.$kvariant}
+    fi
+
     cp -R libafs_tree _kmod_build_${kvariant}
     pushd _kmod_build_${kvariant}
     ./configure --with-afs-sysname=${sysname} \
@@ -861,7 +877,7 @@ for kvariant in %{kvariants} ; do
        --libdir=%{_libdir} \
        --bindir=%{_bindir} \
        --sbindir=%{_sbindir} \
-       --with-linux-kernel-headers=%{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu} \
+       --with-linux-kernel-headers=${ksrc} \
 %if %{krb5support}
        --with-krb5-conf=/usr/kerberos/bin/krb5-config \
 %endif
@@ -1196,14 +1212,25 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/libafsrpc.so.*
 for kvariant in %{kvariants}
 do
   if [ -n "$kvariant" ] ; then
-    srcdir=_kmod_build_$kvariant/src/libafs/MODLOAD-%{kverrel}${kvariant}-SP
+    if [ -d _kmod_build_$kvariant/src/libafs/MODLOAD-%{kverrel}${kvariant}-SP ] ; then
+      srcdir=_kmod_build_$kvariant/src/libafs/MODLOAD-%{kverrel}${kvariant}-SP
+    else
+      srcdir=_kmod_build_$kvariant/src/libafs/MODLOAD-%{kverrel}.%{_target_cpu}.${kvariant}-SP
+    fi
   else
     srcdir=${sysname}/dest/root.client%{_prefix}/vice/etc/modload
   fi
 
-  dstdir=$RPM_BUILD_ROOT/lib/modules/%{kverrel}${kvariant}/extra/openafs
+  if [ -f ${srcdir}/libafs-%{kverrel}${kvariant}.ko ] ; then
+    srcmod=${srcdir}/libafs-%{kverrel}${kvariant}.ko
+    dstdir=$RPM_BUILD_ROOT/lib/modules/%{kverrel}${kvariant}/extra/openafs
+  else
+    srcmod=${srcdir}/libafs-%{kverrel}.%{_target_cpu}${kvariant:+.$kvariant}.ko
+    dstdir=$RPM_BUILD_ROOT/lib/modules/%{kverrel}.%{_target_cpu}${kvariant:+.$kvariant}/extra/openafs
+  fi
+
   mkdir -p ${dstdir}
-  install -m 755 ${srcdir}/libafs-%{kverrel}${kvariant}.ko $dstdir/openafs.ko
+  install -m 755 ${srcmod} ${dstdir}/openafs.ko
 done
 %else
 # Install the kernel modules