📄 e100.spec
字号:
Name: e100Summary: Intel(R) PRO/100 driver for LinuxVersion: 3.5.17Release: 1Source: %{name}-%{version}.tar.gzVendor: Intel CorporationLicense: GPLExclusiveOS: linuxGroup: System Environment/KernelProvides: %{name}URL: http://support.intel.com/support/go/linux/e100.htmBuildRoot: %{_tmppath}/%{name}-%{version}-root# macros for finding system files to update at install time (pci.ids, pcitable)%define find() %(for f in %*; do if [ -e $f ]; then echo $f; break; fi; done)%define _pciids /usr/share/pci.ids /usr/share/hwdata/pci.ids%define _pcitable /usr/share/kudzu/pcitable /usr/share/hwdata/pcitable /dev/null%define pciids %find %{_pciids}%define pcitable %find %{_pcitable}Requires: kernel, fileutils, findutils, gawk, bash%descriptionThis package contains the Linux driver for theIntel(R) PRO/100 Family of Adapters.%prep%setup%buildmkdir -p %{buildroot}KV=$(uname -r)KA=%{_arch}KV_BASE=$(echo $KV | sed '{ s/-bigmem//g; s/-default//g; s/hugemem//g; s/[-]*smp//g; s/enterprise//g; }' )if [ -e /usr/src/kernels ] && [ $(echo $KV_BASE | grep "^2.6") ]; then if [ -e /etc/redhat-release ]; then KSP=$(ls /lib/modules | grep $KV_BASE) for K in $KSP ; do if [ $KA == "x86_64" ] && \ [ $(echo $K | grep hugemem) ]; then # Include path for x86_64 hugemem is broken # on RHEL4 continue fi make -C src clean make -C src KSP=/lib/modules/$K/build \ INSTALL_MOD_PATH=%{buildroot} \ KVERSION=$K \ MANDIR=%{_mandir} \ CFLAGS_EXTRA="$CFLAGS_EXTRA" install done else make -C src clean make -C src INSTALL_MOD_PATH=%{buildroot} \ MANDIR=%{_mandir} install fielse SwitchRHKernel () { CFLAGS_EXTRA="" for K in $2 ; do if [ $K == $1 ] ; then CFLAGS_EXTRA="$CFLAGS_EXTRA -D__BOOT_KERNEL_$K=1" else CFLAGS_EXTRA="$CFLAGS_EXTRA -D__BOOT_KERNEL_$K=0" fi done } KSP="/lib/modules/$KV/build /usr/src/linux-$KV /usr/src/linux-$(echo $KV | sed 's/-.*//') /usr/src/kernel-headers-$KV /usr/src/kernel-source-$KV /usr/src/linux-$(echo $KV | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/') /usr/src/linux" KSRC=$(for d in $KSP ; do [ -e $d/include/linux ] && echo $d; echo; done) KSRC=$(echo $KSRC | awk '{ print $1 }') if [ -e $KSRC/include/linux/rhconfig.h ] ; then RHKL=$(grep 'BOOT_KERNEL_.* [01]' /boot/kernel.h | sed 's/.*BOOT_KERNEL_\(.*\) [01]/\1/') if echo $RHKL | grep BIGMEM then RHKL=$(echo $RHKL | sed 's/ENTERPRISE//') fi if echo $RHKL | grep HUGEMEM then RHKL=$(echo $RHKL | sed 's/BIGMEM//') fi for K in $RHKL ; do SwitchRHKernel $K "$RHKL" make -C src clean if [ $KA == "x86_64" ] ; then CFLAGS_EXTRA="$CFLAGS_EXTRA -D__MODULE_KERNEL_x86_64=0 -D__MODULE_KERNEL_ia32e=1" fi make -C src INSTALL_MOD_PATH=%{buildroot} \ MANDIR=%{_mandir} CFLAGS_EXTRA="$CFLAGS_EXTRA" install done else make -C src clean make -C src INSTALL_MOD_PATH=%{buildroot} MANDIR=%{_mandir} install fifi%install# Append .new to driver name to avoid conflict with kernel RPMcd %{buildroot}find lib -name "e100.*o" -exec mv {} {}.new \; \ -fprintf %{_builddir}/%{name}-%{version}/file.list "/%p.new\n"%cleanrm -rf %{buildroot}%files -f %{_builddir}/%{name}-%{version}/file.list%defattr(-,root,root)%{_mandir}/man7/e100.7.gz%doc LICENSE%doc README%doc ldistrib.txt%doc file.list%postFL="%{_docdir}/%{name}-%{version}/file.list %{_docdir}/%{name}/file.list"FL=$(for d in $FL ; do if [ -e $d ]; then echo $d; break; fi; done)if [ -d /usr/local/lib/%{name} ]; then rm -rf /usr/local/lib/%{name}fiif [ -d /usr/local/share/%{name} ]; then rm -rf /usr/local/share/%{name}fi# Save old drivers (aka .o and .o.gz)echo "original pci.ids saved in /usr/local/share/%{name}";if [ -f /etc/redhat-release ]; then echo "original pcitable saved in /usr/local/share/%{name}";fifor k in $(sed 's/\/lib\/modules\/\([0-9a-zA-Z_\.\-]*\).*/\1/' $FL) ; do d_drivers=/lib/modules/$k d_usr=/usr/local/share/%{name}/$k mkdir -p $d_usr cd $d_drivers; find . -name %{name}.*o -exec cp --parents {} $d_usr \; -exec rm -f {} \; cd $d_drivers; find . -name %{name}_*.*o -exec cp --parents {} $d_usr \; -exec rm -f {} \; cd $d_drivers; find . -name %{name}.*o.gz -exec cp --parents {} $d_usr \; -exec rm -f {} \; cd $d_drivers; find . -name %{name}_*.*o.gz -exec cp --parents {} $d_usr \; -exec rm -f {} \; cp --parents %{pciids} /usr/local/share/%{name}/; if [ -f /etc/redhat-release ]; then cp --parents %{pcitable} /usr/local/share/%{name}/; fidone# Add driver linkfor f in $(sed 's/\.new$//' $FL) ; do ln -f $f.new $f done# Check if kernel version rpm was built on IS the same as running kernelBK_LIST=$(sed 's/\/lib\/modules\/\([0-9a-zA-Z_\.\-]*\).*/\1/' $FL)MATCH=nofor i in $BK_LISTdo if [ $(uname -r) == $i ] ; then MATCH=yes break fidoneif [ $MATCH == no ] ; then echo -n "WARNING: Running kernel is $(uname -r). " echo -n "RPM supports kernels ( " for i in $BK_LIST do echo -n "$i " done echo ")"fi# If any adapters are configured to use eepro100, reconfigure to use e100.if ( grep eepro100 /etc/modules.conf > /dev/null 2>&1 ); then mv -f /etc/modules.conf /etc/modules.conf.OLD sed -e s/eepro100/e100/g /etc/modules.conf.OLD >> /etc/modules.confelse rm -f /etc/modules.conf.OLDfiif [ -f /etc/redhat-release ]then# Update Kudzu's device table such that future devices will use e100,# not eepro100.if ( grep eepro100 %{pcitable} > /dev/null 2>&1 ); then mv -f %{pcitable} %{pcitable}.OLD sed -e s/eepro100/e100/g %{pcitable}.OLD >> %{pcitable}else rm -f %{pcitable}.OLDfifiif [ -f /etc/redhat-release ] ; thencat <<END > %{_docdir}/%{name}-%{version}/pci.updatesEND#Yes, this really needs bashbash -s %{pciids} \ %{pcitable} \ %{_docdir}/%{name}-%{version}/pci.updates \ %{_docdir}/%{name}-%{version}/pci.ids.new \ %{_docdir}/%{name}-%{version}/pcitable.new \ %{name} \<<"END"#! /bin/bash# $1 = system pci.ids file to update# $2 = system pcitable file to update# $3 = file with new entries in pci.ids file format# $4 = pci.ids output file# $5 = pcitable output file# $6 = driver name for use in pcitable fileexec 3<$1exec 4<$2exec 5<$3exec 6>$4exec 7>$5driver=$6IFS=# pattern matching stringsID="[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]"VEN="${ID}*"DEV=" ${ID}*"SUB=" ${ID}*"TABLE_DEV="0x${ID} 0x${ID} \"*"TABLE_SUB="0x${ID} 0x${ID} 0x${ID} 0x${ID} \"*"line=table_line=ids_in=table_in=vendor=device=subdev=subdev=ven_str=dev_str=sub_str=# force a sub-shell to fork with a new stdin# this is needed if the shell is reading these instructions from stdinwhile truedo # get the first line of each data file to jump start things exec 0<&3 read -r ids_in exec 0<&4 read -r table_in # outer loop reads lines from the updates file exec 0<&5 while read -r line do # vendor entry if [[ $line == $VEN ]] then vendor=0x${line:0:4} ven_str=${line#${line:0:6}} # add entry to pci.ids exec 0<&3 exec 1>&6 while [[ $ids_in != $VEN || 0x${ids_in:0:4} < $vendor ]] do echo "$ids_in" read -r ids_in done echo "$line" if [[ 0x${ids_in:0:4} == $vendor ]] then read -r ids_in fi # device entry elif [[ $line == $DEV ]] then device=0x${line:1:4} dev_str=${line#${line:0:7}} table_line="$vendor $device \"$driver\" \"$ven_str|$dev_str\"" # add entry to pci.ids exec 0<&3 exec 1>&6 while [[ $ids_in != $DEV || 0x${ids_in:1:4} < $device ]] do if [[ $ids_in == $VEN ]] then break fi echo "$ids_in" read -r ids_in done echo "$line" if [[ 0x${ids_in:1:4} == $device ]] then read -r ids_in fi # add entry to pcitable exec 0<&4 exec 1>&7 while [[ $table_in != $TABLE_DEV || ${table_in:0:6} < $vendor || ( ${table_in:0:6} == $vendor && ${table_in:7:6} < $device ) ]] do echo "$table_in" read -r table_in done echo "$table_line" if [[ ${table_in:0:6} == $vendor && ${table_in:7:6} == $device ]] then read -r table_in fi # subsystem entry elif [[ $line == $SUB ]] then subven=0x${line:2:4} subdev=0x${line:7:4} sub_str=${line#${line:0:13}} table_line="$vendor $device $subven $subdev \"$driver\" \"$ven_str|$sub_str\"" # add entry to pci.ids exec 0<&3 exec 1>&6 while [[ $ids_in != $SUB || 0x${ids_in:2:4} < $subven || ( 0x${ids_in:2:4} == $subven && 0x${ids_in:7:4} < $subdev ) ]] do if [[ $ids_in == $VEN || $ids_in == $DEV ]] then break fi if [[ ! (${ids_in:2:4} == "1014" && ${ids_in:7:4} == "052C") ]] then echo "$ids_in" fi read -r ids_in done echo "$line" if [[ 0x${ids_in:2:4} == $subven && 0x${ids_in:7:4} == $subdev ]] then read -r ids_in fi # add entry to pcitable exec 0<&4 exec 1>&7 while [[ $table_in != $TABLE_SUB || ${table_in:14:6} < $subven || ( ${table_in:14:6} == $subven && ${table_in:21:6} < $subdev ) ]] do if [[ $table_in == $TABLE_DEV ]] then break fi if [[ ! (${table_in:14:6} == "0x1014" && ${table_in:21:6} == "0x052C") ]] then echo "$table_in" fi read -r table_in done echo "$table_line" if [[ ${table_in:14:6} == $subven && ${table_in:21:6} == $subdev ]] then read -r table_in fi fi exec 0<&5 done # print the remainder of the original files exec 0<&3 exec 1>&6 echo "$ids_in" while read -r ids_in do echo "$ids_in" done exec 0>&4 exec 1>&7 echo "$table_in" while read -r table_in do echo "$table_in" done breakdone <&5exec 3<&-exec 4<&-exec 5<&-exec 6>&-exec 7>&-ENDmv -f %{_docdir}/%{name}-%{version}/pci.ids.new %{pciids}mv -f %{_docdir}/%{name}-%{version}/pcitable.new %{pcitable}fiuname -r | grep BOOT || /sbin/depmod -a > /dev/null 2>&1 || true%preun# If doing RPM un-installif [ $1 -eq 0 ] ; then FL="%{_docdir}/%{name}-%{version}/file.list %{_docdir}/%{name}/file.list" FL=$(for d in $FL ; do if [ -e $d ]; then echo $d; break; fi; done) # Remove driver link for f in $(sed 's/\.new$//' $FL) ; do rm -f $f done # Restore old drivers if [ -d /usr/local/share/%{name} ]; then cd /usr/local/share/%{name}; find . -name '%{name}.*o*' -exec cp --parents {} /lib/modules/ \; cd /usr/local/share/%{name}; find . -name '%{name}_*.*o*' -exec cp --parents {} /lib/modules/ \; rm -rf /usr/local/share/%{name} fifi%postun# If any adapters were configured to use eepro100, restore the original.if [ -e /etc/modules.conf.OLD ]; then if ( grep eepro100 /etc/modules.conf.OLD > /dev/null 2>&1 ); then rm -f /etc/modules.conf.OLD mv -f /etc/modules.conf /etc/modules.conf.OLD sed -e s/e100$/eepro100/g /etc/modules.conf.OLD >> /etc/modules.conf fifiif [ -f /etc/redhat-release ]then# Update Kudzu's device table such that future devices that will use# eepro100 if this was the set before e100 install.if [ -e %{pcitable}.OLD ]; then if ( grep eepro100 %{pcitable}.OLD > /dev/null 2>&1 ); then mv -f %{pcitable} %{pcitable}.OLD sed -e s/\"e100\"/\"eepro100\"/g %{pcitable}.OLD >> %{pcitable} rm -f %{pcitable}.OLD fififiuname -r | grep BOOT || /sbin/depmod -a > /dev/null 2>&1 || true
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -