[Pkg-dkms-commits] [dkms] 01/01: Imported Upstream version 2.2.1.0+git20160527

Aron Xu aron at debian.org
Tue Aug 23 09:21:23 UTC 2016


This is an automated email from the git hooks/post-receive script.

aron pushed a commit to branch upstream
in repository dkms.

commit 548ca39fc02eef6a0331c601386ebbf55ac468b0
Author: Aron Xu <aron at debian.org>
Date:   Tue Aug 23 14:23:45 2016 +0800

    Imported Upstream version 2.2.1.0+git20160527
---
 Makefile                       |   25 +-
 README.dkms                    |    9 +-
 debian/HOWTO.Debian            |   40 +
 debian/changelog               |  379 +++++
 debian/compat                  |    1 +
 debian/control                 |   28 +
 debian/copyright               |   24 +
 debian/dkms.lintian-overrides  |    1 +
 debian/examples                |    4 +
 debian/install                 |    4 +
 debian/modprobe                |    4 +
 debian/patches/series          |    1 +
 debian/postinst                |   20 +
 debian/preinst                 |   37 +
 debian/rules                   |   30 +
 debian/scripts/dh_dkms         |  169 ++
 debian/scripts/dh_dkms.1       |  189 +++
 debian/scripts/dkms.pm         |    8 +
 debian/scripts/postinst-dkms   |   27 +
 debian/scripts/prerm-dkms      |   10 +
 debian/source/format           |    1 +
 debian/watch                   |    3 +
 dkms                           | 3326 ++++++++++++++++++++++------------------
 dkms.8                         |   81 +-
 dkms.service                   |   11 +
 dkms.spec                      |  121 +-
 dkms_apport.py                 |   35 +-
 dkms_autoinstaller             |   62 +-
 dkms_common.postinst           |   60 +-
 dkms_framework.conf            |   10 +
 sample.spec                    |    2 +-
 template-dkms-mkrpm.spec       |    2 +-
 test/README                    |    1 +
 test/dkms_test-1.0/Makefile    |    7 +
 test/dkms_test-1.0/dkms.conf   |   13 +
 test/dkms_test-1.0/dkms_test.c |   23 +
 36 files changed, 3166 insertions(+), 1602 deletions(-)

diff --git a/Makefile b/Makefile
index c64332e..572bc3f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
-RELEASE_DATE := "07-December-2011"
+RELEASE_DATE := "22-September-2014"
 RELEASE_MAJOR := 2
 RELEASE_MINOR := 2
-RELEASE_SUBLEVEL := 0
-RELEASE_EXTRALEVEL := .3
+RELEASE_SUBLEVEL := 1
+RELEASE_EXTRALEVEL := .0
 RELEASE_NAME := dkms
 RELEASE_VERSION := $(RELEASE_MAJOR).$(RELEASE_MINOR).$(RELEASE_SUBLEVEL)$(RELEASE_EXTRALEVEL)
 RELEASE_STRING := $(RELEASE_NAME)-$(RELEASE_VERSION)
@@ -13,13 +13,13 @@ SBIN = $(DESTDIR)/usr/sbin
 ETC = $(DESTDIR)/etc/dkms
 VAR = $(DESTDIR)/var/lib/dkms
 MAN = $(DESTDIR)/usr/share/man/man8
-INITD = $(DESTDIR)/etc/init.d
-INITD_RH = $(DESTDIR)/etc/rc.d/init.d 
+INITD = $(DESTDIR)/etc/rc.d/init.d
 LIBDIR = $(DESTDIR)/usr/lib/dkms
 BASHDIR = $(DESTDIR)/etc/bash_completion.d
 KCONF = $(DESTDIR)/etc/kernel
 SHAREDIR = $(DESTDIR)/usr/share
 DOCDIR = $(SHAREDIR)/doc/dkms
+SYSTEMD = $(DESTDIR)/usr/lib/systemd/system
 
 #Define the top-level build directory
 BUILDDIR := $(shell pwd)
@@ -56,14 +56,23 @@ doc-perms:
 	# ensure doc file permissions ok
 	chmod 0644 $(DOCFILES)
 
-install-redhat: install doc-perms
-	mkdir -m 0755 -p  $(INITD_RH)
+install-redhat-sysv: install doc-perms
+	mkdir -m 0755 -p  $(INITD)
 	install -p -m 0755 dkms_mkkerneldoth $(LIBDIR)/mkkerneldoth
 	install -p -m 0755 dkms_find-provides $(LIBDIR)/find-provides
 	install -p -m 0755 lsb_release $(LIBDIR)/lsb_release
 	install -p -m 0644 template-dkms-mkrpm.spec $(ETC)
 	install -p -m 0644 template-dkms-redhat-kmod.spec $(ETC)
-	install -p -m 0755 dkms_autoinstaller $(INITD_RH)
+	install -p -m 0755 dkms_autoinstaller $(INITD)
+
+install-redhat-systemd: install doc-perms
+	mkdir -m 0755 -p  $(SYSTEMD)
+	install -p -m 0755 dkms_mkkerneldoth $(LIBDIR)/mkkerneldoth
+	install -p -m 0755 dkms_find-provides $(LIBDIR)/find-provides
+	install -p -m 0755 lsb_release $(LIBDIR)/lsb_release
+	install -p -m 0644 template-dkms-mkrpm.spec $(ETC)
+	install -p -m 0644 template-dkms-redhat-kmod.spec $(ETC)
+	install -p -m 0644 dkms.service $(SYSTEMD)
 
 install-doc:
 	mkdir -m 0755 -p $(DOCDIR)
diff --git a/README.dkms b/README.dkms
index 9d1e7a4..46b68c3 100644
--- a/README.dkms
+++ b/README.dkms
@@ -1,12 +1,9 @@
-README.dkms
-Version 1.1
-2/4/2004
-
 This intention of this README is to explain how a DKMS enabled module RPM
 functions and also how DKMS can be used in conjunction with tarballs which
 contain a dkms.conf file within them.
 
-The DKMS project (and any updates) can be found at: http://linux.dell.com/dkms/
+The DKMS project (and any updates) can be found at: https://github.com/dell-oss/dkms
+NOTE: IT IS NO LONGER HOSTED ON LINUX.DELL.COM.
 
 Table of Contents
 0. Installation of DKMS via RPM
@@ -133,4 +130,4 @@ dkms.conf configuration file.
 You may also wish to join the dkms-devel public mailing-list at
 http://lists.us.dell.com/.
 
-The DKMS project is located at: http://linux.dell.com/dkms/
+The DKMS project is located at: https://github.com/dell-oss/dkms
diff --git a/debian/HOWTO.Debian b/debian/HOWTO.Debian
new file mode 100644
index 0000000..532e5b9
--- /dev/null
+++ b/debian/HOWTO.Debian
@@ -0,0 +1,40 @@
+HOWTO Build DKMS debs w/ Debian & Ubuntu systems
+Copyright 2008 Dell Inc.
+ Author: Mario Limonciello <Mario_Limonciello at Dell.com>
+
+------------
+
+A dkms deb is a common representation of a DKMS package that can be distributed across multiple machines.
+After you have a functional DKMS package, you can follow these steps to build a DKMS deb.
+
+1) Start out by putting together a tree in /usr/src/PACKAGE-VERSION.  For our example, we are going to use
+the PACKAGE lirc and VERSION 0.8.3~pre1.  Create a dkms.conf per the recommendations in the DKMS guide.
+
+2) "Add" the package to the dkms tree system:
+	dkms add -m lirc -v 0.8.3~pre1
+
+3) "Build" the binary modules for the current kernel:
+	dkms build -m lirc -v 0.8.3~pre1
+
+4) Make the deb and/or dsc for the package:
+	dkms mkdeb -m lirc -v 0.8.3~pre1
+	dkms mkdsc -m lirc -v 0.8.3~pre1
+
+The end result will be a deb and/or dsc in /var/lib/dkms/lirc/0.8.3~pre1/deb or /var/lib/dkms/lirc/0.8.3~pre1/dsc
+
+------------
+If you would prefer not to contaminate your system with the changes from building these debs, you should
+create a framework.conf that contains these variables (adjust for your use case):
+
+	source_tree="/path/to/source/tree"
+	dkms_tree="/path/to/dkms/tree"
+
+You will then call DKMS with an extra variable, '--dkmsframework'.  Here is an example of how this would work
+using the same lirc example above:
+
+	dkms add -m lirc -v 0.8.3~pre1 --dkmsframework framework.conf
+	dkms build -m lirc -v 0.8.3~pre1 --dkmsframework framework.conf
+	dkms mkdeb -m lirc -v 0.8.3~pre1 --dkmsframework framework.conf
+	dkms mkdsc -m lirc -v 0.8.3~pre1 --dkmsframework framework.conf
+
+The end result will be both a debian binary package and a debian source package that you can use.
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..950d983
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,379 @@
+dkms (2.2.0.1-0ubuntu1) oneiric; urgency=low
+
+  * New upstream version.  Bugs fixed in Ubuntu:
+  * Apport hook:
+    - Only generate reports about supported kernel version (LP: #766150)
+    - Include fglrx make file (LP: #792444)
+    - Crashes in get_source() (LP: #532496)
+    - Apport script fails (LP: #798498)
+  * Openafs modules leaving empty make.log (LP: #593509)
+  * '_' in module name causes mkdeb to fail (LP: #511619)
+  * PRE_BUILD command invoked from wrong directory. (LP: #702638)
+  * Speed up for large amounts of modules (LP: #786672)
+  * Leaves temp files in /tmp (LP: #810134)
+  * Generate .changes file for LP: upload (LP: #582668)
+  * Don't change access rights of upstream source (LP: #582670)
+  * common.postinst fails on failed build (LP: #595968)
+  * Using a hyphen as part of PACKAGE_VERSION causes failures (LP: #599983)
+  * dkms shouldn't source all the variables in dkms.conf (LP: #599985)
+
+ -- Mario Limonciello <Mario_Limonciello at Dell.com>  Thu, 14 Jul 2011 13:18:56 -0500
+
+dkms (2.1.1.2-0ubuntu1) lucid; urgency=low
+
+  [ Mario Limonciello ]
+  * dkms_autoinstaller:
+    - Fix a mismatched if/elif.
+  * dkms:
+    - Make sure to start up depmod from /sbin/
+  * Pull in changes from debian to support dh_dkms.
+
+  [ Anders Kaseorg ]
+  * Don't fail to run other debhelper steps in postinst if we fail. (LP: #497149)
+
+ -- Mario Limonciello <Mario_Limonciello at Dell.com>  Tue, 16 Feb 2010 16:28:14 -0600
+
+dkms (2.1.1.1-0ubuntu1) karmic; urgency=low
+
+  [ Mario Limonciello ]
+  * dkms_common.postinst: Add some missing quotes around strings used in comparisons
+    to make sure that this is safe on more shells.
+  * Makefile, debian/rules: Only copy the init script in for redhat targets.
+  * kernel_postinst.d: Make sure that dkms_autoinstaller is executable (LP: #480055)
+  * Move the architecture mapping logic out of the DKMS template and into
+    common.postinst for Ubuntu only. (LP: #497149)
+  * template-dkms-mkdeb/debian/control: Build-depends on dkms (LP: #506959)
+
+  [ Thomas Chenault ]
+  * Fix parsing in find_external_dependencies(). The existing code behaves improperly 
+    when a driver disk module has more than two dependencies.
+
+ -- Mario Limonciello <mario_limonciello at dell.com>  Mon, 25 Jan 2010 17:42:40 -0600
+
+dkms (2.1.1.0-0ubuntu8) lucid; urgency=low
+
+  * kernel_postinst.d_dkms: Upload the fixed version. 
+
+ -- Scott James Remnant <scott at ubuntu.com>  Tue, 15 Dec 2009 17:08:06 +0000
+
+dkms (2.1.1.0-0ubuntu7) lucid; urgency=low
+
+  * Argh, correct the preinst versioning.  I'm having a key mashing afternoon
+    clearly.
+
+ -- Scott James Remnant <scott at ubuntu.com>  Tue, 15 Dec 2009 17:00:06 +0000
+
+dkms (2.1.1.0-0ubuntu6) lucid; urgency=low
+
+  * Remove /etc/init/dkms_autoinstaller.conf on upgrade too.
+
+ -- Scott James Remnant <scott at ubuntu.com>  Tue, 15 Dec 2009 16:51:07 +0000
+
+dkms (2.1.1.0-0ubuntu5) lucid; urgency=low
+
+  * dkms_autoinstaller: Fix missing "then"
+
+ -- Scott James Remnant <scott at ubuntu.com>  Tue, 15 Dec 2009 15:09:49 +0000
+
+dkms (2.1.1.0-0ubuntu3) lucid; urgency=low
+
+  * dkms_autoinstaller: Copy logic from update-initramfs; when no kernel
+    version is given, use the /vmlinuz link maintained by the kernel package
+    to select one (or fallback to the current).  This should build modules
+    for the right kernel from module package postinst; rebuilding when that
+    link is changed is already taken care of by the kernel postinst.
+
+ -- Scott James Remnant <scott at ubuntu.com>  Tue, 15 Dec 2009 11:33:15 +0000
+
+dkms (2.1.1.0-0ubuntu2) lucid; urgency=low
+
+  * Remove the init script and Upstart job.
+    There is no reason that DKMS needs to run on boot; you can build
+    modules for non-running kernels just fine at installation time.
+
+ -- Scott James Remnant <scott at ubuntu.com>  Tue, 15 Dec 2009 11:20:37 +0000
+
+dkms (2.1.1.0-0ubuntu1) lucid; urgency=low
+
+  [ Mario Limonciello ]
+  * New upstream version
+  * dkms_autoinstall: Minor logic cleanups from submitted patches.
+  * dkms_autoinstall: Run under dash since dkms.conf isn't sourced anymore.
+  * dkms_autoinstall: Whitespace cleanup.
+  * Convert DKMS to an upstart script that starts up before GDM or KDM can
+    start.  This ensures that drivers are built before X tries to start.
+    (LP: #453365)
+  * dkms_autoinstall: Rather than having if/else clauses all over the script,
+    stub out any functions that aren't provided on Debian/Ubuntu when
+    /etc/debian_version isn't present.
+  * dkms_autoinstall: Exit immediately if this script is present but DKMS
+    isn't anymore rather than sourcing functions and then exiting.
+  * kernel_postinst.d_dkms: Launch the upstart script instead. In the process
+    all output will be going to /var/log/dkms_autoinstaller (LP: #292606)
+  * dkms_autoinstall: Don't ever output to stdout, even with kernel parameters.
+  * dkms_autoinstall: Don't log the situation that we already have everything
+    installed that needs to be.
+  * dkms_autoinstall: Rather than logging to /var/log/dkms_autoinstaller,
+    use logger to log to syslog during build and install.
+  * dkms_autoinstall: Clean up the method to get arch.  These hacks shouldn't
+    be necessary.  If you have problems with them gone, file a bug and we'll
+    fix them more cleanly.
+  * dkms_autoinstall: Notate the kernel we are building a module against
+    when building it.
+  * debian/rules: Don't attempt to stop DKMS on upgrades.  It's a task, not
+    a daemon, so stop wouldn't do anything.
+  * Makefile: Install the old initscript to /usr/lib so that different distros
+    can migrate to upstart at their leisure.
+  * Makefile: Move any debian specific calls into the Makefile.
+  * dkms: Revert the code that runs DKMS as the user "nobody".  
+    - It's causing problems with people with nonstandard PAM configs because it
+      uses "su". (LP: #484725)
+    - Also people have reported that nothing should be owned by 'nobody' per
+      Debian & Ubuntu policy.  This could have been fixed by creating a DKMS
+      user, but that still wouldn't solve the problems with using 'su'.
+  * dkms: Emit built-module MODULE=foo if initctl is available on the system
+    after done building a module.   
+  * Add a special apport package-hook for when package builds fail to try
+    to report them against the package providing that DKMS package.
+    (LP: #484871)
+  
+  [ Alberto Milone ]
+  * dkms_common.postinst: try to build the module for the most recent
+    kernel in addition to building it for the current kernel (LP: #474917).
+
+  [ Steve Langasek ]
+  * dkms_autoinstall: optimize with a single find call instead of multiple
+    loops with ls. (LP: 3484386)
+  * dkms_autoinstall: drop localization of the usage message - this is
+    inconsistent with all other init scripts on the system.
+
+  [ Pauli Virtanen ]
+  * Remove dependence from environment's umask and certain environment 
+    variables. (LP: #438393, #436039)
+
+  [ Giuseppe Iuculano ]
+  * dkms_autoinstall: Correct the provides in the LSB block.
+
+  [ David Paleino ]
+  * dkms: improve error message, and add Debian/Ubuntu specific suggestion.
+
+ -- Mario Limonciello <mario_limonciello at dell.com>  Fri, 21 Aug 2009 15:49:58 -0500
+
+dkms (2.0.22.0-1) unstable; urgency=low
+
+  * [023618e] Imported Upstream version 2.0.22.0
+  * [d6e0b15] Deleted patches merged in upstream: 01-fix_manpage.patch
+    02-fix_distribution.patch 04-use_su-to-root.patch 05-
+    do_not_check_admin_group.patch 06-fakeroot.patch 07-exit-if-build-
+    fails.patch 09-lilo_detection.patch 10-lsb.patch 11-bash-
+    completion.patch 12-use_invoke-rc.d.patch 13-template.patch
+    14_new_module-init-tools.patch 08-support_kernel-img.conf.patch
+  * [c5b7822] debian/patches/15_modprobe.patch: do not create an empty
+    /etc/modprobe.d/package_name.conf. It is opened and parsed every
+    time modprobe is run (and it is run very often at boot time). Create
+    it only if necessary.
+  * [3731c00] debian/patches/08-support_kernel-img.conf.patch: Use
+    update-initramfs, it is the default in Debian/Ubuntu and it also computes
+    and stores some checksums. (Closes: #529038)
+  * [f4a197f] debian/patches/16_old_module.patch: Do not move away the old
+    module, by default dkms install the new one in
+    /lib/modules/<kernelversion>/updates/dkms (Closes: #529059)
+  * [db7ffe7] debian/patches/01_kernel_postinst.patch: shut up "which" in the
+    the kernel kernel_postinst.d script, only the exit code is needed.
+
+ -- Giuseppe Iuculano <giuseppe at iuculano.it>  Fri, 05 Jun 2009 22:00:35 +0200
+
+dkms (2.0.21.1-1) unstable; urgency=low
+
+  * [bcda131] Imported Upstream version 2.0.21.1
+  * [487ad26] debian/patches/13-template.patch: 
+    Updated template-dkms-mkdeb Changes: 
+    - Bump to debhelper 7 compatibility levels 
+    - Updated to standards version 3.8.1 
+    - Use Dynamic Kernel Modules Support Team as maintainer field
+    - Remove bash and add ${misc:Depends} in Depends
+    - Use dh_prep instead of dh_clean -k
+  * [c75e860] Updated to standards version 3.8.1 (No changes needed)
+  * [0d14f3e] Update dkms to check for /etc/modprobe.d/dkms.conf,
+    dh_installmodules now gives files in /etc/modprobe.d a .conf syntax,
+    as required by new module-init-tools.
+  * [ceff6d3] Move to kernel section as by ftpmasters override
+  * [aa84c76] debian/control: Fix VCS-Browser field
+  * [6cd45ec] debian/patches/15_modprobe.patch: Do not install
+    /etc/modprobe.d/dkms, it only contains comments and is opened and
+    parsed every time modprobe is run (and it is run very often at boot
+    time). Use instead (and create if necessary)
+    /etc/modprobe.d/package_name.conf. (Closes: #525379)
+  * [171907c] debian/postinst: if /etc/modprobe.d/dkms is modified, put
+    its content in /etc/modprobe.d/dkms.conf and remove it.
+  * [426868b] update debian/copyright to add Giuseppe Iuculano to
+    copyright on debian/*
+  * [1ffb2cd] Removed 03-use-new-header_postinst.d_directory.patch,
+    /etc/kernel/header_postinst.d is used only by kernel-package. dkms
+    must use /etc/kernel/postinst.d/ directory.
+  * [eff2f3e] debian/control: demoted linux-headers and linux-image in
+    Recommends, removed kernel-package and build-essential from Depends,
+    and added only gcc and make.
+  * [508c115] debian/postinst: Remove also
+    /etc/kernel/header_postinst.d/dkms and do an init script remove to
+    un-do the "bad" links created by previous version
+
+  [ Mario Limonciello ]
+  * [848d7f9] update debian/copyright to add Mario Limonciello to
+    copyright on debian/*
+  * [791fc37] Update debian/rules to only run DKMS on the startup
+    targets. This change was proposed from Ubuntu some time back as DKMS
+    doesn't do anything on shutdown.
+
+
+ -- Giuseppe Iuculano <giuseppe at iuculano.it>  Mon, 04 May 2009 09:55:18 +0200
+
+dkms (2.0.21.0-1) unstable; urgency=low
+
+  * [0c2c36b] New Upstream version 2.0.21.0
+  * First Debian release (Closes: #481590)
+  * [6723982] debian/patches/: Refreshed patches, and deleted
+    03-remove_dkms_lib_directory_if_empty.patch (now it is in upstream)
+  * [592acec] debian/patches/04-use_su-to-root.patch: Do not test for $DISPLAY
+    as su-to-root does not require an X display
+  * [22d2ce2] debian/patches/09-lilo_detection.patch: grep for
+    do_bootloader instead of postinst_hook
+  * [b910eb3] debian/patches/03-use-new-
+    header_postinst.d_directory.patch: Use new
+    /etc/kernel/header_postinst.d directory introduced in kernel-package
+    11.017
+  * [f59cc66] debian/control: Add kernel-package (>= 11.017) in Depends
+  * [6ebb0c4] Removed debian/postinst and debian/prerm
+
+ -- Giuseppe Iuculano <giuseppe at iuculano.it>  Mon, 16 Feb 2009 11:06:58 +0100
+
+dkms (2.0.20.4-1) unstable; urgency=low
+
+  [ David Paleino ]
+  * debian/control:
+    - using new Homepage field in source stanza
+    - setting team as Maintainer
+    - adding myself and Mario Limonciello as Uploaders
+    - removed awk and bash dependencies: they are "essential" (de facto)
+      packages (LP: #314774)
+    - DM-Upload-Allowed set
+    - added menu|sudo to Recommends
+  * debian/copyright:
+    - updated to machine-readable format
+    - clarified license for debian/HOWTO.Debian
+  * debian/compat bumped to 7
+  * debian/docs:
+    - sample.{conf,spec} moved to debian/examples
+  * debian/rules updated
+  * debian/patches/01-fix_manpage.patch added, to fix hyphen-used-as-minus-sign
+    lintian warning
+  * debian/postinst added
+  * debian/HOWTO.Debian from Ubuntu package added
+  * debian/modprobe added
+  * debian/prerm:
+    - use sed instead of tricky grep hack
+    - always do the default thing
+  * added get-svn-source to debian/rules
+  * debian/patches/08-use_update-initramfs.patch: updated to parse
+    /etc/kernel-img.conf
+  * debian/patches/11-bash-completion.patch:
+    - better usage of bash builtins
+    - _filename_parts(): fix wrong behaviour when /usr/src/ is a symlink
+    - added patch description
+
+  [ Giuseppe Iuculano ]
+  * Added myself as Uploader
+  * Standards-Version bumped to 3.8.0
+    - Add debian/README.source to document quilt usage
+  * debian/prerm: quiet grep, do not write anything to standard output.
+  * debian/rules: 
+    - remove some pointless blank lines
+    - fix dh-clean-k-is-deprecated lintian warning, use dh_prep instead of
+      dh_clean -k
+  * debian/patches/03-remove_dkms_lib_directory_if_empty.patch: Merge from
+    Ubuntu, ensure that the /lib/modules/<version>/updates/dkms directory is
+    removed if it is empty after a removal.  This allows the modules directory
+    to be removed as it becomes empty.
+  * debian/patches/04-use_su-to-root.patch:  Use su-to-root if available
+  * debian/patches/05-do_not_check_admin_group.patch:
+    - Do not check for admin group, this isn't a Debian standard group.
+    - added a g modifier to replace all underscores in function make_debian()
+  * debian/patches/06-fakeroot.patch: Do not use fakeroot for source-
+    only build, and use -rfakeroot for binary build
+  * debian/patches/07-exit-if-build-fails.patch: Fix exit when build
+    fails
+  * debian/patches/08-support_kernel-img.conf.patch: Use update-initramfs
+    if ramdisk value in /etc/kernel-img.conf is missing
+  * debian/patches/09-lilo_detection.patch: check /etc/kernel-img.conf
+    to find if user is using grub
+  * debian/patches/10-lsb.patch: 
+    - /etc/lsb-release is not present in Debian, so run run lsb_release
+    - Added Debian as known distro in override_dest_module_location()
+  * debian/control: 
+    - Added lsb-release in Recommends
+    - Updated VCS control field
+    - Added build-essential in Depends (LP: #304014), 
+      Removed ${shlibs:Depends} from Depends and removed make, dpkg-dev and
+      gcc from Recommends
+  * debian/patches/11-bash-completion.patch: Improve bash-completion
+    support (Origin Mandriva)
+  * debian/patches/01-fix_manpage.patch: fix wrong path into man page
+    (LP: #292289)
+  * debian/patches/12-use_invoke-rc.d.patch: Use invoke-rc.d in
+    kernel_postinst.d_dkms and fix script-calls-init-script-directly lintian
+    warning
+
+ -- Giuseppe Iuculano <giuseppe at iuculano.it>  Thu, 08 Jan 2009 15:01:39 +0100
+
+dkms (2.0.19-0ubuntu2) hardy; urgency=low
+
+  * Depend on awk instead of gawk.  All variants of awk provide the
+    currently required functionality.
+
+ -- Mario Limonciello <mario_limonciello at dell.com>  Wed, 26 Mar 2008 16:51:33 -0500
+
+dkms (2.0.19-0ubuntu1) hardy; urgency=low
+
+  * New upstream version.
+    - Fixes appending date to debian/changelog in mkdeb.
+
+ -- Mario Limonciello <mario_limonciello at dell.com>  Wed, 26 Mar 2008 10:46:52 -0500
+
+dkms (2.0.17.6-0ubuntu1) hardy; urgency=low
+
+  [ Matt Domsch ]
+  * Correct kernel uninstall trigger (LP: #192240)
+  * Call udevadm trigger if present, fall back to udevtrigger (LP: #192241)
+  * Fix uninstallation with weak modules (Red Hat BZ#429410)
+  * debian/control:
+    - Update standards version to 3.7.3
+    - Add Vcs-git repository.
+
+ -- Mario Limonciello <mario_limonciello at dell.com>  Mon, 18 Feb 2008 09:40:18 -0600
+
+dkms (2.0.17.4-0ubuntu4) hardy; urgency=low
+
+  * Fix -x call.
+
+ -- Scott James Remnant <scott at ubuntu.com>  Fri, 14 Dec 2007 16:52:51 +0000
+
+dkms (2.0.17.4-0ubuntu3) hardy; urgency=low
+
+  * dkms: call udevadm instead of udevtrigger
+
+ -- Scott James Remnant <scott at ubuntu.com>  Fri, 14 Dec 2007 16:15:13 +0000
+
+dkms (2.0.17.5-0ubuntu1) hardy; urgency=low
+	
+  * Correct DKMS file install/uninstall problems  (LP: #151644)
+    - call udevtrigger if we install a module for the currently running kernel
+    - uninstall from /extra before DEST_MODULE_LOCATION
+    - Run depmod after uninstall
+
+ -- Matt Domsch <Matt_Domsch at dell.com>  Mon, 10 Oct 2007 16:50:00 -0500
+
+dkms (2.0.17.4-0ubuntu1) gutsy; urgency=low
+
+  * initial debian packaging for Ubuntu (LP: #121676)
+
+ -- Matt Domsch <Matt_Domsch at dell.com>  Mon, 17 Sep 2007 09:58:46 -0500
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..7f8f011
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+7
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..8854de8
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,28 @@
+Source: dkms
+Section: kernel
+Priority: optional
+Maintainer: Dynamic Kernel Modules Support Team <pkg-dkms-maint at lists.alioth.debian.org>
+Uploaders: David Paleino <dapal at debian.org>,
+ Mario Limonciello <Mario_Limonciello at dell.com>,
+ Giuseppe Iuculano <iuculano at debian.org>
+Build-Depends: debhelper (>= 7.0.50~), quilt
+Standards-Version: 3.9.2
+Homepage: https://github.com/dell-oss/dkms
+Vcs-Git: https://github.com/dell-oss/dkms.git
+Vcs-Browser: https://github.com/dell-oss/dkms.git
+
+Package: dkms
+Architecture: all
+Depends: ${misc:Depends},
+ module-init-tools,
+ gcc,
+ make | build-essential | dpkg-dev,
+ coreutils (>= 7.4),
+ patch
+Recommends: fakeroot,
+ menu | sudo
+Suggests: dpkg-dev, debhelper
+Description: Dynamic Kernel Module Support Framework
+ DKMS is a framework designed to allow individual kernel modules to be upgraded
+ without changing the whole kernel. It is also very easy to rebuild modules as
+ you upgrade kernels.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..844ba56
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,24 @@
+Source: http://linux.dell.com/dkms/
+
+Files: debian/HOWTO.Debian
+Copyright: © 2008, Dell, Inc. <dkms-devel at lists.us.dell.com>
+                   Mario Limonciello <Mario_Limonciello at dell.com>
+License: GPL-2+
+ This package is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+Files: debian/*
+Copyright: © 2008-2009, David Paleino <d.paleino at gmail.com>
+           © 2005-2008, Matt Domsch <Matt_Domsch at dell.com>
+           © 2008-2009, Mario Limonciello <Mario_Limonciello at dell.com>
+           © 2008-2009, Giuseppe Iuculano <giuseppe at iuculano.it>
+License: GPL-2+
+
+Files: *
+Copyright: © 2003-2009, Dell, Inc. <dkms-devel at lists.us.dell.com>
+License: GPL-2+
+
+On Debian systems, the complete text of the GNU General
+Public License v2 can be found in `/usr/share/common-licenses/GPL-2'.
diff --git a/debian/dkms.lintian-overrides b/debian/dkms.lintian-overrides
new file mode 100644
index 0000000..36c1879
--- /dev/null
+++ b/debian/dkms.lintian-overrides
@@ -0,0 +1 @@
+dkms binary: python-script-but-no-python-dep usr/share/apport/package-hooks/dkms_packages.py
diff --git a/debian/examples b/debian/examples
new file mode 100644
index 0000000..2f40b73
--- /dev/null
+++ b/debian/examples
@@ -0,0 +1,4 @@
+sample.conf
+sample.spec
+sample-suse-10-mkkmp.spec
+sample-suse-9-mkkmp.spec
diff --git a/debian/install b/debian/install
new file mode 100644
index 0000000..bc5fcae
--- /dev/null
+++ b/debian/install
@@ -0,0 +1,4 @@
+debian/scripts/dh_dkms      usr/bin
+debian/scripts/dh_dkms.1    usr/share/man/man1/
+debian/scripts/*-dkms       usr/share/debhelper/autoscripts/
+debian/scripts/dkms.pm      usr/share/perl5/Debian/Debhelper/Sequence/
diff --git a/debian/modprobe b/debian/modprobe
new file mode 100644
index 0000000..508b7f4
--- /dev/null
+++ b/debian/modprobe
@@ -0,0 +1,4 @@
+# modprobe information used for DKMS modules
+#
+# This is a stub file, should be edited when needed,
+# used by default by DKMS.
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..1b4d7c4
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+# This is empty for now
diff --git a/debian/postinst b/debian/postinst
new file mode 100644
index 0000000..06e88f7
--- /dev/null
+++ b/debian/postinst
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+set -e
+
+if dpkg --compare-versions "$2" lt-nl "2.0.21.1-1~" ; then
+	if [ -e "/etc/modprobe.d/dkms" ]; then
+		md5sum=$(md5sum /etc/modprobe.d/dkms | sed -e 's/ .*//')
+		old_md5sum=$(dpkg-query -W -f='${Conffiles}' dkms | \
+			sed -n -e "\' /etc/modprobe.d/dkms ' { s/ obsolete$//; s/.* //; p }")
+		if [ "$md5sum" = "$old_md5sum" ]; then
+			rm -f /etc/modprobe.d/dkms
+		else
+			echo "Moving /etc/modprobe.d/dkms to /etc/modprobe.d/dkms.conf ..."
+			mv /etc/modprobe.d/dkms /etc/modprobe.d/dkms.conf
+			rm -f /etc/modprobe.d/dkms
+		fi
+	fi
+fi
+
+#DEBHELPER#
diff --git a/debian/preinst b/debian/preinst
new file mode 100644
index 0000000..f6f0467
--- /dev/null
+++ b/debian/preinst
@@ -0,0 +1,37 @@
+#!/bin/sh
+set -e
+
+#DEBHELPER#
+
+# snippet from http://www.dpkg.org/dpkg/ConffileHandling
+
+# Remove a no-longer used conffile
+rm_conffile() {
+    PKGNAME="$1"
+    CONFFILE="$2"
+    if [ -e "$CONFFILE" ]; then
+        md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
+        old_md5sum="`dpkg-query -W -f='${Conffiles}' $PKGNAME | sed -n -e \"\\\\' $CONFFILE '{s/ obsolete$//;s/.* //p}\"`"
+        if [ "$md5sum" != "$old_md5sum" ]; then
+            echo "Obsolete conffile $CONFFILE has been modified by you."
+            echo "Saving as $CONFFILE.dpkg-bak ..."
+            mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
+        else
+            echo "Removing obsolete conffile $CONFFILE ..."
+            rm -f "$CONFFILE"
+        fi
+    fi
+}
+
+case "$1" in
+install|upgrade)
+    if dpkg --compare-versions "$2" le "2.1.1.1-2"; then
+        rm_conffile dkms "/etc/dkms/template-dkms-mkdeb/debian/postrm"
+	if [ -e "/etc/init.d/dkms_autoinstaller" ]; then
+		update-rc.d -f dkms_autoinstaller remove >/dev/null 2>&1
+		rm_conffile dkms "/etc/init.d/dkms_autoinstaller"
+	fi
+        rm_conffile dkms "/etc/init/dkms_autoinstaller.conf"
+    fi
+
+esac
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..75bad97
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,30 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+
+CURVER = $(shell dpkg-parsechangelog | grep ^Version | cut -d" " -f2 | cut -d"-" -f1 )
+
+%:
+	dh $@
+
+dh_dkms.1: debian/scripts/dh_dkms
+	pod2man \
+		--center "DKMS Debhelper" \
+		--release $(CURVER) \
+		$< > debian/scripts/$@
+
+override_dh_auto_build:
+
+
+override_dh_install:
+	$(MAKE) install-debian DESTDIR=$(CURDIR)/debian/dkms
+	dh_install
+	
+get-orig-source:
+	uscan \
+		--force-download \
+		--download-version $(CURVER) \
+		--rename
+
+get-svn-source:
+	[ -d ../tarballs ] || mkdir ../tarballs
+	cd ../tarballs && make -f $(CURDIR)/debian/rules get-orig-source
diff --git a/debian/scripts/dh_dkms b/debian/scripts/dh_dkms
new file mode 100644
index 0000000..f2644ad
--- /dev/null
+++ b/debian/scripts/dh_dkms
@@ -0,0 +1,169 @@
+#!/usr/bin/perl -w
+
+=head1 NAME
+
+dh_dkms - correctly handle DKMS usage by a kernel module package
+
+=cut
+
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+=head1 SYNOPSIS
+
+B<dh_dkms> [S<I<debhelper options>>] [S<B<-l>>] [S<B<-V>[I<version>]>] [S<B<--> I<file>>]
+
+=head1 DESCRIPTION
+
+dh_dkms is a debhelper program that is responsible for correctly setting
+postinst, postrm and dependencies in kernel module packages using DKMS.
+
+If a file named debian/package.dkms exists, then different actions are
+performed, depending on its contents.
+
+=head1 FILES
+
+=over 4
+
+=item debian/I<package>.dkms
+
+=item debian/dkms
+
+It can be a proper configuration file, and in this case it would be installed
+in the proper directory as dkms.conf.
+
+It can also point to another file (this should be used when the configuration
+is provided by upstream), and in this case that file will be installed as dkms.conf
+in the propery directory.
+
+This file can only miss if a filename is provided when calling dh_dkms.
+
+=back
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-l>, B<--legacy>
+
+Add code to also support DKMS versions < 2.1.0.0.
+
+=item B<-V>, B<-V> I<version>
+
+If C<PACKAGE_VERSION> in F<dkms.conf> is set to C<#MODULE_VERSION#>, set it to
+the given I<version> or, if none is given, default to the upstream version of
+the current package. Otherwise, leave the value specified in F<dkms.conf>.
+
+=item B<--> I<file>
+
+Don't look for debian/I<package>.dkms or debian/dkms, but install I<file> as dkms.conf.
+
+=back
+
+=head1 NOTES
+
+Note that this command is not idempotent. L<dh_prep(1)> should be called
+between invocations of this command. Otherwise, it may cause multiple
+instances of the same text to be added to maintainer scripts.
+
+=cut
+
+init(options => {
+	"l|legacy" => \$dh{LEGACY_DKMS},
+});
+
+foreach my $package (@{$dh{DOPACKAGES}}) {
+	#next if is_udeb($package);
+
+	my $tmp = tmpdir($package);
+	my $dkms_dir = "/usr/lib/dkms/";
+	my $dkms_conf = pkgfile($package, "dkms");
+	my $is_snippet = 0;
+	my @other_conf;
+	my $name;
+	my $package_name;
+	my $package_version;
+
+	if ($dkms_conf) {
+		# let's see if it's a proper snippet
+		open(IN, "< $dkms_conf");
+		while (my $l = <IN>) {
+			$l =~ /PACKAGE_NAME=(["'])(.*)\1/ && ($is_snippet = 1);
+		}
+		close(IN);
+
+		if ($is_snippet) {
+			$name = $dkms_conf;
+		}
+		else {
+			@other_conf = filearray($dkms_conf);
+			if ($#other_conf > 1) {
+				error "cannot list more than one file in $dkms_conf!";
+			}
+			else {
+				$name = $other_conf[0];
+			}
+		}
+	}
+	elsif ($#ARGV == 0) {
+		$name = $ARGV[0];
+	}
+	else {
+		next;
+	}
+	verbose_print "installing $name as dkms.conf";
+
+	# now, parse our configuration file
+	open(IN, "< $name");
+	while (my $l = <IN>) {
+		$l =~ /PACKAGE_NAME=(["'])(.*)\1/ && ($is_snippet = 1 && $package_name = $2);
+		$l =~ /PACKAGE_VERSION=(["'])(.*)\1/ && ($package_version = $2);
+	}
+	close(IN);
+
+	#$ENV{DH_AUTOSCRIPTDIR} = "debian/scripts/";
+	if ($dh{LEGACY_DKMS}) {
+		doit("install", "-p", "-D", "-m755", "$dkms_dir/common.postinst", "$tmp/usr/share/$package/postinst");
+		addsubstvar($package, "misc:Depends", "dkms");
+	}
+	else {
+		addsubstvar($package, "misc:Depends", "dkms", ">= 2.1.0.0");
+	}
+
+	if ($dh{V_FLAG_SET}) {
+		$package_version = $dh{V_FLAG};
+		if ($package_version eq "") {
+			# Call isnative because it sets $dh{VERSION}
+			# as a side effect.
+			isnative($package);
+			$package_version = $dh{VERSION};
+			# Remove the Debian revision
+			$package_version =~ s/-[^-]+$//;
+		}
+
+		my $old_name = $name;
+		$name = "debian/".pkgext($package)."dkms.debhelper";
+		doit("cp", "-a", $old_name, $name);
+		doit("sed", "-i", "s/#MODULE_VERSION#/$package_version/g", $name);
+	}
+
+	autoscript($package, "prerm", "prerm-dkms",
+	    "s/#MODULE_NAME#/$package_name/;s/#MODULE_VERSION#/$package_version/");
+	autoscript($package, "postinst", "postinst-dkms",
+	    "s/#MODULE_NAME#/$package_name/;s/#MODULE_VERSION#/$package_version/");
+	doit("install", "-p", "-D", "-m644", "$name", "$tmp/usr/src/$package_name-$package_version/dkms.conf");
+}
+
+=head1 SEE ALSO
+
+L<debhelper(1)>
+
+This program is part of the Debian DKMS package.
+
+L<dkms(8)>
+
+=head1 AUTHOR
+
+David Paleino <dapal at debian.org>
+
+=cut
diff --git a/debian/scripts/dh_dkms.1 b/debian/scripts/dh_dkms.1
new file mode 100644
index 0000000..da722ab
--- /dev/null
+++ b/debian/scripts/dh_dkms.1
@@ -0,0 +1,189 @@
+.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.07)
+.\"
+.\" Standard preamble:
+.\" ========================================================================
+.de Sp \" Vertical space (when we can't use .PP)
+.if t .sp .5v
+.if n .sp
+..
+.de Vb \" Begin verbatim text
+.ft CW
+.nf
+.ne \\$1
+..
+.de Ve \" End verbatim text
+.ft R
+.fi
+..
+.\" Set up some character translations and predefined strings.  \*(-- will
+.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
+.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
+.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
+.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
+.\" nothing in troff, for use with C<>.
+.tr \(*W-
+.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
+.ie n \{\
+.    ds -- \(*W-
+.    ds PI pi
+.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
+.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
+.    ds L" ""
+.    ds R" ""
+.    ds C` ""
+.    ds C' ""
+'br\}
+.el\{\
+.    ds -- \|\(em\|
+.    ds PI \(*p
+.    ds L" ``
+.    ds R" ''
+'br\}
+.\"
+.\" Escape single quotes in literal strings from groff's Unicode transform.
+.ie \n(.g .ds Aq \(aq
+.el       .ds Aq '
+.\"
+.\" If the F register is turned on, we'll generate index entries on stderr for
+.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
+.\" entries marked with X<> in POD.  Of course, you'll have to process the
+.\" output yourself in some meaningful fashion.
+.ie \nF \{\
+.    de IX
+.    tm Index:\\$1\t\\n%\t"\\$2"
+..
+.    nr % 0
+.    rr F
+.\}
+.el \{\
+.    de IX
+..
+.\}
+.\"
+.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
+.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
+.    \" fudge factors for nroff and troff
+.if n \{\
+.    ds #H 0
+.    ds #V .8m
+.    ds #F .3m
+.    ds #[ \f1
+.    ds #] \fP
+.\}
+.if t \{\
+.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
+.    ds #V .6m
+.    ds #F 0
+.    ds #[ \&
+.    ds #] \&
+.\}
+.    \" simple accents for nroff and troff
+.if n \{\
+.    ds ' \&
+.    ds ` \&
+.    ds ^ \&
+.    ds , \&
+.    ds ~ ~
+.    ds /
+.\}
+.if t \{\
+.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
+.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
+.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
+.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
+.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
+.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
+.\}
+.    \" troff and (daisy-wheel) nroff accents
+.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
+.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
+.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
+.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
+.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
+.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
+.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
+.ds ae a\h'-(\w'a'u*4/10)'e
+.ds Ae A\h'-(\w'A'u*4/10)'E
+.    \" corrections for vroff
+.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
+.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
+.    \" for low resolution devices (crt and lpr)
+.if \n(.H>23 .if \n(.V>19 \
+\{\
+.    ds : e
+.    ds 8 ss
+.    ds o a
+.    ds d- d\h'-1'\(ga
+.    ds D- D\h'-1'\(hy
+.    ds th \o'bp'
+.    ds Th \o'LP'
+.    ds ae ae
+.    ds Ae AE
+.\}
+.rm #[ #] #H #V #F C
+.\" ========================================================================
+.\"
+.IX Title "DH_DKMS 1"
+.TH DH_DKMS 1 "2010-02-17" "2.1.1.1" "DKMS Debhelper"
+.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
+.\" way too many mistakes in technical documents.
+.if n .ad l
+.nh
+.SH "NAME"
+dh_dkms \- correctly handle DKMS usage by a kernel module package
+.SH "SYNOPSIS"
+.IX Header "SYNOPSIS"
+\&\fBdh_dkms\fR [\fIdebhelper\ options\fR] [\fB\-l\fR] [\fB\-V\fR[\fIversion\fR]] [\fB\-\-\fR\ \fIfile\fR]
+.SH "DESCRIPTION"
+.IX Header "DESCRIPTION"
+dh_dkms is a debhelper program that is responsible for correctly setting
+postinst, postrm and dependencies in kernel module packages using \s-1DKMS\s0.
+.PP
+If a file named debian/package.dkms exists, then different actions are
+performed, depending on its contents.
+.SH "FILES"
+.IX Header "FILES"
+.IP "debian/\fIpackage\fR.dkms" 4
+.IX Item "debian/package.dkms"
+.PD 0
+.IP "debian/dkms" 4
+.IX Item "debian/dkms"
+.PD
+It can be a proper configuration file, and in this case it would be installed
+in the proper directory as dkms.conf.
+.Sp
+It can also point to another file (this should be used when the configuration
+is provided by upstream), and in this case that file will be installed as dkms.conf
+in the proper directory.
+.Sp
+This file can only miss if a filename is provided when calling dh_dkms.
+.SH "OPTIONS"
+.IX Header "OPTIONS"
+.IP "\fB\-l\fR, \fB\-\-legacy\fR" 4
+.IX Item "-l, --legacy"
+Add code to also support \s-1DKMS\s0 versions < 2.1.0.0.
+.IP "\fB\-V\fR, \fB\-V\fR \fIversion\fR" 4
+.IX Item "-V, -V version"
+If \f(CW\*(C`PACKAGE_VERSION\*(C'\fR in \fIdkms.conf\fR is set to \f(CW\*(C`#MODULE_VERSION#\*(C'\fR, set it to
+the given \fIversion\fR or, if none is given, default to the upstream version of
+the current package. Otherwise, leave the value specified in \fIdkms.conf\fR.
+.IP "\fB\-\-\fR \fIfile\fR" 4
+.IX Item "-- file"
+Don't look for debian/\fIpackage\fR.dkms or debian/dkms, but install \fIfile\fR as dkms.conf.
+.SH "NOTES"
+.IX Header "NOTES"
+Note that this command is not idempotent. \fIdh_prep\fR\|(1) should be called
+between invocations of this command. Otherwise, it may cause multiple
+instances of the same text to be added to maintainer scripts.
+
+IMPORTANT: binary packages using dh_dkms must have a name that ends in '-dkms'.
+.SH "SEE ALSO"
+.IX Header "SEE ALSO"
+\&\fIdebhelper\fR\|(1)
+.PP
+This program is part of the Debian \s-1DKMS\s0 package.
+.PP
+\&\fIdkms\fR\|(8)
+.SH "AUTHOR"
+.IX Header "AUTHOR"
+David Paleino <dapal at debian.org>
diff --git a/debian/scripts/dkms.pm b/debian/scripts/dkms.pm
new file mode 100644
index 0000000..a337a9c
--- /dev/null
+++ b/debian/scripts/dkms.pm
@@ -0,0 +1,8 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+insert_before("dh_installinit", "dh_dkms");
+
+1;
diff --git a/debian/scripts/postinst-dkms b/debian/scripts/postinst-dkms
new file mode 100644
index 0000000..0084a6e
--- /dev/null
+++ b/debian/scripts/postinst-dkms
@@ -0,0 +1,27 @@
+# The original file can be found in template-dkms-mkdeb/debian/postinst
+# in the DKMS tarball, check it for copyright notices.
+
+DKMS_NAME=#MODULE_NAME#
+DKMS_PACKAGE_NAME=$DKMS_NAME-dkms
+DKMS_VERSION=#MODULE_VERSION#
+
+postinst_found=0
+
+case "$1" in
+	configure)
+		for DKMS_POSTINST in /usr/lib/dkms/common.postinst /usr/share/$DKMS_PACKAGE_NAME/postinst; do
+			if [ -f $DKMS_POSTINST ]; then
+				$DKMS_POSTINST $DKMS_NAME $DKMS_VERSION /usr/share/$DKMS_PACKAGE_NAME "" $2
+				postinst_found=1
+				break
+			fi
+		done
+		if [ "$postinst_found" -eq 0 ]; then
+			echo "ERROR: DKMS version is too old and $DKMS_PACKAGE_NAME was not"
+			echo "built with legacy DKMS support."
+			echo "You must either rebuild $DKMS_PACKAGE_NAME with legacy postinst"
+			echo "support or upgrade DKMS to a more current version."
+			exit 1
+		fi
+	;;
+esac
diff --git a/debian/scripts/prerm-dkms b/debian/scripts/prerm-dkms
new file mode 100644
index 0000000..6e93a1b
--- /dev/null
+++ b/debian/scripts/prerm-dkms
@@ -0,0 +1,10 @@
+DKMS_NAME=#MODULE_NAME#
+DKMS_VERSION=#MODULE_VERSION#
+
+case "$1" in
+    remove|upgrade|deconfigure)
+      if [  "$(dkms status -m $DKMS_NAME -v $DKMS_VERSION)" ]; then
+         dkms remove -m $DKMS_NAME -v $DKMS_VERSION --all
+      fi
+    ;;
+esac
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/debian/watch b/debian/watch
new file mode 100644
index 0000000..de969ad
--- /dev/null
+++ b/debian/watch
@@ -0,0 +1,3 @@
+version=3
+
+http://linux.dell.com/dkms/permalink/dkms-(.*)\.tar\.gz
diff --git a/dkms b/dkms
index 042acc0..160ce3e 100644
--- a/dkms
+++ b/dkms
@@ -3,6 +3,7 @@
 #  Dynamic Kernel Module Support (DKMS) <dkms-devel at dell.com>
 #  Copyright (C) 2003-2008 Dell, Inc.
 #  by Gary Lerhaupt, Matt Domsch, & Mario Limonciello
+#  Copyright (C) 2012 by Darik Horn <dajhorn at vanadac.com>
 #
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
@@ -23,16 +24,16 @@
 # All of the variables we will accept from dkms.conf.
 # Does not include directives
 readonly dkms_conf_variables="CLEAN REMAKE_INITRD remake_initrd PACKAGE_NAME
-       PACKAGE_VERSION POST_ADD POST_INSTALL POST_REMOVE PRE_BUILD
-       PRE_INSTALL BUILD_EXCLUSIVE_KERNEL BUILD_EXCLUSIVE_ARCH
-       build_exclude OBSOLETE_BY MAKE MAKE_MATCH MODULES_CONF
-       modules_conf_array PATCH PATCH_MATCH patch_array BUILT_MODULE_NAME
-       built_module_name BUILT_MODULE_LOCATION built_module_location
-       DEST_MODULE_NAME dest_module_name MODULES_CONF_OBSOLETES
-       DEST_MODULE_LOCATION dest_module_location
-       modules_conf_obsoletes MODULES_CONF_ALIAS_TYPE
-       modules_conf_alias_type STRIP strip MODULES_CONF_OBSOLETE_ONLY
-       modules_conf_obsolete_only AUTOINSTALL"
+   PACKAGE_VERSION POST_ADD POST_BUILD POST_INSTALL POST_REMOVE PRE_BUILD
+   PRE_INSTALL BUILD_DEPENDS BUILD_EXCLUSIVE_KERNEL BUILD_EXCLUSIVE_ARCH
+   build_exclude OBSOLETE_BY MAKE MAKE_MATCH MODULES_CONF
+   modules_conf_array PATCH PATCH_MATCH patch_array BUILT_MODULE_NAME
+   built_module_name BUILT_MODULE_LOCATION built_module_location
+   DEST_MODULE_NAME dest_module_name MODULES_CONF_OBSOLETES
+   DEST_MODULE_LOCATION dest_module_location
+   modules_conf_obsoletes MODULES_CONF_ALIAS_TYPE
+   modules_conf_alias_type STRIP strip MODULES_CONF_OBSOLETE_ONLY
+   modules_conf_obsolete_only AUTOINSTALL NO_WEAK_MODULES"
 
 # Some important regular expressions.  Requires bash 3 or above.
 # Any poor souls still running bash 2 or older really need an upgrade.
@@ -40,7 +41,7 @@ readonly y_re='^(Y|y)'
 readonly mv_re='^([^/]*)/(.*)$'
 readonly rh_kernels='(debug|summit|smp|enterprise|bigmem|hugemem|BOOT|vmnix)'
 
-#Areas that will vary between Linux and other OS's
+# Areas that will vary between Linux and other OS's
 _get_kernel_dir() {
     KVER=$1
     case ${current_os} in
@@ -69,16 +70,18 @@ invoke_command()
     local exitval=0
     [[ $verbose ]] && echo -e "$1" || echo -en "$2..."
     if [[ $3 = background && ! $verbose ]]; then
-	local exitval_file=$(mktemp_or_die $tmp_location/dkms.XXXXXX)
-	(eval "$1" >/dev/null 2>&1; echo "exitval=$?" >> "$exitval_file") &
-	while [[ -e $exitval_file && ! -s $exitval_file ]]; do
-	    sleep 3
-	    echo -en "."
-	done
-	. "$exitval_file"
-	rm -f "$exitval_file"
+        local pid progresspid
+        (eval "$1" >/dev/null 2>&1) & pid=$!
+        while [ -d /proc/$pid ]; do
+            sleep 3
+            echo -en "."
+        done & progresspid=$!
+        wait $pid 2>/dev/null
+        exitval=$?
+        kill $progresspid 2>/dev/null
+        wait $progresspid 2>/dev/null
     else
-	eval "$1"; exitval=$?
+        eval "$1"; exitval=$?
     fi
     (($exitval > 0)) && echo -en "(bad exit status: $exitval)"
     echo -en "\n"
@@ -126,6 +129,8 @@ show_usage()
     echo $"              [--kernelsourcedir=source-location] [--no-prepare-kernel] [--no-initrd]"
     echo $"              [--binaries-only] [--source-only] [-r release (SuSE)] [--verbose]"
     echo $"              [--size] [--spec=specfile] [--media=floppy|iso|tar] [--legacy-postinst=0|1]"
+    echo $"              [--no-depmod]"
+    echo $"              [-j number]"
 }
 
 VER()
@@ -137,11 +142,23 @@ VER()
     # The result should compare correctly as a string.
 
     echo $1 | sed -e 's:\([^0-9]\)\([0-9]\):\1 \2:g' \
-		  -e 's:\([0-9]\)\([^0-9]\):\1 \2:g' \
-		  -e 's:\(.*\): \1 :' \
-		  -e 's: \([0-9]\) : 00\1 :g' \
-		  -e 's: \([0-9][0-9]\) : 0\1 :g' \
-		  -e 's: ::g'
+        -e 's:\([0-9]\)\([^0-9]\):\1 \2:g' \
+        -e 's:\(.*\): \1 :' \
+        -e 's: \([0-9]\) : 00\1 :g' \
+        -e 's: \([0-9][0-9]\) : 0\1 :g' \
+        -e 's: ::g'
+}
+
+# Find out how many CPUs there are so that we may pass an appropriate -j
+# option to make. Ignore hyperthreading for now.
+get_num_cpus()
+{
+   # use nproc(1) from coreutils 8.1-1+ if available, otherwise single job
+   if [ -x /usr/bin/nproc ]; then
+	nproc
+   else
+	echo "1"
+  fi
 }
 
 # Figure out the correct module suffix for the kernel we are currently
@@ -162,11 +179,14 @@ set_kernel_source_dir()
 
 # A little test function for DKMS commands that only work on one kernel.
 have_one_kernel() {
-    (( ${#kernelver[@]} > 1 )) && \
-	die 4 $"The action $1 does not support multiple kernel version" \
-	$"parameters on the command line."
-    [[ $all ]] && die 5 $"The action $1 does not support the --all" \
-	$"parameter."
+    if (( ${#kernelver[@]} != 1 )); then
+        die 4 $"The action $1 does not support multiple kernel version" \
+        $"parameters on the command line."
+    fi
+    if [[ $all ]]; then
+        die 5 $"The action $1 does not support the --all" \
+        $"parameter."
+    fi
 }
 
 # Set up the kernelver and arch arrays.  You must have a 1:1 correspondence --
@@ -178,66 +198,66 @@ setup_kernels_arches()
 {
     # If all is set, use dkms status to fill the arrays
     if [[ $all && $1 != status ]]; then
-	local i=0
-	while read line; do
-	    line=${line#*/}; line=${line#*/};
-	    # (I would leave out the delimiters in the status output
-	    #  in the first place.)
-	    kernelver[$i]=${line%/*}
-	    arch[$i]=${line#*/}
-	    i=$(($i + 1))
-	done < <(module_status_built "$module" "$module_version")
+        local i=0
+        while read line; do
+            line=${line#*/}; line=${line#*/};
+            # (I would leave out the delimiters in the status output
+            #  in the first place.)
+            kernelver[$i]=${line%/*}
+            arch[$i]=${line#*/}
+            i=$(($i + 1))
+        done < <(module_status_built "$module" "$module_version")
     fi
 
     # Set default kernel version and arch, if none set (but only --all isn't set)
     if [[ $1 != status ]]; then
-	if [[ ! $kernelver && ! $all ]]; then
-	    kernelver[0]=$(uname -r)
-	    kernels_arches_default="yes"
-	fi
-	if [[ ! $arch ]]; then
-	    kernelver_rpm=$(rpm -qf "/lib/modules/$kernelver" 2>/dev/null | \
-		grep -v "not owned by any package" | grep kernel | head -n 1)
-	    if ! arch[0]=$(rpm -q --queryformat "%{ARCH}" "$kernelver_rpm" 2>/dev/null); then
-		arch[0]=$(uname -m)
-		if [[ $arch = x86_64 ]] && \
-		    grep -q Intel /proc/cpuinfo && \
-		    ls $install_tree/$kernelver/build/configs \
-		    2>/dev/null | grep -q "ia32e"; then
-		    arch[0]="ia32e"
-		fi
-	    fi
-	fi
+        if [[ ! $kernelver && ! $all ]]; then
+            kernelver[0]=$(uname -r)
+            kernels_arches_default="yes"
+        fi
+        if [[ ! $arch ]]; then
+            kernelver_rpm=$(rpm -qf "/lib/modules/$kernelver" 2>/dev/null | \
+            grep -v "not owned by any package" | grep kernel | head -n 1)
+            if ! arch[0]=$(rpm -q --queryformat "%{ARCH}" "$kernelver_rpm" 2>/dev/null); then
+                arch[0]=$(uname -m)
+                if [[ $arch = x86_64 ]] && grep -q Intel /proc/cpuinfo && ls $install_tree/$kernelver/build/configs 2>/dev/null | grep -q "ia32e"; then
+                    arch[0]="ia32e"
+                fi
+            fi
+        fi
     fi
 
     # If only one arch is specified, make it so for all the kernels
     if ((${#arch[@]} == 1 && ${#kernelver[@]} > 1)); then
-	while ((${#arch[@]} < ${#kernelver[@]})); do
-	    arch[${#arch[@]}]=$arch
-	done
+        while ((${#arch[@]} < ${#kernelver[@]})); do
+            arch[${#arch[@]}]=$arch
+        done
     fi
 
     # Set global multi_arch
     multi_arch=""
     local i=0
     for ((i=0; $i < ${#arch[@]}; i++)); do
-	[[ $arch != ${arch[$i]} ]] && {
-	    multi_arch="true"
-	    break
-	}
+        [[ $arch != ${arch[$i]} ]] && {
+            multi_arch="true"
+            break
+        }
     done
 }
 
 do_depmod()
 {
+    if [[ $no_depmod ]]; then
+        return
+    fi
     # $1 = kernel version
     if [ "${current_os}" != "Linux" ] ; then
         return
     fi
     if [[ -f /boot/System.map-$1 ]]; then
-	/sbin/depmod -a "$1" -F "/boot/System.map-$1"
+        depmod -a "$1" -F "/boot/System.map-$1"
     else
-	/sbin/depmod -a "$1"
+        depmod -a "$1"
     fi
 }
 
@@ -251,24 +271,24 @@ make_initrd()
     [[ $no_initrd ]] && return
     local mkinitrd kernel_file initrd_dir="/boot"
     for mkinitrd in dracut update-initramfs mkinitrd ''; do
-	[[ $mkinitrd ]] && which "$mkinitrd" >/dev/null 2>&1 && break
+        [[ $mkinitrd ]] && which "$mkinitrd" >/dev/null 2>&1 && break
     done
 
-    # no mkinitrd? Just return.
+    # No mkinitrd? Just return.
     [[ $mkinitrd ]] || return 0
 
-    # back up our current initrd
+    # Back up our current initrd
     echo $""
     [[ $2 = ia64 && -d /boot/efi/efi/redhat ]] && initrd_dir="/boot/efi/efi/redhat"
-    # find out what the proper filename will be
+    # Find out what the proper filename will be
     for initrd in "initrd-$1.img" "initramfs-$1.img" "initrd.img-$1" "initrd-$1" ''; do
-	[[ $initrd && -f $initrd_dir/$initrd ]] && break
+        [[ $initrd && -f $initrd_dir/$initrd ]] && break
     done
     if ! [[ $initrd ]]; then
-	# Return if we cannot find an initrd.
-	warn $"Unable to find an initial ram disk that I know how to handle." \
-	    $"Will not try to make an initrd."
-	return 0
+        # Return if we cannot find an initrd.
+        warn $"Unable to find an initial ram disk that I know how to handle." \
+            $"Will not try to make an initrd."
+        return 0
     fi
     echo $"Backing up $initrd to $initrd_dir/$initrd.old-dkms"
     cp -f "$initrd_dir/$initrd" "$initrd_dir/$initrd.old-dkms"
@@ -276,27 +296,27 @@ make_initrd()
     echo $"(If next boot fails, revert to $initrd.old-dkms image)"
 
     if [[ $mkinitrd = dracut ]]; then
-	invoke_command "$mkinitrd $1" "$mkinitrd" background
+        invoke_command "$mkinitrd -f $initrd_dir/$initrd $1" "$mkinitrd" background
     elif [[ $mkinitrd = update-initramfs ]]; then
-	invoke_command "$mkinitrd -u" "$mkinitrd" background
+        invoke_command "$mkinitrd -u -k $1" "$mkinitrd" background
     elif $mkinitrd --version >/dev/null 2>&1; then
-	invoke_command "$mkinitrd -f $initrd_dir/$initrd $1" "$mkinitrd" background
+        invoke_command "$mkinitrd -f $initrd_dir/$initrd $1" "$mkinitrd" background
     elif [[ -e /etc/SuSE-release || -d /etc/SuSEconfig ]]; then
-	for kernel_file in vmlinuz vmlinux ''; do
-	    [[ $kernel_file && -f $initrd_dir/$kernel_file ]] && break
-	done
-	if [[ ! $kernel_file ]]; then
-	    error $"Unable to find valid kernel file under " \
-		$"$initrd_dir for kernel version $1" 
-	    return 1;
-	fi
-	invoke_command "$mkinitrd -k $kernel_file-$1 -i $initrd" "$mkinitrd" background
+        for kernel_file in vmlinuz vmlinux ''; do
+            [[ $kernel_file && -f $initrd_dir/$kernel_file ]] && break
+        done
+        if [[ ! $kernel_file ]]; then
+            error $"Unable to find valid kernel file under " \
+            $"$initrd_dir for kernel version $1"
+            return 1;
+        fi
+        invoke_command "$mkinitrd -k $kernel_file-$1 -i $initrd" "$mkinitrd" background
     elif [[ -e /etc/debian_version ]]; then
-	invoke_command "$mkinitrd -o $initrd_dir/$initrd $1" "$mkinitrd" background
+        invoke_command "$mkinitrd -o $initrd_dir/$initrd $1" "$mkinitrd" background
     else
-	echo $""
-	echo $"Calling $mkinitrd (bad exit status 9 may occur)"
-	invoke_command "$mkinitrd" "$mkinitrd" background
+        echo $""
+        echo $"Calling $mkinitrd (bad exit status 9 may occur)"
+        invoke_command "$mkinitrd" "$mkinitrd" background
     fi
     return
 }
@@ -308,26 +328,41 @@ distro_version_rpm()
     local r wp ver dist
 
     for r in redhat-release sles-release suse-release ovs-release; do
-	wp=$(rpm -q --whatprovides "$r") || continue
-	ver=$(rpm -q --qf "%{version}\n" ${wp})
-	case $r in
-	    sles*) echo sles${ver};;
-	    suse*) echo suse${ver};;
-	    ovs*)  echo ovm${ver};;
-	    redhat*)
-		case $wp in
-		    redhat*|sl*)
-			ver=$(echo $ver | \
-			sed -e 's/^\([[:digit:]]*\).*/\1/g')
-			echo el${ver};;
-		    centos*|enterprise*) echo el${ver};;
-		    fedora*) echo fc${ver};;
-		    *) echo unknown ;;
-		esac
-	       ;;
-	    *) echo unknown;;
-	esac
-	return
+        wp=$(rpm -q --whatprovides "$r") || continue
+        ver=$(rpm -q --qf "%{version}\n" ${wp})
+        case $r in
+            sles*)
+                echo sles${ver}
+                ;;
+            suse*)
+                echo suse${ver}
+                ;;
+            ovs*)
+                echo ovm${ver}
+                ;;
+            redhat*)
+                case $wp in
+                    redhat*|sl*)
+                        ver=$(echo $ver | \
+                        sed -e 's/^\([[:digit:]]*\).*/\1/g')
+                        echo el${ver}
+                        ;;
+                    centos*|enterprise*)
+                        echo el${ver}
+                        ;;
+                    fedora*)
+                        echo fc${ver}
+                        ;;
+                    *)
+                        echo unknown
+                        ;;
+                esac
+                ;;
+            *)
+                echo unknown
+                ;;
+        esac
+        return
     done
     echo unknown
 }
@@ -339,36 +374,38 @@ distro_version()
     # What distribution are we running?
     local LSB_DESCRIPTION DISTRIB_ID DISTRIB_RELEASE ver
 
-    # try the LSB-provided strings first
+    # Try the LSB-provided strings first
     if [ -r /etc/lsb-release ]; then
-	. /etc/lsb-release
+        . /etc/lsb-release
     elif type lsb_release >/dev/null 2>&1; then
-	DISTRIB_ID=$(lsb_release -i -s)
-	DISTRIB_RELEASE=$(lsb_release -r -s)
+        DISTRIB_ID=$(lsb_release -i -s)
+        DISTRIB_RELEASE=$(lsb_release -r -s)
     fi
 
     case ${DISTRIB_ID} in
-	Fedora)     echo fc${DISTRIB_RELEASE} ;;
-	RedHatEnterprise*|CentOS|ScientificSL)  # OEL also reports as such
-	# format is 4.7, 5.3
-	    ver=$(echo "${DISTRIB_RELEASE}" | \
-		sed -e 's/^\([[:digit:]]*\).*/\1/g')
-	    echo el${ver}
-	    ;;
-	SUSE*)
-	    if [[ $(lsb_release -d -s) =~ Enterprise ]]; then
-		echo sles${DISTRIB_RELEASE}
-	    else
-		echo suse${DISTRIB_RELEASE}
-	    fi
-	    ;;
-	*)
-	    if [[ ${DISTRIB_ID} && ${DISTRIB_RELEASE} ]]; then
-		echo "${DISTRIB_ID}${DISTRIB_RELEASE}"
-	    else
-		distro_version_rpm
-	    fi
-	    ;;
+        Fedora)
+            echo fc${DISTRIB_RELEASE}
+            ;;
+        RedHatEnterprise*|CentOS|ScientificSL)
+            # OEL also reports as such; format is 4.7, 5.3
+            ver=$(echo "${DISTRIB_RELEASE}" | \
+            sed -e 's/^\([[:digit:]]*\).*/\1/g')
+            echo el${ver}
+            ;;
+        SUSE*)
+            if [[ $(lsb_release -d -s) =~ Enterprise ]]; then
+                echo sles${DISTRIB_RELEASE}
+            else
+                echo suse${DISTRIB_RELEASE}
+            fi
+            ;;
+        *)
+            if [[ ${DISTRIB_ID} && ${DISTRIB_RELEASE} ]]; then
+                echo "${DISTRIB_ID}${DISTRIB_RELEASE}"
+            else
+                distro_version_rpm
+            fi
+            ;;
     esac
 }
 
@@ -378,24 +415,44 @@ override_dest_module_location()
     [[ ${addon_modules_dir} ]] && echo "/${addon_modules_dir}" && return
 
     if [ "$current_os" = "GNU/kFreeBSD" ] ; then
-	# Does not support subdirs, regardless of distribution
-	echo "" && return
+        # Does not support subdirs, regardless of distribution
+        echo "" && return
     fi
 
     case "$running_distribution" in
-	fc[12345]) ;;
-	el[1234]) ;;
-	sles[123456789]) ;;
-	suse[123456789]) ;;
-	suse10\.[01]) ;;
-	fc*) echo "/extra" && return ;;
-	el*) echo "/extra" && return ;;
-	ovm*) echo "/extra" && return ;;
-	sles*) echo "/updates" && return ;;
-	suse*) echo "/updates" && return ;;
-	Ubuntu*) echo "/updates/dkms" && return ;;
-	Debian*) echo "/updates/dkms" && return ;;
-	*) ;;
+    fc[12345])
+        ;;
+    el[1234])
+        ;;
+    sles[123456789])
+        ;;
+    suse[123456789])
+        ;;
+    suse10\.[01])
+        ;;
+    fc*)
+        echo "/extra" && return
+        ;;
+    el*)
+        echo "/extra" && return
+        ;;
+    ovm*)
+        echo "/extra" && return
+        ;;
+    sles*)
+        echo "/updates" && return
+        ;;
+    suse*)
+        echo "/updates" && return
+        ;;
+    Ubuntu*)
+        echo "/updates/dkms" && return
+        ;;
+    Debian*)
+        echo "/updates/dkms" && return
+        ;;
+    *)
+        ;;
     esac
     echo "$orig_location"
 }
@@ -413,21 +470,21 @@ safe_source() {
     declare -a -r export_envs=("$@")
     local tmpfile=$(mktemp_or_die)
     ( exec >"$tmpfile"
-	. "$to_source_file" >/dev/null
-	# This is really ugly, but a neat hack
-	# Remember, in bash 2.0 and greater all variables are really arrays.
-	for _export_env in "${export_envs[@]}"; do
-	    for _i in $(eval echo \${!$_export_env[@]}); do
-		eval echo '$_export_env[$_i]=\"${'$_export_env'[$_i]}\"'
-	    done
-	done
-
-	# handle DKMS_DIRECTIVE stuff specially.
-	for directive in $(set | grep ^DKMS_DIRECTIVE | cut -d = -f 2-3); do
-	    directive_name=${directive%%=*}
-	    directive_value=${directive#*=}
-	    echo "$directive_name=\"$directive_value\""
-	done
+    . "$to_source_file" >/dev/null
+    # This is really ugly, but a neat hack
+    # Remember, in bash 2.0 and greater all variables are really arrays.
+    for _export_env in "${export_envs[@]}"; do
+        for _i in $(eval echo \${!$_export_env[@]}); do
+            eval echo '$_export_env[$_i]=\"${'$_export_env'[$_i]}\"'
+        done
+    done
+
+    # handle DKMS_DIRECTIVE stuff specially.
+    for directive in $(set | grep ^DKMS_DIRECTIVE | cut -d = -f 2-3); do
+        directive_name=${directive%%=*}
+        directive_value=${directive#*=}
+        echo "$directive_name=\"$directive_value\""
+    done
     )
     . "$tmpfile"
     rm "$tmpfile"
@@ -456,15 +513,15 @@ read_conf()
     [[ $3 ]] && read_conf_file="$3"
 
     [[ -r $read_conf_file ]] || die 4 $"Could not locate dkms.conf file." \
-	$"File: $conf does not exist."
+    $"File: $conf does not exist."
 
     [[ $last_mvka = $module/$module_version/$1/$2 && \
-	$last_mvka_conf = $(readlink -f $read_conf_file) ]] && return
+    $last_mvka_conf = $(readlink -f $read_conf_file) ]] && return
 
 
     # Clear variables and arrays
     for var in $dkms_conf_variables; do
-	unset $var
+        unset $var
     done
 
     # Source in the dkms.conf.
@@ -478,10 +535,10 @@ read_conf()
 
     # Source in the directive_array
     for directive in "${directive_array[@]}"; do
-	directive_name=${directive%%=*}
-	directive_value=${directive#*=}
-	export $directive_name="$directive_value"
-	echo $"DIRECTIVE: $directive_name=\"$directive_value\""
+        directive_name=${directive%%=*}
+        directive_value=${directive#*=}
+        export $directive_name="$directive_value"
+        echo $"DIRECTIVE: $directive_name=\"$directive_value\""
     done
 
     # Set variables
@@ -499,159 +556,169 @@ read_conf()
     # Set module naming/location arrays
     local index array_size=0 s
     for s in ${#BUILT_MODULE_NAME[@]} \
-	${#BUILT_MODULE_LOCATION[@]} \
-	${#DEST_MODULE_NAME[@]} \
-	${#DEST_MODULE_LOCATION[@]}; do
-	((s > array_size)) && array_size=$s
+        ${#BUILT_MODULE_LOCATION[@]} \
+        ${#DEST_MODULE_NAME[@]} \
+        ${#DEST_MODULE_LOCATION[@]}; do
+        ((s > array_size)) && array_size=$s
     done
     for ((index=0; index < array_size; index++)); do
-	# Set values
-	built_module_name[$index]=${BUILT_MODULE_NAME[$index]}
-	built_module_location[$index]=${BUILT_MODULE_LOCATION[$index]}
-	dest_module_name[$index]=${DEST_MODULE_NAME[$index]}
-	dest_module_location[$index]=${DEST_MODULE_LOCATION[$index]}
-	modules_conf_obsoletes[$index]=${MODULES_CONF_OBSOLETES[$index]}
-	modules_conf_alias_type[$index]=${MODULES_CONF_ALIAS_TYPE[$index]}
-	case ${MODULES_CONF_OBSOLETE_ONLY[$index]} in
-	    [yY]*) modules_conf_obsolete_only[$index]="yes";;
-	esac
-	case ${STRIP[$index]} in
-	    [nN]*) strip[$index]="no";;
-	    *)     strip[$index]="yes";;
-	esac
-
-	# If unset, set by defaults
-	[[ ! ${built_module_name[$index]} ]] && \
-	    ((${#DEST_MODULE_LOCATION[@]} == 1)) && \
-	    built_module_name[$index]=$module
-	[[ ! ${dest_module_name[$index]} ]] && \
-	    dest_module_name[$index]=${built_module_name[$index]}
-	[[ ${built_module_location[$index]} && \
-	    ${built_module_location[$index]:(-1)} != / ]] && \
-	    built_module_location[$index]="${built_module_location[$index]}/"
-
-	# FAIL if no built_module_name
-	if [[ ! ${built_module_name[$index]} ]]; then
-	    echo $"dkms.conf: Error! No 'BUILT_MODULE_NAME' directive specified for record #$index." >&2
-	    return_value=1
-	fi
+        # Set values
+        built_module_name[$index]=${BUILT_MODULE_NAME[$index]}
+        built_module_location[$index]=${BUILT_MODULE_LOCATION[$index]}
+        dest_module_name[$index]=${DEST_MODULE_NAME[$index]}
+        dest_module_location[$index]=${DEST_MODULE_LOCATION[$index]}
+        modules_conf_obsoletes[$index]=${MODULES_CONF_OBSOLETES[$index]}
+        modules_conf_alias_type[$index]=${MODULES_CONF_ALIAS_TYPE[$index]}
+        case ${MODULES_CONF_OBSOLETE_ONLY[$index]} in
+            [yY]*)
+                modules_conf_obsolete_only[$index]="yes"
+                ;;
+        esac
+        case ${STRIP[$index]} in
+            [nN]*)
+                strip[$index]="no"
+                ;;
+            [yY]*)
+                strip[$index]="yes"
+                ;;
+            '')
+                strip[$index]=${strip[0]:-yes}
+                ;;
+        esac
+
+        # If unset, set by defaults
+        [[ ! ${built_module_name[$index]} ]] && \
+            ((${#DEST_MODULE_LOCATION[@]} == 1)) && \
+            built_module_name[$index]=$module
+        [[ ! ${dest_module_name[$index]} ]] && \
+            dest_module_name[$index]=${built_module_name[$index]}
+        [[ ${built_module_location[$index]} && \
+            ${built_module_location[$index]:(-1)} != / ]] && \
+            built_module_location[$index]="${built_module_location[$index]}/"
+
+        # FAIL if no built_module_name
+        if [[ ! ${built_module_name[$index]} ]]; then
+            echo $"dkms.conf: Error! No 'BUILT_MODULE_NAME' directive specified for record #$index." >&2
+            return_value=1
+        fi
 
-	# FAIL if built_module_name ends in .o or .ko
-	case ${built_module_name[$index]} in
-	*.o|*.ko)
-	    echo $"dkms.conf: Error! 'BUILT_MODULE_NAME' directive ends in '.o' or '.ko' in record #$index." >&2
-	    return_value=1
-	    ;;
-	esac
-
-	# FAIL if dest_module_name ends in .o or .ko
-	case ${dest_module_name[$index]} in
-	*.o|*.ko)
-	    echo $"dkms.conf: Error! 'DEST_MODULE_NAME' directive ends in '.o' or '.ko' in record #$index." >&2
-	    return_value=1
-	    ;;
-	esac
-
-	# Override location for specific kernels
-	dest_module_location[$index]="$(override_dest_module_location ${dest_module_location[$index]})"
-
-	# Fail if no DEST_MODULE_LOCATION
-	if [[ ! ${DEST_MODULE_LOCATION[$index]} ]]; then
-	    echo $"dkms.conf: Error! No 'DEST_MODULE_LOCATION' directive specified for record #$index.">&2
-	    return_value=1
-	fi
-	    # Fail if bad DEST_MODULE_LOCATION
-	case ${DEST_MODULE_LOCATION[$index]} in
-	    /kernel*) ;;
-	    /updates*) ;;
-	    /extra*) ;;
-	    *)
-		echo $"dkms.conf: Error! Directive 'DEST_MODULE_LOCATION' does not begin with">&2
-		echo $"'/kernel', '/updates', or '/extra' in record #$index.">&2
-		return_value=1
-		;;
-	esac
+        # FAIL if built_module_name ends in .o or .ko
+        case ${built_module_name[$index]} in
+            *.o|*.ko)
+                echo $"dkms.conf: Error! 'BUILT_MODULE_NAME' directive ends in '.o' or '.ko' in record #$index." >&2
+                return_value=1
+                ;;
+        esac
+
+        # FAIL if dest_module_name ends in .o or .ko
+        case ${dest_module_name[$index]} in
+            *.o|*.ko)
+                echo $"dkms.conf: Error! 'DEST_MODULE_NAME' directive ends in '.o' or '.ko' in record #$index." >&2
+                return_value=1
+                ;;
+        esac
+
+        # Override location for specific kernels
+        dest_module_location[$index]="$(override_dest_module_location ${dest_module_location[$index]})"
+
+        # Fail if no DEST_MODULE_LOCATION
+        if [[ ! ${DEST_MODULE_LOCATION[$index]} ]]; then
+            echo $"dkms.conf: Error! No 'DEST_MODULE_LOCATION' directive specified for record #$index.">&2
+            return_value=1
+        fi
+            # Fail if bad DEST_MODULE_LOCATION
+        case ${DEST_MODULE_LOCATION[$index]} in
+            /kernel*)
+                ;;
+            /updates*)
+                ;;
+            /extra*)
+                ;;
+            *)
+            echo $"dkms.conf: Error! Directive 'DEST_MODULE_LOCATION' does not begin with">&2
+            echo $"'/kernel', '/updates', or '/extra' in record #$index.">&2
+            return_value=1
+            ;;
+        esac
     done
 
     # Get the correct make command
     [[ ${MAKE_MATCH[0]} ]] || make_command="${MAKE[0]}"
     for ((index=0; index < ${#MAKE[@]}; index++)); do
-	[[ ${MAKE[$index]} && ${MAKE_MATCH[$index]} && \
-	    $1 =~ ${MAKE_MATCH[$index]} ]] && \
-	    make_command="${MAKE[$index]}"
+    [[ ${MAKE[$index]} && ${MAKE_MATCH[$index]} && \
+        $1 =~ ${MAKE_MATCH[$index]} ]] && \
+        make_command="${MAKE[$index]}"
     done
 
     # Use the generic make and make clean commands if not specified
     if [[ $(VER $1) < $(VER 2.6.6) ]]; then
-	[[ ! $make_command ]] && \
-	    make_command="make -C $kernel_source_dir SUBDIRS=$dkms_tree/$module/$module_version/build modules"
-	[[ ! $clean ]] && \
-	    clean="make -C $kernel_source_dir SUBDIRS=$dkms_tree/$module/$module_version/build clean"
+        [[ ! $make_command ]] && make_command="make -C $kernel_source_dir SUBDIRS=$dkms_tree/$module/$module_version/build modules"
+        [[ ! $clean ]] && clean="make -C $kernel_source_dir SUBDIRS=$dkms_tree/$module/$module_version/build clean"
     else
-	[[ ! $make_command ]] && \
-	    make_command="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build"
-	 [[ ! $clean ]] && \
-	     clean="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build clean"
+        [[ ! $make_command ]] && make_command="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build"
+        [[ ! $clean ]] && clean="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build clean"
     fi
 
     # Set modules_conf_array
     for ((index=0; index < ${#MODULES_CONF[@]}; index++)); do
-	[[ ${MODULES_CONF[$index]} ]] && modules_conf_array[$index]="${MODULES_CONF[$index]}"
+        [[ ${MODULES_CONF[$index]} ]] && modules_conf_array[$index]="${MODULES_CONF[$index]}"
     done
 
     # Set patch_array (including kernel specific patches)
     count=0
     for ((index=0; index < ${#PATCH[@]}; index++)); do
-	if [[ ${PATCH[$index]} && (! ${PATCH_MATCH[$index]} || \
-		$1 =~ ${PATCH_MATCH[$index]}) ]]; then
-	    patch_array[$count]="${PATCH[$index]}"
-	    count=$(($count+1))
-	fi
+    if [[ ${PATCH[$index]} && (! ${PATCH_MATCH[$index]} || $1 =~ ${PATCH_MATCH[$index]}) ]]; then
+        patch_array[$count]="${PATCH[$index]}"
+        count=$(($count+1))
+    fi
     done
 
     # Set remake_initrd
     [[ $REMAKE_INITRD =~ $y_re ]] && remake_initrd="yes"
 
     # Set build_exclude
-    [[ $BUILD_EXCLUSIVE_KERNEL && ! $1 =~ $BUILD_EXCLUSIVE_KERNEL ]] && \
-       build_exclude="yes"
-    [[ $BUILD_EXCLUSIVE_ARCH && ! $2 =~ $BUILD_EXCLUSIVE_ARCH ]] && \
-	build_exclude="yes"
+    [[ $BUILD_EXCLUSIVE_KERNEL && ! $1 =~ $BUILD_EXCLUSIVE_KERNEL ]] && build_exclude="yes"
+    [[ $BUILD_EXCLUSIVE_ARCH && ! $2 =~ $BUILD_EXCLUSIVE_ARCH ]] && build_exclude="yes"
 
     # Fail if absolutely no DEST_MODULE_LOCATION
     if ((${#dest_module_location[@]} == 0)); then
-	echo $"dkms.conf: Error! No 'DEST_MODULE_LOCATION' directive specified." >&2
-	return_value=1
+        echo $"dkms.conf: Error! No 'DEST_MODULE_LOCATION' directive specified." >&2
+        return_value=1
     fi
 
     # Fail if no PACKAGE_NAME
     if [[ ! $package_name ]]; then
-	echo $"dkms.conf: Error! No 'PACKAGE_NAME' directive specified.">&2
-	return_value=1
+        echo $"dkms.conf: Error! No 'PACKAGE_NAME' directive specified.">&2
+        return_value=1
     fi
 
     # Fail if no PACKAGE_VERSION
     if [[ ! $package_version ]]; then
-	echo $"dkms.conf: Error! No 'PACKAGE_VERSION' directive specified.">&2
-	return_value=1
+        echo $"dkms.conf: Error! No 'PACKAGE_VERSION' directive specified.">&2
+        return_value=1
     fi
 
     # Set clean
     [[ $clean ]] || clean="make clean"
 
-    ((return_value == 0)) && last_mvka="$module/$module_version/$1/$2" && \
-	last_mvka_conf="$(readlink -f "$read_conf_file")"
+    ((return_value == 0)) && last_mvka="$module/$module_version/$1/$2" && last_mvka_conf="$(readlink -f "$read_conf_file")"
     return $return_value
 }
 
 # Little helper function for parsing the output of modinfo.
 get_module_verinfo(){
+    unset res
     local vals=
     while read -a vals; do
-	case ${vals[0]} in
-	    version:) res[0]=${vals[1]}; res[2]=${vals[2]};;
-	    srcversion:) res[1]=${vals[1]};;
-	esac
+    case ${vals[0]} in
+        version:)
+            res[0]=${vals[1]}
+            res[2]=${vals[2]}
+            ;;
+        srcversion:)
+        res[1]=${vals[1]}
+        ;;
+    esac
     done < <(modinfo $1)
 }
 
@@ -670,107 +737,108 @@ check_version_sanity()
     local -a kernels_info dkms_info
     set_module_suffix
     read -a kernels_module < <(find $lib_tree -name ${4}$module_suffix)
-    [[ $kernels_module ]] || return 0
+    if [ -z $kernels_module ]; then
+        # Magic split into array syntax saves trivial awk and cut calls.
+        local -a obs=(${3//-/ })
+        local -a my=(${1//-/ })
+        local obsolete=0
+        if [[ ${obs} && ${my} ]]; then
+            if [[ $(VER ${obs}) == $(VER ${my}) && ! $force ]]; then
+                # They get obsoleted possibly in this kernel release
+                if [[ ! ${obs[1]} ]]; then
+                    # They were obsoleted in this upstream kernel
+                    obsolete=1
+                elif [[ $(VER ${my[1]}) > $(VER ${obs[1]}) ]]; then
+                    # They were obsoleted in an earlier ABI bump of the kernel
+                    obsolete=1
+                elif [[ $(VER ${my[1]}) = $(VER ${obs[1]}) ]]; then
+                    # They were obsoleted in this ABI bump of the kernel
+                    obsolete=1
+                fi
+            elif [[ $(VER ${my}) > $(VER ${obs}) && ! $force ]]; then
+                # They were obsoleted in an earlier kernel release
+                obsolete=1
+            fi
+        fi
+
+        if ((obsolete == 1)); then
+            echo $"" >&2
+            echo $"Module has been obsoleted due to being included" >&2
+            echo $"in kernel $3.  We will avoid installing" >&2
+            echo $"for future kernels above $3." >&2
+            echo $"You may override by specifying --force." >&2
+            return 1
+  else
+          return 0
+        fi
+    fi
+
     if [[ ${kernels_module[1]} ]]; then
-	warn $"Warning! Cannot do version sanity checking because multiple ${4}$module_suffix" \
-	    $"modules were found in kernel $1."
-	return 0
+        warn $"Warning! Cannot do version sanity checking because multiple ${4}$module_suffix" \
+            $"modules were found in kernel $1."
+        return 0
     fi
     local dkms_module="$dkms_tree/$module/$module_version/$1/$2/module/${4}$module_suffix"
     get_module_verinfo $kernels_module; kernels_info=("${res[@]}")
     get_module_verinfo $dkms_module; dkms_info=("${res[@]}")
     if [[ ! ${dkms_info[1]} && ${kernels_info[1]} ]]; then
-	# use obsolete checksum info
-	dkms_info[1]=${dkms_info[2]}
-	kernels_info[1]=${kernels_info[2]}
-    fi
-
-    if [[ ${kernels_info[1]} && ${dkms_info[1]} && \
-	${kernels_info[1]} = ${dkms_info[1]} && ! $force ]]; then
-	echo $"" >&2
-	echo $"Good news! Module version $dkms_info for ${4}$module_suffix" >&2
-	echo $"exactly matches what is already found in kernel $1." >&2
-	echo $"DKMS will not replace this module." >&2
-	echo $"You may override by specifying --force." >&2
-	return 1
-    fi
-
-    if [[ $kernels_info && $dkms_info && \
-	! ( $(VER $dkms_info) > $(VER $kernels_info) ) && ! $force ]]; then
-	error $"Module version $dkms_info for ${4}$module_suffix" \
-	    $"is not newer than what is already found in kernel $1 ($kernels_info)." \
-	    $"You may override by specifying --force."
-	return 1
-    fi
-
-    # magic split into array syntax saves trivial awk and cut calls.
-    local -a obs=(${3//-/ })
-    local -a my=(${1//-/ })
-    local obsolete=0
-    if [[ ${obs} && ${my} ]]; then
-	if [[ $(VER ${obs}) == $(VER ${my}) && ! $force ]]; then
-	    #they get obsoleted possibly in this kernel release
-	    if [[ ! ${obs[1]} ]]; then
-		#they were obsoleted in this upstream kernel
-		obsolete=1
-	    elif [[ $(VER ${my[1]}) > $(VER ${obs[1]}) ]]; then
-		#they were obsoleted in an earlier ABI bump of the kernel
-		obsolete=1
-	    elif [[ $(VER ${my[1]}) = $(VER ${obs[1]}) ]]; then
-		#they were obsoleted in this ABI bump of the kernel
-		obsolete=1
-	    fi
-	elif [[ $(VER ${my}) > $(VER ${obs}) && ! $force ]]; then
-	    #they were obsoleted in an earlier kernel release
-	    obsolete=1
-	fi
+        # Use obsolete checksum info
+        dkms_info[1]=${dkms_info[2]}
+        kernels_info[1]=${kernels_info[2]}
+    fi
+
+    if [[ ${kernels_info[1]} && ${dkms_info[1]} && ${kernels_info[1]} = ${dkms_info[1]} && ! $force ]]; then
+        echo $"" >&2
+        echo $"Good news! Module version $dkms_info for ${4}$module_suffix" >&2
+        echo $"exactly matches what is already found in kernel $1." >&2
+        echo $"DKMS will not replace this module." >&2
+        echo $"You may override by specifying --force." >&2
+        return 1
     fi
 
-    if ((obsolete == 1)); then
-	echo $"" >&2
-	echo $"Module has been obsoleted due to being included" >&2
-	echo $"in kernel $3.  We will avoid installing" >&2
-	echo $"for future kernels above $3." >&2
-	echo $"You may override by specifying --force." >&2
-	return 1
+    if [[ $kernels_info && $dkms_info && ! ( $(VER $dkms_info) > $(VER $kernels_info) ) && ! $force ]]; then
+        error $"Module version $dkms_info for ${4}$module_suffix" \
+            $"is not newer than what is already found in kernel $1 ($kernels_info)." \
+            $"You may override by specifying --force."
+        return 1
     fi
+
     return 0
 }
 
 moduleconfig_update_obsoletes()
 {
     # $@ = files to process
-    # do nothing if we have no obsoletes
-    [[ ${modules_conf_obsoletes[@]} ]] || return 0
-    # generate sed args to remove obsolete modules
+    # Do nothing if we have no obsoletes
+    ( IFS=; [[ "${modules_conf_obsoletes[*]}" ]] ) || return 0
+    # Generate sed args to remove obsolete modules
     local mod_diff
     for ((index=0; index < ${#dest_module_name[@]}; index++)); do
-	[[ ${modules_conf_obsoletes[$index]} ]] || continue
-	for obsolete_module in ${modules_conf_obsoletes[$index]//,/ }; do
-	    # for module.conf style syntax
-	    sa_mc_o[${#sa_mc_o[@]}]="-e"
-	    sa_mc_o[${#sa_mc_o[@]}]="s/\(alias ${modules_conf_alias_type[$index]}[0-9]*\) $obsolete_module$/\1 ${dest_module_name[$index]}/g"
-
-	    # for /etc/sysconfig/kernel style syntax
-	    sa_sck_o[${#sa_sck_o[@]}]="-e"
-	    sa_sck_o[${#sa_sck_o[@]}]="s/\(INITRD_MODULES.*\)$obsolete_module\b\(.*\)/\1${dest_module_name[$index]}\2/"
-	done
+        [[ ${modules_conf_obsoletes[$index]} ]] || continue
+        for obsolete_module in ${modules_conf_obsoletes[$index]//,/ }; do
+            # For module.conf style syntax
+            sa_mc_o[${#sa_mc_o[*]}]="-e"
+            sa_mc_o[${#sa_mc_o[*]}]="s/\(alias ${modules_conf_alias_type[$index]}[0-9]*\) $obsolete_module$/\1 ${dest_module_name[$index]}/g"
+            # For /etc/sysconfig/kernel style syntax
+            sa_sck_o[${#sa_sck_o[*]}]="-e"
+            sa_sck_o[${#sa_sck_o[*]}]="s/\(INITRD_MODULES.*\)$obsolete_module\b\(.*\)/\1${dest_module_name[$index]}\2/"
+        done
     done
 
-    # do all the changes at once, record the diffs for posterity
+    # Do all the changes at once, record the diffs for posterity
     for file in "$@"; do
-	[[ $file && -w $file ]] || continue
-	if [[ $file = /etc/sysconfig/kernel ]]; then
-	    sed "${sa_sck_o[@]}" "$file" > "$temp_dir_name/${file##*/}.new"
-	else
-	    sed "${sa_mc_o[@]}" "$file" > "$temp_dir_name/${file##*/}.new"
-	fi
-	if ! mod_diff=$(diff -u "$temp_dir_name/${file##*/}.new" "$file"); then
-	    echo $"$file updated to replace obsoleted module references:"
-	    echo "$mod_diff"
-	    cp -fp "$temp_dir_name/${file##*/}.new" "$file"
-	    rm -f "$temp_dir_name/${file##*/}.new"
-	fi
+        [[ $file && -w $file ]] || continue
+        if [[ $file = /etc/sysconfig/kernel ]]; then
+            sed "${sa_sck_o[*]}" "$file" > "$temp_dir_name/${file##*/}.new"
+        else
+            sed "${sa_mc_o[*]}" "$file" > "$temp_dir_name/${file##*/}.new"
+        fi
+        if ! mod_diff=$(diff -u "$temp_dir_name/${file##*/}.new" "$file"); then
+            echo $"$file updated to replace obsoleted module references:"
+            echo "$mod_diff"
+            cp -fp "$temp_dir_name/${file##*/}.new" "$file"
+            rm -f "$temp_dir_name/${file##*/}.new"
+        fi
     done
 }
 
@@ -781,46 +849,45 @@ moduleconfig_add()
     local temp_dir_name=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX)
     local -a sa_mc_o=() sa_sck_o=()
     modconfig_files="/etc/modprobe.d/dkms.conf
-		     /etc/modprobe.d/dkms
-		     /etc/modules.conf
-		     /etc/modprobe.conf
-		     /etc/modprobe.d/$package_name.conf
-		     /etc/sysconfig/kernel"
+        /etc/modprobe.d/dkms
+        /etc/modules.conf
+        /etc/modprobe.conf
+        /etc/modprobe.d/$package_name.conf
+        /etc/sysconfig/kernel"
 
     moduleconfig_update_obsoletes $modconfig_files
 
     for moduleconfig in $modconfig_files; do
-	[[ -e $moduleconfig ]] || continue
-	for ((index=0; index < ${#dest_module_name[@]}; index++)); do
-
-	    # Only add it if it can't be found already in config file
-	    if [[ ${modules_conf_alias_type[$index]} ]] && \
-	       ! grep -qs "alias ${modules_conf_alias_type[$index]}[0-9]* ${dest_module_name[$index]}\b" $moduleconfig && \
-	       [[ ${modules_conf_obsolete_only[$index]} != yes ]]; then
-		if [[ $modconfig_files = /etc/modprobe.d/$package_name.conf ]] && \
-		    [[ ! -e /etc/modprobe.d/$package_name.conf ]]; then
-		    touch /etc/modprobe.d/$package_name.conf
-		    echo $"created /etc/modprobe.d/$package_name.conf.">&2
-		fi
-		aliases=$(awk "/^alias ${modules_conf_alias_type[$index]}/ {print \$2}" $moduleconfig)
-		if [[ $aliases ]]; then
-		    alias_number=$(($(echo "$aliases" | sed "s/${modules_conf_alias_type[$index]}//" | sort -n | tail -n 1) + 1))
-		else
-		    alias_number=0
-		fi
-		echo -e "alias ${modules_conf_alias_type[$index]}${alias_number} ${dest_module_name[$index]}" >> $moduleconfig
-		echo $"$moduleconfig: added alias reference for '${dest_module_name[$index]}'"
-	    fi
-	done
-
-	# Add anything else
-	for ((index=0; index < ${#modules_conf_array[@]}; index++)); do
-	    if [ -n "${modules_conf_array[$index]}" ] && \
-	    ! grep -q "${modules_conf_array[$index]}" "$moduleconfig"; then
-	    echo -e $"$moduleconfig: added '${modules_conf_array[$index]}'"
-	    echo -e "${modules_conf_array[$index]}" >> $moduleconfig
-	    fi
-	done
+    [[ -e $moduleconfig ]] || continue
+    for ((index=0; index < ${#dest_module_name[@]}; index++)); do
+
+        # Only add it if it can't be found already in config file
+        if [[ ${modules_conf_alias_type[$index]} ]] && \
+           ! grep -qs "alias ${modules_conf_alias_type[$index]}[0-9]* ${dest_module_name[$index]}\b" $moduleconfig && \
+           [[ ${modules_conf_obsolete_only[$index]} != yes ]]; then
+            if [[ $modconfig_files = /etc/modprobe.d/$package_name.conf ]] && [[ ! -e /etc/modprobe.d/$package_name.conf ]]; then
+                touch /etc/modprobe.d/$package_name.conf
+                echo $"created /etc/modprobe.d/$package_name.conf.">&2
+            fi
+            aliases=$(awk "/^alias ${modules_conf_alias_type[$index]}/ {print \$2}" $moduleconfig)
+            if [[ $aliases ]]; then
+                alias_number=$(($(echo "$aliases" | sed "s/${modules_conf_alias_type[$index]}//" | sort -n | tail -n 1) + 1))
+            else
+                alias_number=0
+            fi
+            echo -e "alias ${modules_conf_alias_type[$index]}${alias_number} ${dest_module_name[$index]}" >> $moduleconfig
+            echo $"$moduleconfig: added alias reference for '${dest_module_name[$index]}'"
+        fi
+    done
+
+    # Add anything else
+    for ((index=0; index < ${#modules_conf_array[@]}; index++)); do
+        if [ -n "${modules_conf_array[$index]}" ] && \
+        ! grep -q "${modules_conf_array[$index]}" "$moduleconfig"; then
+        echo -e $"$moduleconfig: added '${modules_conf_array[$index]}'"
+        echo -e "${modules_conf_array[$index]}" >> $moduleconfig
+        fi
+    done
     done
 
     # Delete the temp dir
@@ -840,40 +907,41 @@ moduleconfig_remove()
     [ -e /etc/modprobe.d/$package_name.conf ] && modconfig_files="/etc/modprobe.d/$package_name.conf"
 
     for moduleconfig in $modconfig_files; do
-	for ((index=0; index < ${#dest_module_name[@]}; index++)); do
-	    # Remove/Replace aliases (maybe)
-	    [[ ${modules_conf_alias_type[$index]} ]] || continue
-	    find "$install_tree/$1/" -name "${dest_module_name[$index]}.*" -quit 2>/dev/null && continue
-
-	    local conf_replacement=""
-	    for obsolete_module in ${modules_conf_obsoletes[$index]//,/ }; do
-		find $install_tree/$1/ -name "$obsolete_module.*" -quit 2>/dev/null || continue
-		conf_replacement=$obsolete_module
-		break
-	    done
-
-	    if [[ ! $conf_replacement ]]; then
-		grep -v "alias ${modules_conf_alias_type[$index]}[0-9]* ${dest_module_name[$index]}" $moduleconfig > $temp_dir_name/moduleconfig.new
-		mv -f $temp_dir_name/moduleconfig.new $moduleconfig
-		echo $"$moduleconfig: removed alias for '${dest_module_name[$index]}'"
-		if [[ $modconfig_files = /etc/modprobe.d/$package_name.conf ]]; then
-		    rm -f /etc/modprobe.d/$package_name.conf
-		    echo $"$moduleconfig: deleted /etc/modprobe.d/$package_name.conf file"
-		fi
-	    elif grep -q "alias ${modules_conf_alias_type[$index]}[0-9]* ${dest_module_name[$index]}$" $moduleconfig; then
-		sed "s/\(alias ${modules_conf_alias_type[$index]}[0-9]*\) ${dest_module_name[$index]}$/\1 $conf_replacement/g" $moduleconfig > $temp_dir_name/moduleconfig.new
-		mv -f $temp_dir_name/moduleconfig.new $moduleconfig
-		echo $"$moduleconfig: alias for '${dest_module_name[$index]}' changed back to '$conf_replacement'"
-	    fi
-	done
-
-	# Remove static conf entries
-	for ((index=0; index < ${#modules_conf_array[@]}; index++)); do
-	    [[ ${modules_conf_array[$index]} ]] || continue
-	    grep -v "${modules_conf_array[$index]}" "$moduleconfig" > $temp_dir_name/moduleconfig.new
-	    echo $"$moduleconfig: removed '${modules_conf_array[$index]}'"
-	    mv -f $temp_dir_name/moduleconfig.new $moduleconfig
-	done
+        for ((index=0; index < ${#dest_module_name[@]}; index++)); do
+            # Remove/Replace aliases (maybe)
+            [[ ${modules_conf_alias_type[$index]} ]] || continue
+            find "$install_tree/$1/" -name "${dest_module_name[$index]}.*" -quit 2>/dev/null && continue
+
+            local conf_replacement=""
+            for obsolete_module in ${modules_conf_obsoletes[$index]//,/ }; do
+                find $install_tree/$1/ -name "$obsolete_module.*" -quit 2>/dev/null || continue
+                conf_replacement=$obsolete_module
+                break
+            done
+
+            if [[ ! $conf_replacement ]]; then
+                grep -v "alias ${modules_conf_alias_type[$index]}[0-9]* ${dest_module_name[$index]}" $moduleconfig > $temp_dir_name/moduleconfig.new
+                mv -f $temp_dir_name/moduleconfig.new $moduleconfig
+                echo $"$moduleconfig: removed alias for '${dest_module_name[$index]}'"
+                if [[ $modconfig_files = /etc/modprobe.d/$package_name.conf ]]; then
+                    rm -f /etc/modprobe.d/$package_name.conf
+                    echo $"$moduleconfig: deleted /etc/modprobe.d/$package_name.conf file"
+                fi
+                elif grep -q "alias ${modules_conf_alias_type[$index]}[0-9]* ${dest_module_name[$index]}$" $moduleconfig; then
+                    sed "s/\(alias ${modules_conf_alias_type[$index]}[0-9]*\) ${dest_module_name[$index]}$/\1 $conf_replacement/g" \
+                        $moduleconfig > $temp_dir_name/moduleconfig.new
+                    mv -f $temp_dir_name/moduleconfig.new $moduleconfig
+                    echo $"$moduleconfig: alias for '${dest_module_name[$index]}' changed back to '$conf_replacement'"
+            fi
+        done
+
+        # Remove static conf entries
+        for ((index=0; index < ${#modules_conf_array[@]}; index++)); do
+            [[ ${modules_conf_array[$index]} ]] || continue
+            grep -v "${modules_conf_array[$index]}" "$moduleconfig" > $temp_dir_name/moduleconfig.new
+            echo $"$moduleconfig: removed '${modules_conf_array[$index]}'"
+            mv -f $temp_dir_name/moduleconfig.new $moduleconfig
+        done
     done
 
     # Delete the temp dir
@@ -887,20 +955,20 @@ etc_sysconfig_kernel_modify()
     # Make a temp directory to store files
     local temp_dir_name=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX)
     if [[ $1 = add ]]; then
-	. /etc/sysconfig/kernel
-	for m in "${dest_module_name[@]}"; do
-	    for l in "${INITRD_MODULES}"; do
-		[[ $m = $l ]] && continue 2
-	    done
-	    sed -e "s/INITRD_MODULES=\"\(.*\)\"/INITRD_MODULES=\"\1 $m\"/" /etc/sysconfig/kernel > $temp_dir_name/kernel.new
-	    mv $temp_dir_name/kernel.new /etc/sysconfig/kernel
-	done
+        . /etc/sysconfig/kernel
+        for m in "${dest_module_name[@]}"; do
+            for l in "${INITRD_MODULES}"; do
+                [[ $m = $l ]] && continue 2
+            done
+            sed -e "s/INITRD_MODULES=\"\(.*\)\"/INITRD_MODULES=\"\1 $m\"/" /etc/sysconfig/kernel > $temp_dir_name/kernel.new
+            mv $temp_dir_name/kernel.new /etc/sysconfig/kernel
+        done
     # Remove /etc/sysconfig/kernel entries
     elif [[ $1 = delete ]]; then
-	for m in "${dest_module_name[@]}"; do
-	    sed -e "s/\(INITRD_MODULES.*\)$m\b\(.*\)/\1\2/" /etc/sysconfig/kernel > $temp_dir_name/kernel.new
-	    mv $temp_dir_name/kernel.new /etc/sysconfig/kernel
-	done
+        for m in "${dest_module_name[@]}"; do
+            sed -e "s/\(INITRD_MODULES.*\)$m\b\(.*\)/\1\2/" /etc/sysconfig/kernel > $temp_dir_name/kernel.new
+            mv $temp_dir_name/kernel.new /etc/sysconfig/kernel
+        done
     fi
     # Delete the temp dir
     rm -rf $temp_dir_name
@@ -911,13 +979,13 @@ check_module_args() {
     die 1 $"Invalid number of arguments passed." \
         $"Usage: $1 <module>/<module-version> or" \
         $"       $1 -m <module>/<module-version> or" \
-	$"       $1 -m <module> -v <module-version>"
+        $"       $1 -m <module> -v <module-version>"
 }
 
 read_conf_or_die() {
     read_conf "$@" && return
     die 8 $"Bad conf file." $"File: $conf" \
-	$"does not represent a valid dkms.conf file."
+        $"does not represent a valid dkms.conf file."
 }
 
 run_build_script() {
@@ -926,8 +994,12 @@ run_build_script() {
     local script_type run
     [[ $2 ]] || return 0
     case "$1" in
-        pre_build|post_build) script_type='build';;
-        *) script_type='source'
+        pre_build|post_build)
+            script_type='build'
+            ;;
+        *)
+            script_type='source'
+            ;;
     esac
     run="$dkms_tree/$module/$module_version/$script_type/$2"
     if [[ -x ${run%% *} ]]; then
@@ -949,12 +1021,12 @@ run_build_script() {
 # being unpacked into /usr/src/$module-$module_version.
 add_module()
 {
-    # if $archive is set and $module and $module_version are not,
+    # If $archive is set and $module and $module_version are not,
     # try loading the tarball passed first.
     if [[ $archive_location && ! $module && ! $module_version ]]; then
-	load_tarball
+        load_tarball
     elif [[ $try_source_tree && ! $module && ! $module_version ]]; then
-	add_source_tree "$try_source_tree"
+        add_source_tree "$try_source_tree"
     fi
 
     # Check that we have all the arguments
@@ -962,24 +1034,24 @@ add_module()
 
     # Check that this module-version hasn't already been added
     if is_module_added "$module" "$module_version"; then
-	die 3 $"DKMS tree already contains: $module-$module_version" \
-	    $"You cannot add the same module/version combo more than once."
+        die 3 $"DKMS tree already contains: $module-$module_version" \
+            $"You cannot add the same module/version combo more than once."
     fi
 
     [[ $conf ]] || conf="$source_tree/$module-$module_version/dkms.conf"
 
     # Check that /usr/src/$module-$module_version exists
     if ! [[ -d $source_tree/$module-$module_version ]]; then
-	die 2 $"Could not find module source directory." \
-	    $"Directory: $source_tree/$module-$module_version does not exist."
+        die 2 $"Could not find module source directory." \
+            $"Directory: $source_tree/$module-$module_version does not exist."
     fi
 
     # Do stuff for --rpm_safe_upgrade
     if [[ $rpm_safe_upgrade ]]; then
-	local pppid=$(awk '/PPid:/ {print $2}' /proc/$PPID/status)
-	local lock_name=$(mktemp_or_die $tmp_location/dkms_rpm_safe_upgrade_lock.$pppid.XXXXXX)
-	echo "$module-$module_version" >> $lock_name
-	ps -o lstart --no-headers -p $pppid 2>/dev/null >> $lock_name
+        local pppid=$(awk '/PPid:/ {print $2}' /proc/$PPID/status)
+        local lock_name=$(mktemp_or_die $tmp_location/dkms_rpm_safe_upgrade_lock.$pppid.XXXXXX)
+        echo "$module-$module_version" >> $lock_name
+        ps -o lstart --no-headers -p $pppid 2>/dev/null >> $lock_name
     fi
 
     # Check the conf file for sanity
@@ -1011,26 +1083,29 @@ prepare_kernel()
 
     # Check that kernel-source exists
     _check_kernel_dir "$1" || {
-	case "$running_distribution" in
-	    Debian* | Ubuntu* )
-		die 1 $"Your kernel headers for kernel $1 cannot be found." \
-		    $"Please install the linux-headers-$1 package," \
-		    $"or use the --kernelsourcedir option to tell DKMS where it's located";;
-	    * ) die 1 echo $"Your kernel headers for kernel $1 cannot be found at" \
-		$"/lib/modules/$1/build or /lib/modules/$1/source."
-		$"You can use the --kernelsourcedir option to tell DKMS where it's located."
-	esac
+    case "$running_distribution" in
+        Debian* | Ubuntu* )
+            die 1 $"Your kernel headers for kernel $1 cannot be found." \
+                $"Please install the linux-headers-$1 package," \
+                $"or use the --kernelsourcedir option to tell DKMS where it's located"
+                ;;
+        * )
+            die 1 echo $"Your kernel headers for kernel $1 cannot be found at" \
+                $"/lib/modules/$1/build or /lib/modules/$1/source."
+                $"You can use the --kernelsourcedir option to tell DKMS where it's located."
+            ;;
+    esac
     }
 
     [[ $no_prepare_kernel ]] && return
 
     if [[ (! ( $(VER $1) < $(VER 2.6.5) ) || -d /etc/SuSEconfig) && \
-       -d "$kernel_source_dir" && \
-       -z "$ksourcedir_fromcli" ]]; then
-	echo $""
-	echo $"Kernel preparation unnecessary for this kernel.  Skipping..."
-	no_clean_kernel="no-clean-kernel"
-	return 1
+        -d "$kernel_source_dir" && \
+        -z "$ksourcedir_fromcli" ]]; then
+        echo $""
+        echo $"Kernel preparation unnecessary for this kernel.  Skipping..."
+        no_clean_kernel="no-clean-kernel"
+        return 1
     fi
 
     # Prepare kernel for module build
@@ -1039,101 +1114,103 @@ prepare_kernel()
     echo $"(This is not compiling a kernel, just preparing kernel symbols)"
     cd $kernel_source_dir
     [[ -r .config ]] && {
-	config_contents=$(cat .config)
-	echo $"Storing current .config to be restored when complete"
+        config_contents=$(cat .config)
+        echo $"Storing current .config to be restored when complete"
     }
 
     # Set kernel_config
     if [[ -e /etc/redhat-release || -e /etc/fedora-release ]]; then
-	# Note this also applies to VMware 3.x
-	if [[ -z $kernel_config && -d $kernel_source_dir/configs ]]; then
-	    local kernel_trunc=${1%%-*}
-	    # Try a .config specific to whatever kernel we are running
-	    if [[ $1 =~ $rh_kernels && \
-		-e $kernel_source_dir/configs/kernel-$kernel_trunc-$2-${BASH_REMATCH[1]}.config ]]; then
-		kernel_config="$kernel_source_dir/configs/kernel-$kernel_trunc-$2-${BASH_REMATCH[1]}.config"
-	    elif [[ -e $kernel_source_dir/configs/kernel-$kernel_trunc-$2.config ]]; then
-		# If that one does not exist, try a generic one.
-		kernel_config="$kernel_source_dir/configs/kernel-$kernel_trunc-$2.config"
-	    else
-		# If that does not exist, fall back to no config file
-		kernel_config=""
-	    fi
-	fi
-    elif [[ (-e /etc/SuSE-release || -d /etc/SuSEconfig) && \
-	-z $kernel_config && -d $kernel_source_dir/arch ]]; then
-	    local kernel_trunc=${1%%-*}
-	    case $2 in
-		i586|i686) config_arch="i386";;
-		*) config_arch=$2;;
-	    esac
-	    for config_type in default smp bigsmp; do
-		[[ $1 =~ $config_type ]] && kernel_config="$kernel_source_dir/arch/$config_arch/defconfig.$config_type"
-		[[ -e $kernel_config ]] || kernel_config=""
-	    done
-	    [[ $kernel_config ]] || kernel_config="$kernel_source_dir/arch/$config_arch/defconfig.default"
-	    [[ -e $kernel_config ]] || kernel_config=""
+    # Note this also applies to VMware 3.x
+    if [[ -z $kernel_config && -d $kernel_source_dir/configs ]]; then
+        local kernel_trunc=${1%%-*}
+        # Try a .config specific to whatever kernel we are running
+        if [[ $1 =~ $rh_kernels && -e $kernel_source_dir/configs/kernel-$kernel_trunc-$2-${BASH_REMATCH[1]}.config ]]; then
+            kernel_config="$kernel_source_dir/configs/kernel-$kernel_trunc-$2-${BASH_REMATCH[1]}.config"
+        elif [[ -e $kernel_source_dir/configs/kernel-$kernel_trunc-$2.config ]]; then
+            # If that one does not exist, try a generic one.
+            kernel_config="$kernel_source_dir/configs/kernel-$kernel_trunc-$2.config"
+        else
+            # If that does not exist, fall back to no config file
+            kernel_config=""
+        fi
+    fi
+    elif [[ (-e /etc/SuSE-release || -d /etc/SuSEconfig) && -z $kernel_config && -d $kernel_source_dir/arch ]]; then
+        local kernel_trunc=${1%%-*}
+        case $2 in
+            i586|i686)
+                config_arch="i386"
+                ;;
+            *)
+                config_arch=$2
+                ;;
+        esac
+        for config_type in default smp bigsmp; do
+            [[ $1 =~ $config_type ]] && kernel_config="$kernel_source_dir/arch/$config_arch/defconfig.$config_type"
+            [[ -e $kernel_config ]] || kernel_config=""
+        done
+        [[ $kernel_config ]] || kernel_config="$kernel_source_dir/arch/$config_arch/defconfig.default"
+        [[ -e $kernel_config ]] || kernel_config=""
     fi
 
     # Do preparation
     if [ -e /boot/vmlinuz.version.h ]; then
-	echo $"Running UnitedLinux preparation routine"
-	local kernel_config="/boot/vmlinuz.config"
-	invoke_command "make mrproper" "make mrproper" background
-	[[ $config_contents ]] && echo "$config_contents" > .config
-	invoke_command "cp /boot/vmlinuz.version.h include/linux/version.h" "using /boot/vmlinux.version.h"
-	invoke_command "cp -f $kernel_config .config" "using $kernel_config"
-	invoke_command "make KERNELRELEASE=$1 cloneconfig" "make cloneconfig" background
-	invoke_command "make CONFIG_MODVERSIONS=1 KERNELRELEASE=$1 dep" "make CONFIG_MODVERSIONS=1 dep" background
+        echo $"Running UnitedLinux preparation routine"
+        local kernel_config="/boot/vmlinuz.config"
+        invoke_command "make mrproper" "make mrproper" background
+        [[ $config_contents ]] && echo "$config_contents" > .config
+        invoke_command "cp /boot/vmlinuz.version.h include/linux/version.h" "using /boot/vmlinux.version.h"
+        invoke_command "cp -f $kernel_config .config" "using $kernel_config"
+        invoke_command "make KERNELRELEASE=$1 cloneconfig" "make cloneconfig" background
+        invoke_command "make -j$parallel_jobs CONFIG_MODVERSIONS=1 KERNELRELEASE=$1 dep" "make CONFIG_MODVERSIONS=1 dep" background
     elif grep -q rhconfig.h $kernel_source_dir/include/linux/{modversions,version}.h 2>/dev/null; then
-	echo $"Running Red Hat style preparation routine"
-	invoke_command "make clean" "make clean" background
-	[[ $config_contents ]] && echo "$config_contents" > .config
-
-	if [[ $kernel_config ]]; then
-	    echo $"using $kernel_config"
-	    cp -f "$kernel_config" .config
-	elif [[ -e .config ]]; then
-	    warn $"Using $kernel_source_dir/.config" \
-		$"(I hope this is the correct config for this kernel)"
-	else
-	    warn $"Cannot find a .config file to prepare your kernel with." \
-		$"Try using the --config option to specify where one can be found." \
-		$"Your build will likely fail because of this."
-	fi
+        echo $"Running Red Hat style preparation routine"
+        invoke_command "make clean" "make clean" background
+        [[ $config_contents ]] && echo "$config_contents" > .config
+
+        if [[ $kernel_config ]]; then
+            echo $"using $kernel_config"
+            cp -f "$kernel_config" .config
+        elif [[ -e .config ]]; then
+            warn $"Using $kernel_source_dir/.config" \
+                $"(I hope this is the correct config for this kernel)"
+        else
+            warn $"Cannot find a .config file to prepare your kernel with." \
+                $"Try using the --config option to specify where one can be found." \
+                $"Your build will likely fail because of this."
+        fi
 
-	# Hack to workaround broken tmp_include_depends for Red Hat
-	if grep -q "/usr/src/build" $kernel_source_dir/tmp_include_depends 2>/dev/null; then
-	    sed 's/\/usr\/src\/build\/.*\/install//g' $kernel_source_dir/tmp_include_depends > $kernel_source_dir/tmp_include_depends.new
-	    mv -f $kernel_source_dir/tmp_include_depends.new $kernel_source_dir/tmp_include_depends
-	fi
+        # Hack to workaround broken tmp_include_depends for Red Hat
+        if grep -q "/usr/src/build" $kernel_source_dir/tmp_include_depends 2>/dev/null; then
+            sed 's/\/usr\/src\/build\/.*\/install//g' $kernel_source_dir/tmp_include_depends > $kernel_source_dir/tmp_include_depends.new
+            mv -f $kernel_source_dir/tmp_include_depends.new $kernel_source_dir/tmp_include_depends
+        fi
 
-	invoke_command "make KERNELRELEASE=$1 oldconfig" "make oldconfig" background
-	kerneldoth_contents=$(cat /boot/kernel.h 2>/dev/null)
-	invoke_command "/usr/lib/dkms/mkkerneldoth --kernelver $1 --targetarch $2 --output /boot/kernel.h" "running mkkerneldoth" background
+        invoke_command "make KERNELRELEASE=$1 oldconfig" "make oldconfig" background
+        kerneldoth_contents=$(cat /boot/kernel.h 2>/dev/null)
+        invoke_command "/usr/lib/dkms/mkkerneldoth --kernelver $1 --targetarch $2 --output /boot/kernel.h" "running mkkerneldoth" background
     else
-	echo $"Running Generic preparation routine"
-	invoke_command "make mrproper" "make mrproper" background
-	[[ $config_contents ]] && echo "$config_contents" > .config
-
-	if [[ $kernel_config ]]; then
-	    echo $"using $kernel_config"
-	    cp -f "$kernel_config" .config
-	elif [[ -e .config ]]; then
-	    warn $"using $kernel_source_dir/.config" \
-		$"(I hope this is the correct config for this kernel)"
-	else
-	    warn $"Warning! Cannot find a .config file to prepare your kernel with." \
-		$"Try using the --config option to specify where one can be found." \
-		$"Your build will likely fail because of this."
-	fi
+        echo $"Running Generic preparation routine"
+        invoke_command "make mrproper" "make mrproper" background
+        [[ $config_contents ]] && echo "$config_contents" > .config
+
+        if [[ $kernel_config ]]; then
+            echo $"using $kernel_config"
+            cp -f "$kernel_config" .config
+        elif [[ -e .config ]]; then
+            warn $"using $kernel_source_dir/.config" \
+                $"(I hope this is the correct config for this kernel)"
+        else
+            warn $"Warning! Cannot find a .config file to prepare your kernel with." \
+                $"Try using the --config option to specify where one can be found." \
+                $"Your build will likely fail because of this."
+        fi
 
-	invoke_command "make KERNELRELEASE=$1 oldconfig" "make oldconfig" background
-	if [[ $(VER $1) < $(VER 2.5) ]]; then
-	    invoke_command "make KERNELRELEASE=$1 dep" "make dep" background
-	else
-	    invoke_command "make KERNELRELEASE=$1 prepare-all scripts" "make prepare-all" background
-	fi
+        invoke_command "make KERNELRELEASE=$1 oldconfig" "make oldconfig" background
+        if [[ $(VER $1) < $(VER 2.5) ]]; then
+            invoke_command "make -j$parallel_jobs KERNELRELEASE=$1 dep" "make dep" background
+        else
+            invoke_command "make -j$parallel_jobs KERNELRELEASE=$1 prepare-all scripts" "make prepare-all" background
+        fi
     fi
     cd - >/dev/null
 }
@@ -1152,9 +1229,9 @@ prepare_build()
 
     # Check that the module has not already been built for this kernel
     [[ -d $base_dir ]] && die 3 \
-	$"This module/version has already been built on: $kernelver" \
-	$"Directory: $base_dir" \
-	$"already exists.  Use the dkms remove function before trying to build again."
+        $"This module/version has already been built on: $kernelver" \
+        $"Directory: $base_dir" \
+        $"already exists.  Use the dkms remove function before trying to build again."
 
     # Read the conf file
     set_module_suffix "$kernelver"
@@ -1162,31 +1239,31 @@ prepare_build()
 
     # Error out if build_exclude is set
     [[ $build_exclude ]] && die 9 \
-	$" The dkms.conf for this module includes a BUILD_EXCLUSIVE directive which" \
-	$"does not match this kernel/arch.  This indicates that it should not be built."
+        $" The dkms.conf for this module includes a BUILD_EXCLUSIVE directive which" \
+        $"does not match this kernel/arch.  This indicates that it should not be built."
 
     # Error out if source_tree is basically empty (binary-only dkms tarball w/ --force check)
     (($(ls $dkms_tree/$module/$module_version/source | wc -l | awk {'print $1'}) < 2)) && die 8 \
-	$"The directory $dkms_tree/$module/$module_version/source/" \
-	$"does not appear to have module source located within it.  Build halted."
+        $"The directory $dkms_tree/$module/$module_version/source/" \
+        $"does not appear to have module source located within it.  Build halted."
 
     prepare_kernel "$kernelver" "$arch"
 
     # Set up temporary build directory for build
     rm -rf "$dkms_tree/$module/$module_version/build"
-    cp -rf "$dkms_tree/$module/$module_version/source/" "$dkms_tree/$module/$module_version/build"
+    cp -a "$dkms_tree/$module/$module_version/source/" "$dkms_tree/$module/$module_version/build"
 
     cd "$dkms_tree/$module/$module_version/build"
 
     # Apply any patches
     for p in "${patch_array[@]}"; do
-	[[ ! -e $dkms_tree/$module/$module_version/build/patches/$p ]] && \
-	    report_build_problem 5 \
-	    $" Patch $p as specified in dkms.conf cannot be" \
-	    $"found in $dkms_tree/$module/$module_version/build/patches/."
-	invoke_command "patch -p1 < ./patches/$p" "applying patch $p" || \
-	    report_build_problem 6 $"Application of patch $p failed." \
-	    $"Check $dkms_tree/$module/$module_version/build/ for more information."
+        [[ ! -e $dkms_tree/$module/$module_version/build/patches/$p ]] && \
+            report_build_problem 5 \
+            $" Patch $p as specified in dkms.conf cannot be" \
+            $"found in $dkms_tree/$module/$module_version/build/patches/."
+        invoke_command "patch -p1 < ./patches/$p" "applying patch $p" || \
+            report_build_problem 6 $"Application of patch $p failed." \
+            $"Check $dkms_tree/$module/$module_version/build/ for more information."
     done
 
     # Run the pre_build script
@@ -1204,19 +1281,19 @@ do_build()
     invoke_command "$clean" "cleaning build area" background
     echo $"DKMS make.log for $module-$module_version for kernel $kernelver ($arch)" >> "$dkms_tree/$module/$module_version/build/make.log"
     date >> "$dkms_tree/$module/$module_version/build/make.log"
-    local the_make_command="${make_command/#make/make KERNELRELEASE=$kernelver}"
+    local the_make_command="${make_command/#make/make -j$parallel_jobs KERNELRELEASE=$kernelver}"
 
     invoke_command "{ $the_make_command; } >> $dkms_tree/$module/$module_version/build/make.log 2>&1" "$the_make_command" background || \
-	report_build_problem 10 $"Bad return status for module build on kernel: $kernelver ($arch)" \
-	$"Consult $dkms_tree/$module/$module_version/build/make.log for more information."
+        report_build_problem 10 $"Bad return status for module build on kernel: $kernelver ($arch)" \
+        $"Consult $dkms_tree/$module/$module_version/build/make.log for more information."
 
     # Make sure all the modules built successfully
     for ((count=0; count < ${#built_module_name[@]}; count++)); do
-	[[ -e ${built_module_location[$count]}${built_module_name[$count]}$module_suffix ]] && continue
-	report_build_problem 7 \
-	    $" Build of ${built_module_name[$count]}$module_suffix failed for: $kernelver ($arch)" \
-	    $"Consult the make.log in the build directory" \
-	    $"$dkms_tree/$module/$module_version/build/ for more information."
+        [[ -e ${built_module_location[$count]}${built_module_name[$count]}$module_suffix ]] && continue
+        report_build_problem 7 \
+            $" Build of ${built_module_name[$count]}$module_suffix failed for: $kernelver ($arch)" \
+            $"Consult the make.log in the build directory" \
+            $"$dkms_tree/$module/$module_version/build/ for more information."
     done
     cd - >/dev/null
 
@@ -1228,8 +1305,9 @@ do_build()
     # Save a copy of the new module
     mkdir "$base_dir/module" >/dev/null
     for ((count=0; count < ${#built_module_name[@]}; count++)); do
-	[[ ${strip[$count]} != no ]] && strip -g "$dkms_tree/$module/$module_version/build/${built_module_location[$count]}${built_module_name[$count]}$module_suffix"
-	cp -f "$dkms_tree/$module/$module_version/build/${built_module_location[$count]}${built_module_name[$count]}$module_suffix" "$base_dir/module/${dest_module_name[$count]}$module_suffix" >/dev/null
+    [[ ${strip[$count]} != no ]] && strip -g "$dkms_tree/$module/$module_version/build/${built_module_location[$count]}${built_module_name[$count]}$module_suffix"
+    cp -f "$dkms_tree/$module/$module_version/build/${built_module_location[$count]}${built_module_name[$count]}$module_suffix" \
+        "$base_dir/module/${dest_module_name[$count]}$module_suffix" >/dev/null
     done
 
     # Run the post_build script
@@ -1248,17 +1326,17 @@ clean_build()
        -d $kernel_source_dir && \
        ! -h $kernel_source_dir && \
        ! $ksourcedir_fromcli ]]; then
-	echo $"Kernel cleanup unnecessary for this kernel.  Skipping..."
+        echo $"Kernel cleanup unnecessary for this kernel.  Skipping..."
     elif [[ ! $no_clean_kernel ]]; then
-	cd "$kernel_source_dir"
-	[[ $kerneldoth_contents ]] || invoke_command "make mrproper" "cleaning kernel tree (make mrproper)" background
-	[[ $config_contents ]] || echo "$config_contents" > .config
-	[[ $kerneldoth_contents ]] && echo "$kerneldoth_contents" > /boot/kernel.h
-	cd - >/dev/null
+        cd "$kernel_source_dir"
+        [[ $kerneldoth_contents ]] || invoke_command "make mrproper" "cleaning kernel tree (make mrproper)" background
+        [[ $config_contents ]] || echo "$config_contents" > .config
+        [[ $kerneldoth_contents ]] && echo "$kerneldoth_contents" > /boot/kernel.h
+        cd - >/dev/null
     fi
 
     # Clean the build directory
-    rm -rf "$dkms_tree/$module/$module_version/build/*"
+    rm -rf "$dkms_tree/$module/$module_version/build"
 }
 
 build_module()
@@ -1270,6 +1348,28 @@ build_module()
     echo $"DKMS: build completed."
 }
 
+# Force the installation of a module if this is listed
+# in the files in $forced_modules_dir, if any
+force_installation()
+{
+    forced_modules_dir="/usr/share/dkms/modules_to_force_install"
+    to_force=""
+    if [ -d $forced_modules_dir ]; then
+        for elem in $forced_modules_dir/*; do
+            if [ -e $elem ]; then
+                to_force="$to_force $(cat $elem)"
+            fi
+        done
+
+        for elem in $to_force; do
+            if [ "${1}" = "${elem}" ]; then
+                return 0
+            fi
+        done
+    fi
+    return 1
+}
+
 # Install a previously built module
 # There are huge swaths of code here that special-case for various distros.
 # They should be split into their own functions.
@@ -1280,20 +1380,27 @@ install_module()
     local base_dir="$dkms_tree/$module/$module_version/$kernelver/$arch"
     check_module_args install
 
+    # Save the status of $force
+    tmp_force="$force"
+
+    # If the module is set to be force-installed
+    force_installation $module && echo "Forcing installation of $module" \
+        && force="true"
+
     # Make sure that kernel exists to install into
     [[ -e $install_tree/$kernelver ]] || die 6 \
-	$"The directory $install_tree/$kernelver doesn't exist." \
-	$"You cannot install a module onto a non-existant kernel."
+        $"The directory $install_tree/$kernelver doesn't exist." \
+        $"You cannot install a module onto a non-existant kernel."
 
     # Read the conf file
     read_conf_or_die "$kernelver" "$arch"
 
     # Check that its not already installed (kernel symlink)
     is_module_installed "$module" "$module_version" "$kernelver" "$arch" && die 5 \
-	$"This module/version combo is already installed" \
-	$"for kernel: $kernelver ($arch)"
+        $"This module/version combo is already installed" \
+        $"for kernel: $kernelver ($arch)"
 
-    # if upgrading using rpm_safe_upgrade, go ahead and force the install
+    # If upgrading using rpm_safe_upgrade, go ahead and force the install
     # else we can wind up with the first half of an upgrade failing to install anything,
     # while the second half of the upgrade, the removal, then succeeds, leaving us with
     # nothing installed.
@@ -1303,84 +1410,86 @@ install_module()
     local lib_tree="$install_tree/$kernelver"
     local count
     for ((count=0; count < ${#built_module_name[@]}; count++)); do
-	echo $""
-	echo $"${dest_module_name[$count]}$module_suffix:"
-	# Check this version against what is already in the kernel
-	check_version_sanity "$kernelver" "$arch" \
-	    "$obsolete_by" "${dest_module_name[$count]}" || continue
-
-	if ((count == 0)) && ! run_build_script pre_install "$pre_install" && \
-	    ! [[ $force ]]; then
-	    die 101 $"pre_install failed, aborting install." \
-		$"You may override by specifying --force."
-	fi
-	local module_count=$(find $lib_tree -name ${dest_module_name[$count]}$module_suffix -type f | wc -l | awk {'print $1'})
-	echo $" - Original module"
-	if [[ -L $dkms_tree/$module/kernel-$kernelver-$arch && \
-	    -e $dkms_tree/$module/original_module/$kernelver/$arch/${dest_module_name[$count]}$module_suffix ]]; then
-	    echo $"   - An original module was already stored during a previous install"
-	elif ! [[ -L $dkms_tree/$module/kernel-$kernelver-$arch ]]; then
-	    local archive_pref1="$lib_tree/extra/${dest_module_name[$count]}$module_suffix"
-	    local archive_pref2="$lib_tree/updates/${dest_module_name[$count]}$module_suffix"
-	    local archive_pref3="$lib_tree${dest_module_location[$count]}/${dest_module_name[$count]}$module_suffix"
-	    local archive_pref4=""
-	    ((module_count == 1)) && archive_pref4=$(find $lib_tree -name ${dest_module_name[$count]}$module_suffix -type f)
-	    local original_module=""
-	    local found_orginal=""
-	    for original_module in $archive_pref1 $archive_pref2 $archive_pref3 $archive_pref4; do
-		[[ -f $original_module ]] || continue
-		case "$running_distribution" in
-		    Debian* | Ubuntu* ) ;;
-		    *)
-			echo $"   - Found $original_module"
-			echo $"   - Storing in $dkms_tree/$module/original_module/$kernelver/$arch/"
-			echo $"   - Archiving for uninstallation purposes"
-			mkdir -p "$dkms_tree/$module/original_module/$kernelver/$arch"
-			mv -f "$original_module" "$dkms_tree/$module/original_module/$kernelver/$arch/"
-			;;
-		esac
-		found_original="yes"
-		break
-	    done
-	    if [[ ! $found_original ]] && ((module_count > 1)); then
-		echo $"   - Multiple original modules exist but DKMS does not know which to pick"
-		echo $"   - Due to the confusion, none will be considered during a later uninstall"
-	    elif [[ ! $found_original ]]; then
-		echo $"   - No original module exists within this kernel"
-	    fi
-	else
-	    echo $"   - This kernel never originally had a module by this name"
-	fi
-
-	if ((module_count > 1)); then
-	    echo $" - Multiple same named modules!"
-	    echo $"   - $module_count named ${dest_module_name[$count]}$module_suffix in $lib_tree/"
-	    case "$running_distribution" in
-		Debian* | Ubuntu* ) ;;
-		*)
-		    echo $"   - All instances of this module will now be stored for reference purposes ONLY"
-		    echo $"   - Storing in $dkms_tree/$module/original_module/$kernelver/$arch/collisions/"
-		    ;;
-	    esac
-	    for module_dup in $(find $lib_tree -name ${dest_module_name[$count]}$module_suffix -type f); do
-		dup_tree="${module_dup#$lib_tree}";
-		dup_tree="${dup_tree/${dest_module_name[$count]}$module_suffix}"
-		case "$running_distribution" in
-		Debian* | Ubuntu* ) ;;
-		*)
-		   echo $"     - Stored $module_dup"
-		   mkdir -p "$dkms_tree/$module/original_module/$kernelver/$arch/collisions/$dup_tree"
-		   mv -f $module_dup "$dkms_tree/$module/original_module/$kernelver/$arch/collisions/$dup_tree"
-		   ;;
-		esac
-	    done
-	fi
-
-	# Copy module to its location
-	echo $" - Installation"
-	echo $"   - Installing to $install_tree/$kernelver${dest_module_location[$count]}/"
-	mkdir -p $install_tree/$kernelver${dest_module_location[$count]}
-	cp -f "$base_dir/module/${dest_module_name[$count]}$module_suffix" "$install_tree/$kernelver${dest_module_location[$count]}/${dest_module_name[$count]}$module_suffix"
+    echo $""
+    echo $"${dest_module_name[$count]}$module_suffix:"
+    # Check this version against what is already in the kernel
+    check_version_sanity "$kernelver" "$arch" "$obsolete_by" "${dest_module_name[$count]}" || continue
+
+    if ((count == 0)) && ! run_build_script pre_install "$pre_install" && ! [[ $force ]]; then
+        die 101 $"pre_install failed, aborting install." \
+            $"You may override by specifying --force."
+    fi
+    local module_count=$(find $lib_tree -name ${dest_module_name[$count]}$module_suffix -type f | wc -l | awk {'print $1'})
+    echo $" - Original module"
+    if [[ -L $dkms_tree/$module/kernel-$kernelver-$arch && \
+        -e $dkms_tree/$module/original_module/$kernelver/$arch/${dest_module_name[$count]}$module_suffix ]]; then
+        echo $"   - An original module was already stored during a previous install"
+    elif ! [[ -L $dkms_tree/$module/kernel-$kernelver-$arch ]]; then
+        local archive_pref1="$lib_tree/extra/${dest_module_name[$count]}$module_suffix"
+        local archive_pref2="$lib_tree/updates/${dest_module_name[$count]}$module_suffix"
+        local archive_pref3="$lib_tree${dest_module_location[$count]}/${dest_module_name[$count]}$module_suffix"
+        local archive_pref4=""
+        ((module_count == 1)) && archive_pref4=$(find $lib_tree -name ${dest_module_name[$count]}$module_suffix -type f)
+        local original_module=""
+        local found_orginal=""
+        for original_module in $archive_pref1 $archive_pref2 $archive_pref3 $archive_pref4; do
+            [[ -f $original_module ]] || continue
+            case "$running_distribution" in
+                Debian* | Ubuntu* )
+                    ;;
+                *)
+                echo $"   - Found $original_module"
+                echo $"   - Storing in $dkms_tree/$module/original_module/$kernelver/$arch/"
+                echo $"   - Archiving for uninstallation purposes"
+                mkdir -p "$dkms_tree/$module/original_module/$kernelver/$arch"
+                mv -f "$original_module" "$dkms_tree/$module/original_module/$kernelver/$arch/"
+                ;;
+            esac
+            found_original="yes"
+            break
+        done
+        if [[ ! $found_original ]] && ((module_count > 1)); then
+            echo $"   - Multiple original modules exist but DKMS does not know which to pick"
+            echo $"   - Due to the confusion, none will be considered during a later uninstall"
+        elif [[ ! $found_original ]]; then
+            echo $"   - No original module exists within this kernel"
+        fi
+    else
+        echo $"   - This kernel never originally had a module by this name"
+    fi
+
+    if ((module_count > 1)); then
+        echo $" - Multiple same named modules!"
+        echo $"   - $module_count named ${dest_module_name[$count]}$module_suffix in $lib_tree/"
+        case "$running_distribution" in
+            Debian* | Ubuntu* )
+                ;;
+            *)
+                echo $"   - All instances of this module will now be stored for reference purposes ONLY"
+                echo $"   - Storing in $dkms_tree/$module/original_module/$kernelver/$arch/collisions/"
+                ;;
+        esac
+        for module_dup in $(find $lib_tree -name ${dest_module_name[$count]}$module_suffix -type f); do
+            dup_tree="${module_dup#$lib_tree}";
+            dup_tree="${dup_tree/${dest_module_name[$count]}$module_suffix}"
+            case "$running_distribution" in
+                Debian* | Ubuntu* )
+                    ;;
+                *)
+                   echo $"     - Stored $module_dup"
+                   mkdir -p "$dkms_tree/$module/original_module/$kernelver/$arch/collisions/$dup_tree"
+                   mv -f $module_dup "$dkms_tree/$module/original_module/$kernelver/$arch/collisions/$dup_tree"
+                   ;;
+            esac
+        done
+    fi
+
+    # Copy module to its location
+    echo $" - Installation"
+    echo $"   - Installing to $install_tree/$kernelver${dest_module_location[$count]}/"
+    mkdir -p $install_tree/$kernelver${dest_module_location[$count]}
+    [[ $symlink_modules ]] && symlink="-s"
+    cp -f $symlink  "$base_dir/module/${dest_module_name[$count]}$module_suffix" "$install_tree/$kernelver${dest_module_location[$count]}/${dest_module_name[$count]}$module_suffix"
 
     done
 
@@ -1388,11 +1497,13 @@ install_module()
     rm -f "$dkms_tree/$module/kernel-$kernelver-$arch" 2>/dev/null
     ln -s "$module_version/$kernelver/$arch" "$dkms_tree/$module/kernel-$kernelver-$arch" 2>/dev/null
 
-    # add to kabi-tracking
-    if [[ ${weak_modules} ]]; then
-	echo $"Adding any weak-modules"
-	list_each_installed_module "$module" "$kernelver" "$arch" | ${weak_modules} --add-modules
-    fi
+    # Add to kabi-tracking
+	if [ -z "$NO_WEAK_MODULES" ]; then
+		if [[ ${weak_modules} ]]; then
+			echo $"Adding any weak-modules"
+			list_each_installed_module "$module" "$kernelver" "$arch" | ${weak_modules} ${weak_modules_no_initrd} --add-modules
+		fi
+	fi
 
     # Run the post_install script
     run_build_script post_install "$post_install"
@@ -1403,20 +1514,23 @@ install_module()
     etc_sysconfig_kernel_modify "add"
 
     invoke_command "do_depmod $kernelver" "depmod" background || {
-	do_uninstall "$kernelver" "$arch"
-	die 6 $"Problems with depmod detected.  Automatically uninstalling this module." \
-	    $"DKMS: Install Failed (depmod problems).  Module rolled back to built state."
-	    exit 6
+        do_uninstall "$kernelver" "$arch"
+        die 6 $"Problems with depmod detected.  Automatically uninstalling this module." \
+            $"DKMS: Install Failed (depmod problems).  Module rolled back to built state."
+            exit 6
     }
 
     # Do remake_initrd things (save old initrd)
     [[ $remake_initrd ]] && ! make_initrd "$kernelver" "$arch" && {
-	do_uninstall "$kernelver" "$arch"
-	die 7 $"Problems with mkinitrd detected.  Automatically uninstalling this module." \
-	    $"DKMS: Install Failed (mkinitrd problems).  Module rolled back to built state."
+        do_uninstall "$kernelver" "$arch"
+        die 7 $"Problems with mkinitrd detected.  Automatically uninstalling this module." \
+            $"DKMS: Install Failed (mkinitrd problems).  Module rolled back to built state."
     }
     echo $""
     echo $"DKMS: install completed."
+
+    # Restore the status of $force
+    force="$tmp_force"
 }
 
 # List each kernel object that has been installed for a particular module.
@@ -1428,8 +1542,8 @@ list_each_installed_module()
     local count
     local real_dest_module_location
     for ((count=0; count < ${#built_module_name[@]}; count++)); do
-	real_dest_module_location="$(find_actual_dest_module_location $1 $count $2 $3)"
-	echo "$install_tree/$2${real_dest_module_location}/${dest_module_name[$count]}$module_suffix"
+        real_dest_module_location="$(find_actual_dest_module_location $1 $count $2 $3)"
+        echo "$install_tree/$2${real_dest_module_location}/${dest_module_name[$count]}$module_suffix"
     done
 }
 
@@ -1445,7 +1559,7 @@ is_module_built() {
     [[ -d $d/module ]] || return 1
     read_conf_or_die "$3" "$4" "$dkms_tree/$1/$2/source/dkms.conf"
     for m in "${dest_module_name[@]}"; do
-	[[ -f $d/module/$m.ko || -f $d/module/$m.o ]] || return 1
+        [[ -f $d/module/$m.ko || -f $d/module/$m.o ]] || return 1
     done
 }
 
@@ -1462,24 +1576,24 @@ is_module_installed() { is_module_built "$@" && _is_module_installed "$@"; }
 
 maybe_add_module() (
     is_module_added "$1" "$2" && {
-	echo $"Module $1/$2 already added."
-	return 0
+        echo $"Module $1/$2 already added."
+        return 0
     }
     module="$1" module_version="$2" add_module
 )
 
 maybe_build_module() (
     is_module_built "$1" "$2" "$3" "$4" && {
-	echo $"Module $1/$2 already built for kernel $3/4"
-	return 0
+        echo $"Module $1/$2 already built for kernel $3/4"
+        return 0
     }
     module="$1" module_version="$2" kernelver="$3" arch="$4" build_module
 )
 
 maybe_install_module() (
     is_module_installed "$1" "$2" "$3" "$4" && {
-	echo $"Module $1/$2 already installed on kernel $3/$4"
-	return 0
+        echo $"Module $1/$2 already installed on kernel $3/$4"
+        return 0
     }
     module="$1" module_version="$2" kernelver="$3" arch="$4" install_module
 )
@@ -1487,21 +1601,21 @@ maybe_install_module() (
 build_modules() {
     local i=0
     for ((i=0; i < ${#kernelver[@]}; i++)); do
-	maybe_build_module "$module" "$module_version" "${kernelver[$i]}" "${arch[$i]}"
+        maybe_build_module "$module" "$module_version" "${kernelver[$i]}" "${arch[$i]}"
     done
 }
 
 install_modules() {
     local i=0
     for ((i=0; i < ${#kernelver[@]}; i++)); do
-	maybe_install_module "$module" "$module_version" "${kernelver[$i]}" "${arch[$i]}"
+        maybe_install_module "$module" "$module_version" "${kernelver[$i]}" "${arch[$i]}"
     done
 }
 
 check_module_exists() {
     is_module_added "$module" "$module_version" && return
     die 2 $"DKMS tree does not contain: $module-$module_version" \
-	$"Build cannot continue without the proper tree."
+        $"Build cannot continue without the proper tree."
 }
 
 possible_dest_module_locations()
@@ -1533,11 +1647,11 @@ find_actual_dest_module_location()
     dkms_owned="${dkms_tree}/${module}/kernel-${kernelver}-${arch}/module/${dest_module_name[$count]}${module_suffix}"
 
     for l in $locations; do
-	installed="${install_tree}/${kernelver}${l}/${dest_module_name[${count}]}${module_suffix}"
-	if [[ -f ${installed} ]] && diff "${dkms_owned}" "${installed}" > /dev/null 2>&1; then
-	    echo "${l}"
-	    return 0
-	fi
+        installed="${install_tree}/${kernelver}${l}/${dest_module_name[${count}]}${module_suffix}"
+        if [[ -f ${installed} ]] && diff "${dkms_owned}" "${installed}" > /dev/null 2>&1; then
+            echo "${l}"
+            return 0
+        fi
     done
 
 }
@@ -1562,51 +1676,57 @@ do_uninstall()
     local kernel_symlink=$(readlink -f "$dkms_tree/$module/kernel-$1-$2")
     local real_dest_module_location
     if [[ $kernel_symlink = $dkms_tree/$module/$module_version/$1/$2 ]]; then
-	was_active="true"
-	echo $""
-	echo $"Status: Before uninstall, this module version was ACTIVE on this kernel."
-	# remove kabi-tracking if last instance removed
-	if [[ ${weak_modules} ]] && \
-	    (module_status_built $module $module_version |grep -q "installed"); then
-	    echo $"Removing any linked weak-modules"
-	    list_each_installed_module "$module" "$1" "$2" | ${weak_modules} --remove-modules
-	fi
-
-	for ((count=0; count < ${#built_module_name[@]}; count++)); do
-	    real_dest_module_location="$(find_actual_dest_module_location $module $count $1 $2)"
-	    echo $""
-	    echo $"${dest_module_name[$count]}$module_suffix:"
-	    echo $" - Uninstallation"
-	    echo $"   - Deleting from: $install_tree/$1${real_dest_module_location}/"
-	    rm -f "$install_tree/$1${real_dest_module_location}/${dest_module_name[$count]}$module_suffix"
-	    echo $" - Original module"
-	    if [[ -e $dkms_tree/$module/original_module/$1/$2/${dest_module_name[$count]}$module_suffix ]]; then
-		case "$running_distribution" in
-		Debian* | Ubuntu* ) ;;
-		*)
-		    echo $"   - Archived original module found in the DKMS tree"
-		    echo $"   - Moving it to: $install_tree/$1${DEST_MODULE_LOCATION[$count]}/"
-		    mkdir -p "$install_tree/$1${DEST_MODULE_LOCATION[$count]}/"
-		    mv -f "$dkms_tree/$module/original_module/$1/$2/${dest_module_name[$count]}$module_suffix" \
-			"$install_tree/$1${DEST_MODULE_LOCATION[$count]}/" 2>/dev/null
-		    ;;
-		esac
-	    else
-		echo $"   - No original module was found for this module on this kernel."
-		echo $"   - Use the dkms install command to reinstall any previous module version."
-
-		# Remove modules_conf entries from /etc/modules.conf if remake_initrd is set or if this is last instance removed
-		if [[ $remake_initrd ]] || \
-		    (do_status $module $module_version | grep -q "installed"); then
-		    echo $""
-		    moduleconfig_remove "$1"
+        was_active="true"
+        echo $""
+        echo $"Status: Before uninstall, this module version was ACTIVE on this kernel."
+        # remove kabi-tracking if last instance removed
+		if [ -z "$NO_WEAK_MODULES" ]; then
+			if [[ ${weak_modules} ]] && (module_status_built $module $module_version |grep -q "installed"); then
+				echo $"Removing any linked weak-modules"
+				list_each_installed_module "$module" "$1" "$2" | ${weak_modules} ${weak_modules_no_initrd} --remove-modules
+			fi
 		fi
-	    fi
-	done
-	rm -f "$dkms_tree/$module/kernel-$1-$2"
+
+    for ((count=0; count < ${#built_module_name[@]}; count++)); do
+        real_dest_module_location="$(find_actual_dest_module_location $module $count $1 $2)"
+        echo $""
+        echo $"${dest_module_name[$count]}$module_suffix:"
+        echo $" - Uninstallation"
+        echo $"   - Deleting from: $install_tree/$1${real_dest_module_location}/"
+        rm -f "$install_tree/$1${real_dest_module_location}/${dest_module_name[$count]}$module_suffix"
+        dir_to_remove="${real_dest_module_location#/}"
+        while [ "${dir_to_remove}" != "${dir_to_remove#/}" ]; do
+            dir_to_remove="${dir_to_remove#/}"
+        done
+        (cd "$install_tree/$1" && rmdir --parents --ignore-fail-on-non-empty "${dir_to_remove}" || true)
+        echo $" - Original module"
+        if [[ -e $dkms_tree/$module/original_module/$1/$2/${dest_module_name[$count]}$module_suffix ]]; then
+            case "$running_distribution" in
+                Debian* | Ubuntu* )
+                    ;;
+                *)
+                    echo $"   - Archived original module found in the DKMS tree"
+                    echo $"   - Moving it to: $install_tree/$1${DEST_MODULE_LOCATION[$count]}/"
+                    mkdir -p "$install_tree/$1${DEST_MODULE_LOCATION[$count]}/"
+                    mv -f "$dkms_tree/$module/original_module/$1/$2/${dest_module_name[$count]}$module_suffix" \
+                    "$install_tree/$1${DEST_MODULE_LOCATION[$count]}/" 2>/dev/null
+                    ;;
+            esac
+            else
+            echo $"   - No original module was found for this module on this kernel."
+            echo $"   - Use the dkms install command to reinstall any previous module version."
+
+            # Remove modules_conf entries from /etc/modules.conf if remake_initrd is set or if this is last instance removed
+            if [[ $remake_initrd ]] || (do_status $module $module_version | grep -q "installed"); then
+                echo $""
+                moduleconfig_remove "$1"
+            fi
+        fi
+    done
+    rm -f "$dkms_tree/$module/kernel-$1-$2"
     else
-	echo $""
-	echo $"Status: This module version was INACTIVE for this kernel."
+        echo $""
+        echo $"Status: This module version was INACTIVE for this kernel."
     fi
 
     # Run the post_remove script
@@ -1617,22 +1737,21 @@ do_uninstall()
 
     # Do remake_initrd things (remake initrd)
     if [[ $remake_initrd && $was_active ]] && ! make_initrd "$1" "$2"; then
-	warn $"There was a problem remaking your initrd.  You must manually remake it" \
-	    $"before booting into this kernel."
+        warn $"There was a problem remaking your initrd.  You must manually remake it" \
+            $"before booting into this kernel."
     fi
 
     # Delete the original_module if nothing for this kernel is installed anymore
-    if [[ $was_active && -d $dkms_tree/$module/original_module/$1/$2 && \
-	! -d $dkms_tree/$module/original_module/$1/$2/collisions ]]; then
-	echo $""
-	echo $"Removing original_module from DKMS tree for kernel $1 ($2)"
-	rm -rf "$dkms_tree/$module/original_module/$1/$2" 2>/dev/null
-	[[ $(find $dkms_tree/$module/original_module/$1/* -maxdepth 0 -type d 2>/dev/null) ]] || rm -rf "$dkms_tree/$module/original_module/$1"
+    if [[ $was_active && -d $dkms_tree/$module/original_module/$1/$2 && ! -d $dkms_tree/$module/original_module/$1/$2/collisions ]]; then
+        echo $""
+        echo $"Removing original_module from DKMS tree for kernel $1 ($2)"
+        rm -rf "$dkms_tree/$module/original_module/$1/$2" 2>/dev/null
+        [[ $(find $dkms_tree/$module/original_module/$1/* -maxdepth 0 -type d 2>/dev/null) ]] || rm -rf "$dkms_tree/$module/original_module/$1"
     elif [[ $was_active && -d $dkms_tree/$module/original_module/$1/$2/collisions ]]; then
-	echo $""
-	echo $"Keeping directory $dkms_tree/$module/original_module/$1/$2/collisions/"
-	echo $"for your reference purposes.  Your kernel originally contained multiple"
-	echo $"same-named modules and this directory is now where these are located."
+        echo $""
+        echo $"Keeping directory $dkms_tree/$module/original_module/$1/$2/collisions/"
+        echo $"for your reference purposes.  Your kernel originally contained multiple"
+        echo $"same-named modules and this directory is now where these are located."
     fi
     [[ $(find $dkms_tree/$module/original_module/* -maxdepth 0 -type d 2>/dev/null) ]] || rm -rf "$dkms_tree/$module/original_module"
 
@@ -1652,13 +1771,13 @@ uninstall_module()
 
     # Check that $module is in the dkms tree
     [[ -d $dkms_tree/$module ]] || die 2 \
-	$"There are no instances of module: $module" \
-	$"located in the DKMS tree."
+        $"There are no instances of module: $module" \
+        $"located in the DKMS tree."
 
     # Make sure that its installed in the first place
     [[ -d $dkms_tree/$module/$module_version ]] || die 3 \
-	$"The module/version combo: $module-$module_version" \
-	$"is not located in the DKMS tree."
+        $"The module/version combo: $module-$module_version" \
+        $"is not located in the DKMS tree."
 
     # Read the conf file
     read_conf_or_die "$kernelver" "$arch"
@@ -1666,8 +1785,8 @@ uninstall_module()
     # Only do stuff if module/module version is currently installed
     local kernel_symlink=$(readlink -f "$dkms_tree/$module/kernel-$kernelver-$arch")
     [[ $kernel_symlink = $dkms_tree/$module/$module_version/$kernelver/$arch ]] || die 5 \
-	    $"The module $module $module_version is not currently installed." \
-	    $"This module is not currently ACTIVE for kernel $kernelver ($arch)."
+        $"The module $module $module_version is not currently installed." \
+        $"This module is not currently ACTIVE for kernel $kernelver ($arch)."
     do_uninstall "$kernelver" "$arch"
 }
 
@@ -1676,68 +1795,67 @@ remove_module()
 {
     # Check that the right arguments were passed
     if [[ ! ($module && $module_version) || $kernels_arches_default  ]]; then
-	die 1 $"Invalid number of parameters passed." \
-	    $"Usage: remove <module>/<module-version> --all" \
-	    $"   or: remove <module>/<module-version> -k <kernel-version>"
+        die 1 $"Invalid number of parameters passed." \
+            $"Usage: remove <module>/<module-version> --all" \
+            $"   or: remove <module>/<module-version> -k <kernel-version>"
     fi
 
     # Check that $module is in the dkms tree
     if ! [[ -d $dkms_tree/$module/$module_version ]]; then
-	die 3 $"There are no instances of module: $module" \
-	    $"$module_version located in the DKMS tree."
+        die 3 $"There are no instances of module: $module" \
+            $"$module_version located in the DKMS tree."
     fi
 
     local i
     for ((i=0; i < ${#kernelver[@]}; i++)); do
-	# make sure its there first before removing
-	if ! [[ -d $dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]} ]]; then
-	    die 4 $"There is no instance of $module $module_version" \
-		$"for kernel ${kernelver[$i]} (${arch[$i]}) located in the DKMS tree."
-	fi
+        # Make sure its there first before removing
+        if ! [[ -d $dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]} ]]; then
+            die 4 $"There is no instance of $module $module_version" \
+            $"for kernel ${kernelver[$i]} (${arch[$i]}) located in the DKMS tree."
+        fi
 
-	# Do --rpm_safe_upgrade check (exit out and don't do remove if inter-release RPM upgrade scenario occurs)
-	if [[ $rpm_safe_upgrade ]]; then
-	    local pppid=$(awk '/PPid:/ {print $2}' /proc/$PPID/status)
-	    local time_stamp=$(ps -o lstart --no-headers -p $pppid 2>/dev/null)
-	    for lock_file in $tmp_location/dkms_rpm_safe_upgrade_lock.$pppid.*; do
-		[[ -f $lock_file ]] || continue
-		lock_head=$(head -n 1 $lock_file 2>/dev/null)
-		lock_tail=$(tail -n 1 $lock_file 2>/dev/null)
-		[[ $lock_head = $module-$module_version && $time_stamp && $lock_tail = $time_stamp ]] || continue
-		rm -f $lock_file
-		die 0 $"DKMS: Remove cancelled because --rpm_safe_upgrade scenario detected."
-	    done
-	fi
+        # Do --rpm_safe_upgrade check (exit out and don't do remove if inter-release RPM upgrade scenario occurs)
+        if [[ $rpm_safe_upgrade ]]; then
+            local pppid=$(awk '/PPid:/ {print $2}' /proc/$PPID/status)
+            local time_stamp=$(ps -o lstart --no-headers -p $pppid 2>/dev/null)
+            for lock_file in $tmp_location/dkms_rpm_safe_upgrade_lock.$pppid.*; do
+                [[ -f $lock_file ]] || continue
+                lock_head=$(head -n 1 $lock_file 2>/dev/null)
+                lock_tail=$(tail -n 1 $lock_file 2>/dev/null)
+                [[ $lock_head = $module-$module_version && $time_stamp && $lock_tail = $time_stamp ]] || continue
+                rm -f $lock_file
+                die 0 $"DKMS: Remove cancelled because --rpm_safe_upgrade scenario detected."
+            done
+        fi
 
-	# Read the conf file
-	read_conf_or_die "${kernelver[$i]}" "${arch[$i]}"
+        # Read the conf file
+        read_conf_or_die "${kernelver[$i]}" "${arch[$i]}"
 
-	do_uninstall "${kernelver[$i]}" "${arch[$i]}"
+        do_uninstall "${kernelver[$i]}" "${arch[$i]}"
 
-	# Delete the $kernel_version/$arch_used part of the tree
-	rm -rf "$dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}"
-	[[ $(find $dkms_tree/$module/$module_version/${kernelver[$i]}/* \
-	    -maxdepth 0 -type d 2>/dev/null) ]] || \
-	    rm -rf "$dkms_tree/$module/$module_version/${kernelver[$i]}"
+        # Delete the $kernel_version/$arch_used part of the tree
+        rm -rf "$dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}"
+        [[ $(find $dkms_tree/$module/$module_version/${kernelver[$i]}/* -maxdepth 0 -type d 2>/dev/null) ]] || \
+            rm -rf "$dkms_tree/$module/$module_version/${kernelver[$i]}"
     done
 
     # Delete the $module_version part of the tree if no other $module_version/$kernel_version dirs exist
     if ! find $dkms_tree/$module/$module_version/* -maxdepth 0 -type d 2>/dev/null | egrep -qv "(build|tarball|driver_disk|rpm|deb|source)$"; then
-	echo $""
-	echo $"------------------------------"
-	echo $"Deleting module version: $module_version"
-	echo $"completely from the DKMS tree."
-	echo $"------------------------------"
-	rm -rf "$dkms_tree/$module/$module_version"
-	echo $"Done."
+        echo $""
+        echo $"------------------------------"
+        echo $"Deleting module version: $module_version"
+        echo $"completely from the DKMS tree."
+        echo $"------------------------------"
+        rm -rf "$dkms_tree/$module/$module_version"
+        echo $"Done."
     fi
 
     # Get rid of any remnant directories if necessary
     if (($(ls "$dkms_tree/$module" | wc -w | awk '{print $1}') == 0)); then
-	rm -rf "$dkms_tree/$module" 2>/dev/null
+        rm -rf "$dkms_tree/$module" 2>/dev/null
 
-	# Its now safe to completely remove references in /etc/sysconfig/kernel for SuSE
-	etc_sysconfig_kernel_modify "delete"
+        # Its now safe to completely remove references in /etc/sysconfig/kernel for SuSE
+        etc_sysconfig_kernel_modify "delete"
     fi
 }
 
@@ -1750,13 +1868,13 @@ find_module_from_ko()
     local kernellink
 
     for kernellink in "$dkms_tree"/*/kernel-*; do
-	[[ -L $kernellink ]] || continue
-	module=${kernellink#$dkms_tree/}
-	module=${module%/kernel-*}
-	diff "$kernellink/module/${basename_ko}" "${ko}" >/dev/null 2>&1 || continue
-	rest=$(readlink $kernellink)
-	echo "$module/$rest"
-	return 0
+        [[ -L $kernellink ]] || continue
+        module=${kernellink#$dkms_tree/}
+        module=${module%/kernel-*}
+        diff "$kernellink/module/${basename_ko}" "${ko}" >/dev/null 2>&1 || continue
+        rest=$(readlink $kernellink)
+        echo "$module/$rest"
+        return 0
     done
     return 1
 }
@@ -1768,24 +1886,23 @@ find_module_from_ko()
 module_status_weak() {
     # $1 = module, $2 = module version, $3 = kernel version weak installed to,
     # $4 = kernel arch, $5 = kernel version built for
+	[ -z "$NO_WEAK_MODULES" ] || return 1
     [[ $weak_modules ]] || return 1
-    local weak_ko mod installed_ko f ret=1 oifs=$IFS
+    local m v k a weak_ko mod installed_ko f ret=1 oifs=$IFS
     local -a already_found
     for weak_ko in "$install_tree/"*/weak-updates/*; do
-	[[ -e $weak_ko ]] || continue
-	[[ -L $weak_ko ]] && installed_ko="$(readlink -f "$weak_ko")" || continue
-	IFS=/ read m v k a < <(IFS=$oifs find_module_from_ko "$weak_ko") || continue
-	kern=${weak_ko#$install_tree/}
-	kern=${kern%/weak-updates/*}
-	[[ $m = ${1:-*} && $v = ${2:-*} && $k = ${5:-*} && \
-	    $a = ${4:-*} && $kern = ${3:-*} ]] || \
-	    continue
-	ret=0
-	for f in "${already_found[@]}"; do
-	    [[ $f = $m/$v/$kern/$a/$k ]] && continue 2
-	done
-	already_found[${#already_found[@]}]="$m/$v/$kern/$a/$k"
-	echo "installed-weak $m/$v/$kern/$a/$k"
+        [[ -e $weak_ko ]] || continue
+        [[ -L $weak_ko ]] && installed_ko="$(readlink -f "$weak_ko")" || continue
+        IFS=/ read m v k a < <(IFS=$oifs find_module_from_ko "$weak_ko") || continue
+        kern=${weak_ko#$install_tree/}
+        kern=${kern%/weak-updates/*}
+        [[ $m = ${1:-*} && $v = ${2:-*} && $k = ${5:-*} && $a = ${4:-*} && $kern = ${3:-*} ]] || continue
+        ret=0
+        for f in "${already_found[@]}"; do
+            [[ $f = $m/$v/$kern/$a/$k ]] && continue 2
+        done
+        already_found[${#already_found[@]}]="$m/$v/$kern/$a/$k"
+        echo "installed-weak $m/$v/$kern/$a/$k"
     done
     return $ret
 }
@@ -1795,8 +1912,8 @@ do_status_weak()
 {
     local mvka m v k a kern status
     while read status mvka; do
-	IFS=/ read m v k a kern <<< "$mvka"
-	echo "$m, $v, $k, $a: installed-weak from $kern"
+        IFS=/ read m v k a kern <<< "$mvka"
+        echo "$m, $v, $k, $a: installed-weak from $kern"
     done < <(module_status_weak "$@")
 }
 
@@ -1807,15 +1924,15 @@ module_status_built_extra() (
     read_conf "$3" "$4" "$dkms_tree/$1/$2/source/dkms.conf"
     [[ -d $dkms_tree/$1/original_module/$3/$4 ]] && echo -n " (original_module exists)"
     for ((count=0; count < ${#dest_module_name[@]}; count++)); do
-	tree_mod="$dkms_tree/$1/$2/$3/$4/module/${dest_module_name[$count]}$module_suffix"
-	if ! [[ -e $tree_mod ]]; then
-	    echo -n " (WARNING! Missing some built modules!)"
-	elif _is_module_installed "$@"; then
-	    real_dest="$(find_actual_dest_module_location "$1" $count "$3" "$4")"
-	    if ! diff -q "$tree_mod" "$install_tree/$3${real_dest}/${dest_module_name[$count]}$module_suffix" >/dev/null 2>&1; then
-		echo -n " (WARNING! Diff between built and installed module!)"
-	    fi
-	fi
+        tree_mod="$dkms_tree/$1/$2/$3/$4/module/${dest_module_name[$count]}$module_suffix"
+        if ! [[ -e $tree_mod ]]; then
+            echo -n " (WARNING! Missing some built modules!)"
+        elif _is_module_installed "$@"; then
+            real_dest="$(find_actual_dest_module_location "$1" $count "$3" "$4")"
+            if ! diff -q "$tree_mod" "$install_tree/$3${real_dest}/${dest_module_name[$count]}$module_suffix" >/dev/null 2>&1; then
+                echo -n " (WARNING! Diff between built and installed module!)"
+            fi
+        fi
     done
 )
 
@@ -1825,17 +1942,16 @@ module_status_built_extra() (
 module_status_built() {
     local ret=1 directory ka k a state oifs="$IFS" IFS=''
     for directory in "$dkms_tree/$1/$2/"${3:-[0-9].*}/${4:-*}; do
-	IFS="$oifs"
-	ka="${directory#$dkms_tree/$1/$2/}"
-	k="${ka%/*}"
-	a="${ka#*/}"
-	is_module_built "$1" "$2" "$k" "$a" || continue
-	ret=0
-	state="built"
-	_is_module_installed "$1" "$2" "$k" "$a" && \
-	    state="installed"
-	echo "$state $1/$2/$k/$a"
-	IFS=''
+        IFS="$oifs"
+        ka="${directory#$dkms_tree/$1/$2/}"
+        k="${ka%/*}"
+        a="${ka#*/}"
+        is_module_built "$1" "$2" "$k" "$a" || continue
+        ret=0
+        state="built"
+        _is_module_installed "$1" "$2" "$k" "$a" && state="installed"
+        echo "$state $1/$2/$k/$a"
+        IFS=''
     done
     IFS="$oifs"
     return $ret
@@ -1845,14 +1961,14 @@ module_status_built() {
 module_status() {
     local oifs="$IFS" IFS='' mv m v directory ret=1
     for directory in "$dkms_tree/"${1:-*}/${2:-*}; do
-	IFS="$oifs"
-	mv="${directory#$dkms_tree/}"
-	m="${mv%/*}"
-	v="${mv#*/}"
-	is_module_added "$m" "$v" || continue
-	ret=0
-	module_status_built "$m" "$v" "$3" "$4" || echo "added $m/$v"
-	IFS=''
+        IFS="$oifs"
+        mv="${directory#$dkms_tree/}"
+        m="${mv%/*}"
+        v="${mv#*/}"
+        is_module_added "$m" "$v" || continue
+        ret=0
+        module_status_built "$m" "$v" "$3" "$4" || echo "added $m/$v"
+        IFS=''
     done
     IFS="$oifs"
     return $ret
@@ -1864,13 +1980,17 @@ module_status() {
 do_status() {
     local status mvka m v k a
     while read status mvka; do
-	IFS=/ read m v k a <<< "$mvka"
-	case $status in
-	    added) echo "$m, $v: $status";;
-	    built|installed) echo -n "$m, $v, $k, $a: $status"
-		module_status_built_extra "$m" "$v" "$k" "$a"
-		echo;;
-	esac
+        IFS=/ read m v k a <<< "$mvka"
+        case $status in
+            added)
+                echo "$m, $v: $status"
+                ;;
+            built|installed)
+                echo -n "$m, $v, $k, $a: $status"
+                module_status_built_extra "$m" "$v" "$k" "$a"
+                echo
+                ;;
+        esac
     done < <(module_status "$@")
 }
 
@@ -1880,13 +2000,13 @@ show_status()
 {
     local j state_array
     if ((${#kernelver[@]} == 0)); then
-	do_status "$module" "$module_version" "$kernelver" "$arch"
-	do_status_weak "$module" "$module_version" "$kernelver" "$arch"
+        do_status "$module" "$module_version" "$kernelver" "$arch"
+        do_status_weak "$module" "$module_version" "$kernelver" "$arch"
     else
-	for ((j=0; j < ${#kernelver[@]}; j++)); do
-	    do_status "$module" "$module_version" "${kernelver[$j]}" "${arch[$j]}"
-	    do_status_weak "$module" "$module_version" "${kernelver[$j]}" "${arch[$j]}"
-	done
+    for ((j=0; j < ${#kernelver[@]}; j++)); do
+        do_status "$module" "$module_version" "${kernelver[$j]}" "${arch[$j]}"
+        do_status_weak "$module" "$module_version" "${kernelver[$j]}" "${arch[$j]}"
+    done
     fi
 }
 
@@ -1919,7 +2039,10 @@ delete_temporary_trees()
     temporary_trees_del_command=
 }
 
-in_temporary_trees() { [[ $temporary_trees_del_command ]] ;}
+in_temporary_trees()
+{
+    [[ $temporary_trees_del_command ]]
+}
 
 media_valid()
 {
@@ -1938,8 +2061,12 @@ make_driver_disk_floppy()
     rm -f "$image_name"
     invoke_command "dd if=/dev/zero of=$image_name bs=$(($size/20))k count=20" "making a blank floppy image" background
     case $fs in
-	vfat) invoke_command "mkdosfs $image_name" "mkdosfs" background;;
-	ext2) invoke_command "mke2fs -F $image_name" "mke2fs" background;;
+        vfat)
+            invoke_command "mkdosfs $image_name" "mkdosfs" background
+            ;;
+        ext2)
+            invoke_command "mke2fs -F $image_name" "mke2fs" background
+            ;;
     esac
 
     local mntdir=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX)
@@ -1957,8 +2084,12 @@ make_driver_disk_isotar()
     local source_dir="$3"
     local file
     case $type in
-	iso) invoke_command "mkisofs -v -r -J -pad -V $module -o $image_name ." "mkisofs" background;;
-	tar) invoke_command "tar cvf $image_name ." "tar" background;;
+        iso)
+            invoke_command "mkisofs -v -r -J -pad -V $module -o $image_name ." "mkisofs" background
+            ;;
+        tar)
+            invoke_command "tar cvf $image_name ." "tar" background
+            ;;
     esac
 }
 
@@ -1967,79 +2098,91 @@ make_driver_disk_media()
     echo "Copying files $2"
 
     case $media in
-	floppy*) make_driver_disk_floppy "$1" "$2";;
-	iso*) make_driver_disk_isotar "iso" "$1" "$2";;
-	tar*) make_driver_disk_isotar "tar" "$1" "$2";;
+        floppy*)
+            make_driver_disk_floppy "$1" "$2"
+            ;;
+        iso*)
+            make_driver_disk_isotar "iso" "$1" "$2"
+            ;;
+        tar*)
+            make_driver_disk_isotar "tar" "$1" "$2"
+            ;;
     esac
 }
 
 driver_disk_suffix()
 {
     case $media in
-	floppy*) echo "img";;
-	iso*) echo "iso";;
-	tar*) echo "tar";;
+    floppy*)
+        echo "img"
+        ;;
+    iso*)
+        echo "iso"
+        ;;
+    tar*)
+        echo "tar"
+        ;;
     esac
 }
 
 make_redhat_driver_disk()
 {
     local i count
-    # kludge to allow redhat1 driver disks with BOOT kernel modules (arch i386)
+    # Kludge to allow redhat1 driver disks with BOOT kernel modules (arch i386)
     if [[ $distro = redhat1 && $multi_arch = true ]]; then
-	local redhat1_okay="true"
-	local other_arch=""
-	for ((i=0; i < ${#kernelver[@]}; i++)); do
-	    if [[ ${arch[$i]} != i386 && $other_arch != ${arch[$i]} && $other_arch ]]; then
-		die 3 $"You have specified a Red Hat version 1 driver disk, but have also" \
-		    $"specified multiple architectures.  Version 1 does not support this." \
-		    $"Use 'redhat2' instead (only OSes >= RHEL3, FC1 support version 2)."
-	    elif [[ ${arch[$i]} != i386 && $other_arch != ${arch[$i]} && ! $other_arch ]]; then
-		other_arch="${arch[$i]}"
-	    fi
-	done
+        local redhat1_okay="true"
+        local other_arch=""
+        for ((i=0; i < ${#kernelver[@]}; i++)); do
+            if [[ ${arch[$i]} != i386 && $other_arch != ${arch[$i]} && $other_arch ]]; then
+                die 3 $"You have specified a Red Hat version 1 driver disk, but have also" \
+                    $"specified multiple architectures.  Version 1 does not support this." \
+                    $"Use 'redhat2' instead (only OSes >= RHEL3, FC1 support version 2)."
+            elif [[ ${arch[$i]} != i386 && $other_arch != ${arch[$i]} && ! $other_arch ]]; then
+                other_arch="${arch[$i]}"
+            fi
+        done
     fi
     if [ "$distro" == "redhat2" ]  && [ -z "$redhat1_okay" ]; then
-	echo $"Creating Red Hat v2 driver disk (arch support)."
-	echo $""
-	local rhdd_filename="rhdd"
+        echo $"Creating Red Hat v2 driver disk (arch support)."
+        echo $""
+        local rhdd_filename="rhdd"
     elif [ "$distro" == "redhat3" ] && [ -z "$redhat1_okay" ]; then
         echo $"Creating Red Hat v3 driver disk."
-	echo $""
-	make_redhat3_driver_disk
-	return
+        echo $""
+        make_redhat3_driver_disk
+        return
     else
-	echo $"Creating Red Hat v1 driver disk."
-	echo $""
-	local rhdd_filename="rhdd-6.1"
+        echo $"Creating Red Hat v1 driver disk."
+        echo $""
+        local rhdd_filename="rhdd-6.1"
     fi
 
     cpioarchive_dir_name=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX)
 
     for ((i=0; i < ${#kernelver[@]}; i++)); do
-	set_module_suffix "${kernelver[$i]}"
-
-	local dd_prefix="${kernelver[$i]}"
-	[[ $distro = redhat2 ]] && dd_prefix="${kernelver[$i]}/${arch[$i]}"
-	[[ $multi_arch = true && -z $redhat1_okay ]] && dd_prefix="${kernelver[$i]}/${arch[$i]}"
-	maybe_build_module "$module" "$module_version" "${kernelver[$i]}" "${arch[$i]}" || {
-	    rm -rf "$cpioarchive_dir_name"
-	    die 5 $"Cannot build $module/$module_version for redhat driver disk."
-	}
-	
-	# FIXME: add check for KMP binary RPMs to include in the driver disk
-	if [[ ! $kernel_version_list ]]; then
-	    kernel_version_list="kernel${kernelver[$i]}-${arch[$i]}"
-	else
-	    kernel_version_list="$kernel_version_list-kernel${kernelver[$i]}-${arch[$i]}"
-	fi
-	mkdir -p $cpioarchive_dir_name/$dd_prefix
-	for f in "$dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}/module/"*"$module_suffix"; do
-	    [[ -f $f ]] || continue
-	    echo "Marking ${f#$dkms_tree/$module/$module_version/}..."
-	    cp "$f" "$cpioarchive_dir_name/$dd_prefix/"
-	    modules_cgz_list="$dd_prefix/${f##*/} ${modules_cgz_list}"
-	done
+        set_module_suffix "${kernelver[$i]}"
+
+        local dd_prefix="${kernelver[$i]}"
+        [[ $distro = redhat2 ]] && dd_prefix="${kernelver[$i]}/${arch[$i]}"
+        [[ $multi_arch = true && -z $redhat1_okay ]] && dd_prefix="${kernelver[$i]}/${arch[$i]}"
+        maybe_build_module "$module" "$module_version" "${kernelver[$i]}" "${arch[$i]}" || {
+            rm -rf "$cpioarchive_dir_name"
+            die 5 $"Cannot build $module/$module_version for redhat driver disk."
+        }
+
+        # FIXME: add check for KMP binary RPMs to include in the driver disk
+        if [[ ! $kernel_version_list ]]; then
+            kernel_version_list="kernel${kernelver[$i]}-${arch[$i]}"
+        else
+            kernel_version_list="$kernel_version_list-kernel${kernelver[$i]}-${arch[$i]}"
+        fi
+        mkdir -p $cpioarchive_dir_name/$dd_prefix
+        for f in "$dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}/module/"*"$module_suffix"; do
+            [[ -f $f ]] || continue
+            echo "Marking ${f#$dkms_tree/$module/$module_version/}..."
+            cp "$f" "$cpioarchive_dir_name/$dd_prefix/"
+            modules_cgz_list="$dd_prefix/${f##*/} ${modules_cgz_list}"
+        done
 
     done
 
@@ -2054,18 +2197,18 @@ make_redhat_driver_disk()
 
     local files_into_driverdisk="modules.cgz $rhdd_filename modules.alias"
     for file in $files_for_driverdisk; do
-	if [[ -e $dkms_tree/$module/$module_version/source/redhat_driver_disk/$file ]]; then
-	    files_into_driverdisk="$file $files_into_driverdisk"
-	    cp -f "$dkms_tree/$module/$module_version/source/redhat_driver_disk/$file" "$driver_disk_dir/" 2>/dev/null
-	else
-	    warn $"File: $file not found in $dkms_tree/$module/$module_version/source/redhat_driver_disk/"
-	fi
+        if [[ -e $dkms_tree/$module/$module_version/source/redhat_driver_disk/$file ]]; then
+            files_into_driverdisk="$file $files_into_driverdisk"
+            cp -f "$dkms_tree/$module/$module_version/source/redhat_driver_disk/$file" "$driver_disk_dir/" 2>/dev/null
+        else
+            warn $"File: $file not found in $dkms_tree/$module/$module_version/source/redhat_driver_disk/"
+        fi
     done
     echo "$module-$module_version driver disk" > "$driver_disk_dir/$rhdd_filename"
 
     # Make sure the kernel_version_list is not too long
     if (( $(echo $kernel_version_list | wc -m | awk {'print $1'}) > 200 )); then
-	kernel_version_list="manykernels"
+        kernel_version_list="manykernels"
     fi
 
     local suffix="$(driver_disk_suffix)"
@@ -2077,17 +2220,17 @@ make_redhat_driver_disk()
     invoke_command "echo '$modules_cgz_list' | cpio -oH crc 2>/dev/null | gzip -9 > ./modules.cgz" "compressing modules.cgz" background
     cp -f ./modules.cgz "$driver_disk_dir/"
 
-    # generate modules.alias file
+    # Generate modules.alias file
     # On 2.4 kernels and kernels with no aliases. this won't yield anything.
     touch ./modules.alias
     for f in ${modules_cgz_list}; do
-	module_wo_suffix=$(basename ${f} ${module_suffix})
-	tmp_alias="./modules.alias.${module_wo_suffix}"
-	f="./${f}"
-	depmod -n ${f} 2>/dev/null | grep ^alias > ${tmp_alias}
-	if [[ -s ${tmp_alias} ]]; then
-	    cat "${tmp_alias}" >> ./modules.alias
-	fi
+        module_wo_suffix=$(basename ${f} ${module_suffix})
+        tmp_alias="./modules.alias.${module_wo_suffix}"
+        f="./${f}"
+        depmod -n ${f} 2>/dev/null | grep ^alias > ${tmp_alias}
+        if [[ -s ${tmp_alias} ]]; then
+            cat "${tmp_alias}" >> ./modules.alias
+        fi
     done
     [[ -e ./modules.alias ]] && cp -f ./modules.alias "$driver_disk_dir/"
     # FIXME: add rpms/ directory, copy in KMP RPMs, run createrepo --pretty
@@ -2113,15 +2256,15 @@ make_driver_disk()
 {
     # Check that the right arguments were passed
     if ! [[ $module && $module_version && $distro && $kernelver ]]; then
-	die 1 $"Invalid number of parameters passed." \
-	$"Usage: mkdriverdisk <module>/<module-version> -d <distro> -k <kernelver> [--media floppy|iso|tar]"
+        die 1 $"Invalid number of parameters passed." \
+        $"Usage: mkdriverdisk <module>/<module-version> -d <distro> -k <kernelver> [--media floppy|iso|tar]"
     fi
 
-    # default to floppy media
+    # Default to floppy media
     [[ $media ]] || media="floppy"
     if ! media_valid; then
-	die 1 $"Media $media is invalid." \
-	    $"Usage: mkdriverdisk <module>/<module-version> -d <distro> -k <kernelver> [--media floppy|iso|tar]"
+        die 1 $"Media $media is invalid." \
+            $"Usage: mkdriverdisk <module>/<module-version> -d <distro> -k <kernelver> [--media floppy|iso|tar]"
     fi
 
     # Check that source symlink works
@@ -2129,19 +2272,28 @@ make_driver_disk()
 
     # Confirm that distro is supported
     case $distro in
-	redhat | redhat[123] | suse | UnitedLinux | ubuntu) ;;
-	*) die 3 $"Invalid distro argument. Currently, the distros" \
-		$"supported are: redhat, redhat1, redhat2, redhat3, suse, UnitedLinux" \
-		$"               ubuntu";;
+        redhat | redhat[123] | suse | UnitedLinux | ubuntu)
+            ;;
+        *)
+            die 3 $"Invalid distro argument. Currently, the distros" \
+                $"supported are: redhat, redhat1, redhat2, redhat3, suse, UnitedLinux" \
+                $"               ubuntu"
+            ;;
     esac
 
     # Read the conf file
     read_conf_or_die "$kernelver" "$arch"
 
     case $distro in
-	redhat*) make_redhat_driver_disk;;
-	ubuntu) make_ubuntu_driver_disk;;
-	*) make_suse_driver_disk;;
+        redhat*)
+            make_redhat_driver_disk
+            ;;
+        ubuntu)
+            make_ubuntu_driver_disk
+            ;;
+        *)
+            make_suse_driver_disk
+            ;;
     esac
 }
 
@@ -2150,34 +2302,34 @@ find_external_dependencies()
     local mod count i
     local -a deps
 
-    # find all module dependencies
+    # Find all module dependencies
     for ((count=0; count < ${#dest_module_name[@]}; count++)); do
-	for ((i=0; i < ${#kernelver[@]}; i++)); do
-	    set_module_suffix "${kernelver[$i]}"
-	    mod="$dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}/module/${dest_module_name[$count]}$module_suffix"
-	    deps=(${deps[@]} $(modinfo "$mod" | sed -n 's/,/ /g; s/^depends: *//p'))
-	done
+        for ((i=0; i < ${#kernelver[@]}; i++)); do
+            set_module_suffix "${kernelver[$i]}"
+            mod="$dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}/module/${dest_module_name[$count]}$module_suffix"
+            deps=(${deps[@]} $(modinfo "$mod" | sed -n 's/,/ /g; s/^depends: *//p'))
+        done
     done
 
-    # prune internally satisfied dependencies
+    # Prune internally satisfied dependencies
 
     for ((i=0; i < ${#deps[@]}; i++)); do
-	for mod in ${dest_module_name[@]}; do
-	    [[ ${deps[i]} = $mod ]] && deps[i]=
-	done
+        for mod in ${dest_module_name[@]}; do
+            [[ ${deps[i]} = $mod ]] && deps[i]=
+        done
     done
 
     for dep in "${deps[@]}"; do
-	echo $dep
+        echo $dep
     done | sort -u
 }
 
 make_suse_driver_disk()
 {
     [[ $release ]] || die 3 \
-	$"Invalid number of parameters passed for suse/UnitedLinux driver disk." \
-	$"Usage: mkdriverdisk <module>/<module-version> -d <distro> -k <kernelver>" \
-	$"                    -r <release-number>"
+        $"Invalid number of parameters passed for suse/UnitedLinux driver disk." \
+        $"Usage: mkdriverdisk <module>/<module-version> -d <distro> -k <kernelver>" \
+        $"                    -r <release-number>"
 
     local driver_disk_dir=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX)
     local suffix="$(driver_disk_suffix)"
@@ -2195,95 +2347,96 @@ make_suse_driver_disk()
     
     local count
     for ((count=0; count < ${#dest_module_name[@]}; count++)); do
-	local i
-	local topdir=$(printf "%02d" $(($count+1+offset)))
-	for ((i=0; i < ${#kernelver[@]}; i++)); do
-	    set_module_suffix "${kernelver[$i]}"
-
-	    if ! [[ -e $dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}/module/${dest_module_name[$count]}$module_suffix ]]; then
-		rm -rf $temp_dir_name
-		die 5 \
-		    $"Cannot find module ${dest_module_name[$count]}$module_suffix for kernel ${kernelver[$i]} (${arch[$i]})." \
-		    $"Module/version must be in built state before making a driver disk."
-	    fi
-	    # FIXME: add check for KMP binary RPMs to include in the driver disk
-	    suse_arch=${arch[$i]}
-	    case $suse_arch in
-		i?86) suse_arch=i386;;
-	    esac
-
-	    echo "Marking ${kernelver[$i]}/${arch[$i]}/modules/${dest_module_name[$count]}$module_suffix..."
-	    mkdir -p "$driver_disk_dir/$topdir/$suse_arch-$release/install/lib/modules/${kernelver[$i]}${dest_module_location[$count]}"
-	    cp "$dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}/module/${dest_module_name[$count]}$module_suffix" "$driver_disk_dir/$topdir/$suse_arch-$release/install/lib/modules/${kernelver[$i]}${dest_module_location[$count]}/"
-
-	    case ${kernelver[$i]} in
-		*-default)
-		    mkdir -p "$driver_disk_dir/$topdir/$suse_arch-$release/modules/"
-		    cp "$dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}/module/${dest_module_name[$count]}$module_suffix" "$driver_disk_dir/$topdir/$suse_arch-$release/modules/"
-		    ;;
-	    esac
-
-	    # create directory for dependency information
-	    [[ ${deps[@]} ]] && mkdir -p "$driver_disk_dir/01/linux/$distro/$suse_arch-$release/modules"
-
-	done
-
-	# ---
-	for arch_release in $(find $driver_disk_dir/$topdir -maxdepth 1 -mindepth 1 -type d | sed "s#$driver_disk_dir\/$topdir\/##"); do
-	    cd "$driver_disk_dir/$topdir/$arch_release/install/"
-	    invoke_command "tar cvzf update.tar.gz lib/" "making update.tar.gz for $arch_release" background
-	    cd - >/dev/null
-
-	    mkdir -p "$driver_disk_dir/$topdir/linux/$distro/$arch_release/install"
-	    mkdir -p "$driver_disk_dir/$topdir/linux/$distro/$arch_release/modules"
-
-	    echo $"  copying update.tar.gz for $arch_release to disk image..."
-	    cp -f "$driver_disk_dir/$topdir/$arch_release/install/update.tar.gz" "$driver_disk_dir/$topdir/linux/$distro/$arch_release/install/"
-
-	    postkernels=
-	    archtest=${arch_release/-*}
-	    for ((i=0; i<${#kernelver[@]}; i++)); do
-		[[ ${arch[$i]} = ${archtest} ]] && \
-		    postkernels="${postkernels} ${kernelver[$i]}"
-	    done
-
-	    if [[ ${postkernels} ]]; then
-		dstfile="$driver_disk_dir/$topdir/linux/$distro/$arch_release/install/update.post"
-		echo $"  creating update.post for $arch_release..."
-		(cat << EOF
+    local i
+    local topdir=$(printf "%02d" $(($count+1+offset)))
+    for ((i=0; i < ${#kernelver[@]}; i++)); do
+        set_module_suffix "${kernelver[$i]}"
+
+        if ! [[ -e $dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}/module/${dest_module_name[$count]}$module_suffix ]]; then
+            rm -rf $temp_dir_name
+            die 5 \
+                $"Cannot find module ${dest_module_name[$count]}$module_suffix for kernel ${kernelver[$i]} (${arch[$i]})." \
+                $"Module/version must be in built state before making a driver disk."
+        fi
+        # FIXME: add check for KMP binary RPMs to include in the driver disk
+        suse_arch=${arch[$i]}
+        case $suse_arch in
+            i?86)
+                suse_arch=i386
+                ;;
+        esac
+
+        echo "Marking ${kernelver[$i]}/${arch[$i]}/modules/${dest_module_name[$count]}$module_suffix..."
+        mkdir -p "$driver_disk_dir/$topdir/$suse_arch-$release/install/lib/modules/${kernelver[$i]}${dest_module_location[$count]}"
+        cp "$dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}/module/${dest_module_name[$count]}$module_suffix" "$driver_disk_dir/$topdir/$suse_arch-$release/install/lib/modules/${kernelver[$i]}${dest_module_location[$count]}/"
+
+        case ${kernelver[$i]} in
+        *-default)
+            mkdir -p "$driver_disk_dir/$topdir/$suse_arch-$release/modules/"
+            cp "$dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}/module/${dest_module_name[$count]}$module_suffix" "$driver_disk_dir/$topdir/$suse_arch-$release/modules/"
+            ;;
+        esac
+
+        # Create directory for dependency information
+        [[ ${deps[@]} ]] && mkdir -p "$driver_disk_dir/01/linux/$distro/$suse_arch-$release/modules"
+
+    done
+
+    # ---
+    for arch_release in $(find $driver_disk_dir/$topdir -maxdepth 1 -mindepth 1 -type d | sed "s#$driver_disk_dir\/$topdir\/##"); do
+        cd "$driver_disk_dir/$topdir/$arch_release/install/"
+        invoke_command "tar cvzf update.tar.gz lib/" "making update.tar.gz for $arch_release" background
+        cd - >/dev/null
+
+        mkdir -p "$driver_disk_dir/$topdir/linux/$distro/$arch_release/install"
+        mkdir -p "$driver_disk_dir/$topdir/linux/$distro/$arch_release/modules"
+
+        echo $"  copying update.tar.gz for $arch_release to disk image..."
+        cp -f "$driver_disk_dir/$topdir/$arch_release/install/update.tar.gz" "$driver_disk_dir/$topdir/linux/$distro/$arch_release/install/"
+
+        postkernels=
+        archtest=${arch_release/-*}
+        for ((i=0; i<${#kernelver[@]}; i++)); do
+            [[ ${arch[$i]} = ${archtest} ]] && postkernels="${postkernels} ${kernelver[$i]}"
+        done
+
+        if [[ ${postkernels} ]]; then
+            dstfile="$driver_disk_dir/$topdir/linux/$distro/$arch_release/install/update.post"
+            echo $"  creating update.post for $arch_release..."
+            (cat << EOF
 #!/bin/sh
 
 kernlist="${postkernels}"
 
 for kernel in \${kernlist}; do
     if [ -e /boot/System.map-\${kernel} ]; then
-	depmod -a -F /boot/System.map-\${kernel} \${kernel}
+    depmod -a -F /boot/System.map-\${kernel} \${kernel}
     fi
 done
 
 EOF
-		) > ${dstfile}
-		chmod a+x ${dstfile}
-	    fi
-
-	    if [[ -d $driver_disk_dir/$topdir/$arch_release/modules/ ]]; then
-		echo $"  copying kernel modules for installation kernel to disk image..."
-		cp -f $driver_disk_dir/$topdir/$arch_release/modules/* $driver_disk_dir/$topdir/linux/$distro/$arch_release/modules/ 2>/dev/null
-	    else
-		warn $"No kernel modules found for -default kernel."
-	    fi
-
-	    rm -fr "$driver_disk_dir/$topdir/$arch_release"
-	done
+            ) > ${dstfile}
+            chmod a+x ${dstfile}
+            fi
+
+            if [[ -d $driver_disk_dir/$topdir/$arch_release/modules/ ]]; then
+                echo $"  copying kernel modules for installation kernel to disk image..."
+                cp -f $driver_disk_dir/$topdir/$arch_release/modules/* $driver_disk_dir/$topdir/linux/$distro/$arch_release/modules/ 2>/dev/null
+            else
+                warn $"No kernel modules found for -default kernel."
+            fi
+
+            rm -fr "$driver_disk_dir/$topdir/$arch_release"
+        done
     done
 
     local dir
     if [[ ${deps[@]} ]]; then
-	for dir in "$driver_disk_dir/01/linux/$distro/"*"/modules"; do
-	    for dep in "${deps[@]}"; do
-		echo $dep >> "$dir/module.order"
-	    done
-	done
+        for dir in "$driver_disk_dir/01/linux/$distro/"*"/modules"; do
+            for dep in "${deps[@]}"; do
+                echo $dep >> "$dir/module.order"
+            done
+        done
     fi
 
     # FIXME: add suse-equivalent rpms/ directory, copy in KMP RPMs, run createrepo --pretty
@@ -2309,33 +2462,33 @@ make_ubuntu_driver_disk()
 
     local tempdir=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX)
 
-   # Check that the dh_make command is present
-   if ! which dpkg-deb >/dev/null 2>&1 ; then
-	die 1 $"dpkg-deb not present." \
-	    $"Install the dpkg-dev package."
-   fi
-
-   local i
-   for ((i=0; i < ${#kernelver[@]}; i++)); do
-      set_module_suffix "${kernelver[$i]}"
-      # Driver disks only recognize i386 as package arch
-      local karch=${arch[$i]/i?86/i386}
-      local kvers=${kernelver[$i]/-/_}; kvers=${kvers%%_*}
-       # ubuntu-drivers/<kver>/*_<debarch>.deb
-      local dd_prefix="ubuntu-drivers/$kvers"
-      local dd_suffix="_${karch}.deb"
-      maybe_build_module "$module" "$module_version" "${kernelver[$i]}" "${arch[$i]}" || {
-	  rm -rf "$tempdir"
-	  die 5 $"Unable to build $module/$module_version for Ubuntu driver disk."
-      }
-      mkdir -p "$tempdir/$dd_prefix"
-      local deb_dir="$tempdir/$dd_prefix/debian"
-      local deb_lib_dir="$deb_dir/lib/modules/${kernelver[$i]}/updates/dkms"
-      mkdir -p "$deb_lib_dir"
-      cp "$dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}/module/"*"$module_suffix" "$deb_lib_dir"
-      pushd "$deb_dir" > /dev/null 2>&1
-      mkdir DEBIAN
-      cat > DEBIAN/control <<EOF
+    # Check that the dh_make command is present
+    if ! which dpkg-deb >/dev/null 2>&1 ; then
+        die 1 $"dpkg-deb not present." \
+            $"Install the dpkg-dev package."
+    fi
+
+    local i
+    for ((i=0; i < ${#kernelver[@]}; i++)); do
+        set_module_suffix "${kernelver[$i]}"
+        # Driver disks only recognize i386 as package arch
+        local karch=${arch[$i]/i?86/i386}
+        local kvers=${kernelver[$i]/-/_}; kvers=${kvers%%_*}
+        # ubuntu-drivers/<kver>/*_<debarch>.deb
+        local dd_prefix="ubuntu-drivers/$kvers"
+        local dd_suffix="_${karch}.deb"
+        maybe_build_module "$module" "$module_version" "${kernelver[$i]}" "${arch[$i]}" || {
+            rm -rf "$tempdir"
+            die 5 $"Unable to build $module/$module_version for Ubuntu driver disk."
+        }
+        mkdir -p "$tempdir/$dd_prefix"
+        local deb_dir="$tempdir/$dd_prefix/debian"
+        local deb_lib_dir="$deb_dir/lib/modules/${kernelver[$i]}/updates/dkms"
+        mkdir -p "$deb_lib_dir"
+        cp "$dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}/module/"*"$module_suffix" "$deb_lib_dir"
+        pushd "$deb_dir" > /dev/null 2>&1
+        mkdir DEBIAN
+        cat > DEBIAN/control <<EOF
 Package: ${module}-modules-${kernelver[$i]}
 Version: ${module_version}-1
 Section: misc
@@ -2387,10 +2540,10 @@ make_tarball()
 
     # Check for dkms_dbversion
     if ! [[ -e $dkms_tree/dkms_dbversion ]]; then
-	echo $"" >&2
-	echo $"Could not find the file $dkms_tree/dkms_dbversion." >&2
-	echo $"Creating w/ default contents." >&2
-	echo "2.0.0" > $dkms_tree/dkms_dbversion
+        echo $"" >&2
+        echo $"Could not find the file $dkms_tree/dkms_dbversion." >&2
+        echo $"Creating w/ default contents." >&2
+        echo "2.0.0" > $dkms_tree/dkms_dbversion
     fi
 
     # Read the conf file
@@ -2400,26 +2553,26 @@ make_tarball()
     mkdir -p $temp_dir_name/dkms_main_tree
 
     if [[ $source_only ]]; then
-	kernel_version_list="source-only"
+    kernel_version_list="source-only"
     else
-	local i
-	for ((i=0; i<${#kernelver[@]}; i++)); do
-	    if ! [[ -d $dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]} ]]; then
-		rm -rf "$temp_dir_name" 2>/dev/null
-		die 6  $"No modules built for ${kernelver[$i]} (${arch[$i]})." \
-		    $"Modules must already be in the built state before using mktarball."
-	    fi
-
-	    set_module_suffix "${kernelver[$i]}"
-
-	    echo "Marking modules for ${kernelver[$i]} (${arch[$i]}) for archiving..."
-	    if [[ ! $kernel_version_list ]]; then
-		kernel_version_list="kernel${kernelver[$i]}-${arch[$i]}"
-	    else
-		kernel_version_list="${kernel_version_list}-kernel${kernelver[$i]}-${arch[$i]}"
-	    fi
-	    mkdir -p "$temp_dir_name/dkms_main_tree/${kernelver[$i]}/${arch[$i]}"
-	    cp -rf "$dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}" "$temp_dir_name/dkms_main_tree/${kernelver[$i]}"
+    local i
+    for ((i=0; i<${#kernelver[@]}; i++)); do
+        if ! [[ -d $dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]} ]]; then
+            rm -rf "$temp_dir_name" 2>/dev/null
+            die 6  $"No modules built for ${kernelver[$i]} (${arch[$i]})." \
+                $"Modules must already be in the built state before using mktarball."
+        fi
+
+        set_module_suffix "${kernelver[$i]}"
+
+        echo "Marking modules for ${kernelver[$i]} (${arch[$i]}) for archiving..."
+        if [[ ! $kernel_version_list ]]; then
+            kernel_version_list="kernel${kernelver[$i]}-${arch[$i]}"
+        else
+            kernel_version_list="${kernel_version_list}-kernel${kernelver[$i]}-${arch[$i]}"
+        fi
+        mkdir -p "$temp_dir_name/dkms_main_tree/${kernelver[$i]}/${arch[$i]}"
+        cp -rf "$dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}" "$temp_dir_name/dkms_main_tree/${kernelver[$i]}"
     done
     fi
 
@@ -2428,22 +2581,22 @@ make_tarball()
 
     # Copy the source_tree or make special binaries-only structure
     if [[ $binaries_only ]]; then
-	echo $""
-	echo $"Creating tarball structure to specifically accomodate binaries."
-	mkdir $temp_dir_name/dkms_binaries_only
-	echo "$module" > $temp_dir_name/dkms_binaries_only/PACKAGE_NAME
-	echo "$module_version" > $temp_dir_name/dkms_binaries_only/PACKAGE_VERSION
-	[[ ! $conf ]] && conf="$dkms_tree/$module/$module_version/source/dkms.conf"
-	cp -f $conf $temp_dir_name/dkms_binaries_only/ 2>/dev/null
+        echo $""
+        echo $"Creating tarball structure to specifically accomodate binaries."
+        mkdir $temp_dir_name/dkms_binaries_only
+        echo "$module" > $temp_dir_name/dkms_binaries_only/PACKAGE_NAME
+        echo "$module_version" > $temp_dir_name/dkms_binaries_only/PACKAGE_VERSION
+        [[ ! $conf ]] && conf="$dkms_tree/$module/$module_version/source/dkms.conf"
+        cp -f $conf $temp_dir_name/dkms_binaries_only/ 2>/dev/null
     else
-	echo $""
-	echo $"Marking $dkms_tree/$module/$module_version/source for archiving..."
-	mkdir -p $temp_dir_name/dkms_source_tree
-	cp -rf $dkms_tree/$module/$module_version/source/* $temp_dir_name/dkms_source_tree
+        echo $""
+        echo $"Marking $dkms_tree/$module/$module_version/source for archiving..."
+        mkdir -p $temp_dir_name/dkms_source_tree
+        cp -rf $dkms_tree/$module/$module_version/source/* $temp_dir_name/dkms_source_tree
     fi
 
     if (( $(echo $kernel_version_list | wc -m | awk {'print $1'}) > 200 )); then
-	kernel_version_list="manykernels"
+        kernel_version_list="manykernels"
     fi
 
     local tarball_name="$module-$module_version-$kernel_version_list.dkms.tar.gz"
@@ -2451,16 +2604,16 @@ make_tarball()
 
     # Die if we will not be able to create the tarball due to permissions.
     if [[ $archive_location ]]; then
-	tarball_name="${archive_location##*/}"
+        tarball_name="${archive_location##*/}"
         if [[ ${archive_location%/*} != $archive_location && \
             -d ${archive_location%/*} && -w ${archive_location%/*} ]]; then
             tarball_dest="${archive_location%/*}"
         elif [[ ${archive_location%/*} != $archive_location ]] && ! mkdir -p $tarball_dest; then
-	    die 9 $"Will not be able to create $archive_location due to a permissions problem."
-	fi
+            die 9 $"Will not be able to create $archive_location due to a permissions problem."
+        fi
     fi
     if [ ! -d $tarball_dest ]; then
-	mkdir -p "$dkms_tree/$module/$module_version/tarball/"
+        mkdir -p "$dkms_tree/$module/$module_version/tarball/"
     fi
 
     echo $""
@@ -2472,19 +2625,25 @@ make_tarball()
     # Make the tarball
     cd $temp_dir_name
     if tar -cf $temp_dir_name/$tarball_name ./* 2>/dev/null; then
-	cd - >/dev/null
-	echo $""
-	mv -f "$temp_dir_name/$tarball_name" "$tarball_dest/$tarball_name"
-	rm -rf $temp_dir_name
+        cd - >/dev/null
+        echo $""
+        mv -f "$temp_dir_name/$tarball_name" "$tarball_dest/$tarball_name"
+        rm -rf $temp_dir_name
     else
-	cd - >/dev/null
-	rm -rf $temp_dir_name
-	die 6 $"Failed to make tarball."
+        cd - >/dev/null
+        rm -rf $temp_dir_name
+        die 6 $"Failed to make tarball."
     fi
     case $tarball_ext in
-	gz) gzip -9 "$tarball_dest/$tarball_name";;
-	bz2) bzip2 -9 "$tarball_dest/$tarball_name";;
-	xz) xz -9 "$tarball_dest/$tarball_name";;
+        gz)
+            gzip --force -9 "$tarball_dest/$tarball_name"
+            ;;
+        bz2)
+            bzip2 --force -9 "$tarball_dest/$tarball_name"
+            ;;
+        xz)
+            xz --force -9 "$tarball_dest/$tarball_name"
+            ;;
     esac
     echo $""
     echo $"DKMS: mktarball completed."
@@ -2504,7 +2663,7 @@ load_tarball()
 {
     # Error out if $archive_location does not exist
     if [[ ! -e $archive_location ]]; then
-	die 2 $"$archive_location does not exist."
+        die 2 $"$archive_location does not exist."
     fi
 
     # If it is an .rpm file. install it with rpm, run an autoinstall, and then exit.
@@ -2522,13 +2681,19 @@ load_tarball()
     # Note that this does not depend on the extensions being correct.
     local tar_options=""
     for xpand in gzip bzip xz; do
-	$xpand -t $archive_location 2>/dev/null || continue
-	case $xpand in
-	    gzip) tar_options=z;;
-	    bzip2) tar_options=j;;
-	    xz) tar_options=J;;
-	esac
-	break
+        $xpand -t $archive_location 2>/dev/null || continue
+        case $xpand in
+            gzip)
+                tar_options=z
+                ;;
+            bzip2)
+                tar_options=j
+                ;;
+            xz)
+                tar_options=J
+                ;;
+        esac
+        break
     done
 
     # Untar it into $tmp_location
@@ -2537,16 +2702,16 @@ load_tarball()
     tar -${tar_options}xf $archive_location -C $temp_dir_name
 
     if [[ ! $temp_dir_name/dkms_main_tree ]]; then
-	# Tarball was not generated from mktarball.
-	# Just find the dkms.conf file and load the source.
-	conf=$(find $temp_dir_name/ -name dkms.conf 2>/dev/null | head -n 1)
-	if [[ ! $conf ]]; then
-	    rm -rf $temp_dir_name
-	    die 3 $"Tarball does not appear to be a correctly formed" \
-		$"DKMS archive. No dkms.conf found within it."
-	fi
-	add_source_tree "${conf%dkms.conf}"
-	return
+    # Tarball was not generated from mktarball.
+    # Just find the dkms.conf file and load the source.
+    conf=$(find $temp_dir_name/ -name dkms.conf 2>/dev/null | head -n 1)
+    if [[ ! $conf ]]; then
+        rm -rf $temp_dir_name
+        die 3 $"Tarball does not appear to be a correctly formed" \
+            $"DKMS archive. No dkms.conf found within it."
+    fi
+    add_source_tree "${conf%dkms.conf}"
+    return
     fi
 
     # Check that dkms_dbversion is not a future version
@@ -2555,76 +2720,78 @@ load_tarball()
     # the structure of the tarball.
     db_from_tarball=$(cat $temp_dir_name/dkms_main_tree/dkms_dbversion 2>/dev/null)
     db_from_dkms=$(cat $dkms_tree/dkms_dbversion 2>/dev/null)
-    if [[ $db_from_tarball && $db_from_dkms && \
-	$(VER "$db_from_tarball") > $(VER "$db_from_dkms") ]]; then
-	die 9 \
-	    $"The tarball you are trying to load indicates it is database version" \
-	    $"$db_from_tarball.  This version of DKMS only supports $db_from_dkms or lower."
+    if [[ $db_from_tarball && $db_from_dkms && $(VER "$db_from_tarball") > $(VER "$db_from_dkms") ]]; then
+        die 9 \
+            $"The tarball you are trying to load indicates it is database version" \
+            $"$db_from_tarball.  This version of DKMS only supports $db_from_dkms or lower."
     fi
 
     # Make sure its a sane tarball. Sane ones will have one of the two
     # directories we test for.
     for loc in dkms_source_tree dkms_binaries_only ''; do
-	if [[ ! $loc ]]; then
-	    die 7 $"No valid dkms.conf in dkms_source_tree or dkms_binaries_only." \
-		$"$archive_location is not a valid DKMS tarball."
-	fi
-	local conf="$temp_dir_name/$loc/dkms.conf"
-	[[ -f $conf ]] || continue
-	if ! get_pkginfo_from_conf "$conf"; then
-	    echo >&2
-	    echo $"Malformed dkms.conf, refusing to load." >&2
-	    continue
-	fi
-	if is_module_added "$PACKAGE_NAME" "$PACKAGE_VERSION" && \
-	    [[ ! $force ]]; then
-	    die 8  $"$PACKAGE_NAME-$PACKAGE_VERSION is already added!" \
-		$"Aborting."
-	fi
-	module="$PACKAGE_NAME"; module_version="$PACKAGE_VERSION"
-	echo $""
-	echo $"Loading tarball for $module-$module_version"
-	case $loc in
-	    dkms_source_tree)
-		add_source_tree "$temp_dir_name/dkms_source_tree";;
-	    dkms_binaries_only)
-		#if there is a source tree on the system already, don't build a binaries stub
-		if [[ ! -d $source_tree/$module-$module_version ]]; then
-			echo $"Creating $dkms_tree/$module/$module_version/source"
-			mkdir -p "$dkms_tree/$module/$module_version/source"
-			echo $"Copying dkms.conf to $dkms_tree/$module/$module_version/source..."
-			cp -rf "$temp_dir_name/dkms_binaries_only/dkms.conf" "$dkms_tree/$module/$module_version/source"
-		fi;;
-	    *)  die 8 $"$FUNCNAME:$LINENO: Cannot happen." \
-		$"Report this error to dkms-devel at dell.com";;
-	esac
-	break
+    if [[ ! $loc ]]; then
+        die 7 $"No valid dkms.conf in dkms_source_tree or dkms_binaries_only." \
+            $"$archive_location is not a valid DKMS tarball."
+    fi
+    local conf="$temp_dir_name/$loc/dkms.conf"
+    [[ -f $conf ]] || continue
+    if ! get_pkginfo_from_conf "$conf"; then
+        echo >&2
+        echo $"Malformed dkms.conf, refusing to load." >&2
+        continue
+    fi
+    if is_module_added "$PACKAGE_NAME" "$PACKAGE_VERSION" && \
+        [[ ! $force ]]; then
+        die 8  $"$PACKAGE_NAME-$PACKAGE_VERSION is already added!" \
+        $"Aborting."
+    fi
+    module="$PACKAGE_NAME"; module_version="$PACKAGE_VERSION"
+    echo $""
+    echo $"Loading tarball for $module-$module_version"
+    case $loc in
+        dkms_source_tree)
+            add_source_tree "$temp_dir_name/dkms_source_tree"
+            ;;
+        dkms_binaries_only)
+            #if there is a source tree on the system already, don't build a binaries stub
+            if [[ ! -d $source_tree/$module-$module_version ]]; then
+                echo $"Creating $dkms_tree/$module/$module_version/source"
+                mkdir -p "$dkms_tree/$module/$module_version/source"
+                echo $"Copying dkms.conf to $dkms_tree/$module/$module_version/source..."
+                cp -rf "$temp_dir_name/dkms_binaries_only/dkms.conf" "$dkms_tree/$module/$module_version/source"
+            fi
+            ;;
+        *)
+            die 8 $"$FUNCNAME:$LINENO: Cannot happen." \
+                $"Report this error to dkms-devel at dell.com";;
+    esac
+    break
     done
 
-    # at this point, the source has been copied to the appropriate location
+    # At this point, the source has been copied to the appropriate location
     # and registered with dkms, or a binary-only config has been noted.
     # Now, add any included precompiled modules.
 
     # Is tarball from before DKMS 2.0 (prior to arch support)
     if [[ ! -e $temp_dir_name/dkms_main_tree/dkms_dbversion ]]; then
-	[[ $loc = dkms_binaries_only ]] && rm -rf "$dkms_tree/$module/$module_version/source"
-	die 10 $" This tarball was created with dkms < 2.0 and contains" \
-	    $"no arch info. DKMS is refusing to install precompiled modules."
+        [[ $loc = dkms_binaries_only ]] && rm -rf "$dkms_tree/$module/$module_version/source"
+        die 10 $" This tarball was created with dkms < 2.0 and contains" \
+            $"no arch info. DKMS is refusing to install precompiled modules."
     fi
 
     # Load precompiled modules.
     for directory in "$temp_dir_name/dkms_main_tree"/*/*; do
-	[[ -d $directory ]] || continue
-	kernel_arch_to_load=${directory/*dkms_main_tree\/}
-	dkms_dir_location="$dkms_tree/$module/$module_version/$kernel_arch_to_load"
-	if [[ -d $dkms_dir_location && ! $force ]]; then
-	    warn $"$dkms_dir_location already exists.  Skipping..."
-	else
-	    echo $"Loading $dkms_dir_location..."
-	    rm -rf $dkms_dir_location
-	    mkdir -p $dkms_dir_location
-	    cp -rf $directory/* $dkms_dir_location/
-	fi
+        [[ -d $directory ]] || continue
+        kernel_arch_to_load=${directory/*dkms_main_tree\/}
+        dkms_dir_location="$dkms_tree/$module/$module_version/$kernel_arch_to_load"
+        if [[ -d $dkms_dir_location && ! $force ]]; then
+            warn $"$dkms_dir_location already exists.  Skipping..."
+        else
+            echo $"Loading $dkms_dir_location..."
+            rm -rf $dkms_dir_location
+            mkdir -p $dkms_dir_location
+            cp -rf $directory/* $dkms_dir_location/
+        fi
     done
 
     echo $""
@@ -2638,14 +2805,14 @@ run_match()
 
     # Error if $template_kernel is unset
     if [[ ! $template_kernel ]]; then
-	die 1 $"Invalid number of parameters passed." \
-	    $"Usage: match --templatekernel=<kernel-version> -k <kernel-version>" \
-	    $"   or: match --templatekernel=<kernel-version> -k <kernel-version> <module>"
+        die 1 $"Invalid number of parameters passed." \
+            $"Usage: match --templatekernel=<kernel-version> -k <kernel-version>" \
+            $"   or: match --templatekernel=<kernel-version> -k <kernel-version> <module>"
     fi
 
     # Error out if $template_kernel = $kernel_version
     if [[ $template_kernel = $kernelver ]]; then
-	die 2 $"The templatekernel and the specified kernel version are the same."
+        die 2 $"The templatekernel and the specified kernel version are the same."
     fi
 
     # Read in the status of template_kernel
@@ -2653,11 +2820,11 @@ run_match()
 
     # If $module is set, grep the status only for that module
     if [[ $module ]]; then
-	# Make sure that its installed in the first place
-	if ! [[ -d $dkms_tree/$module/ ]]; then
-	    die 3 $"The module: $module is not located in the DKMS tree."
-	fi
-	template_kernel_status=$(echo "$template_kernel_status" | grep "^$module,")
+        # Make sure that its installed in the first place
+        if ! [[ -d $dkms_tree/$module/ ]]; then
+            die 3 $"The module: $module is not located in the DKMS tree."
+        fi
+        template_kernel_status=$(echo "$template_kernel_status" | grep "^$module,")
     fi
 
     echo $""
@@ -2666,56 +2833,53 @@ run_match()
 
     # Prepare the kernel just once but only if there is actual work to do
     if [[ ! $template_kernel_status ]]; then
-	echo $""
-	echo $"There is nothing to be done for this match."
+        echo $""
+        echo $"There is nothing to be done for this match."
     else
-	prepare_kernel "$kernelver" "$arch"
-
-	# Iterate over the kernel_status and match kernel to the template_kernel
-	while read template_line; do
-	    template_module=`echo "$template_line" | awk {'print $1'} | sed 's/,$//'`
-	    template_version=`echo "$template_line" | awk {'print $2'} | sed 's/,$//'`
-
-	    # Print out a match header
-	    echo $""
-	    echo $"---- Match Beginning ----"
-	    echo $"Module:  $template_module"
-	    echo $"Version: $template_version"
-	    echo $"-------------------------"
-
-	    # Figure out what to do from here
-	    if show_status "$template_module" "$template_version" "$kernelver" "$arch" 2>/dev/null | grep -q ": installed"; then
-		echo $""
-		echo $"This module/version combo is already installed.  Nothing to be done."
-	    elif show_status "$template_module" "$template_version" "$kernelver" "$arch" 2>/dev/null | grep -q ": built"; then
-		echo $""
-		echo $"This module/version combo is built.  Installing it:"
-		module="$template_module"
-		module_version="$template_version"
-		install_module
-	    else
-		echo $""
-		echo $"Building & Installing this module/version:"
-		module="$template_module"
-		module_version="$template_version"
-		build_module
-		install_module
-	    fi
-	done < <(echo "$template_kernel_status")
-
-	# Clean up the kernel tree
-	if [[ ! ( $(VER $kernelver) < $(VER 2.6.6) ) && \
-	    -d "$kernel_source_dir" && \
-	    ! -h "$kernel_source_dir" && \
-	    -z "$ksourcedir_fromcli" ]]; then
-	    echo $"Kernel cleanup unnecessary for this kernel.  Skipping..."
-	elif [[ ! $no_clean_kernel ]]; then
-	    cd "$kernel_source_dir"
-	    [[ $kerneldoth_contents ]] || invoke_command "make mrproper" "cleaning kernel tree (make mrproper)" background
-	    [[ $config_contents ]] && echo "$config_contents" > .config
-	    [[ $kerneldoth_contents ]] && echo "$kerneldoth_contents" > /boot/kernel.h
-	    cd - >/dev/null
-	fi
+    prepare_kernel "$kernelver" "$arch"
+
+    # Iterate over the kernel_status and match kernel to the template_kernel
+    while read template_line; do
+        template_module=`echo "$template_line" | awk {'print $1'} | sed 's/,$//'`
+        template_version=`echo "$template_line" | awk {'print $2'} | sed 's/,$//'`
+
+        # Print out a match header
+        echo $""
+        echo $"---- Match Beginning ----"
+        echo $"Module:  $template_module"
+        echo $"Version: $template_version"
+        echo $"-------------------------"
+
+        # Figure out what to do from here
+        if show_status "$template_module" "$template_version" "$kernelver" "$arch" 2>/dev/null | grep -q ": installed"; then
+            echo $""
+            echo $"This module/version combo is already installed.  Nothing to be done."
+        elif show_status "$template_module" "$template_version" "$kernelver" "$arch" 2>/dev/null | grep -q ": built"; then
+            echo $""
+            echo $"This module/version combo is built.  Installing it:"
+            module="$template_module"
+            module_version="$template_version"
+            install_module
+        else
+        echo $""
+        echo $"Building & Installing this module/version:"
+        module="$template_module"
+        module_version="$template_version"
+        build_module
+        install_module
+        fi
+    done < <(echo "$template_kernel_status")
+
+    # Clean up the kernel tree
+    if [[ ! ( $(VER $kernelver) < $(VER 2.6.6) ) && -d "$kernel_source_dir" && ! -h "$kernel_source_dir" && -z "$ksourcedir_fromcli" ]]; then
+        echo $"Kernel cleanup unnecessary for this kernel.  Skipping..."
+    elif [[ ! $no_clean_kernel ]]; then
+        cd "$kernel_source_dir"
+        [[ $kerneldoth_contents ]] || invoke_command "make mrproper" "cleaning kernel tree (make mrproper)" background
+        [[ $config_contents ]] && echo "$config_contents" > .config
+        [[ $kerneldoth_contents ]] && echo "$kerneldoth_contents" > /boot/kernel.h
+        cd - >/dev/null
+    fi
     fi
 
     # Done
@@ -2729,8 +2893,8 @@ make_rpm()
 
     # Check that the rpmbuild command is present
     if ! which rpmbuild >/dev/null 2>&1 ; then
-	die 1 $"rpmbuild not present." \
-	    $"Install the rpm-build package."
+        die 1 $"rpmbuild not present." \
+            $"Install the rpm-build package."
     fi
 
     # Read the conf file
@@ -2740,34 +2904,33 @@ make_rpm()
 
     echo $""
     local sp
-    for sp in "$dkms_tree/$module/$module_version/source/$module-dkms-mkrpm.spec" \
-	"/etc/dkms/template-dkms-mkrpm.spec"; do
-	[[ -e $sp ]] || continue
-	SPECFILE="$sp"
-	break
+    for sp in "$dkms_tree/$module/$module_version/source/$module-dkms-mkrpm.spec" "/etc/dkms/template-dkms-mkrpm.spec"; do
+        [[ -e $sp ]] || continue
+        SPECFILE="$sp"
+        break
     done
     if [[ ! $SPECFILE ]]; then
-	die 5 $"Cannot find $sp which is needed by" \
-	    $"DKMS in order use mkrpm."
+        die 5 $"Cannot find $sp which is needed by" \
+            $"DKMS in order use mkrpm."
     fi
 
     # Run a dkms mktarball for use in the rpm
     local mktarball_line
     if [[ ! $source_only || $binaries_only ]]; then
-	mktarball_line="--binaries-only"
-	local i
-	echo $""
-	for ((i=0; i<${#kernelver[@]}; i++)); do
-	    if ! [[ -d $dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]} ]]; then
-	    die 5 $"You do not seem to have $module $module_version built for" \
-		$"${kernelver[$i]} (${arch[$i]}).  All modules must be in" \
-		$"the built state before you can use mkrpm."
-	    fi
-	    echo $"Marking ${kernelver[$i]} (${arch[$i]}) for RPM..."
-	    mktarball_line="-k ${kernelver[$i]} -a ${arch[$i]} $mktarball_line"
-	done
+        mktarball_line="--binaries-only"
+        local i
+        echo $""
+        for ((i=0; i<${#kernelver[@]}; i++)); do
+            if ! [[ -d $dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]} ]]; then
+                die 5 $"You do not seem to have $module $module_version built for" \
+                    $"${kernelver[$i]} (${arch[$i]}).  All modules must be in" \
+                    $"the built state before you can use mkrpm."
+            fi
+            echo $"Marking ${kernelver[$i]} (${arch[$i]}) for RPM..."
+            mktarball_line="-k ${kernelver[$i]} -a ${arch[$i]} $mktarball_line"
+        done
     else
-	mktarball_line="none"
+        mktarball_line="none"
     fi
 
     local temp_dir_name=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX)
@@ -2775,26 +2938,26 @@ make_rpm()
     mkdir -p ${temp_dir_name}/{BUILD,RPMS,SRPMS,SPECS,SOURCES}
     cp ${SPECFILE} ${temp_dir_name}/SPECS/dkms_mkrpm.spec
 
-    #if using legacy mode, install common postinst
+    # If using legacy mode, install common postinst
     if ((legacy_postinst != 0)); then
-	invoke_command "cp '$PREFIX/usr/lib/dkms/common.postinst' '${temp_dir_name}/SOURCES'" "copying legacy postinstall template"
+        invoke_command "cp '$PREFIX/usr/lib/dkms/common.postinst' '${temp_dir_name}/SOURCES'" "copying legacy postinstall template"
     fi
 
-    #Copy in the source tree
+    # Copy in the source tree
     if [[ ! $binaries_only ]]; then
-	invoke_command "cp -Lpr '$dkms_tree/$module/$module_version/source' '${temp_dir_name}/SOURCES/$module-$module_version'" "Copying source tree"
+        invoke_command "cp -Lpr '$dkms_tree/$module/$module_version/source' '${temp_dir_name}/SOURCES/$module-$module_version'" "Copying source tree"
     fi
 
     if invoke_command "LC_ALL=C rpmbuild --define \"_topdir ${temp_dir_name}\" --define \"version $module_version\" --define \"module_name $module\" --define \"kernel_versions ${kernelver[*]}\" --define \"mktarball_line $mktarball_line\" --define \"__find_provides  /usr/lib/dkms/find-provides\" --define \"_use_internal_dependency_generator 0\" -ba ${temp_dir_name}/SPECS/dkms_mkrpm.spec > ${temp_dir_name}/rpmbuild.log 2>&1" "rpmbuild"; then
-	mkdir -p ${rpm_basedir}
-	cp -a ${temp_dir_name}/SRPMS/* ${temp_dir_name}/RPMS/*/* ${rpm_basedir}/
-	echo $""
-	cat ${temp_dir_name}/rpmbuild.log | grep ^Wrote | sed -e "s:${temp_dir_name}/:${rpm_basedir}/:" -e 's:SRPMS/::' -e 's:RPMS/.*/::'
-	echo $""
-	echo $"DKMS: mkrpm completed."
+        mkdir -p ${rpm_basedir}
+        cp -a ${temp_dir_name}/SRPMS/* ${temp_dir_name}/RPMS/*/* ${rpm_basedir}/
+        echo $""
+        cat ${temp_dir_name}/rpmbuild.log | grep ^Wrote | sed -e "s:${temp_dir_name}/:${rpm_basedir}/:" -e 's:SRPMS/::' -e 's:RPMS/.*/::'
+        echo $""
+        echo $"DKMS: mkrpm completed."
     else
-	cat ${temp_dir_name}/rpmbuild.log >&2
-	die 7 $"There was a problem creating your rpm."
+        cat ${temp_dir_name}/rpmbuild.log >&2
+        die 7 $"There was a problem creating your rpm."
     fi
     rm -rf $temp_dir_name
     trap > /dev/null 2>&1
@@ -2805,9 +2968,9 @@ preproc_file()
     local date_str="$(date -R)"
     echo "modifying $1..."
     sed -e "s/DEBIAN_PACKAGE/$debian_package/g" \
-	-e "s/MODULE_NAME/$module/g" \
-	-e "s/MODULE_VERSION/$module_version/g" \
-	-e "s/DATE_STAMP/$date_str/" "$1" > "$1.dkms-pp"
+        -e "s/MODULE_NAME/$module/g" \
+        -e "s/MODULE_VERSION/$module_version/g" \
+        -e "s/DATE_STAMP/$date_str/" "$1" > "$1.dkms-pp"
     mv "$1.dkms-pp" "$1"
 }
 
@@ -2817,37 +2980,43 @@ debian_install()
     local getroot  tmpfile i
     local -a packages=("$@")
     for ((i=0; i < ${#packages[@]}; i++)); do
-	dpkg-query -s "${packages[$i]}"| egrep -q '^Status:.* installed$' || continue
-	unset package[$i]
+        dpkg-query -s "${packages[$i]}"| egrep -q '^Status:.* installed$' || continue
+        unset package[$i]
     done
     # if they are already installed, we are OK.
     [[ ${package[@]} ]] || return
     if ((UID != 0)); then
-	# figure out how to get root
-	for getroot in su-to-root gksudo kdesu sudo; do
-	    which $getroot >/dev/null 2>&1 || continue
-	    case $getroot in
-		su-to-root) getroot="$getroot -c";;
-		gksudo) [[ $DISPLAY ]] || continue
-		    getroot="$getroot --description 'DKMS Debian package builder' ";;
-		kdesu) [[ $DISPLAY ]] || continue;;
-	    esac
-	    break
-	done
+        # figure out how to get root
+        for getroot in su-to-root gksudo kdesu sudo; do
+            which $getroot >/dev/null 2>&1 || continue
+            case $getroot in
+                su-to-root)
+                    getroot="$getroot -c"
+                    ;;
+                gksudo)
+                    [[ $DISPLAY ]] || continue
+                    getroot="$getroot --description 'DKMS Debian package builder' "
+                    ;;
+                kdesu)
+                    [[ $DISPLAY ]] || continue
+                    ;;
+            esac
+            break
+        done
     fi
     if [[ -x /usr/sbin/synaptic && $DISPLAY ]] && tmpfile=$(mktemp_or_die); then
-	# Pretty GUI install.
-	trap 'rm -f "$tmpfile"' EXIT
-	for ((i=0; i=${#packages[@]}; i++)); do
-	    [[ ${packages[$i]} ]] && echo "install ${packages[$i]}" >>$tmpfile
-	done
-	$getroot "sh -c '/usr/sbin/synaptic --set-selections --non-interactive --hide-main-window < $tmpfile'"
+        # Pretty GUI install.
+        trap 'rm -f "$tmpfile"' EXIT
+        for ((i=0; i=${#packages[@]}; i++)); do
+            [[ ${packages[$i]} ]] && echo "install ${packages[$i]}" >>$tmpfile
+        done
+        $getroot "sh -c '/usr/sbin/synaptic --set-selections --non-interactive --hide-main-window < $tmpfile'"
     else
-	$getroot apt-get -y install "${packages[@]}"
+        $getroot apt-get -y install "${packages[@]}"
     fi
     if (( $? != 0)); then
-	die 4 $"Missing ${packages[@]}" \
-	    $"and unable to install.  Please ask an admin to install for you."
+        die 4 $"Missing ${packages[@]}" \
+            $"and unable to install.  Please ask an admin to install for you."
     fi
 }
 
@@ -2866,87 +3035,87 @@ make_debian()
     read_conf_or_die "$kernelver" "$arch"
     debian_install fakeroot dpkg-dev debhelper
 
-    #skeleton to load templates from
+    # Skeleton to load templates from
     local system_mk="$dkms_tree/$module/$module_version/source/$module-dkms-mk${create_type}"
     local local_mk="/etc/dkms/template-dkms-mk${create_type}"
     if [[ -e ${system_mk} ]]; then
-	echo $"Using ${system_mk}"
-	DEBDIR=${system_mk}
+        echo $"Using ${system_mk}"
+        DEBDIR=${system_mk}
     elif [[ -e ${local_mk} ]]; then
-	echo $"Using ${local_mk}"
-	DEBDIR=${local_mk}
+        echo $"Using ${local_mk}"
+        DEBDIR=${local_mk}
     else
-	die 5 $"Cannot find ${local_mk} which is needed by" \
-	    $"DKMS in order to use mk${create_type}."
+        die 5 $"Cannot find ${local_mk} which is needed by" \
+            $"DKMS in order to use mk${create_type}."
     fi
 
-    #prepare build directory and copy template
+    # Prepare build directory and copy template
     local temp_dir=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX)
     trap "rm -rf $temp_dir; delete_temporary_trees" EXIT HUP TERM
     local temp_dir_debian="$temp_dir/$debian_package-dkms-$module_version"
     invoke_command "cp -ar '$DEBDIR/' '$temp_dir_debian'" "copying template"
     pushd "$temp_dir_debian" > /dev/null 2>&1
     for file in debian/*; do
-	preproc_file "$file"
-	chmod 755 "$file"
+        preproc_file "$file"
+        chmod 755 "$file"
     done
     popd > /dev/null 2>&1
 
-     #if using legacy mode, install common postinst
+    # If using legacy mode, install common postinst
     if ((legacy_postinst != 0)); then
-	invoke_command "cp '$PREFIX/usr/lib/dkms/common.postinst' '$temp_dir_debian'" "copying legacy postinstall template"
+        invoke_command "cp '$PREFIX/usr/lib/dkms/common.postinst' '$temp_dir_debian'" "copying legacy postinstall template"
     fi
 
-    #Copy in the source tree
+    # Copy in the source tree
     if [[ ! $binaries_only ]]; then
-	invoke_command "cp -Lpr '$dkms_tree/$module/$module_version/source' '$temp_dir_debian/$module-$module_version'" "Copying source tree"
+        invoke_command "cp -Lpr '$dkms_tree/$module/$module_version/source' '$temp_dir_debian/$module-$module_version'" "Copying source tree"
     fi
 
-    #Only if we are shipping binary modules, make a .tgz for the deb
+    # Only if we are shipping binary modules, make a .tgz for the deb
     local archive_location="$dkms_tree/$module/$module_version/tarball/$module-$module_version.dkms.tar.gz"
     if [[ ! $source_only ]]; then
-	binaries_only="binaries-only"
-	invoke_command "make_tarball" "Gathering binaries"
-	if [[ -f $archive_location ]]; then
-	    invoke_command "cp '$archive_location' '$temp_dir_debian'" "Copying DKMS tarball into DKMS tree"
-	else
-	    die 12 $"Unable to find created tarball."
-	fi
+        binaries_only="binaries-only"
+        invoke_command "make_tarball" "Gathering binaries"
+        if [[ -f $archive_location ]]; then
+            invoke_command "cp '$archive_location' '$temp_dir_debian'" "Copying DKMS tarball into DKMS tree"
+        else
+            die 12 $"Unable to find created tarball."
+        fi
     fi
 
-    #calculate destination directory
+    # Calculate destination directory
     deb_basedir=$dkms_tree/$module/$module_version/${create_type}
     mkdir -p ${deb_basedir} >/dev/null 2>&1
 
-    #create deb
+    # Create deb
     pushd "$temp_dir_debian" > /dev/null 2>&1
     case "$create_type" in
-	dsc)
-	    invoke_command "dpkg-buildpackage -S -us -uc 1>/dev/null" "Building source package" || \
-		die 7 $"There was a problem creating your ${create_type}."
-	    echo $""
-	    echo $"DKMS: mk${create_type} completed."
-	    invoke_command "mv '$temp_dir/${debian_package}-dkms_${module_version}_source.changes' '$temp_dir/${debian_package}-dkms_${module_version}.dsc' '$temp_dir/${debian_package}-dkms_${module_version}.tar.gz' '$deb_basedir'" "Moving built files to $deb_basedir"
-	    ;;
-	deb)
-	    invoke_command "dpkg-buildpackage -rfakeroot -d -b -us -uc 1>/dev/null" "Building binary package" || \
-		die 7 $"There was a problem creating your ${create_type}."
-	    echo $""
-	    echo $"DKMS: mk${create_type} completed."
-	    invoke_command "mv '$temp_dir/${debian_package}-dkms_${module_version}_all.deb' '$deb_basedir'" "Moving built files to $deb_basedir"
-	    ;;
+    dsc)
+        invoke_command "dpkg-buildpackage -S -us -uc 1>/dev/null" "Building source package" || \
+            die 7 $"There was a problem creating your ${create_type}."
+        echo $""
+        echo $"DKMS: mk${create_type} completed."
+        invoke_command "mv '$temp_dir/${debian_package}-dkms_${module_version}_source.changes' '$temp_dir/${debian_package}-dkms_${module_version}.dsc' '$temp_dir/${debian_package}-dkms_${module_version}.tar.gz' '$deb_basedir'" "Moving built files to $deb_basedir"
+        ;;
+    deb)
+        invoke_command "dpkg-buildpackage -rfakeroot -d -b -us -uc 1>/dev/null" "Building binary package" || \
+            die 7 $"There was a problem creating your ${create_type}."
+        echo $""
+        echo $"DKMS: mk${create_type} completed."
+        invoke_command "mv '$temp_dir/${debian_package}-dkms_${module_version}_all.deb' '$deb_basedir'" "Moving built files to $deb_basedir"
+        ;;
     esac
     popd > /dev/null 2>&1
 
     if in_temporary_trees; then
-	echo "Copying built files to "`pwd`"/.." >&2
-	cp "${deb_basedir}/"* ..
+        echo "Copying built files to "`pwd`"/.." >&2
+        cp "${deb_basedir}/"* ..
     fi
 
-    #cleanup
+    # Cleanup
     invoke_command "rm $temp_dir -fr" "Cleaning up temporary files"
     delete_temporary_trees || \
-	die 7 $"There was a problem cleaning up temporary files."
+        die 7 $"There was a problem cleaning up temporary files."
 }
 
 make_common_test()
@@ -2960,8 +3129,8 @@ make_common_test()
 
     # Make sure that its installed in the first place
     [[ -d $dkms_tree/$module/$module_version ]] ||
-	die 3 $"The module/version combo: $module-$module_version" \
-	    $"is not located in the DKMS tree."
+        die 3 $"The module/version combo: $module-$module_version" \
+        $"is not located in the DKMS tree."
 }
 
 make_kmp_srpm()
@@ -2970,8 +3139,7 @@ make_kmp_srpm()
     trap 'rm -rf $temp_dir_name' EXIT HUP TERM
     mkdir -p $temp_dir_name/{BUILD,RPMS,SRPMS,SPECS,SOURCES}
     pushd "$dkms_tree/$module/$module_version" > /dev/null 2>&1
-    # want to change name of the top-level of the tarball
-    # from build to $module-$module_version
+    # Want to change name of the top-level of the tarball from build to $module-$module_version
     cp -lr build ${module}-${module_version}
     tar cvjf $temp_dir_name/SOURCES/${module}-${module_version}.tar.bz2 ${module}-${module_version} > /dev/null 2>&1
     rm -rf ${module}-${module_version}
@@ -2981,12 +3149,12 @@ make_kmp_srpm()
     grep ^Wrote $temp_dir_name/rpmbuild.log > /dev/null 2>&1
     local RC="$?"
     if ((RC == 0)); then
-	local kmp_basedir="$dkms_tree/$module/$module_version/rpm"
-	mkdir -p $kmp_basedir
-	RPMS=$(LANG=C cp -va ${temp_dir_name}/SRPMS/* $kmp_basedir | awk '{print $NF}')
+        local kmp_basedir="$dkms_tree/$module/$module_version/rpm"
+        mkdir -p $kmp_basedir
+        RPMS=$(LANG=C cp -va ${temp_dir_name}/SRPMS/* $kmp_basedir | awk '{print $NF}')
     else
-	echo $"rpmbuild error log:"
-	cat $temp_dir_name/rpmbuild.log
+        echo $"rpmbuild error log:"
+        cat $temp_dir_name/rpmbuild.log
     fi
     popd > /dev/null 2>&1
     rm -rf $temp_dir_name
@@ -2996,9 +3164,9 @@ make_kmp_srpm()
 
 report_build_problem()
 {
-    #If apport is on the system, files a build problem
-    if [ -x /usr/share/apport/apport ] && which python>/dev/null; then
-	python /usr/share/apport/package-hooks/dkms_packages.py -m $module -v $module_version -k ${kernelver[0]}
+    # If apport is on the system, files a build problem
+    if [ -x /usr/share/apport/apport ] && which python3 >/dev/null; then
+        python3 /usr/share/apport/package-hooks/dkms_packages.py -m $module -v $module_version -k ${kernelver[0]}
     fi
     die "$@"
 }
@@ -3012,12 +3180,12 @@ read_arg() {
     # $3 = arg parameter
     local rematch='^[^=]*=(.*)$'
     if [[ $2 =~ $rematch ]]; then
-	read "$1" <<< "${BASH_REMATCH[1]}"
+        read "$1" <<< "${BASH_REMATCH[1]}"
     else
-	read "$1" <<< "$3"
-	# There is no way to shift our callers args, so
-	# return 1 to indicate they should do it instead.
-	return 1
+        read "$1" <<< "$3"
+        # There is no way to shift our callers args, so
+        # return 1 to indicate they should do it instead.
+        return 1
     fi
 }
 
@@ -3028,10 +3196,10 @@ read_arg() {
 # they are all passed at the same time.
 parse_kernelarch(){
     if [[ $1 =~ $mv_re ]]; then
-	kernelver[${#kernelver[@]}]="${BASH_REMATCH[1]}"
-	arch[${#arch[@]}]="${BASH_REMATCH[2]}"
+        kernelver[${#kernelver[@]}]="${BASH_REMATCH[1]}"
+        arch[${#arch[@]}]="${BASH_REMATCH[2]}"
     else
-	kernelver[${#kernelver[@]}]="$1"
+        kernelver[${#kernelver[@]}]="$1"
     fi
 }
 
@@ -3043,10 +3211,10 @@ parse_kernelarch(){
 # commands on the commandline.
 parse_moduleversion(){
     if [[ $1 =~ $mv_re ]]; then
-	module="${BASH_REMATCH[1]}"
-	module_version="${BASH_REMATCH[2]}"
+        module="${BASH_REMATCH[1]}"
+        module_version="${BASH_REMATCH[2]}"
     else
-	module="$1"
+        module="$1"
     fi
 }
 
@@ -3061,26 +3229,32 @@ check_root() {
 add_source_tree() {
     local from=$(readlink -f $1)
     if ! [[ $from && -f $from/dkms.conf ]]; then
-	die 9 $"$1 must contain a dkms.conf file!"
+        die 9 $"$1 must contain a dkms.conf file!"
     fi
     check_root
     setup_kernels_arches
     if ! get_pkginfo_from_conf "$from/dkms.conf" ; then
-	die 10 $"Malformed dkms.conf file. Cannot load source tree."
+        die 10 $"Malformed dkms.conf file. Cannot load source tree."
     fi
     module="$PACKAGE_NAME"
     module_version="$PACKAGE_VERSION"
     if [[ $force && -d $source_tree/$module-$module_version ]]; then
-	echo >&2
-	echo $"Forcing install of $module-$module_version"
-	rm -rf "$source_tree/$module-$module_version"
+        echo >&2
+        echo $"Forcing install of $module-$module_version"
+        rm -rf "$source_tree/$module-$module_version"
     fi
 
     # We are already installed, just return.
     case $from in
-	"$source_tree/$module-$module_version") return;;
-	"$dkms_tree/$module/$version/source") return;;
-	"$dkms_tree/$module/$version/build") return;;
+        "$source_tree/$module-$module_version")
+            return
+            ;;
+        "$dkms_tree/$module/$version/source")
+            return
+            ;;
+        "$dkms_tree/$module/$version/build")
+            return
+            ;;
     esac
     mkdir -p "$source_tree/$module-$module_version"
     cp -fr "$from"/* "$source_tree/$module-$module_version"
@@ -3095,14 +3269,14 @@ make_kmp()
 
     echo $""
     if [[ $specfile && -e $dkms_tree/$module/$module_version/source/$specfile ]]; then
-	echo $"Using $dkms_tree/$module/$module_version/source/$specfile"
-	SPECFILE="$dkms_tree/$module/$module_version/source/$specfile"
+        echo $"Using $dkms_tree/$module/$module_version/source/$specfile"
+        SPECFILE="$dkms_tree/$module/$module_version/source/$specfile"
     elif [[ -e $dkms_tree/$module/$module_version/source/$module-kmp.spec ]]; then
-	echo $"Using $dkms_tree/$module/$module_version/source/$module-kmp.spec"
-	SPECFILE="$dkms_tree/$module/$module_version/source/$module-kmp.spec"
+        echo $"Using $dkms_tree/$module/$module_version/source/$module-kmp.spec"
+        SPECFILE="$dkms_tree/$module/$module_version/source/$module-kmp.spec"
     else
-	die 5 $"Cannot find a suitable spec file which is needed by" \
-	    $"DKMS in order use mkkmp.  Please specify --spec=specfile."
+        die 5 $"Cannot find a suitable spec file which is needed by" \
+            $"DKMS in order use mkkmp.  Please specify --spec=specfile."
     fi
 
     prepare_build
@@ -3111,12 +3285,12 @@ make_kmp()
     clean_build
 
     if ((RC == 0)); then
-	echo $""
-	echo $"KMP SRPM location: $RPMS"
-	echo $""
-	echo $"DKMS: mkkmp completed."
+        echo $""
+        echo $"KMP SRPM location: $RPMS"
+        echo $""
+        echo $"DKMS: mkkmp completed."
     else
-	die 7 $"There was a problem creating your KMP source rpm."
+        die 7 $"There was a problem creating your KMP source rpm."
     fi
     # FIXME: hand SRPM to mock or build system to build
 }
@@ -3127,41 +3301,101 @@ make_kmp()
 # by hand if dkms_autoinstaller is not used.
 autoinstall() {
     local status mv mvka m v k a last_v last_m tenative
+    local install_count next_depends
     local -a to_install=()
+    local -a next_install=()
+    local -a installed_modules=()
+    local -A build_depends=()
+
     # Walk through our list of installed and built modules, and create
     # a list of modules that need to be reinstalled.
+    # Assuming all versions of same module to be parsed sequentially.
     while read status mvka; do
         IFS='/' read m v k a <<< "$mvka"
         [[ ! $last_m ]] && last_m="$m"
+        # autoinstall previous module's latest version after its deps.
+        if [[ $last_m != $m ]]; then
+            if [[ $tenative ]]; then
+                to_install[${#to_install[@]}]="$tenative"
+                build_depends["$last_m"]="${BUILD_DEPENDS[@]}"
+            fi
+            last_m="$m"
+            last_v='0'
+            tenative=''
+        fi
         # If the module is already installed or weak-installed, skip it.
-        _is_module_installed "$m" "$v" "$kernelver" "$arch" && continue
-        module_status_weak "$m" "$v" "$kernelver" "$arch" >/dev/null && continue
+        if _is_module_installed "$m" "$v" "$kernelver" "$arch"; then
+            installed_modules[${#installed_modules[@]}]="$m"
+            continue
+        fi
+        if module_status_weak "$m" "$v" "$kernelver" "$arch" >/dev/null; then
+            installed_modules[${#installed_modules[@]}]="$m"
+            continue
+        fi
         # if the module does not want to be autoinstalled, skip it.
         read_conf_or_die "$k" "$a" "$dkms_tree/$m/$v/source/dkms.conf"
         if [[ ! $AUTOINSTALL ]]; then
             continue
-        # otherwise, only autoinstall the latest version we have hanging around.
-        elif [[ $last_m != $m ]]; then
-            last_m="$m"
-            last_v='0'
-            [[ $tenative ]] && to_install[${#to_install[@]}]="$tenative"
-            tenative=''
         fi
+        # otherwise, only autoinstall the latest version we have hanging around.
         if [[ ($(VER $v) > $(VER $last_v)) ]]; then
             last_v="$v"
             tenative="$m/$v"
         fi
     done < <(module_status)
+
     # We may have exited the loop with $tenative set.  If it is,
     # it contains something that should be updated.
-    [[ $tenative ]] && to_install[${#to_install[@]}]="$tenative"
+    if [[ $tenative ]]; then
+        to_install[${#to_install[@]}]="$tenative"
+        build_depends["$m"]="${BUILD_DEPENDS[@]}"
+    fi
+
     [[ $to_install ]] || return 0
-    # Install modules that need to be updated in parallel.
+
+    while true; do
+        install_count=0
+        next_install=( )
+
+        # Step 1: Remove installed modules from all dependency lists.
+        for m in ${!build_depends[@]}; do
+            next_depends=
+            for d in ${build_depends[$m]}; do
+                for i in ${installed_modules[@]}; do
+                    [[ "$d" = "$i" ]] && continue 2
+                done
+                next_depends+="$d "
+            done
+            build_depends[$m]="${next_depends%% }"
+        done
+
+        # Step 2: Install modules that have an empty dependency list.
+        for mv in "${to_install[@]}"; do
+            IFS=/ read m v <<< "$mv"
+            if [[ -z "${build_depends[$m]}" ]]; then
+                (module="$m"; module_version="$v"; install_module)
+                installed_modules[${#installed_modules[@]}]="$m"
+                install_count=$(($install_count +1))
+            else
+                next_install[${#next_install[@]}]="$mv"
+            fi
+        done
+
+        wait
+
+        # Step 3: Keep going if at least one module was installed during
+        # this iteration.
+        [[ "$install_count" -gt 0 ]] || break;
+
+        # Step 4: Remove modules that were installed during Step 2 from
+        # the job queue.
+        to_install=( "${next_install[@]}" )
+
+    done
     for mv in "${to_install[@]}"; do
         IFS=/ read m v <<< "$mv"
-        (module="$m"; module_version="$v"; install_module) &
+        echo "$m/$v autoinstall failed due to missing dependencies: ${build_depends[$m]}"
     done
-    wait
 }
 
 function make_redhat3_driver_disk ()
@@ -3205,7 +3439,7 @@ function make_redhat3_driver_disk ()
     fi
     # Set up temporary build directory for build
     rm -rf "$dkms_tree/$module/$module_version/build"
-    cp -rf "$dkms_tree/$module/$module_version/source/" "$dkms_tree/$module/$module_version/build"
+    cp -a "$dkms_tree/$module/$module_version/source/" "$dkms_tree/$module/$module_version/build"
 
     cd "$dkms_tree/$module/$module_version/build"
 
@@ -3242,11 +3476,11 @@ function make_redhat3_driver_disk ()
     cp ${SPECFILE} ${temp_dir_name}/SPECS/$module.spec
     cp -rax $dkms_tree/$module/$module_version/build/ $temp_dir_name/SOURCES/$module-$module_version/
     # Clean the build directory
-    rm -rf "$dkms_tree/$module/$module_version/build/*"
+    rm -rf "$dkms_tree/$module/$module_version/build"
     cd $temp_dir_name/SOURCES
     invoke_command "tar -jcvf $temp_dir_name/SOURCES/$module-$module_version.tar.bz2 $module-$module_version/" "creating source tarball"
     local i=0
-    #Build RPMS
+    # Build RPMS
     while [ $i -lt ${#kernelver[@]} ]; do
         invoke_command "LC_ALL=C rpmbuild --define \"_topdir ${temp_dir_name}\" --define \"version $module_version\" --define \"module_name $module\" --define \"kernel_version ${kernelver[$i]}\" -bb --target ${arch[$i]} ${temp_dir_name}/SPECS/$module.spec > ${temp_dir_name}/rpmbuild.log 2>&1" "rpmbuild"
         if [ "$?" -ne 0 ]; then
@@ -3349,9 +3583,10 @@ source_tree="/usr/src"
 install_tree="/lib/modules"
 tmp_location=${TMPDIR:-/tmp}
 verbose=""
+symlink_modules=""
 dkms_frameworkconf="/etc/dkms/framework.conf"
 
-# these can come from the environment or the config file
+# These can come from the environment or the config file
 [[ ! ${ADDON_MODULES_DIR} && -e /etc/sysconfig/module-init-tools ]] && . /etc/sysconfig/module-init-tools
 addon_modules_dir="${ADDON_MODULES_DIR}"
 [[ ! ${addon_modules_dir} ]] && running_distribution="$(distro_version)"
@@ -3392,70 +3627,146 @@ try_source_tree=''
 die_is_fatal="yes"
 [ -x /sbin/weak-modules ] && weak_modules='/sbin/weak-modules'
 [ -x /usr/lib/module-init-tools/weak-modules ] && weak_modules='/usr/lib/module-init-tools/weak-modules'
+no_depmod=""
 
 action_re='^(remove|(auto|un)?install|match|mk(driverdisk|tarball|rpm|deb|dsc|kmp)|build|add|status|ldtarball)$'
 
 # Parse command line arguments
 while (($# > 0)); do
     case $1 in
-	--dkmsframework*)    read_arg dkms_frameworkconf "$1" "$2" || shift
-			     #immediately load this config
-			     . $dkms_frameworkconf 2> /dev/null;;
-	--module*|-m)        read_arg _mv "$1" "$2" || shift
-			     parse_moduleversion "$_mv";;
-	-v)                  read_arg module_version "$1" "$2" || shift;;
-	--kernelver*|-k)     read_arg _ka "$1" "$2" || shift
-			     parse_kernelarch "$_ka";;
-	--distro*|-d)        read_arg distro "$1" "$2" || shift;;
-	--media*)            read_arg media "$1" "$2" ||shift;;
-	--release*|-r)       read_arg release "$1" "$2" || shift;;
-	--templatekernel*)   read_arg template_kernel "$1" "$2" || shift;;
-	-c)                  read_arg conf "$1" "$2" || shift;;
-	--quiet|-q)          exec >/dev/null 2>&1;;
-	--version|-V)        echo $"dkms: 2.2.0.3"
-			     exit 0;;
-	--no-prepare-kernel) no_prepare_kernel="no-prepare-kernel";;
-	--no-clean-kernel)   no_clean_kernel="no-clean-kernel";;
-	--no-initrd)         no_initrd="no-initrd";;
-	--binaries-only)     binaries_only="binaries-only";;
-	--source-only)       source_only="source-only";;
-	--force)             force="true";;
-	--all)               all="true";;
-	--verbose)           verbose="true";;
-	--rpm_safe_upgrade)  rpm_safe_upgrade="true";;
-	--dkmstree*)         read_arg dkms_tree "$1" "$2" || shift;;
-	--sourcetree*)       read_arg source_tree "$1" "$2" || shift;;
-	--installtree*)      read_arg install_tree "$1" "$2" || shift;;
-	--config*)           read_arg kernel_config "$1" "$2" || shift;;
-	--archive*)          read_arg archive_location "$1" "$2" || shift;;
-	--legacy-postinst*)  read_arg legacy_postinst "$1" "$2" || shift;;
-	--arch*|-a)          read_arg _aa "$1" "$2" || shift
-			     arch[${#arch[@]}]="$_aa";;
-	--size*)             read_arg size "$1" "$2" || shift;;
-	--kernelsourcedir*)  read_arg kernel_source_dir "$1" "$2" || shift
-			     ksourcedir_fromcli="true";;
-	--directive*)        read_arg _da "$1" "$2" || shift
-			     directive_array[${#directive_array[@]}]="$_da";;
-	--spec*)             read_arg specfile "$1" "$2" || shift;;
-	--debug)
-	    export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '
-	    set -x;;
-	-*|--*)              error $" Unknown option: $1"
-			     show_usage
-			     exit 2;;
-	*) if [[ $1 =~ $action_re ]]; then
-	    action="$action $1" # Add actions to the action list
-	    elif [[ -f $1 && $1 = *dkms.conf ]]; then
-	    try_source_tree="${1%dkms.conf}./" # Flag as a source tree
-	    elif [[ -d $1 && -f $1/dkms.conf ]]; then
-	    try_source_tree="$1" # ditto
-	    elif [[ -f $1 ]]; then
-	    archive_location="$1" # It is a file, assume it is an archive.
-	    elif [[ ! $module ]]; then
-	    parse_moduleversion "$1" # Assume it is a module/version pair.
-	    else
-	    warn $"I do not know how to handle $1."
-	    fi;;
+        --dkmsframework*)
+            read_arg dkms_frameworkconf "$1" "$2" || shift
+            #immediately load this config
+            . $dkms_frameworkconf 2> /dev/null
+            ;;
+        --module*|-m)
+            read_arg _mv "$1" "$2" || shift
+            parse_moduleversion "$_mv"
+            ;;
+        -v)
+            read_arg module_version "$1" "$2" || shift
+            ;;
+        --kernelver*|-k)
+            read_arg _ka "$1" "$2" || shift
+            parse_kernelarch "$_ka"
+            ;;
+        --distro*|-d)
+            read_arg distro "$1" "$2" || shift
+            ;;
+        --media*)
+            read_arg media "$1" "$2" ||shift
+            ;;
+        --release*|-r)
+            read_arg release "$1" "$2" || shift
+            ;;
+        --templatekernel*)
+            read_arg template_kernel "$1" "$2" || shift
+            ;;
+        -c)
+            read_arg conf "$1" "$2" || shift
+            ;;
+        --quiet|-q)
+            exec >/dev/null 2>&1
+            ;;
+        --version|-V)
+            echo $"dkms: [INSERT_VERSION_HERE]"
+            exit 0
+            ;;
+        --no-prepare-kernel)
+            no_prepare_kernel="no-prepare-kernel"
+            ;;
+        --no-clean-kernel)
+            no_clean_kernel="no-clean-kernel"
+            ;;
+        --no-initrd)
+            no_initrd="no-initrd"
+            ;;
+        --binaries-only)
+            binaries_only="binaries-only"
+            ;;
+        --source-only)
+            source_only="source-only"
+            ;;
+        --force)
+            force="true"
+            ;;
+        --all)
+            all="true"
+            ;;
+        --verbose)
+            verbose="true"
+            ;;
+        --rpm_safe_upgrade)
+            rpm_safe_upgrade="true"
+            ;;
+        --dkmstree*)
+            read_arg dkms_tree "$1" "$2" || shift
+            ;;
+        --sourcetree*)
+            read_arg source_tree "$1" "$2" || shift
+            ;;
+        --installtree*)
+            read_arg install_tree "$1" "$2" || shift
+            ;;
+        --symlink-modules)
+            symlink_module="true"
+            ;;
+        --config*)
+            read_arg kernel_config "$1" "$2" || shift
+            ;;
+        --archive*)
+            read_arg archive_location "$1" "$2" || shift
+            ;;
+        --legacy-postinst*)
+            read_arg legacy_postinst "$1" "$2" || shift
+            ;;
+        --arch*|-a)
+            read_arg _aa "$1" "$2" || shift
+            arch[${#arch[@]}]="$_aa"
+            ;;
+        --size*)
+            read_arg size "$1" "$2" || shift
+            ;;
+        --kernelsourcedir*)
+            read_arg kernel_source_dir "$1" "$2" || shift
+            ksourcedir_fromcli="true"
+            ;;
+        --directive*)
+            read_arg _da "$1" "$2" || shift
+            directive_array[${#directive_array[@]}]="$_da"
+            ;;
+        --spec*)
+            read_arg specfile "$1" "$2" || shift
+            ;;
+        --no-depmod)
+            no_depmod="true"
+            ;;
+        --debug)
+            export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '
+            set -x
+            ;;
+        -j)
+            read_arg parallel_jobs "$1" "$2" || shift;;
+        -*|--*)
+            error $" Unknown option: $1"
+            show_usage
+            exit 2
+            ;;
+        *)
+            if [[ $1 =~ $action_re ]]; then
+                action="$action $1" # Add actions to the action list
+            elif [[ -f $1 && $1 = *dkms.conf ]]; then
+                try_source_tree="${1%dkms.conf}./" # Flag as a source tree
+            elif [[ -d $1 && -f $1/dkms.conf ]]; then
+                try_source_tree="$1" # ditto
+            elif [[ -f $1 ]]; then
+                archive_location="$1" # It is a file, assume it is an archive.
+            elif [[ ! $module ]]; then
+                parse_moduleversion "$1" # Assume it is a module/version pair.
+            else
+                warn $"I do not know how to handle $1."
+            fi
+            ;;
     esac
     shift
 done
@@ -3465,54 +3776,107 @@ done
 # Error out if binaries-only is set and source-only is set
 if [[ $binaries_only && $source_only ]]; then
     die 8 $" You have specified both --binaries-only and --source-only." \
-	$"You cannot do this."
+        $"You cannot do this."
 fi
 
 # Error if # of arches doesn't match # of kernels
 if (( ${#kernelver[@]} != ${#arch[@]} && \
     ${#arch[@]} > 1 )); then
     die 1 $" If more than one arch is specified on the command line, then there" \
-	$"must be an equal number of kernel versions also specified (1:1 relationship)."
+        $"must be an equal number of kernel versions also specified (1:1 relationship)."
 fi
 
 # Check that kernel version and all aren't both set simultaneously
 if [[ $kernelver && $all ]]; then
     die 2 $" You cannot specify a kernel version and also specify" \
-	$"--all on the command line."
+        $"--all on the command line."
 fi
 
 # Check that arch and all aren't both set simultaneously
 if [[ $arch && $all ]]; then
     die 3 $" You cannot specify an arch and also specify" \
-	$"--all on the command line."
+        $"--all on the command line."
+fi
+
+# If initramfs/initrd rebuild is not requested, skip it with Redhat's weak-modules
+if [[ $no_initrd && $weak_modules ]]; then
+    if [[ $running_distribution == el5 ]]; then
+        weak_modules_no_initrd="--no-initrd"
+    else
+        weak_modules_no_initrd="--no-initramfs"
+    fi
 fi
 
+# Default to -j<number of CPUs>
+parallel_jobs=${parallel_jobs:-$(get_num_cpus)}
+
+# Make sure we're not passing -j0 to make; treat -j0 as just "-j"
+[[ "$parallel_jobs" = 0 ]] && parallel_jobs=""
+
 # Run the specified action
+if [ -z "$action" ]; then
+    show_usage
+    die 4 $"No action was specified."
+fi
+
 for action_to_run in $action; do
     setup_kernels_arches "$action_to_run"
     case "$action_to_run" in
-	remove)       check_root && remove_module;;
-	install)      check_root && install_modules;;
-	autoinstall)  check_root && autoinstall;;
-	match)        check_root && have_one_kernel && run_match;;
-	uninstall)    check_root && have_one_kernel && uninstall_module;;
-	mkdriverdisk) check_root && make_driver_disk;;
-	build)        build_modules;;
-	add)          add_module;;
-	mktarball)    make_tarball;;
-	mkrpm)        make_rpm;;
-	mkdeb)        make_debian "deb";;
-	mkdsc)        make_debian "dsc";;
-	mkkmp)        have_one_kernel && make_kmp;;
-	status)       show_status;;
-	ldtarball) # Make sure they're root if we're using --force
-	    if ((UID != 0)) && [[ $force = true ]]; then
-		die 1 $"You must be root to use this command with the --force option."
-	    fi
-	    load_tarball && add_module;;
-	'') error $"No action was specified."
-	    show_usage;;
-	*)  error $"Unknown action specified: $action_to_run"
-	    show_usage;;
+    remove)
+        check_root && remove_module
+        ;;
+    install)
+        check_root && install_modules
+        ;;
+    autoinstall)
+        check_root && autoinstall
+        ;;
+    match)
+        check_root && have_one_kernel && run_match
+        ;;
+    uninstall)
+        check_root && have_one_kernel && uninstall_module
+        ;;
+    mkdriverdisk)
+        check_root && make_driver_disk
+        ;;
+    build)
+        build_modules
+        ;;
+    add)
+        add_module
+        ;;
+    mktarball)
+        make_tarball
+        ;;
+    mkrpm)
+        make_rpm
+        ;;
+    mkdeb)
+        make_debian "deb"
+        ;;
+    mkdsc)
+        make_debian "dsc"
+        ;;
+    mkkmp)
+        have_one_kernel && make_kmp
+        ;;
+    status)
+        show_status
+        ;;
+    ldtarball) # Make sure they're root if we're using --force
+        if ((UID != 0)) && [[ $force = true ]]; then
+            die 1 $"You must be root to use this command with the --force option."
+        fi
+        load_tarball && add_module
+        ;;
+    '')
+        error $"No action was specified."
+        show_usage
+        ;;
+    *)
+        error $"Unknown action specified: $action_to_run"
+        show_usage
+        ;;
     esac
 done
diff --git a/dkms.8 b/dkms.8
index 908d9db..6b7b5ec 100644
--- a/dkms.8
+++ b/dkms.8
@@ -1,4 +1,42 @@
 .\" -*- nroff -*-
+.\"
+.\" .SY, .YS, .OP macros from /usr/share/groff/1.21/tmac/an-ext.tmac
+.\"
+.\" Declare start of command synopsis.  Sets up hanging indentation.
+.de SY
+.  ie !\\n(mS \{\
+.    nh
+.    nr mS 1
+.    nr mA \\n(.j
+.    ad l
+.    nr mI \\n(.i
+.  \}
+.  el \{\
+.    br
+.    ns
+.  \}
+.
+.  HP \w'\fB\\$1\fP\ 'u
+.  B "\\$1"
+..
+.
+.
+.\" End of command synopsis.  Restores adjustment.
+.de YS
+.  in \\n(mIu
+.  ad \\n(mA
+.  hy \\n(HY
+.  nr mS 0
+..
+.
+.
+.\" Declare optional option.
+.de OP
+.  ie \\n(.$-1 \
+.    RI "[\fB\\$1\fP" "\ \\$2" "]"
+.  el \
+.    RB "[" "\\$1" "]"
+..
 .TH DKMS 8 "June 2008" "Version 2.0.20"
 .SH NAME
 dkms \- Dynamic Kernel Module Support
@@ -243,7 +281,6 @@ load this tarball, build and install modules on the end user's system.  If you d
 not want your RPM to contain any prebuilt binaries, be sure to specify
 .B \-\-source\-only
 in the mkrpm command.
-.TP
 .SY mkdeb
 .OP module/module\-version
 .OP -k kernel/arch
@@ -464,6 +501,13 @@ ensure that modules are compiled correctly.
 This option keeps DKMS from cleaning your kernel source tree after a
 build.
 .TP
+.B \-\-no\-depmod
+This option prevents DKMS from running the depmod command during
+.B install
+and
+.B uninstall
+which will avoid (re)calculating module dependencies and thereby save time.
+.TP
 .B \-\-kernelsourcedir <kernel\-source\-directory\-location>
 Using this option you can specify the location of your kernel source
 directory.  Most likely you will not need to set this if your kernel
@@ -516,6 +560,15 @@ prior than DKMS 2.1.  This option currently defaults to 1.
 A supplemental configuration file to the system-wide dkms framework, typically located
 in /etc/dkms/framework.conf.  All option that are normally provided on a command line
 can be provided in this file.
+.TP
+.B \-j number
+Run no more than
+.I number
+jobs in parallel; see the -j option of
+.I make(1).
+Defaults to the number of CPUs in the system, detected by
+.I nproc(1).
+Specify 0 to impose no limit on the number of parallel jobs.
 .SH ORIGINAL MODULES
 During the first install of a module for a <kernelversion>,
 .B dkms
@@ -720,6 +773,7 @@ array directive.
 .B STRIP[#]=
 By default strip is considered to be "yes".  If set to "no", DKMS will not
 run strip \-g against your built module to remove debug symbols from it.
+STRIP[0] is used as the default for any unset entries in the STRIP array.
 .TP
 .B PACKAGE_NAME=
 This directive is used to give the name associated with the entire package of modules.  This is the same
@@ -825,6 +879,14 @@ on
 .B dkms_autoinstaller
 for more information.
 .TP
+.B BUILD_DEPENDS[#]=
+This optional directive is an array that allows you to specify other modules as
+dependencies for your module. Each array element should be the
+.B PACKAGE_NAME
+of another module that is managed by dkms. Do not specify a version or
+architecture in the dependency. Note that this directive is only advisory;
+missing or broken dependencies cause non-fatal warnings.
+.TP
 .B BUILD_EXCLUSIVE_KERNEL=
 This optional directive allows you to specify a regular expression which defines
 the subset of kernels which DKMS is allowed to build your module for.  If the kernel
@@ -924,9 +986,18 @@ default values for the variables.
 .B $source_tree
 and
 .B $install_tree
-which control where DKMS looks for its framework.  Note that these variables can also
-be manipulated on the command line with \-\-dkmstree, \-\-sourcetree
-and \-\-installtree options.
+which control where DKMS looks for its framework.  The 
+.B $symlink_modules
+variable controls wheter binary modules are copied to /lib/modules or if only symlinks are
+created there. Note that these variables can also
+be manipulated on the command line with \-\-dkmstree, \-\-sourcetree, \-\-installtree 
+and \-\-symlink-modules options.
+
+The
+.B $autoinstall_all_kernels
+variable is used by the common postinst for DKMS modules. It controls if the build should be done
+for all installed kernels or only for the current and latest installed kernel. It has no command 
+line equivalent.
 .SH dkms_autoinstaller
 This boot\-time service automatically installs any module which has
 .B AUTOINSTALL="yes"
@@ -1064,7 +1135,7 @@ works within the DKMS framework.
 .SH AUTHOR
 Gary Lerhaupt
 .SH WEBPAGE
-.I http://linux.dell.com/dkms
+.I https://github.com/dell-oss/dkms
 .SH WHITE\-PAPERS
 .I http://linux.dell.com/dkms/dkms\-ols2004.pdf
 
diff --git a/dkms.service b/dkms.service
new file mode 100644
index 0000000..b212702
--- /dev/null
+++ b/dkms.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Builds and install new kernel modules through DKMS
+Documentation=man:dkms(8)
+
+[Service]
+Type=oneshot
+RemainAfterExit=true
+ExecStart=/bin/sh -c 'dkms autoinstall --verbose --kernelver $(uname -r)'
+
+[Install]
+WantedBy=multi-user.target
diff --git a/dkms.spec b/dkms.spec
index 959d496..8e85d85 100644
--- a/dkms.spec
+++ b/dkms.spec
@@ -1,30 +1,63 @@
+%if 0%{?rhel} == 5
+%define _sharedstatedir /var/lib
+%endif
+
 Summary: Dynamic Kernel Module Support Framework
 Name: dkms
-Version: 2.2.0.3
+Version: [INSERT_VERSION_HERE]
 Release: 1%{?dist}
 License: GPLv2+
 Group: System Environment/Base
 BuildArch: noarch
-Requires: sed gawk findutils modutils tar cpio gzip grep mktemp
-Requires: bash > 1.99
-# because Mandriva calls this package dkms-minimal
-Provides: dkms-minimal = %{version}
 URL: http://linux.dell.com/dkms
-Source0: http://linux.dell.com/dkms/permalink/dkms-%{version}.tar.gz
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+Source0: http://linux.dell.com/dkms/permalink/dkms-%{version}.tar.gz
+# because Mandriva calls this package dkms-minimal
+Provides: dkms-minimal = %{version}
+
+Requires: coreutils
+Requires: cpio
+Requires: findutils
+Requires: gawk
+Requires: gcc
+Requires: grep
+Requires: gzip
+Requires: kernel-devel
+Requires: sed
+Requires: tar 
+Requires: which
+Requires: bash > 1.99
+
+%if 0%{?fedora} || 0%{?rhel} >= 7
+Requires:       kmod
+%else
+Requires:       module-init-tools
+%endif
+
+%if 0%{?fedora} >= 20 || 0%{?rhel} >= 7
+BuildRequires:          systemd
+Requires(post):         systemd
+Requires(preun):        systemd
+Requires(postun):       systemd
+%else
+Requires(post):         /sbin/chkconfig
+Requires(preun):        /sbin/chkconfig
+Requires(preun):        /sbin/service
+Requires(postun):       /sbin/service
+%endif
 
 %if 0%{?fedora}
 Requires: kernel-devel
 %endif
 
 %description
-This package contains the framework for the Dynamic
-Kernel Module Support (DKMS) method for installing
-module RPMS as originally developed by Dell.
+This package contains the framework for the Dynamic Kernel Module Support (DKMS)
+method for installing module RPMS as originally developed by Dell.
 
 %prep
 
 %setup -q
+
 %build
 
 %triggerpostun -- %{name} < 1.90.00-1
@@ -76,33 +109,78 @@ echo ""
 
 %install
 rm -rf $RPM_BUILD_ROOT
-make install-redhat DESTDIR=$RPM_BUILD_ROOT \
+
+%if 0%{?fedora} >= 20 || 0%{?rhel} >= 7
+make install-redhat-systemd DESTDIR=$RPM_BUILD_ROOT \
+    SBIN=$RPM_BUILD_ROOT%{_sbindir} \
+    VAR=$RPM_BUILD_ROOT%{_localstatedir}/lib/%{name} \
+    MAN=$RPM_BUILD_ROOT%{_mandir}/man8 \
+    ETC=$RPM_BUILD_ROOT%{_sysconfdir}/%{name} \
+    BASHDIR=$RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d \
+    LIBDIR=$RPM_BUILD_ROOT%{_prefix}/lib/%{name}
+%else
+make install-redhat-sysv DESTDIR=$RPM_BUILD_ROOT \
     SBIN=$RPM_BUILD_ROOT%{_sbindir} \
     VAR=$RPM_BUILD_ROOT%{_localstatedir}/lib/%{name} \
     MAN=$RPM_BUILD_ROOT%{_mandir}/man8 \
     ETC=$RPM_BUILD_ROOT%{_sysconfdir}/%{name} \
     BASHDIR=$RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d \
     LIBDIR=$RPM_BUILD_ROOT%{_prefix}/lib/%{name}
+%endif
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
+%if 0%{?fedora} >= 20 || 0%{?rhel} >= 7
+
+%post
+%systemd_post %{name}.service
+
+%preun
+if [ $1 -eq 0 ]; then
+    # Package removal, not upgrade
+    /bin/systemctl --no-reload disable %{name}.service >/dev/null 2>&1 || :
+fi
+
+%systemd_preun %{name}.service
+
+%postun
+%systemd_postun %{name}.service
+
+%else
+
+%post
+# enable on initial install
+[ $1 -lt 2 ] && /sbin/chkconfig --add dkms_autoinstaller >/dev/null 2>&1 ||:
+[ $1 -lt 2 ] && /sbin/chkconfig dkms_autoinstaller on >/dev/null 2>&1 ||:
+
+%preun
+# remove on uninstall
+[ $1 -lt 1 ] && /sbin/chkconfig dkms_autoinstaller off >/dev/null 2>&1 ||:
+[ $1 -lt 1 ] && /sbin/chkconfig --del dkms_autoinstaller >/dev/null 2>&1 ||:
+
+%endif
+
 %files
 %defattr(-,root,root)
-%{_sbindir}/%{name}
-%{_localstatedir}/lib/%{name}
+%doc sample.spec sample.conf AUTHORS COPYING README.dkms
+%if 0%{?fedora} >= 20 || 0%{?rhel} >= 7
+%{_unitdir}/%{name}.service
+%else
+%{_initrddir}/%{name}_autoinstaller
+%endif
 %{_prefix}/lib/%{name}
 %{_mandir}/*/*
+%{_sbindir}/%{name}
+%{_localstatedir}/lib/%{name}
 %config(noreplace) %{_sysconfdir}/%{name}
-%doc sample.spec sample.conf AUTHORS COPYING README.dkms
-%doc sample-suse-9-mkkmp.spec sample-suse-10-mkkmp.spec
 # these dirs are for plugins - owned by other packages
-%{_initddir}/dkms_autoinstaller
 %{_sysconfdir}/kernel/postinst.d/%{name}
 %{_sysconfdir}/kernel/prerm.d/%{name}
 %{_sysconfdir}/bash_completion.d/%{name}
 
 %if 0%{?suse_version}
+%doc sample-suse-9-mkkmp.spec sample-suse-10-mkkmp.spec
 # suse doesnt yet support /etc/kernel/{prerm.d,postinst.d}, but will fail build
 # with unowned dirs if we dont own them ourselves
 # when opensuse *does* add this support, we will need to BuildRequires kernel
@@ -111,17 +189,10 @@ rm -rf $RPM_BUILD_ROOT
 %dir %{_sysconfdir}/kernel/prerm.d
 %endif
 
-
-%post
-[ -e /sbin/dkms ] && mv -f /sbin/dkms /sbin/dkms.old 2>/dev/null
-# enable on initial install
-[ $1 -lt 2 ] && /sbin/chkconfig dkms_autoinstaller on ||:
-
-%preun
-# remove on uninstall
-[ $1 -lt 1 ] && /sbin/chkconfig dkms_autoinstaller off ||:
-
 %changelog
+* Mon Sep 22 2014 Mario Limonciello <Mario_Limonciello at dell.com>
+- Merge with the spec file that has been adopted for RHEL/Fedora/CentOS.
+
 * Sat Aug 22 2009 Matt Domsch <Matt_Domsch at dell.com> - 2.1.0.0-1
 - update to latest upstream
 - drop Requires: lsb.  avoid calling rpm (recursively) if possible.
diff --git a/dkms_apport.py b/dkms_apport.py
index 8b2ca84..ebf87fd 100755
--- a/dkms_apport.py
+++ b/dkms_apport.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 #
 #  Dynamic Kernel Module Support (DKMS) <dkms-devel at dell.com>
 #  Copyright (C) 2009 Dell, Inc.
@@ -36,24 +36,28 @@ optparser.add_option('-k', help="Specify the kernel version",
 options=optparser.parse_args()[0]
 
 if not options.module or not options.version:
-    print >> sys.stderr, 'ERROR (dkms apport): both -m and -v are required'
+    sys.stderr.write('ERROR (dkms apport): both -m and -v are required\n')
     sys.exit(2)
 
 package=packaging.get_file_package('/usr/src/' + options.module + '-' + options.version)
 if package is None:
-    print >> sys.stderr, 'ERROR (dkms apport): binary package for %s: %s not found' % (options.module,options.version)
+    sys.stderr.write('ERROR (dkms apport): binary package for %s: %s not found\n' % (options.module,options.version))
     sys.exit(1)
 
 if options.kernel:
     # TODO: Ubuntu specific
     kernel_package = "linux-headers-" + options.kernel
 
+    supported_kernel = True
     try:
-        apport.packaging.is_distro_package(kernel_package)
-    except ValueError, e:
-        if e == 'package does not exist':
-            print >> sys.stderr, 'ERROR (dkms apport): kernel package %s is not supported' % (kernel_package)
-            sys.exit(1)
+        supported_kernel = apport.packaging.is_distro_package(kernel_package)
+    except ValueError as e:
+        if str(e) == 'package does not exist':
+            supported_kernel = False
+
+    if not supported_kernel:
+        sys.stderr.write('ERROR (dkms apport): kernel package %s is not supported\n' % (kernel_package))
+        sys.exit(1)
 
 make_log=os.path.join('/var','lib','dkms',options.module,options.version,'build','make.log')
 
@@ -62,7 +66,7 @@ report['Package'] = package
 try:
     report['SourcePackage'] = apport.packaging.get_source(package)
 except ValueError:
-    print >> sys.stderr, 'ERROR (dkms apport): unable to determine source package for %s' % package
+    sys.stderr.write('ERROR (dkms apport): unable to determine source package for %s\n' % package)
     sys.exit(3)
 try:
     version = packaging.get_version(package)
@@ -81,15 +85,14 @@ attach_file_if_exists(report, make_log, 'DKMSBuildLog')
 if 'DKMSBuildLog' in report:
     this_year = str(datetime.today().year)
     if 'Segmentation fault' in report['DKMSBuildLog']:
-        print >> sys.stderr, 'ERROR (dkms apport): There was a segmentation fault when trying to build the module'
+        sys.stderr.write('ERROR (dkms apport): There was a segmentation fault when trying to build the module\n')
         sys.exit(1)
-    dupe_sig = ''
     for line in report['DKMSBuildLog'].split('\n'):
-        if line.endswith(this_year):
-            continue
-        dupe_sig += line + '\n'
-    report['DuplicateSignature'] = dupe_sig
+        if ': error:' in line:
+            report['DuplicateSignature'] = 'dkms:%s:%s:%s' % (package, version, line.strip())
+            break
 
 if options.kernel:
     report['DKMSKernelVersion'] = options.kernel
-report.write(open(apport.fileutils.make_report_path(report), 'w'))
+with open(apport.fileutils.make_report_path(report), 'wb') as f:
+    report.write(f)
diff --git a/dkms_autoinstaller b/dkms_autoinstaller
index 798e796..0e7f070 100755
--- a/dkms_autoinstaller
+++ b/dkms_autoinstaller
@@ -1,25 +1,27 @@
 #!/bin/sh
 #
-# dkms_autoinstaller        A service to automatically install DKMS modules
-#                           for new kernels.
-# chkconfig: 345 04 04
-# description: An autoinstaller bootup service for DKMS
+# dkms_autoinstaller - A service to automatically install DKMS modules for new kernels.
 #
+# chkconfig: 345 04 04
+# description: Compiles and install kernel modules automatically for new \
+#              kernels at boot.
+
 ### BEGIN INIT INFO
 # Provides: dkms_autoinstaller dkms
-# Default-Start: 2 3 4 5
-# Default-Stop:
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 2 6
 # Required-Start: $local_fs
-# Required-Stop: $null
-# Short-Description: Automatically install DKMS modules for new kernels
+# Short-Description: DKMS kernel modules installer service
 # Description: A service to automatically install DKMS modules for new kernels.
 ### END INIT INFO
 
-test -f /usr/sbin/dkms || exit 0
 
 if [ -f /lib/lsb/init-functions ]; then
     . /lib/lsb/init-functions
+elif [ -f /etc/rc.d/init.d/functions ]; then 
+    . /etc/rc.d/init.d/functions
 fi
+
 #We only have these functions on debian/ubuntu
 # so on other distros just stub them out
 if [ ! -f /etc/debian_version ]; then
@@ -29,24 +31,30 @@ if [ ! -f /etc/debian_version ]; then
     alias log_action_end_msg=log_end_msg
 fi
 
-if [ -n "$2" ]; then
-    kernel="$2"
-else
-    kernel=`uname -r`
-fi
+exec="/usr/sbin/dkms"
+prog=${exec##*/}
+
+test -f $exec || exit 0
+
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
 
-# See how we were called.
 case "$1" in
-  start)
-    log_daemon_msg "dkms: running auto installation service for kernel $kernel"
-    dkms autoinstall --kernelver $kernel
-    log_end_msg $?
-    ;;
-  stop|restart|force-reload|status|reload)
-    # ignore
-    ;;
-  *)
-    echo "Usage: $0 {start}"
+    start)
+		if [ -n "$2" ]; then
+			kernel="$2"
+		else
+			kernel=`uname -r`
+		fi
+		log_daemon_msg "$prog: running auto installation service for kernel $kernel"
+		dkms autoinstall --kernelver $kernel
+		log_end_msg $?
+		;;
+	stop|restart|force-reload|status|reload)
+		# There is no stop action, this and the 04 priority during stop is
+		# added to make RHEL chkconfig happy.
+		# Ignore others on debian/ubuntu too
+        ;;
+    *)
+        echo $"Usage: $0 {start}"
+        exit 2
 esac
-
-exit 0
diff --git a/dkms_common.postinst b/dkms_common.postinst
index d8cf3a7..d3d2829 100644
--- a/dkms_common.postinst
+++ b/dkms_common.postinst
@@ -146,7 +146,12 @@ if [ -z "$NAME" ] || [ -z "$VERSION" ]; then
     exit 1
 fi
 
-KERNELS=$(ls /lib/modules/)
+# read framework configuration options
+if [ -r /etc/dkms/framework.conf ]; then
+    . /etc/dkms/framework.conf
+fi
+
+KERNELS=$(ls /lib/modules/ 2>/dev/null || true)
 CURRENT_KERNEL=$(uname -r)
 
 #We never want to keep an older version side by side to prevent conflicts
@@ -189,45 +194,36 @@ fi
 #
 # NOTE: if the headers are not installed then the
 #       module won't be built, as usual
-if [ -z "$UPGRADE" ]; then
-    echo "First Installation: checking all kernels..."
-    for KERNEL in $KERNELS; do
-        if [ ${KERNEL} = ${CURRENT_KERNEL} ]; then
-            # Kernel found
-            KERNELS=$CURRENT_KERNEL
-            break
-        fi
-    done
-else
-    KERNELS=$CURRENT_KERNEL
-fi
 
 # Here we look for the most recent kernel so that we can
 # build the module for it (in addition to doing it for the
 # current kernel.
 NEWEST_KERNEL=$(get_newest_kernel "$KERNELS")
 
-# If the current kernel doesn't come from the host of a chroot
-if [ `_is_kernel_name_correct $CURRENT_KERNEL` = "yes" ]; then
-    # See if it's worth building the module for both the newest kernel
-    # and for the current kernel
-    if [ -n "$NEWEST_KERNEL" ] && [ ${CURRENT_KERNEL} != ${NEWEST_KERNEL} ]; then
-        echo "Building for $CURRENT_KERNEL and $NEWEST_KERNEL"
-        KERNELS="$CURRENT_KERNEL $NEWEST_KERNEL"
+if [ -z "$autoinstall_all_kernels" ]; then
+    # If the current kernel is installed on the system or chroot
+    if [ `_is_kernel_name_correct $CURRENT_KERNEL` = "yes" ]; then
+        if [ -n "$NEWEST_KERNEL" ] && [ ${CURRENT_KERNEL} != ${NEWEST_KERNEL} ]; then
+            KERNELS="$CURRENT_KERNEL $NEWEST_KERNEL"
+        else
+            KERNELS=$CURRENT_KERNEL
+        fi
+    # The current kernel is not useful as it's not installed
     else
-        echo "Building only for $CURRENT_KERNEL"
-    fi
-# The current kernel is not useful as it's the host's
-else
-    echo "It is likely that $CURRENT_KERNEL belongs to a chroot's host"
-
-    # Let's use only the newest kernel
-    if [ -n "$NEWEST_KERNEL" ]; then
-        KERNELS="$NEWEST_KERNEL"
-        echo "Building only for $NEWEST_KERNEL"
+        echo "It is likely that $CURRENT_KERNEL belongs to a chroot's host"
+
+        # Let's use only the newest kernel if this is not a first installation
+        # otherwise build for all kernels
+        if [ -n "$NEWEST_KERNEL" -a -n "$UPGRADE" ]; then
+            KERNELS="$NEWEST_KERNEL"
+        fi
     fi
 fi
 
+# Take care of displaying newline separated list
+echo "Building for $KERNELS" | tr '\n' ',' \
+    | sed -e 's/,/, /g; s/, $/\n/; s/, \([^,]\+\)$/ and \1/'
+
 if [ -n "$ARCH" ]; then
     if which lsb_release >/dev/null && [ $(lsb_release -s -i) = "Ubuntu" ]; then
         case $ARCH in
@@ -281,8 +277,8 @@ for KERNEL in $KERNELS; do
             esac
             dkms_status=`dkms status -m $NAME -v $VERSION -k $KERNEL $ARCH`
         else
-            echo "Module build for the currently running kernel was skipped since the"
-            echo "kernel source for this kernel does not seem to be installed."
+            echo "Module build for kernel $KERNEL was skipped since the"
+            echo "kernel headers for this kernel does not seem to be installed."
         fi
     fi
 
diff --git a/dkms_framework.conf b/dkms_framework.conf
index fd2cf57..852f3b7 100644
--- a/dkms_framework.conf
+++ b/dkms_framework.conf
@@ -16,3 +16,13 @@
 
 ## verbosity setting (verbose will be active if you set it to a non-null value)
 # verbose=""
+
+## symlink kernel modules (will be active if you set it to a non-null value)
+## This creates symlinks from the install_tree into the dkms_tree instead of
+## copying the modules. This preserves some space on the costs of being less
+## safe.
+# symlink_modules=""
+
+## Automatic installation and upgrade for all installed kernels (if set to a
+## non-null value)
+# autoinstall_all_kernels=""
diff --git a/sample.spec b/sample.spec
index ff8421f..3abdf07 100644
--- a/sample.spec
+++ b/sample.spec
@@ -93,7 +93,7 @@ if [ -z "$loaded_tarballs" ]; then
 	else
 		echo -e ""
 		echo -e "Module build for the currently running kernel was skipped since the"
-		echo -e "kernel source for this kernel does not seem to be installed."
+		echo -e "kernel headers for this kernel do not seem to be installed."
 	fi
 fi
 exit 0
diff --git a/template-dkms-mkrpm.spec b/template-dkms-mkrpm.spec
index f38a8eb..a5f1f8b 100644
--- a/template-dkms-mkrpm.spec
+++ b/template-dkms-mkrpm.spec
@@ -52,7 +52,7 @@ if [ "$RPM_BUILD_ROOT" != "/" ]; then
 fi
 
 %post
-for POSTINST in %{_libdir}/dkms/common.postinst %{_datarootdir}/%{module_name}/postinst; do
+for POSTINST in %{_prefix}/lib/dkms/common.postinst %{_datarootdir}/%{module_name}/postinst; do
         if [ -f $POSTINST ]; then
                 $POSTINST %{module_name} %{version} %{_datarootdir}/%{module_name}
                 exit $?
diff --git a/test/README b/test/README
new file mode 100644
index 0000000..6b02d40
--- /dev/null
+++ b/test/README
@@ -0,0 +1 @@
+A sample module to test dkms.
diff --git a/test/dkms_test-1.0/Makefile b/test/dkms_test-1.0/Makefile
new file mode 100644
index 0000000..c6c2d32
--- /dev/null
+++ b/test/dkms_test-1.0/Makefile
@@ -0,0 +1,7 @@
+obj-m += dkms_test.o
+
+all:
+	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/test/dkms_test-1.0/dkms.conf b/test/dkms_test-1.0/dkms.conf
new file mode 100644
index 0000000..cb5fa65
--- /dev/null
+++ b/test/dkms_test-1.0/dkms.conf
@@ -0,0 +1,13 @@
+
+PACKAGE_NAME="dkms_test"
+PACKAGE_VERSION="1.0"
+BUILT_MODULE_NAME="dkms_test"
+
+MAKE="make -C /lib/modules/${kernelver}/build SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules"
+
+CLEAN="make -C /lib/modules/${kernelver}/build SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build  M=$PWD clean"
+
+REMAKE_INITRD="yes"
+
+DEST_MODULE_LOCATION="/kernel/extra"
+
diff --git a/test/dkms_test-1.0/dkms_test.c b/test/dkms_test-1.0/dkms_test.c
new file mode 100644
index 0000000..7533a16
--- /dev/null
+++ b/test/dkms_test-1.0/dkms_test.c
@@ -0,0 +1,23 @@
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+
+#define  DKMS_TEST_VER "1.0"
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("A Simple dkms test module");
+
+static int __init dkms_test_init(void)
+{
+    printk(KERN_INFO "DKMS Test Module -%s Loaded\n",DKMS_TEST_VER);
+    return 0;    
+}
+
+static void __exit dkms_test_cleanup(void)
+{
+    printk(KERN_INFO "Cleaning up after dkms test module.\n");
+}
+
+module_init(dkms_test_init);
+module_exit(dkms_test_cleanup);
+MODULE_VERSION(DKMS_TEST_VER);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-dkms/dkms.git



More information about the Pkg-dkms-commits mailing list