#!/bin/bash # This scripts creates the files for a driver disk from a driver source # file. The script follows symbolic links and other nasty things, so don't # trust it overly much. # # To run it, install the kernel-source RPM that you want to build the drivers # for. You will also need the anaconda-runtime package installed. Once these # are installed, run this script with the source file name for the module and # the kernel version as it's arguments. For example: # # ./mk-dd eepro100.c 2.4.2-0.1.49 # # might be appropriate for you. # # Drivers will be generated for the uniprocessor, smp, BOOT, and enterprise # kernels. If you don't need all of these, you may remove the extra drivers # from the modules.cgz file. If you would like to have drivers for other # kernels on the same driver disk, repeat this process against a different # kernel, and combine the modules.cgz files (unpack each one in the same # place, and repack them with something like "find . -type f | cpio -H crc # -o | gzip -9 > /some/driver/disk/modules.cgz"). # # When mk-dd completes, the files in /tmp/modules comprise a driver disk. # Copy these to a dos or ext2 floppy, and you're all set. # # Please note that this script is intended as an example to guide you in # creating driver disks. Another (in many ways, better) solution is available # at http://people.redhat.com/~dledford. This driver development kit is # recommended for most uses. version=$2 srcname=$1 usage () { echo "usage: ./mk-dd " exit 1 } if [ ! -x /usr/lib/anaconda-runtime/modlist -o ! -f /usr/lib/anaconda-runtime/loader/module-info ]; then echo "You need to have anaconda-runtime installed." usage fi modversions=$(rpm -ql kernel-source-$version | grep modversions.h) if [ ! -f "$srcname" ]; then echo "$srcname does not exist" usage fi if [ ! -f "$modversions" ]; then echo "$modversions doesn't exist" usage fi rm -rf /tmp/modules mkdir /tmp/modules name=$(echo $srcname | sed 's/\.c$//') obj=${name}.o klist="UP- SMP-smp ENTERPRISE-enterprise BOOT-BOOT" for kinfo in $klist; do n=$(echo $kinfo | cut -d- -f1) dir=/tmp/modules/${version}$(echo $kinfo | cut -d- -f2) echo -n "Building $n..." defines="" for k in $klist; do flag=$(echo $k | cut -d- -f1) if [ $flag = $n ]; then val=1 else val=0 fi defines="-D__BOOT_KERNEL_${flag}=${val} $defines" done mkdir $dir gcc $defines -I/usr/src/linux-${version}/include -include $modversions -DMODVERSIONS -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -c $srcname -o $dir/$obj rc=$? echo if [ "$rc" != 0 ]; then exit 1 fi done cd /tmp/modules find ${version}* -type f | cpio --quiet -H crc -o | gzip -9 > modules.cgz rm -rf ${version}* echo "$name driver disk" > rhdd-6.1 grep "$name" /usr/share/hwdata/pcitable > pcitable touch modules.dep /usr/lib/anaconda-runtime/modlist -m -f /usr/lib/anaconda-runtime/loader/module-info $name | sed 's/ "/ "Updated /' > modinfo echo "Copy the contents of /tmp/modules to a diskette to create a driver disk."