pax_global_header00006660000000000000000000000064127616112430014515gustar00rootroot0000000000000052 comment=4d476115049f6bf698dfd64acdaf45d612888914 dkms-2.3/000077500000000000000000000000001276161124300123175ustar00rootroot00000000000000dkms-2.3/AUTHORS000066400000000000000000000013021276161124300133630ustar00rootroot00000000000000Mario Limonciello - Debian/Ubuntu packaging, mkdeb/mkdsc. Gary Lerhaupt - Main DKMS software development - Build from source adaptation from QLogic RPM Fred Treasure - Kernel preparation support for SuSE/UL Matt Domsch - DKMS Architecture and Linux standards input and advice - Kernel preparation shortcut for Red Hat John Hull - For thinking big Robert Hentosh - For spamming with help for --rpm_safe_upgrade Mike Morgan - Debian / Ubuntu targeting Victor Lowther - Full bashification and code cleanupdkms-2.3/COPYING000066400000000000000000000431271276161124300133610ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. dkms-2.3/Makefile000066400000000000000000000135511276161124300137640ustar00rootroot00000000000000RELEASE_DATE := "22-September-2014" RELEASE_MAJOR := 2 RELEASE_MINOR := 2 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) DIST := unstable SHELL=bash SBIN = $(DESTDIR)/usr/sbin ETC = $(DESTDIR)/etc/dkms VAR = $(DESTDIR)/var/lib/dkms MAN = $(DESTDIR)/usr/share/man/man8 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) TOPDIR := $(shell pwd) .PHONY = tarball all: clean tarball rpm debs clean: -rm -rf *~ dist/ dkms-freshmeat.txt install: mkdir -m 0755 -p $(VAR) $(SBIN) $(MAN) $(ETC) $(BASHDIR) $(SHAREDIR) $(LIBDIR) sed -e "s/\[INSERT_VERSION_HERE\]/$(RELEASE_VERSION)/" dkms > dkms.versioned mv -f dkms.versioned dkms install -p -m 0755 dkms_common.postinst $(LIBDIR)/common.postinst install -p -m 0755 dkms $(SBIN) install -p -m 0755 dkms_autoinstaller $(LIBDIR) install -p -m 0644 dkms_framework.conf $(ETC)/framework.conf install -p -m 0644 dkms_dbversion $(VAR) install -p -m 0644 dkms.bash-completion $(BASHDIR)/dkms # install compressed manpage with proper timestamp and permissions gzip -c -9 dkms.8 > $(MAN)/dkms.8.gz chmod 0644 $(MAN)/dkms.8.gz touch --reference=dkms.8 $(MAN)/dkms.8.gz mkdir -p -m 0755 $(KCONF)/prerm.d $(KCONF)/postinst.d install -p -m 0755 kernel_prerm.d_dkms $(KCONF)/prerm.d/dkms install -p -m 0755 kernel_postinst.d_dkms $(KCONF)/postinst.d/dkms DOCFILES=sample.spec sample.conf AUTHORS COPYING README.dkms sample-suse-9-mkkmp.spec sample-suse-10-mkkmp.spec doc-perms: # ensure doc file permissions ok chmod 0644 $(DOCFILES) 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) 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) install -p -m 0644 $(DOCFILES) $(DOCDIR) install-debian: install install-doc mkdir -p -m 0755 $(SHAREDIR)/apport/package-hooks install -p -m 0755 dkms_apport.py $(SHAREDIR)/apport/package-hooks/dkms_packages.py mkdir -p -m 0755 $(KCONF)/header_postinst.d install -p -m 0755 kernel_postinst.d_dkms $(KCONF)/header_postinst.d/dkms mkdir -p -m 0755 $(ETC)/template-dkms-mkdeb/debian ln -s template-dkms-mkdeb $(ETC)/template-dkms-mkdsc install -p -m 0664 template-dkms-mkdeb/Makefile $(ETC)/template-dkms-mkdeb/ install -p -m 0664 template-dkms-mkdeb/debian/* $(ETC)/template-dkms-mkdeb/debian/ chmod +x $(ETC)/template-dkms-mkdeb/debian/postinst chmod +x $(ETC)/template-dkms-mkdeb/debian/prerm chmod +x $(ETC)/template-dkms-mkdeb/debian/rules rm $(DOCDIR)/COPYING* rm $(DOCDIR)/sample* deb_destdir=$(BUILDDIR)/dist TARBALL=$(deb_destdir)/$(RELEASE_STRING).tar.gz tarball: $(TARBALL) $(TARBALL): mkdir -p $(deb_destdir) tmp_dir=`mktemp -d --tmpdir dkms.XXXXXXXX` ; \ cp -a ../$(RELEASE_NAME) $${tmp_dir}/$(RELEASE_STRING) ; \ sed -e "s/\[INSERT_VERSION_HERE\]/$(RELEASE_VERSION)/" dkms > $${tmp_dir}/$(RELEASE_STRING)/dkms ; \ sed -e "s/\[INSERT_VERSION_HERE\]/$(RELEASE_VERSION)/" dkms.spec > $${tmp_dir}/$(RELEASE_STRING)/dkms.spec ; \ find $${tmp_dir}/$(RELEASE_STRING) -depth -name .git -type d -exec rm -rf \{\} \; ; \ find $${tmp_dir}/$(RELEASE_STRING) -depth -name dist -type d -exec rm -rf \{\} \; ; \ find $${tmp_dir}/$(RELEASE_STRING) -depth -name \*~ -type f -exec rm -f \{\} \; ; \ find $${tmp_dir}/$(RELEASE_STRING) -depth -name dkms\*.rpm -type f -exec rm -f \{\} \; ; \ find $${tmp_dir}/$(RELEASE_STRING) -depth -name dkms\*.tar.gz -type f -exec rm -f \{\} \; ; \ find $${tmp_dir}/$(RELEASE_STRING) -depth -name dkms-freshmeat.txt -type f -exec rm -f \{\} \; ; \ rm -rf $${tmp_dir}/$(RELEASE_STRING)/debian ; \ sync ; sync ; sync ; \ tar cvzf $(TARBALL) -C $${tmp_dir} $(RELEASE_STRING); \ rm -rf $${tmp_dir} ; rpm: $(TARBALL) dkms.spec tmp_dir=`mktemp -d --tmpdir dkms.XXXXXXXX` ; \ mkdir -p $${tmp_dir}/{BUILD,RPMS,SRPMS,SPECS,SOURCES} ; \ cp $(TARBALL) $${tmp_dir}/SOURCES ; \ sed "s/\[INSERT_VERSION_HERE\]/$(RELEASE_VERSION)/" dkms.spec > $${tmp_dir}/SPECS/dkms.spec ; \ pushd $${tmp_dir} > /dev/null 2>&1; \ rpmbuild -ba --define "_topdir $${tmp_dir}" SPECS/dkms.spec ; \ popd > /dev/null 2>&1; \ cp $${tmp_dir}/RPMS/noarch/* $${tmp_dir}/SRPMS/* dist ; \ rm -rf $${tmp_dir} debmagic: $(TARBALL) mkdir -p dist/ ln -s $(TARBALL) $(DEB_TMP_BUILDDIR)/$(RELEASE_NAME)_$(RELEASE_VERSION).orig.tar.gz tar -C $(DEB_TMP_BUILDDIR) -xzf $(TARBALL) cp -ar debian $(DEB_TMP_BUILDDIR)/$(RELEASE_STRING)/debian chmod +x $(DEB_TMP_BUILDDIR)/$(RELEASE_STRING)/debian/rules cd $(DEB_TMP_BUILDDIR)/$(RELEASE_STRING) ; \ dch -v $(RELEASE_VERSION)-0 "New upstream version, $(RELEASE_VERSION)"; \ dpkg-buildpackage -D -b -rfakeroot ; \ dpkg-buildpackage -D -S -sa -rfakeroot ; \ mv ../$(RELEASE_NAME)_* $(TOPDIR)/dist/ ; \ cd - debs: tmp_dir=`mktemp -d --tmpdir dkms.XXXXXXXX` ; \ make debmagic DEB_TMP_BUILDDIR=$${tmp_dir} DIST=$(DIST); \ rm -rf $${tmp_dir} fm: sed -e "s/\[INSERT_VERSION_HERE\]/$(RELEASE_VERSION)/" dkms-freshmeat.txt.in > dkms-freshmeat.txt dkms-2.3/README.dkms000066400000000000000000000123671276161124300141450ustar00rootroot00000000000000This 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: 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 1. Installation via RPM 2. Installation via DKMS Tarballs 3. Installation on Systems with no Module Source and/or Compiler 4. Further Documentation ############################### 0. Installation of DKMS via RPM ############################### To install DKMS itself, you simply install (or upgrade) it like any other RPM: rpm -Uvh dkms--.noarch.rpm This is a prerequisite to installing DKMS-enabled module RPMs. ####################### 1. Installation via RPM ####################### To install a DKMS enabled module RPM, you simply install it like any other RPM: rpm -ivh --.noarch.rpm With a DKMS enabled module RPM, most of the installation work done by the RPM is actually handed off to DKMS within the RPM. Generally it does the following: a. Installs module source into /usr/src/-/ b. Places a dkms.conf file into /usr/src/-/ c. Runs: dkms add -m -v d. Runs: dkms build -m -v e. Runs: dkms install -m -v Once the RPM installation is complete, you can use DKMS to understand which module and which moduleversion is installed on which kernels. This can be accomplished via the command: dkms status From here, you can then use the various DKMS commands (eg. add, build, install, uninstall) to load that module onto other kernels. ################################## 2. Installation via DKMS Tarballs ################################## DKMS is not limited to installation via RPM only. In fact, DKMS can also install directly from the following: a. Generic module source tarballs which contain a dkms.conf file b. Specially created DKMS tarballs with module source, pre-built module binaries and a dkms.conf file c. Specially created DKMS tarballs with pre-built module binaries and a dkms.conf file d. Manual placement of module source and dkms.conf file into /usr/src/-/ directory In order to load any tarball into the DKMS tree, you must use the following command: dkms ldtarball /path/to/dkms_enabled.tar.gz This command will first inspect the tarball to ensure that it contains a dkms.conf configuration file for that module. If it cannot find this file anywhere within the archive, then the ldtarball will fail. From here, it will place the source in the tarball into /usr/src/- /. If source already exists in the directory, it will not overwrite it unless the --force option is specified. If the tarball is of type "c" above and does not contain source, it will only continue to load the tarball if existing module source is found in /usr/src/-/ or if the --force option is specified. Continuing on, if the tarball is of type "b" or "c" it will then load any pre-built binaries found within the tarball into the dkms tree, but will stop short of installing them. Thus, all pre-built binaries will then be of in the "built" state when checked from the `dkms status` command. You can then use the `dkms install` command to install any of these binaries. To create a tarball of type "a" above, you need only to take module source and a dkms.conf file for that module and create a tarball from them. Tarballs of type "b" or type "c" are created with the `dkms mktarball` command. To create a type "c" tarball, you must specify the flag --binaries-only with the mktarball. ################################################################ 3. Installation on Systems with no Module Source and/or Compiler ################################################################ If you choose not to load module source on your system or if you choose not to load a compiler such as gcc onto your system, DKMS can still be used to install modules. It does this through use of DKMS binary only tarballs as explained in section 2 of this README under tarballs of type "c". If your system does not have module source, loading the dkms tarball will fail because of this. To avoid this, use the --force flag, as such: dkms ldtarball /path/to/dkms_enabled.tar.gz --force This will load the pre-built binaries into the dkms tree, and create the directory /usr/src/-/ which will only contain the module's dkms.conf configuration file. Once the tarball is loaded, you can then use `dkms install` to install any of the pre-built modules. Of course, since module source will not be located in your dkms tree, you will not be able to build any modules with DKMS for this package. ######################## 4. Further Documentation ######################## Once DKMS is installed, you can reference its man page for further information on different DKMS options and also to understand the formatting of a module's 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: https://github.com/dell-oss/dkms dkms-2.3/TODO000066400000000000000000000000771276161124300130130ustar00rootroot00000000000000* do we need to keep the collisions/ directory after a remove? dkms-2.3/debian/000077500000000000000000000000001276161124300135415ustar00rootroot00000000000000dkms-2.3/debian/HOWTO.Debian000066400000000000000000000032731276161124300155520ustar00rootroot00000000000000HOWTO Build DKMS debs w/ Debian & Ubuntu systems Copyright 2008 Dell Inc. Author: Mario Limonciello ------------ 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. dkms-2.3/debian/changelog000066400000000000000000000405011276161124300154130ustar00rootroot00000000000000dkms (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 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 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 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 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 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 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 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 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 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 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//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 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 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 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//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 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 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 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 Mon, 18 Feb 2008 09:40:18 -0600 dkms (2.0.17.4-0ubuntu4) hardy; urgency=low * Fix -x call. -- Scott James Remnant 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 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 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 Mon, 17 Sep 2007 09:58:46 -0500 dkms-2.3/debian/compat000066400000000000000000000000021276161124300147370ustar00rootroot000000000000007 dkms-2.3/debian/control000066400000000000000000000016411276161124300151460ustar00rootroot00000000000000Source: dkms Section: kernel Priority: optional Maintainer: Dynamic Kernel Modules Support Team Uploaders: David Paleino , Mario Limonciello , Giuseppe Iuculano 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. dkms-2.3/debian/copyright000066400000000000000000000016111276161124300154730ustar00rootroot00000000000000Source: https://github.com/dell/dkms Files: debian/HOWTO.Debian Copyright: © 2008-2016, Dell, Inc. 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 © 2005-2008, Matt Domsch © 2008-2009, Mario Limonciello © 2008-2009, Giuseppe Iuculano License: GPL-2+ Files: * Copyright: © 2003-2009, Dell, Inc. 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'. dkms-2.3/debian/dkms.lintian-overrides000066400000000000000000000001351276161124300200560ustar00rootroot00000000000000dkms binary: python-script-but-no-python-dep usr/share/apport/package-hooks/dkms_packages.py dkms-2.3/debian/examples000066400000000000000000000001131276161124300152750ustar00rootroot00000000000000sample.conf sample.spec sample-suse-10-mkkmp.spec sample-suse-9-mkkmp.spec dkms-2.3/debian/install000066400000000000000000000003301276161124300151260ustar00rootroot00000000000000debian/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/ dkms-2.3/debian/modprobe000066400000000000000000000001771276161124300153000ustar00rootroot00000000000000# modprobe information used for DKMS modules # # This is a stub file, should be edited when needed, # used by default by DKMS. dkms-2.3/debian/patches/000077500000000000000000000000001276161124300151705ustar00rootroot00000000000000dkms-2.3/debian/patches/series000066400000000000000000000000301276161124300163760ustar00rootroot00000000000000# This is empty for now dkms-2.3/debian/postinst000066400000000000000000000010631276161124300153470ustar00rootroot00000000000000#!/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# dkms-2.3/debian/preinst000066400000000000000000000021601276161124300151470ustar00rootroot00000000000000#!/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 dkms-2.3/debian/rules000077500000000000000000000011211276161124300146140ustar00rootroot00000000000000#!/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 dkms-2.3/debian/scripts/000077500000000000000000000000001276161124300152305ustar00rootroot00000000000000dkms-2.3/debian/scripts/dh_dkms000066400000000000000000000100141276161124300165600ustar00rootroot00000000000000#!/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 [S>] [S>] [S[I]>] [S I>] =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.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 If C in F is set to C<#MODULE_VERSION#>, set it to the given I or, if none is given, default to the upstream version of the current package. Otherwise, leave the value specified in F. =item B<--> I Don't look for debian/I.dkms or debian/dkms, but install I as dkms.conf. =back =head1 NOTES Note that this command is not idempotent. L 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 = ) { $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 = ) { $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 This program is part of the Debian DKMS package. L =head1 AUTHOR David Paleino =cut dkms-2.3/debian/scripts/dh_dkms.1000066400000000000000000000135501276161124300167270ustar00rootroot00000000000000.\" 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 dkms-2.3/debian/scripts/dkms.pm000066400000000000000000000001721276161124300165240ustar00rootroot00000000000000#!/usr/bin/perl use warnings; use strict; use Debian::Debhelper::Dh_Lib; insert_before("dh_installinit", "dh_dkms"); 1; dkms-2.3/debian/scripts/postinst-dkms000066400000000000000000000014721276161124300177760ustar00rootroot00000000000000# 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 dkms-2.3/debian/scripts/prerm-dkms000066400000000000000000000003671276161124300172420ustar00rootroot00000000000000DKMS_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 dkms-2.3/debian/source/000077500000000000000000000000001276161124300150415ustar00rootroot00000000000000dkms-2.3/debian/source/format000066400000000000000000000000141276161124300162470ustar00rootroot000000000000003.0 (quilt) dkms-2.3/debian/watch000066400000000000000000000003751276161124300145770ustar00rootroot00000000000000version=3 #we no longer are hosted on linux.dell.com #http://linux.dell.com/dkms/permalink/dkms-(.*)\.tar\.gz https://github.com/dell/dkms/releases \ .*[^n]/(?:|v|version-|r|REL_|rel-|dkms(?:_|-))(\d[^\s/]*)\.(?:tar\.xz|txz|tar\.bz2|tbz2|tar\.gz|tgz) dkms-2.3/dkms000066400000000000000000004317031276161124300132100ustar00rootroot00000000000000#!/bin/bash # # Dynamic Kernel Module Support (DKMS) # Copyright (C) 2003-2008 Dell, Inc. # by Gary Lerhaupt, Matt Domsch, & Mario Limonciello # Copyright (C) 2012 by Darik Horn # # 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 # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # 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_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. 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 _get_kernel_dir() { KVER=$1 case ${current_os} in Linux) DIR="/lib/modules/$KVER/build" ;; GNU/kFreeBSD) DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;; esac echo $DIR } _check_kernel_dir() { DIR=$(_get_kernel_dir $1) case ${current_os} in Linux) test -e $DIR/include ;; GNU/kFreeBSD) test -e $DIR/kern && test -e $DIR/conf/kmod.mk ;; *) return 1 ;; esac return $? } # Run a command that we may or may not want to be detailed about. invoke_command() { # $1 = command to be executed using eval. # $2 = Description of command to run # $3 = 'background' if you want to run the command asynchronously. local exitval=0 [[ $verbose ]] && echo -e "$1" || echo -en "$2..." if [[ $3 = background && ! $verbose ]]; then 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=$? fi (($exitval > 0)) && echo -en "(bad exit status: $exitval)" echo -en "\n" return $exitval } error() ( exec >&2 echo -n $"Error! " for s in "$@"; do echo "$s"; done ) warn() ( exec >&2 echo -n "$Warning: " for s in "$@"; do echo "$s"; done ) # Print an error message and die with the passed error code. die() { # $1 = error code to return with # rest = strings to print before we exit. ret=$1 shift error "$@" [[ $die_is_fatal = yes ]] && exit $ret || return $ret } mktemp_or_die() { local t t=$(mktemp "$@") && echo "$t" && return [[ $* = *-d* ]] && die 1 $"Unable to make temporary directory" die 1 "Unable to make temporary file." } show_usage() { echo $"Usage: $0 [action] [options]" echo $" [action] = { add | remove | build | install | uninstall | match | autoinstall" echo $" | mkdriverdisk | mktarball | ldtarball | mkrpm | mkkmp | mkdeb | status }" echo $" [options] = [-m module] [-v module-version] [-k kernel-version] [-a arch]" echo $" [-d distro] [-c dkms.conf-location] [-q] [--force] [--all]" echo $" [--templatekernel=kernel] [--directive='cli-directive=cli-value']" echo $" [--config=kernel-.config-location] [--archive=tarball-location]" 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() { # $1 = kernel version string # Pad all numbers in $1 so that they have at least three digits, e.g., # 2.6.9-1cvs200409091247 => 002.006.009-001cvs200409091247 # 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' } # 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 # dealing with, which may or may not be the currently installed kernel. set_module_suffix() { # $1 = the kernel to base the module_suffix on kernel_test="${1-:$(uname -r)}" module_suffix=".ko" [[ $(VER $kernel_test) < $(VER 2.5) ]] && module_suffix=".o" } set_kernel_source_dir() { # $1 = the kernel to base the directory on kernel_source_dir="$(_get_kernel_dir "$1")" } # A little test function for DKMS commands that only work on one kernel. have_one_kernel() { 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 -- # if there is an entry in kernelver[$i], there must also be an entry in arch[$i] # Note the special casing for the status action -- the status functions just # report on what we already have, and will break with the preprocessing that # this function provides. 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") 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 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 fi # Set global multi_arch multi_arch="" local i=0 for ((i=0; $i < ${#arch[@]}; i++)); do [[ $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 depmod -a "$1" -F "/boot/System.map-$1" else depmod -a "$1" fi } # This function is a little hairy -- every distro has slightly different tools # and naming conventions for creating initial ramdisks. It should probably # be split out into one function per distro, with make_initrd left as a stub. make_initrd() { # $1 = kernel version # $2 = arch [[ $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 done # No mkinitrd? Just return. [[ $mkinitrd ]] || return 0 # 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 for initrd in "initrd-$1.img" "initramfs-$1.img" "initrd.img-$1" "initrd-$1" ''; do [[ $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 fi echo $"Backing up $initrd to $initrd_dir/$initrd.old-dkms" cp -f "$initrd_dir/$initrd" "$initrd_dir/$initrd.old-dkms" echo $"Making new $initrd" echo $"(If next boot fails, revert to $initrd.old-dkms image)" if [[ $mkinitrd = dracut ]]; then invoke_command "$mkinitrd -f $initrd_dir/$initrd $1" "$mkinitrd" background elif [[ $mkinitrd = update-initramfs ]]; then 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 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 elif [[ -e /etc/debian_version ]]; then 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 fi return } # Grab our distro information from RPM-based distros. distro_version_rpm() { which rpm > /dev/null 2>&1 || { echo unknown; return; } 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 done echo unknown } # Grab distro information from LSB compliant distros. # Falls back to distro_version_rpm if needed. distro_version() { # What distribution are we running? local LSB_DESCRIPTION DISTRIB_ID DISTRIB_RELEASE ver # Try the LSB-provided strings first if [ -r /etc/lsb-release ]; then . /etc/lsb-release elif type lsb_release >/dev/null 2>&1; then 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 ;; esac } override_dest_module_location() { local orig_location="$1" [[ ${addon_modules_dir} ]] && echo "/${addon_modules_dir}" && return if [ "$current_os" = "GNU/kFreeBSD" ] ; then # 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 ;; *) ;; esac echo "$orig_location" } # Source a file safely. # We want to ensure that the .conf file we source does not stomp all over # parts of the environment we don't want them to. This makes it so that # it is harder to accidentally corrupt our environment. conf files can # still deliberatly trash the environment by abusing dkms_directive env # variables or by crafting special values that will make eval do evil things. safe_source() { # $1 = file to source # $@ = environment variables to echo out local to_source_file="$1"; shift 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 ) . "$tmpfile" rm "$tmpfile" } # Source a dkms.conf file and perform appropriate postprocessing on it. # Do our best to not repeatedly source the same .conf file -- this can happen # when chaining module installtion functions or autoinstalling. read_conf() { # $1 kernel version (required) # $2 arch (required) # $3 dkms.conf location (optional) local return_value=0 local read_conf_file="$dkms_tree/$module/$module_version/source/dkms.conf" # Set variables supported in dkms.conf files (eg. $kernelver) local kernelver="$1" local arch="$2" set_kernel_source_dir "$1" # Find which conf file to check [[ $conf ]] && read_conf_file="$conf" [[ $3 ]] && read_conf_file="$3" [[ -r $read_conf_file ]] || die 4 $"Could not locate dkms.conf file." \ $"File: $conf does not exist." [[ $last_mvka = $module/$module_version/$1/$2 && \ $last_mvka_conf = $(readlink -f $read_conf_file) ]] && return # Clear variables and arrays for var in $dkms_conf_variables; do unset $var done # Source in the dkms.conf. # Allow for user-specified overrides in order of specificity. local _conf_file for _conf_file in "$read_conf_file" "/etc/dkms/$module.conf" \ "/etc/dkms/$module-$module_version.conf" "/etc/dkms/$module-$module_version-$1.conf" \ "/etc/dkms/$module-$module_version-$1-$2.conf"; do [ -e "$_conf_file" ] && safe_source "$_conf_file" $dkms_conf_variables done # 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\"" done # Set variables clean="$CLEAN" package_name="$PACKAGE_NAME" package_version="$PACKAGE_VERSION" post_add="$POST_ADD" post_build="$POST_BUILD" post_install="$POST_INSTALL" post_remove="$POST_REMOVE" pre_build="$PRE_BUILD" pre_install="$PRE_INSTALL" obsolete_by="$OBSOLETE_BY" # 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 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" ;; [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 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]}" 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" 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" fi # Set modules_conf_array for ((index=0; index < ${#MODULES_CONF[@]}; index++)); do [[ ${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 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" # 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 fi # Fail if no PACKAGE_NAME if [[ ! $package_name ]]; then 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 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 $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 done < <(modinfo $1) } # Perform some module version sanity checking whenever we are installing # or removing modules. check_version_sanity() { # $1 = kernel_version # $2 = arch # $3 = obs by kernel version # $4 = dest_module_name local lib_tree="$install_tree/$1" res= echo $"Running module version sanity check." local i=0 local -a kernels_info dkms_info set_module_suffix read -a kernels_module < <(find $lib_tree -name ${4}$module_suffix) 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 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 return 0 } moduleconfig_update_obsoletes() { # $@ = files to process # 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 done # 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 done } moduleconfig_add() { # $1 = kernel version 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" 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 done # Delete the temp dir rm -rf $temp_dir_name } moduleconfig_remove() { # $1 = kernel version local temp_dir_name=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX) modconfig_files="" [ -e /etc/modprobe.d/dkms.conf ] && modconfig_files="/etc/modprobe.d/dkms.conf" [ -e /etc/modprobe.d/dkms ] && modconfig_files="/etc/modprobe.d/dkms" [ -e /etc/modules.conf ] && modconfig_files="$modconfig_files /etc/modules.conf" [ -e /etc/modprobe.conf ] && modconfig_files="$modconfig_files /etc/modprobe.conf" [ -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 done # Delete the temp dir rm -rf $temp_dir_name } etc_sysconfig_kernel_modify() ( [[ -e /etc/sysconfig/kernel && $remake_initrd ]] || return 0 # 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 # 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 fi # Delete the temp dir rm -rf $temp_dir_name ) check_module_args() { [[ $module && $module_version ]] && return die 1 $"Invalid number of arguments passed." \ $"Usage: $1 / or" \ $" $1 -m / or" \ $" $1 -m -v " } read_conf_or_die() { read_conf "$@" && return die 8 $"Bad conf file." $"File: $conf" \ $"does not represent a valid dkms.conf file." } run_build_script() { # $1 = script type # $2 = script to run local script_type run [[ $2 ]] || return 0 case "$1" in pre_build|post_build) script_type='build' ;; *) script_type='source' ;; esac run="$dkms_tree/$module/$module_version/$script_type/$2" if [[ -x ${run%% *} ]]; then echo $"" echo $"Running the $1 script:" ( cd "$dkms_tree/$module/$module_version/$script_type/" exec $run ) else echo $"" warn $"The $1 script is not executable." fi } # Register a DKMS-ified source tree with DKMS. # This function is smart enough to register the module if we # passed a source tree or a tarball instead of relying on the source tree # being unpacked into /usr/src/$module-$module_version. add_module() { # 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 elif [[ $try_source_tree && ! $module && ! $module_version ]]; then add_source_tree "$try_source_tree" fi # Check that we have all the arguments check_module_args add # 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." 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." 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 fi # Check the conf file for sanity read_conf_or_die "$kernelver" "$arch" "$conf" # Create the necessary dkms tree structure echo $"" echo $"Creating symlink $dkms_tree/$module/$module_version/source ->" echo $" $source_tree/$module-$module_version" mkdir -p "$dkms_tree/$module/$module_version/build" ln -s "$source_tree/$module-$module_version" "$dkms_tree/$module/$module_version/source" # Run the post_add script run_build_script post_add "$post_add" echo $"" echo $"DKMS: add completed." } # Prepare a kernel source or include tree for compiling a module. # Most modern-ish distros do not require this function at all, # so it will be removed in a future release. prepare_kernel() { # $1 = kernel version to prepare # $2 = arch to prepare set_kernel_source_dir "$1" # 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 } [[ $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 fi # Prepare kernel for module build echo $"" echo $"Preparing kernel $1 for module build:" 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" } # 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="" 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 -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 # 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 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 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 } # Get ready to build a module that has been registered with DKMS. prepare_build() { # If the module has not been added, try to add it. is_module_added "$module" "$module_version" || add_module set_kernel_source_dir "$kernelver" local base_dir="$dkms_tree/$module/$module_version/$kernelver/$arch" # Check that the right arguments were passed check_module_args 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." # Read the conf file set_module_suffix "$kernelver" read_conf_or_die "$kernelver" "$arch" # 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." # 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." prepare_kernel "$kernelver" "$arch" # Set up temporary build directory for build rm -rf "$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." done # Run the pre_build script run_build_script pre_build "$pre_build" } # Build our previously prepared source tree. prepare_build must be called # before calling this function. do_build() { local base_dir="$dkms_tree/$module/$module_version/$kernelver/$arch" echo $"" echo $"Building module:" 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 -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." # 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." done cd - >/dev/null # Build success, so create DKMS structure for a built module mkdir -p "$base_dir/log" [[ $kernel_config ]] && cp -f "$kernel_config" "$base_dir/log/" mv -f "$dkms_tree/$module/$module_version/build/make.log" "$base_dir/log/make.log" 2>/dev/null # 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 done # Run the post_build script run_build_script post_build "$post_build" } # Clean up after a build. clean_build() { # Run the clean commands cd "$dkms_tree/$module/$module_version/build" invoke_command "$clean" "cleaning build area" background cd - >/dev/null if [[ ! ( $(VER $kernelver) < $(VER 2.6.6) ) && \ -d $kernel_source_dir && \ ! -h $kernel_source_dir && \ ! $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 # Clean the build directory rm -rf "$dkms_tree/$module/$module_version/build" } build_module() { prepare_build do_build clean_build echo $"" 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. install_module() { # If the module has not been built, try to build it first. is_module_built "$module" "$module_version" "$kernelver" "$arch" || build_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." # 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)" # 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. [[ $rpm_safe_upgrade ]] && force="true" # Save the original_module if one exists, none have been saved before, and this is the first module for this kernel 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]} [[ $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 # Create the kernel- symlink to designate this version as active 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 [ -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" # Make modules.conf changes as necessary echo $"" moduleconfig_add "$kernelver" 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 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." } 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. list_each_installed_module() { # $1 = module # $2 = kernel version # $3 = arch 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" done } is_module_added() { [[ $1 && $2 ]] || return 1 [[ -d $dkms_tree/$1/$2 ]] || return 2 [[ -L $dkms_tree/$1/$2/source || -d $dkms_tree/$1/$2/source ]]; } is_module_built() { [[ $1 && $2 && $3 && $4 ]] || return 1 local d="$dkms_tree/$1/$2/$3/$4" m='' [[ -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 done } # This assumes we have already checked to see if the module has been built. _is_module_installed() { [[ $1 && $2 && $3 && $4 ]] || return 1 local d="$dkms_tree/$1/$2/$3/$4" local k="$dkms_tree/$1/kernel-$3-$4" [[ -L $k && $(readlink -f $k) = $d ]] } # This does not. 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 } 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 } 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 } module="$1" module_version="$2" kernelver="$3" arch="$4" install_module ) build_modules() { local i=0 for ((i=0; i < ${#kernelver[@]}; i++)); do 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]}" 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." } possible_dest_module_locations() { # $1 = count # There are two places an installed module may really be: # 1) "$install_tree/$kernelver/${dest_module_location[$count]}/${dest_module_name[$count]}$module_suffix" # 2) "$install_tree/$kernelver/${DEST_MODULE_LOCATION[$count]}/${dest_module_name[$count]}$module_suffix" # override_dest_module_location() is what controls whether or not they're the same. local location location[0]="${dest_module_location[$count]}" [[ ${DEST_MODULE_LOCATION[$count]} != ${dest_module_location[$count]} ]] && \ location[1]="${DEST_MODULE_LOCATION[$count]}" echo "${location[@]}" } find_actual_dest_module_location() { local module="$1" local count="$2" local kernelver="$3" local arch="$4" local locations="$(possible_dest_module_locations $count)" local l local dkms_owned local installed 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 done } # Remove compiled DKMS modules from any kernels they are installed in. do_uninstall() { # $1 = kernel version # $2 = arch echo $"" echo $"-------- Uninstall Beginning --------" echo $"Module: $module" echo $"Version: $module_version" echo $"Kernel: $1 ($2)" echo $"-------------------------------------" set_module_suffix "$1" # If kernel- symlink points to this module, check for original_module and put it back local was_active="" 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 [ -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 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." fi # Run the post_remove script run_build_script post_remove "$post_remove" # Run depmod because we changed /lib/modules invoke_command "do_depmod $1" "depmod" background # 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." 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" 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." fi [[ $(find $dkms_tree/$module/original_module/* -maxdepth 0 -type d 2>/dev/null) ]] || rm -rf "$dkms_tree/$module/original_module" # Re-add entries to modules.conf if this module/version is still installed on another kernel # But only do this if it was just ACTIVE on the kernel we just uninstalled from [[ $was_active && $remake_initrd ]] && do_status $module $module_version | grep -q "installed" && moduleconfig_add "$1" echo $"" echo $"DKMS: uninstall completed." } # Check our preconditions, and then let do_install do all the hard work. uninstall_module() { # Check that the right arguments were passed check_module_args uninstall # 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." # 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." # Read the conf file read_conf_or_die "$kernelver" "$arch" # 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)." do_uninstall "$kernelver" "$arch" } # Unregister a DKMS module. This uninstalls any installed modules along the way. 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 / --all" \ $" or: remove / -k " 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." 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 # 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]}" 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]}" 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." 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 # Its now safe to completely remove references in /etc/sysconfig/kernel for SuSE etc_sysconfig_kernel_modify "delete" fi } # Given a kernel object, figure out which DKMS module it is from. find_module_from_ko() { local ko="$1" local basename_ko="${ko##*/}" local module 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 done return 1 } # Check to see if modules meeting the passed parameters are weak-installed. # This function's calling convention is different from the usual DKMS status # checking functions -- the kernel version we usually have is the one we are currently # running on, not necessarily the one we compiled the module for. 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 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" done return $ret } # Print the requested status lines for weak-installed modules. 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" done < <(module_status_weak "$@") } # Spit out all the extra status information that people running DKMS are # interested in, but that the DKMS internals do not usually care about. module_status_built_extra() ( set_module_suffix "$3" 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 done ) # Return a list of all the modules that are either built or installed. # This and module_status do some juggling of $IFS to ensure that # we do not get word splitting where it would be inconvienent. 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='' done IFS="$oifs" return $ret } # Return the status of all modules that have been added, built, or installed. 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='' done IFS="$oifs" return $ret } # Print out the status in the format that people who call DKMS expect. # Internal callers should use the module_status functions, as their output # is easier to parse. 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 done < <(module_status "$@") } # Show all our status in the format that external callers expect, even # though it is slightly harder to parse. 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" 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 fi } create_temporary_trees() { [[ $module || $module_version || ! -r dkms.conf ]] && return 0 . dkms.conf module="$PACKAGE_NAME" module_version="$PACKAGE_VERSION" source_tree=$(mktemp_or_die -d) dkms_tree=$(mktemp_or_die -d) local source_tree_dir="$source_tree/$PACKAGE_NAME-$PACKAGE_VERSION" mkdir -p "$source_tree_dir" cp -a * "$source_tree_dir" # intentionally skip .git or .hg add_module temporary_trees_del_command="rm -rf $source_tree $dkms_tree" } delete_temporary_trees() { [[ $temporary_trees_del_command ]] || return 0 $temporary_trees_del_command module= module_version= source_tree= dkms_tree= temporary_trees_del_command= } in_temporary_trees() { [[ $temporary_trees_del_command ]] } media_valid() { local mrx='^(floppy|iso|tar)$' [[ $media =~ $mrx ]] } make_driver_disk_floppy() { local image_name="$1" local source_dir="$2" local file local fs='ext2' [[ $distro = redhat* ]] && fs='vfat' 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 ;; esac local mntdir=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX) invoke_command "mount -o loop -t $fs $image_name $mntdir >/dev/null 2>&1" "loopback mounting disk image" [[ -d $mntdir/lost+found ]] && rmdir "$mntdir/lost+found" invoke_command "cp -r $source_dir/* $mntdir/" " copying files to floppy disk image" invoke_command "umount $mntdir" "unmounting disk image" rm -rf "$mntdir" } make_driver_disk_isotar() { local type="$1" local image_name="$2" 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 ;; esac } 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" ;; esac } driver_disk_suffix() { case $media in 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) 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 fi if [ "$distro" == "redhat2" ] && [ -z "$redhat1_okay" ]; then 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 else 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 done # Create directory and necessary files driver_disk_dir=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX) # Copy files for the driver disk (or warn if not present) local files_for_driverdisk="modinfo disk-info modules.dep pcitable modules.pcimap pci.ids" # Fedora Core 5 and higher, RHEL5 and higher, strictly require: rhdd, modules.cgz, modinfo, modules.alias, modules.dep # which is in effect ignoring disk-info, pcitable, modules.pcimap and pci.ids # and adding modules.alias, which will be generated. 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 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" fi local suffix="$(driver_disk_suffix)" local image_dir="$dkms_tree/$module/$module_version/driver_disk" local image_name="$module-$module_version-$kernel_version_list-dd.$suffix" echo $"" echo $"Creating driver disk on $media media:" cd "$cpioarchive_dir_name" 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 # 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 done [[ -e ./modules.alias ]] && cp -f ./modules.alias "$driver_disk_dir/" # FIXME: add rpms/ directory, copy in KMP RPMs, run createrepo --pretty cd - >/dev/null rm -rf "$cpioarchive_dir_name" mkdir -p "$image_dir" rm -f "$image_dir/$image_name" cd "$driver_disk_dir" make_driver_disk_media "$image_dir/$image_name" "$driver_disk_dir" cd - >/dev/null rm -rf "$driver_disk_dir" echo $"" echo $"Disk image location: $image_dir/$image_name" echo $"" echo $"DKMS: mkdriverdisk completed." } 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 / -d -k [--media floppy|iso|tar]" fi # Default to floppy media [[ $media ]] || media="floppy" if ! media_valid; then die 1 $"Media $media is invalid." \ $"Usage: mkdriverdisk / -d -k [--media floppy|iso|tar]" fi # Check that source symlink works check_module_exists # 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" ;; 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 ;; esac } find_external_dependencies() { local mod count i local -a deps # 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 done # Prune internally satisfied dependencies for ((i=0; i < ${#deps[@]}; i++)); do for mod in ${dest_module_name[@]}; do [[ ${deps[i]} = $mod ]] && deps[i]= done done for dep in "${deps[@]}"; do echo $dep done | sort -u } make_suse_driver_disk() { [[ $release ]] || die 3 \ $"Invalid number of parameters passed for suse/UnitedLinux driver disk." \ $"Usage: mkdriverdisk / -d -k " \ $" -r " local driver_disk_dir=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX) local suffix="$(driver_disk_suffix)" local image_dir="$dkms_tree/$module/$module_version/driver_disk" local image_name="$module-$module_version-$distro-$release-dd.$suffix" echo $"" echo $"Creating driver disk:" local deps="$(find_external_dependencies)" local offset=0 # reserve a place for dependencies [[ ${deps[@]} ]] && offset=1 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 #!/bin/sh kernlist="${postkernels}" for kernel in \${kernlist}; do if [ -e /boot/System.map-\${kernel} ]; then 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 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 fi # FIXME: add suse-equivalent rpms/ directory, copy in KMP RPMs, run createrepo --pretty mkdir -p "$image_dir" rm -f "$image_dir/$image_name" cd "$driver_disk_dir" make_driver_disk_media "$image_dir/$image_name" "$driver_disk_dir" cd - >/dev/null rm -rf "$driver_disk_dir" echo $"" echo $"Disk image location: $dkms_tree/$module/$module_version/driver_disk/$image_name" echo $"" echo $"DKMS: mkdriverdisk completed." } make_ubuntu_driver_disk() { local suffix="$(driver_disk_suffix)" local image_dir="$dkms_tree/$module/$module_version/driver_disk" local image_name="$module-$module_version-$distro-dd.$suffix" 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//*_.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 < Description: DKMS packaged binary driver update DKMS automagically generated debian package for driver update disks, used with Ubuntu installation programs (such as Ubiquity). EOF # Generate the DEBIAN/preinst file. # This is tricky as we need some parts evaluated now # and some parts evaluated at runtime cat >DEBIAN/preinst < /dev/null 2>&1 done echo "Copying source..." mkdir -p "$tempdir/ubuntu" cp -ar "$source_tree/$module-$module_version" "$tempdir/ubuntu/" mkdir -p "$image_dir" rm -f "$image_dir/$image_name" cd "$tempdir" make_driver_disk_media "$image_dir/$image_name" "$tempdir" cd - >/dev/null rm -rf "$tempdir" echo $"" echo $"Disk image location: $dkms_tree/$module/$module_version/driver_disk/$image_name" echo $"" echo $"DKMS: mkdriverdisk completed." } make_tarball() { make_common_test "mktarball" # 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 fi # Read the conf file read_conf_or_die "$kernelver" "$arch" temp_dir_name=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX) mkdir -p $temp_dir_name/dkms_main_tree if [[ $source_only ]]; then 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]}" done fi # Store the dkms_dbversion in the tarball cp -f "$dkms_tree/dkms_dbversion" "$temp_dir_name/dkms_main_tree/" # 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 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 fi if (( $(echo $kernel_version_list | wc -m | awk {'print $1'}) > 200 )); then kernel_version_list="manykernels" fi local tarball_name="$module-$module_version-$kernel_version_list.dkms.tar.gz" local tarball_dest="$dkms_tree/$module/$module_version/tarball/" # Die if we will not be able to create the tarball due to permissions. if [[ $archive_location ]]; then 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 fi if [ ! -d $tarball_dest ]; then mkdir -p "$dkms_tree/$module/$module_version/tarball/" fi echo $"" echo $"Tarball location: $tarball_dest/$tarball_name" local tarball_ext=${tarball_name##*.} [[ $tarball_ext = tar ]] || tarball_name=${tarball_name%.$tarball_ext} # 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 else cd - >/dev/null rm -rf $temp_dir_name die 6 $"Failed to make tarball." fi case $tarball_ext in 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." } # A tiny helper function to make sure dkms.conf describes a valid package. get_pkginfo_from_conf() { [[ -f $1 && $1 = *dkms.conf ]] || return read_conf_or_die "$kernelver" "$arch" "$1" [[ $PACKAGE_NAME && $PACKAGE_VERSION ]] } # Unpack a DKMS tarball from a few different supported formats. # We expect $archive_location to have been passed either as a raw argument or # with --archive. load_tarball() { # Error out if $archive_location does not exist if [[ ! -e $archive_location ]]; then die 2 $"$archive_location does not exist." fi # If it is an .rpm file. install it with rpm, run an autoinstall, and then exit. if [[ $archive_location = *.rpm ]]; then if rpm -Uvh "$archive_location"; then autoinstall exit $? else die 9 $"Unable to install $archive_location using rpm." \ $"Check to ensure that your system can install .rpm files." fi fi # Figure out what kind of archive it is (tar.gz, tar, tar.bz, etc) # 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 done # Untar it into $tmp_location local temp_dir_name=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX) trap 'rm -rf $temp_dir_name' EXIT 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 fi # Check that dkms_dbversion is not a future version # As far as I can tell, the only reason we bother with this is for detecting # whether we have arch support or not, which we can also determine by examining # 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." 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@dell.com";; esac break done # 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." 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 done echo $"" echo $"DKMS: ldtarball completed." [[ $loc != dkms_binaries_only ]] || [[ -d $source_tree/$module-$module_version ]] } run_match() { set_kernel_source_dir "$kernelver" # Error if $template_kernel is unset if [[ ! $template_kernel ]]; then die 1 $"Invalid number of parameters passed." \ $"Usage: match --templatekernel= -k " \ $" or: match --templatekernel= -k " 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." fi # Read in the status of template_kernel local template_kernel_status=$(do_status '' '' $template_kernel $arch | grep ": installed") # 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,") fi echo $"" echo $"Matching modules in kernel: $kernelver ($arch)" echo $"to the configuration of kernel: $template_kernel ($arch)" # 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." 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 fi # Done echo $"" echo $"DKMS: match completed." } make_rpm() { make_common_test "mkrpm" # 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." fi # Read the conf file read_conf_or_die "$kernelver" "$arch" local rpm_basedir="$dkms_tree/$module/$module_version/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 done if [[ ! $SPECFILE ]]; then 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 else mktarball_line="none" fi local temp_dir_name=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX) trap 'rm -rf $temp_dir_name' EXIT HUP TERM 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 ((legacy_postinst != 0)); then invoke_command "cp '$PREFIX/usr/lib/dkms/common.postinst' '${temp_dir_name}/SOURCES'" "copying legacy postinstall template" fi # 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" 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." else 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 } 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" mv "$1.dkms-pp" "$1" } # Install a package on a debian system. 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] 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 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'" else $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." fi } make_debian() { create_type="$1" create_temporary_trees trap "delete_temporary_trees" EXIT HUP TERM make_common_test "mk${create_type}" debian_package=${module//_/-} # Read the conf file read_conf_or_die "$kernelver" "$arch" debian_install fakeroot dpkg-dev debhelper # 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} elif [[ -e ${local_mk} ]]; then 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}." fi # 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" done popd > /dev/null 2>&1 # 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" fi # 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" fi # 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 fi # Calculate destination directory deb_basedir=$dkms_tree/$module/$module_version/${create_type} mkdir -p ${deb_basedir} >/dev/null 2>&1 # 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" ;; esac popd > /dev/null 2>&1 if in_temporary_trees; then echo "Copying built files to "`pwd`"/.." >&2 cp "${deb_basedir}/"* .. fi # Cleanup invoke_command "rm $temp_dir -fr" "Cleaning up temporary files" delete_temporary_trees || \ die 7 $"There was a problem cleaning up temporary files." } make_common_test() { local create_type=$1 # Error if $module_version is set but $module is not check_module_args $create_type # Check that source symlink works check_module_exists # 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." } make_kmp_srpm() { local temp_dir_name=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX) 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 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} popd > /dev/null 2>&1 pushd "$temp_dir_name" > /dev/null 2>&1 invoke_command "rpmbuild --define \"_topdir ${temp_dir_name}\" --target=$arch -bs ${SPECFILE} > ${temp_dir_name}/rpmbuild.log 2>&1" "rpmbuild" 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}') else echo $"rpmbuild error log:" cat $temp_dir_name/rpmbuild.log fi popd > /dev/null 2>&1 rm -rf $temp_dir_name trap > /dev/null 2>&1 return ${RC} } report_build_problem() { # 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 "$@" } # Little helper function for reading args from the commandline. # it automatically handles -a b and -a=b variants, and returns 1 if # we need to shift $3. read_arg() { # $1 = arg name # $2 = arg value # $3 = arg parameter local rematch='^[^=]*=(.*)$' if [[ $2 =~ $rematch ]]; then 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 fi } # A couple of helper functions for parsing out our most common arguments. # This one allows you to pass -k kernel.version-extra/arch instead of # -k kernel-version.extra -a arch. # This makes it harder to pass mismatching numbers of kernel/arch pairs, because # 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]}" else kernelver[${#kernelver[@]}]="$1" fi } # This allows you to pass module and module_version information on the commandline # in a more convienent form. Instead of the mostly mandatory and annoying # -m module -v module_version, you can use either -m module/module_version, # or just a raw module/module_version with no -m parameter. # This vastly improves readability and discoverability of # commands on the commandline. parse_moduleversion(){ if [[ $1 =~ $mv_re ]]; then module="${BASH_REMATCH[1]}" module_version="${BASH_REMATCH[2]}" else module="$1" fi } check_root() { ((UID == 0)) && return die 1 $"You must be root to use this command." } # Add a passed source tree to the default source location. # We will check the dkms.conf file to make sure it is valid # beforehand. add_source_tree() { local from=$(readlink -f $1) if ! [[ $from && -f $from/dkms.conf ]]; then 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." 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" 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 ;; esac mkdir -p "$source_tree/$module-$module_version" cp -fr "$from"/* "$source_tree/$module-$module_version" } make_kmp() { make_common_test "mkkmp" # Read the conf file read_conf_or_die "$kernelver" "$arch" 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" 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" else die 5 $"Cannot find a suitable spec file which is needed by" \ $"DKMS in order use mkkmp. Please specify --spec=specfile." fi prepare_build make_kmp_srpm RC=$? clean_build if ((RC == 0)); then echo $"" echo $"KMP SRPM location: $RPMS" echo $"" echo $"DKMS: mkkmp completed." else die 7 $"There was a problem creating your KMP source rpm." fi # FIXME: hand SRPM to mock or build system to build } # This code used to be in dkms_autoinstaller. # Moving it into the main dkms script gets rid of a fair amount of duplicate # functionality, and makes it much easier to reinstall DKMS kernel modules # 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. 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 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. if [[ $tenative ]]; then to_install[${#to_install[@]}]="$tenative" build_depends["$m"]="${BUILD_DEPENDS[@]}" fi [[ $to_install ]] || return 0 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" echo "$m/$v autoinstall failed due to missing dependencies: ${build_depends[$m]}" done } function make_redhat3_driver_disk () { # Check that the rpmbuild command is present if ! which rpmbuild >/dev/null 2>&1 ; then echo $"" >&2 echo $"Error! rpmbuild not present." >&2 echo $"Install the rpm-build package." >&2 exit 1 fi local kmodtool=$(rpm -ql redhat-rpm-config | grep kmodtool) #Check that the kmodtool is present if [ -z "$kmodtool" ]; then echo $"Error! kmodtool not present." >&2 echo $"Install redhat-rpm-config package." >&2 exit 1 fi # Check that the createrepo command is present if ! which createrepo >/dev/null 2>&1 ; then echo $"" >&2 echo $"Error! createrepo not present." >&2 echo $"Install the createrepo package." >&2 exit 1 fi echo $"" if [ -n "$specfile" -a -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" elif [ -e "/etc/dkms/template-dkms-redhat-kmod.spec" ]; then echo $"Using /etc/dkms/template-dkms-redhat-kmod.spec" SPECFILE="/etc/dkms/template-dkms-redhat-kmod.spec" else echo $"" >&2 echo $"Cannot find /etc/dkms/template-dkms-redhat-kmod.spec which is needed by" >&2 echo $"DKMS in order to make Redhat driver disk v3." >&2 exit 5 fi # Set up temporary build directory for build rm -rf "$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" # Run the pre_build script if [ -n "$pre_build" ] && [ -x `echo "$dkms_tree/$module/$module_version/source/$pre_build" | sed 's/ .*//'` ]; then echo $"" echo $"Running the pre_build script:" $dkms_tree/$module/$module_version/build/$pre_build fi # Apply any patches local index=0 while [ $index -lt ${#patch_array[@]} ]; do if ! [ -e "$dkms_tree/$module/$module_version/build/patches/${patch_array[$index]}" ]; then echo $"" >&2 echo $"Error! Patch ${patch_array[$index]} as specified in dkms.conf cannot be" >&2 echo $"found in $dkms_tree/$module/$module_version/build/patches/." >&2 exit 5 fi invoke_command "patch -p1 < ./patches/${patch_array[$index]}" "applying patch ${patch_array[$index]}" if [ "$?" -ne 0 ]; then echo $"" >&2 echo $"Error! Application of patch ${patch_array[$index]} failed." >&2 echo $"Check $dkms_tree/$module/$module_version/build/ for more information." >&2 report_build_problem exit 6 fi index=$(($index+1)) done # Create temp dirs and copy files for build local temp_dir_name=`mktemp -d $tmp_location/dkms.XXXXXX` trap 'rm -rf $temp_dir_name' EXIT HUP TERM mkdir -p ${temp_dir_name}/{disk,BUILD,RPMS,SRPMS,SPECS,SOURCES} 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" 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 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 echo $"" >&2 echo $"Error! There was a problem creating your kmod." >&2 cat ${temp_dir_name}/rpmbuild.log >&2 exit 7 fi local kabi_whitelist=`rpm -ql kabi-whitelists | grep ${arch[$i]}` if [ $kabi_whitelist ]; then local module_file=`rpm -qlp ${temp_dir_name}/RPMS/${arch[$i]}/kmod-${module}-${module_version}* | grep ${module}.ko` cd ${temp_dir_name}/ rpm2cpio ${temp_dir_name}/RPMS/${arch[$i]}/kmod-${module}-${module_version}* | cpio -id --quiet .${module_file} cd - > /dev/null local mod_symbols=( $(modprobe --dump-modversions ${temp_dir_name}/${module_file} | cut -f2) ) local miss_sym_count=0 local missing_symbols for ((i=0; i < "${#mod_symbols[@]}"; i++)) do if [ -z "`grep -o ${mod_symbols[${i}]} ${kabi_whitelist}`" ]; then missing_symbols[$miss_sym_count]="${mod_symbols[${i}]}" miss_sym_count=$(($miss_sym_count+1)) fi done if [ $miss_sym_count -ne 0 ]; then echo $"" >&2 echo $"WARNING: ${module}-${module_version} is using following kernel symbols that are not in the ABI whitelist:" echo $"----------------------------------" for missing_symbol in ${missing_symbols[*]} do echo "$missing_symbol" done echo $"----------------------------------" echo $"" >&2 else echo $"NOTICE: ${module}-${module_version} module seems to use only official Red Hat ABI." fi else echo $"WARNING:${module}-${module_version} module is not checked against Red Hat ABI whitelist." echo $"Install 'kabi-whitelists' package and build driver disk again to run the ABI compliance test." fi i=$(($i + 1)) done i=0 while [ $i -lt ${#arch[@]} ]; do invoke_command "createrepo --pretty ${temp_dir_name}/RPMS/${arch[$i]}" "creating repo" if [ "$?" -ne 0 ]; then echo $"" >&2 echo $"Error! There was a problem creating repository." >&2 exit 7 fi i=$(($i + 1)) done echo "$module-$module_version driver disk" > "${temp_dir_name}/disk/rhdd3" mkdir ${temp_dir_name}/disk/rpms cp -rax ${temp_dir_name}/RPMS/* ${temp_dir_name}/disk/rpms/ local suffix="$(driver_disk_suffix)" local image_dir="$dkms_tree/$module/$module_version/driver_disk" local image_name="$module-$module_version-dd.$suffix" echo $"" echo $"Creating driver disk on $media media:" cd "${temp_dir_name}/disk" mkdir -p "$image_dir" rm -f "$image_dir/$image_name" make_driver_disk_media "$image_dir/$image_name" "${temp_dir_name}/disk" rm -rf $temp_dir_name echo $"" echo $"Disk image location: $image_dir/$image_name" echo $"" echo $"DKMS: mkdriverdisk completed." trap > /dev/null 2>&1 } ############################# #### #### #### Program Starts Here #### #### #### ############################# # Set a standard path PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/lib/dkms" # Ensure files and directories we create are readable to anyone, # since we aim to build as a non-root user umask 022 # Unset environment variables that may interfere with the build unset CC CXX CFLAGS CXXFLAGS LDFLAGS # Set important variables current_kernel=$(uname -r) current_os=$(uname -s) dkms_tree="/var/lib/dkms" 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 [[ ! ${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)" weak_modules="${WEAK_MODULES_BIN}" # Source in /etc/dkms_framework.conf [ -e $dkms_frameworkconf ] && . $dkms_frameworkconf 2>/dev/null # Clear out command line argument variables module="" module_version="" template_kernel="" distro="" media="" release="" conf="" kernel_config="" archive_location="" kernel_source_dir="" ksourcedir_fromcli="" action="" force="" no_prepare_kernel="" no_clean_kernel="" binaries_only="" source_only="" all="" module_suffix="" rpm_safe_upgrade="" size="1440"; specfile="" legacy_postinst="1" declare -a directive_array=() kernelver=() arch=() weak_modules='' last_mvka='' last_mvka_conf='' 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: [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 # Sanity checking # 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." 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)." 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." 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." 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 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 ;; esac done dkms-2.3/dkms-freshmeat.txt.in000066400000000000000000000010771276161124300164040ustar00rootroot00000000000000Project: dkms Branch: Default Home-Page-URL: http://linux.dell.com/dkms/dkms.shtml Changelog-URL: http://linux.dell.com/git/dkms.git/?p=dkms.git;a=shortlog Mailing-List-URL: http://lists.us.dell.com/mailman/listinfo/dkms-devel Hide: N Release-Focus: Minor feature enhancements Version: [INSERT_VERSION_HERE] Gzipped-Tar-URL: http://linux.dell.com/dkms/permalink/dkms-[INSERT_VERSION_HERE].tar.gz RPM-URL: http://linux.dell.com/dkms/permalink/dkms-[INSERT_VERSION_HERE]-1.noarch.rpm Debian-URL: http://linux.dell.com/dkms/permalink/dkms_[INSERT_VERSION_HERE]-0ubuntu1_all.deb dkms-2.3/dkms.8000066400000000000000000001260171276161124300133550ustar00rootroot00000000000000.\" -*- 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 .SH SYNOPSIS .SY dkms .OP action .OP options .OP module/module-version .OP /path/to/source-tree .OP /path/to/tarball.tar .OP /path/to/driver.rpm .YS .SH DESCRIPTION .B dkms is a framework which allows kernel modules to be dynamically built for each kernel on your system in a simplified and organized fashion. .SH ACTIONS .SY add .OP module/module\-version .OP /path/to/source\-tree .OP /path/to/tarball.tar .YS .IP "" 4 Adds a module/module\-version combination to the tree for builds and installs. If module/module\-version, \-m module/module\-version, or \-m module\ \-v version are passed as options, this command requires source in .I /usr/src/\-/ as well as a properly formatted .I dkms.conf file. If .I /path/to/source\-tree is passed as an option, and source-tree contains a .I dkms.conf file, it will copy .I /path/to/source\-tree to .I /usr/src/module\-module\-version. If .I /path/to/tarball.tar is passed, this command behaves like the .B ldtarball command. .SY remove .OP module/module\-version .OP -k kernel/arch .OP \-\-all .YS .IP "" 4 Removes a module/version or module/version/kernel/arch combination from the tree. If the module is currently installed, it first uninstalls it and if applicable, will replace it with its original_module. Use the .B \-\-all option in order to remove all instances for every kernel at once. .SY build .OP module/module\-version .OP -k kernel/arch .YS .IP "" 4 Builds the specified module/version combo for the specified kernel/arch. If the .I \-k option is not specified it builds for the currently running kernel and arch.. All builds occur in the directory .I /var/lib/dkms///build/. If the module/module\-version combo has not been added, dkms will try to add it, and in that case .B build can take the same arguments that .B add can. .SY install .OP module/module\-version .OP -k kernel/arch .OP /path/to/driver.rpm .YS .IP "" 4 Installs a built module/version combo onto the kernel it was built for. If the kernel option is not specified it assumes the currently running kernel. If the module has not been built, dkms will try to build it. If the module has not been added, dkms will try to add it. In both cases, the .B install command can then take the same arguments as the .B build or .B add commands. If you pass a .rpm file, dkms will try to install that file with .B rpm -Uvh , and it will perform an .B autoinstall action to mesure that everything is built for your kernel if the RPM installed sucessfully. .SY uninstall .OP module/module\-version .OP -k kernel/arch .YS .IP "" 4 Uninstalls an installed module/module\-version combo from the kernel/arch passed in the -k option, or the current kernel if the -k option was not passed. upon. After uninstall completion, the driver will be left in the built state. To completely remove a driver, the remove action should be utilized. .SY match .OP --templatekernel kernel/arch .OP -k kernel/arch .YS .IP "" 4 Match installs modules onto the specified kernel by looking at the configuration of the specified .B templatekernel. Every module that is installed on the .B templatekernel within .B dkms is then installed on that specified kernel. .SY mkdriverdisk .OP -d distro .OP -r release .OP --media mediatype .OP -k kernel/arch .OP module/version .YS .IP "" 4 Creates a floppy driver disk image for use when updated drivers are needed to install an OS. Currently, the supported distributions are redhat, suse and UnitedLinux. For Red Hat driver disks, necessary driver disk files are looked for in the redhat_driver_disk subdirectory of your module source directory. You must specify the distro while using this action. Driver disks can be made for single kernels or can be made to support multiple kernels. To create a driver disk image with modules for multiple kernels, just specify multiple \-k parameters on the command line (\-k kernel1/arch1 \-k kernel2/arch2). Red Hat began supporting multi-arched driver disks in RHEL3. To force creation of a driver disk with arch information, specify .B \-d redhat2 or if you specify multiple architectures on the command-line and use .B \-d redhat , DKMS will create a version 2 driver disk. By specifying .B \-d redhat1 , you can force a version 1 driver disk image. Note that redhat1 driver disks actually supported multiple architectures when the second arch was i386 and the kernel module was for the BOOT kernel. DKMS allows for this, and as such you can create a redhat1 style driver disk if the only other arch is i386 and the kernel name ends in BOOT. Red Hat introduced DDv3 starting with RHEL6. To create Red Hat DDv3, specify .B \-d redhat3 and specify the specfile to use with .I \-\-spec=specfile. If no specfile is specified, DKMS will use .I /etc/dkms/template\-dkms\-redhat\-kmod.spec See .I http://people.redhat.com/dledford for more information on the Red Hat driver disk standards and which files are necessary to make a driver disk. Fedora Core 5 and higher, RHEL5 and higher require DKMS version 2.0.14 or higher to generate a proper driver disk image. For suse/UnitedLinux driver disks, /usr/share/YaST2/modules/Vendor.ycp will also be copied to the driver disk; no other files are needed. However, for these distros, you must specify a \-r release. For SuSE 9.1, it would be \-d suse \-r 9.1. For SLES9, it would be \-d suse \-r sles9. By default the disk image it creates is 1440 (k) in size. This can be overridden by specifying a different .B \-\-size #### which should should be given as a number in kilobytes divisible by 20. You may have more content than will fit on a floppy. Therefore, DKMS can now generate image files of different types. .B \-\-media floppy (default) to generate a floppy disk image, or .B \-\-media iso to generate a CD-ROM ISO file, or .B \-\-media tar to generate a tar file. You may copy the floppy or ISO image file to a USB key to be used with OS installer. .SY mktarball .OP module/module\-version .OP -k kernel/arch .OP --archive /path/to/tarball.tar .OP --source-only .OP --binaries-only .YS .IP "" 4 Creates a tarball archive for the specified module/version of all files in the DKMS tree for that module/version combination. This includes the source and any built modules for kernels in the tree (as specified). Otherwise, you can specify a singular kernel to archive only, or multiple kernels to archive (\-k kernel1/arch1 \-k kernel2/arch2). Optionally, you can use .B \-\-archive to specify the file that you would like to save this tarball to. You can also specify .B \-\-binaries\-only if you want the resultant tarball not to include the module source. Likewise, .B \-\-source-only can be used to specify that no prebuilt binaries should be included in the tarball. In general, .B mktarball is great for systems management purposes as you can build your driver on just one system and then use .B ldtarball on all of your other systems to get the same built modules loaded without having to wait for anything to compile. .SY ldtarball .OS /path/to/tarball.tar .OS --force .YS .IP "" 4 This takes a tarball made from the .B mktarball command and loads it into your DKMS tree. This will leave any newly added modules in the built state and .B dkms install should then be called to install any of them. If files already exist where .B ldtarball is attempting to place them, it will warn and not copy over them. The .B \-\-force option should be used to override this. .SY mkrpm .OP module/module\-version .OP -k kernel/arch .OP --source-only .OP --binaries-only .YS .IP "" 4 This action allows you to create an RPM package for a specified module / version. It uses a template .spec file found in .I /etc/dkms/template\-dkms\-mkrpm.spec as the basis for the RPM. Alternatively, if DKMS finds a file called .I /usr/src/\-/\-dkms\-mkrpm.spec it will use that .spec file instead. In general, a DKMS tarball is placed inside the contents of this RPM, and the RPM itself calls various DKMS commands to load this tarball, build and install modules on the end user's system. If you do not want your RPM to contain any prebuilt binaries, be sure to specify .B \-\-source\-only in the mkrpm command. .SY mkdeb .OP module/module\-version .OP -k kernel/arch .OP --binaries-only .OP --source-only .YS .IP "" 4 This action allows you to create a debian binary package for a specified module / version. It uses a template debian directory found in .I /etc/dkms/template\-dkms\-mkdeb as the basis for the package. Alternatively, if DKMS finds a file called .I /usr/src/\-/\-dkms\-mkdeb it will use that folder instead. In general, a DKMS tarball is placed inside the contents of this package, and the package itself calls various DKMS commands to load this tarball, build and install modules on the end user's system. If you do not want your debian package to contain any prebuilt binaries, be sure to specify .B \-\-source\-only in the mkdeb command. .SY mkdsc .OP module/module\-version .OP -k kernel/arch .OP --binaries-only .OP --source-only .YS .IP "" 4 This action allows you to create a debian source package for a specified module / version. It will create a .tar.gz, and a .dsc. All options supported by .B mkdeb are supported by it. The main difference in it's usage is that it will look in .I /etc/dkms/template\-dkms\-mkdsc as the basis for the package. Alternatively, if DKMS finds a file called .I /usr/src/\-/\-dkms\-mkdsc it will use that folder instead. If you do not want your debian source package to contain any prebuilt binaries, be sure to specify .B \-\-source\-only in the mkdsc command. .SY mkkmp .OP module/module\-version .OP --spec specfile .YS .IP "" 4 This action allows you to create an Kernel Module Package source RPM for a specified module / version. It uses the .spec file specified by .I \-\-spec=specfile else .I $module\-kmp.spec as the basis for the RPM. The generated source RPM may then be built using SuSE's build.rpm or Fedora/RHEL's mock chroot environments. See http://kerneldrivers.org/ for more details on KMPs. .SY status .OP module/module\-version .OP -k kernel/arch .YS .IP "" 4 Returns the current status of modules, versions and kernels within the tree as well as whether they have been added, built or installed. Status can be shown for just a certain module, a certain kernel, a module/version combination or a module/version/kernel combination. .SY autoinstall .YS .IP "" 4 Attempt to install the latest revision of all modules that have been installed for other kernel revisions. dkms_autoinstaller is a stub that uses this action to perform its work. .SH OPTIONS .TP .B \-m / The name of the module and module version you wnat to operate on. The .B \-m part of this option is optional, and can be omitted in virtually all circumstances. .TP .B \-v The version of the module to execute the specified action upon. This option only has to be specified if you pass a .B \-m option without a component of its own. .TP .B \-k / The kernel and arch to perform the action upon. You can specify multiple kernel version/arch pairs on the command line by repeating the \-k argument with a different kernel version and arch. However, not all actions support multiple kernel versions (it will error out in this case). The arch part can be omitted, and DKMS will assume you want it to be the arch of the currently running system. .TP .B \-a, \-\-arch The system architecture to perform the action upon. It is optional if you pass it as part of the .B \-k option. If not specified, it assumes the arch of the currently running system (`uname \-m`). You can specify multiple arch parameters on the same command line by repeating the \-a argument with a different arch name. When multiple architectures are specified, there must be a 1:1 relationship between \-k arguments to \-a arguments. DKMS will then assume the first \-a argument aligns with the first \-k kernel and so on for the second, third, etc. For example, if you were to specify: \-k kernel1 \-k kernel2 \-a i386 \-k kernel3 \-a i686 \-a x86_64, DKMS would process this as: kernel1-i386, kernel2-i686, kernel3-x86_64. .TP .B \-q, \-\-quiet Quiet. .TP .B \-V, \-\-version Prints the currently installed version of dkms and exits. .TP .B \-c The location of the .I dkms.conf file. This is needed for the add action and if not specified, it is assumed to be located in .I /usr/src/\-/. See below for more information on the format of .I dkms.conf. .TP .B \-d, \-\-distro The distribution being used. This is only currently needed for .B mkdriverdisk. The supported distros are .B redhat, .B suse and .B UnitedLinux. See the sections on .B mkdriverdisk and .B mkkmp for more information. .TP .B \-r, \-\-release The release being used. This is only currently used for .B mkdriverdisk and is only used for suse or UnitedLinux distros (eg. \-r 9.1). It is used in the internal makeup of the driverdisk. .TP .B \-\-size The size of the driver disk image to be created. By default, this value is set at 1440. Any different size should be given as an integer value only, should be divisible by 20 and should represent the number of kilobytes of the image size you desire. .TP .B \-\-config During a .B build this option is used to specify an alternate location for the kernel .config file which was used to compile that kernel. Normally, .B dkms uses the Red Hat standard location and config filenames located in .I /usr/src/linux\-/configs/. If the config for the kernel that you are building a module for is not located here or does not have the expected name in this location, you will need to tell .B dkms where the necessary .config can be found so that your kernel can be properly prepared for the module build. .TP .B \-\-archive This option is used during a .B ldtarball action to specify the location of the tarball you wish to load into your DKMS tree. You only have to specify the .B --archive part of this option if does not already exist as a file. .TP .B \-\-templatekernel This option is required for the action: .B match. Match will look at the templatekernel specified and install all of the same module/version combinations on the other kernel. .TP .B \-\-force This option can be used in conjunction with .B ldtarball to force copying over of extant files. .TP .B \-\-binaries\-only This option can be used in conjunction with .B mktarball in order to create a DKMS tarball which does not contain the source for the module within it. This can be helpful in reducing the size of the tarball if you know that the system which this tarball will be loaded upon already has the source installed. In order to load a tarball made as binaries-only .B you must have the module source in that systems DKMS tree. If you do not, DKMS .B will refuse to load a binaries-only tarball. .TP .B \-\-source\-only This option can be used in conjunction with .B mktarball or .B mkrpm or .B mkdeb in order to create a DKMS tarball which does not contain any prebuilt kernel module binaries within it. This is helpful if you simply want to easily tar up your source but don't want anything prebuilt within it. Likewise, if you are using .B mkrpm but do not want the RPM you create to have any prebuilt modules within it, passing this option will keep its internal DKMS tarball from containing any prebuilt modules. .TP .B \-\-all This option can be used to automatically specify all relevant kernels/arches for a module/module-version. This is useful for things like .B remove , .B mktarball , etc. This saves the trouble of having to actually specify \-k kernel1 \-a arch1 \-k kernel2 \-a arch2 for every kernel you have built your module for. .TP .B \-\-no\-prepare\-kernel This option keeps DKMS from first preparing your kernel before building a module for it. Generally, this option should not be used so as to ensure that modules are compiled correctly. .TP .B \-\-no\-clean\-kernel 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 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 source is accessible via .I /lib/modules/$kernel_version/build. .TP .B \-\-directive <"cli\-directive=cli\-value"> Using this option, you can specify additional directives from the command line. The .B \-\-directive option can be used multiple times on the same command-line to specify multiple additional command line directives. .TP .B \-\-rpm_safe_upgrade This flag should be used when packaging DKMS enabled modules in RPMs. It should be specified during both the .B add and .B remove actions in the RPM spec to ensure that DKMS and RPM behave correctly in all scenarios when upgrading between various versions of a dkms enabled module RPM package. See the sample.spec file for an example or read more in the section below on Creating RPMs Which Utilize DKMS. .TP .B \-\-spec specfile This option is used by the .B mkkmp action to specify which RPM spec file to use when generating the KMP. .I specfile will be sought in the module source directory. .TP .B \-\-dkmstree path/to/place Provides a destination tree for building and installing modules to. Useful in cases that you don't want to contaminate a system when using solely for building. .TP .B \-\-sourcetree path/to/place Provides a location to build a DKMS package from. Useful for systems that you may not have root access, but would still like to be able to build DKMS packages. .TP .B \-\-installtree path/to/place Provides a location to place modules when a .I dkms install command is issued. .TP .B \-\-legacy\-postinst=[0|1] Includes a legacy postinstall script so that a DEB or RPM built by DKMS can be used on versions prior than DKMS 2.1. This option currently defaults to 1. .TP .B \-\-dkmsframework path/to/file 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 , .B dkms will search .I /lib/modules/ for a pre-existing module of the same name. If one is found, it will automatically be saved as an "original_module" so that if the newer module is later removed, .B dkms will put the original module back in its place. Currently, DKMS searches for these original modules with first preference going to modules located in .I /lib/modules//updates/ followed by .B $DEST_MODULE_LOCATION (as specified in .I dkms.conf ). If one cannot be found in either location, a find will be used to locate one for that kernel. If none are found, then during a later uninstall, your kernel will not have that module replaced. If more than one is found, then the first one located (by preference indicated above) will be considered the "original_module". As well, all copies of the same-named module will be removed from your kernel tree and placed into .I /var/lib/dkms//original_module/$kernelver/collisions so that they can be *manually* accessible later. DKMS will never actually do anything with the modules found underneath the /collisions directory, and they will be stored there until you manually delete them. .SH DKMS.CONF When performing an .B add , a proper .I dkms.conf file must be found. A properly formatted conf file is essential for communicating to .B dkms how and where the module should be installed. While not all the directives are required, providing as many as possible helps to limit any ambiguity. Note that the .I dkms.conf is really only a shell\-script of variable definitions which are then sourced in by the .B dkms executable (of the format, DIRECTIVE="directive text goes here"). As well, the directives are case\-sensitive and should be given in .B ALL CAPS. It is important to understand that many of the DKMS directives are arrays whose index values are tied together. These array associations can be considered families, and there are currently four such families of directive arrays. MAKE[#] and MAKE_MATCH[#] make up one family. PATCH[#] and PATCH_MATCH[#] make up the second family. The third and largest family consists of BUILT_MODULE_NAME[#], BUILT_MODULE_LOCATION[#], DEST_MODULE_NAME[#], DEST_MODULE_LOCATION[#], MODULES_CONF_ALIAS_TYPE[#], MODULES_CONF_OBSOLETES[#], MODULES_CONF_OBSOLETE_ONLY[#] and STRIP[#]. The fourth family is made up of only MODULES_CONF[#]. When indexing these arrays when creating your dkms.conf, each family should start at index value 0. .TP .B MAKE[#]= The MAKE directive array tells DKMS which make command should be used for building your module. The default make command should be put into .B MAKE[0]. Other entries in the MAKE array will only be used if their corresponding entry in .B MAKE_MATCH[#] matches, as a regular expression (using egrep), the kernel that the module is being built for. Note that if no value is placed in .B MAKE_MATCH[#] for any .B MAKE[#] where # > 0, then that .B MAKE directive is ignored. .B MAKE_MATCH[0] is optional and if it is populated, it will be used to determine if MAKE[0] should be used to build the module for that kernel. If multiple .B MAKE_MATCH directives match against the kernel being built for, the last matching .B MAKE[#] will be used to build your module. If no MAKE directive is specified or if no MAKE_MATCH matches the kernel being built for, DKMS will attempt to use a generic MAKE command to build your module. KERNELRELEASE will be automatically appended to MAKE[#]. If you want to suppress this behavior, you can quote the make command: 'make'. .TP .B MAKE_MATCH[#]= See the above entry on .B MAKE[#] directives. This array should be populated with regular expressions which, when matched against the kernel being built for, will tell .B DKMS to use the corresponding make command in the .B MAKE[#] directive array to build your module. .TP .B BUILT_MODULE_NAME[#]= This directive gives the name of the module just after it is built. If your DKMS module package contains more than one module to install, this is a .B required directive for all of the modules. This directive should explicitly not contain any trailing ".o" or ".ko". Note that for each module within a dkms package, the numeric value of .B # must be the same for each of BUILT_MODULE_NAME, BUILT_MODULE_LOCATION, DEST_MODULE_NAME and DEST_MODULE_LOCATION and that the numbering should start at 0 (eg. BUILT_MODULE_NAME[0]="qla2200" BUILT_MODULE_NAME[1]="qla2300"). .TP .B BUILT_MODULE_LOCATION[#]= This directive tells DKMS where to find your built module after it has been built. This pathname should be given relative to the root directory of your source files (where your dkms.conf file can be found). If unset, DKMS expects to find your .B BUILT_MODULE_NAME[#] in the root directory of your source files. Note that for each module within a dkms package, the numeric value of .B # must be the same for each of BUILT_MODULE_NAME, BUILT_MODULE_LOCATION, DEST_MODULE_NAME and DEST_MODULE_LOCATION and that the numbering should start at 0 (eg. BUILT_MODULE_LOCATION[0]="some/dir/" BUILT_MODULE_LOCATION[1]="other/dir/"). .TP .B DEST_MODULE_NAME[#]= This directive can be used to specify the name of the module as it should be installed. This will rename the module from .B BUILT_MODULE_NAME[#] to .B DEST_MODULE_NAME[#]. This directive should explicitly not contain any trailing ".o" or ".ko". If unset, it is assumed to be the same value as .B BUILT_MODULE_NAME[#]. Note that for each module within a dkms package, the numeric value of .B # must be the same for each of BUILT_MODULE_NAME, BUILT_MODULE_LOCATION, DEST_MODULE_NAME and DEST_MODULE_LOCATION and that the numbering should start at 0 (eg. DEST_MODULE_NAME[0]="qla2200_6x" DEST_MODULE_NAME[1]="qla2300_6x"). .TP .B DEST_MODULE_LOCATION[#]= This directive specifies the destination where a module should be installed to, once compiled. It also is used for finding original_modules. This is a .B required directive, except as noted below. This directive must start with the text "/kernel" which is in reference to /lib/modules//kernel. Note that for each module within a dkms package, the numeric value of .B # must be the same for each of BUILT_MODULE_NAME, BUILT_MODULE_LOCATION, DEST_MODULE_NAME and DEST_MODULE_LOCATION and that the numbering should start at 0 (eg. DEST_MODULE_LOCATION[0]="/kernel/drivers/something/" DEST_MODULE_LOCATION[1]="/kernel/drivers/other/"). DEST_MODULE_LOCATION is ignored on Fedora Core 6 and higher, Red Hat Enterprise Linux 5 and higher, Novell SuSE Linux Enterprise Server 10 and higher, Novell SuSE Linux 10.0 and higher, and Ubuntu. Instead, the proper distribution-specific directory is used. .TP .B MODULES_CONF_ALIAS_TYPE[#]= This directive array specifies how your modules should be aliased in .I /etc/modules.conf when your module is installed. This is done in an intelligent fashion so if DKMS detects an already existing reference in modules.conf, it won't add a new line. If it is not detected, it will add it to the modules.conf as the last alias number for that alias type (eg. if MODULES_CONF_ALIAS_TYPE="scsi_hostadapter", no alias currently exists for that module and the last scsi_hostadapter reference is 6, then your module will be added as "scsi_hostadapter7"). Common values for this directive include: .B scsi_hostadapter , .B sound\-slot\- and .B eth. Note that the numeric value of .B # is tied to the index of BUILD_MODULE_NAME, BUILT_MODULE_LOCATION, DEST_MODULE_NAME and DEST_MODULE_LOCATION. The index is also tied to MODULES_CONF_OBSOLETES. .TP .B MODULES_CONF_OBSOLETES[#]= This directive array tells DKMS what modules.conf alias references are obsoleted by the module you are installing. If your module obsoletes more than one module, this directive should be a comma\-delimited list of those modules that are obsoleted (eg. for megaraid2, MODULES_CONF_OBSOLETES[0]="megaraid,megaraid_2002"). When you are installing your module, DKMS ensures that any entries in .I /etc/modules.conf with the same .B MODULES_CONF_ALIAS_TYPE are changed over to the new module name. When you are uninstalling your module, depending on the modules in your .I /lib/modules tree, DKMS will take different actions. If you kernel has an original_module, then modules.conf will not be touched and the non\-obsolete reference will remain. If the kernel does not have an original_module but does have one of the obsolete modules, it will replace those references with the first obsolete module name in the comma\-delimited list that is also in that kernel (thus, your obsolete list should be prioritized from left to right). If no original_module or obsolete modules are found within the kernel, the alias entry is removed all\-together. Note that the numeric value of .B # is tied to the index of BUILD_MODULE_NAME, BUILT_MODULE_LOCATION, DEST_MODULE_NAME and DEST_MODULE_LOCATION. The index is also tied to MODULES_CONF_ALIAS_TYPE. .TP .B MODULES_CONF_OBSOLETE_ONLY[#]= If set to .B yes , this directive will tell DKMS to only modify .I /etc/modules.conf if it finds within it an obsolete reference as specified in the corresponding value of .B MODULES_CONF_OBSOLETES[#] array directive. .TP .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 name that is used with the .B \-m option when building, adding, etc. and may not necessarily be the same as the MODULE_NAME. This directive must be present in every dkms.conf. .TP .B PACKAGE_VERSION= This directive is used to give the version associated with the entire package of modules being installed within that dkms package. This directive must be present in every dkms.conf. .TP .B CLEAN= CLEAN specifies the make clean command to be used to clean up both before and after building the module. If unset, it is assumed to be "make clean". .TP .B REMAKE_INITRD= This directive specifies whether your initrd should be remade after the module is installed onto the kernel. Any text after the first character is ignored and if the first character is not a "y" or a "Y", it is assumed that REMAKE_INITRD="no". .TP .B UDEV_TRIGGER= This optional directive specifies, if the udev daemon will be get a trigger event after the module is installed for your currently running kernel. Because this udev trigger might have some unfriendly side effects on some Linux Systems, you can now disable this trigger, if your driver does not need it anyway. UDEV_TRIGGER=yes is assumed as the default, although this directive may not be given. This ensures backward compatibility to older DKMS releases. Any text after the first character is ignored and if the first character is not a "n" or a "N", it is assumed that UDEV_TRIGGER="yes". .TP .B MODULES_CONF[#]= This directive array specifies what static configuration text lines need to be added into .I /etc/modules.conf for your module. See the section on MODULES.CONF CHANGES for more information regarding the implications of modifying .I /etc/modules.conf .TP .B OBSOLETE_BY= This directive allows you to specify a kernel version that obsoletes the necessity for this particular DKMS module. This can be specified as a particular upstream kernel or an ABI bump of a kernel. For example, "2.6.24" would be an upstream kernel and "2.6.24\-16" would represent an ABI bump for a kernel. Both are valid in this area. Please avoid the use of .B OBSOLETE_BY wherever possible. It's use indicates a lack of proper module versioning using .B MODULE_VERSION() tags in the module source itself. It is better to fix the .B MODULE_VERSION() tags than use .B OBSOLETE_BY. This also introduces a implicit distribution/version dependency on the package, as the value of .B OBSOLETE_BY is meaningful only in the context of a single distribution/version. If you feel you must use it, please use as such in dkms.conf: ubuntu_804="Ubuntu 8.04" if [ \-x /usr/bin/lsb_release ]; then if [ "$(/usr/bin/lsb_release \-sir)" == "${ubuntu_804}" ]; then OBSOLETE_BY="2.6.25" fi fi .TP .B PATCH[#]= Use the PATCH directive array to specify patches which should be applied to your source before a build occurs. All patches are expected to be in \-p1 format and are applied with the patch \-p1 command. Each directive should specify the filename of the patch to apply, and all patches must be located in the patches subdirectory of your source directory ( .I /usr/src/\-/patches/ ). If any patch fails to apply, the build will be halted and the rejections can be inspected in .I /var/lib/dkms///build/. If a PATCH should only be applied conditionally, the .B PATCH_MATCH[#] array should be used, and a corresponding regular expression should be placed in .B PATCH_MATCH[#] which will alert dkms to only use that .B PATCH[#] if the regular expression matches the kernel which the module is currently being built for. .TP .B PATCH_MATCH[#]= See the above description for .B PATCH[#] directives. If you only want a patch applied in certain scenarios, the .B PATCH_MATCH array should be utilized by giving a regular expression which matches the kernels you intend the corresponding .B PATCH[#] to be applied to before building that module. .TP .B AUTOINSTALL= If this directive is set to .B yes then the service .I /etc/rc.d/init.d/dkms_autoinstaller will automatically try to install this module on any kernel you boot into. See the section 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 being built for does not match against this regular expression, the dkms build will error out. For example, if you set it as ="^2\.4.*", your module would not be built for 2.6 kernels. .TP .B BUILD_EXCLUSIVE_ARCH= This optional directive functions very similarly to .B BUILD_EXCLUSIVE_KERNEL except that it matches against the kernel architecture. For example, if you set it to ="i.86", your module would not be built for ia32e, x86_64, amd64, s390, etc. .TP .B POST_ADD= The name of the script to be run after an .B add is performed. The path should be given relative to the root directory of your source. .TP .B POST_BUILD= The name of the script to be run after a .B build is performed. The path should be given relative to the root directory of your source. .TP .B POST_INSTALL= The name of the script to be run after an .B install is performed. The path should be given relative to the root directory of your source. .TP .B POST_REMOVE= The name of the script to be run after a .B remove is performed. The path should be given relative to the root directory of your source. .TP .B PRE_BUILD= The name of the script to be run before a .B build is performed. The path should be given relative to the root directory of your source. .TP .B PRE_INSTALL= The name of the script to be run before an .B install is performed. The path should be given relative to the root directory of your source. If the script exits with a non\-zero value, the install will be aborted. This is typically used to perform a custom version comparison. .TP .SH DKMS.CONF VARIABLES Within your .I dkms.conf file, you can use certain variables which will be replaced at run\-time with their values. .TP .B $kernelver This variable can be used within a directive definition and during use, the actual kernel version in question will be substituted in its place. This is especially useful in MAKE commands when specifying which INCLUDE statements should be used when compiling your module (eg. MAKE="make all INCLUDEDIR=/lib/modules/${kernelver}/build/include"). .TP .B $dkms_tree See the section on /etc/dkms/framework.conf for more information. This variable represents the location of the DKMS tree on the local system. By default this is .I /var/lib/dkms , but this value should not be hard\-coded into a dkms.conf in the event that the local user has changed it on their system. .TP .B $source_tree See the section on /etc/dkms/framework.conf for more information. This variable represents the location where DKMS keeps source on the local system. By default this is .I /usr/src , but this value should not be hard\-coded into a dkms.conf in the event that the local user has changed it on their system. .TP .B $kernel_source_dir This variable holds the value of the location of your kernel source directory. Usually, this will be .I /lib/modules/$kernelver/build , unless otherwise specified with the .B \-\-kernelsourcedir option. .SH DKMS.CONF OVERRIDES You can override the module-provided .I dkms.conf files. Every time after a dkms.conf file is read, dkms will look for and read the following files in order: .I /etc/dkms/.conf\p .I /etc/dkms/\-.conf\p .I /etc/dkms/\-\-.conf\p .I /etc/dkms/\-\-\-.conf You can use these files to override settings in the module-provided dkms.conf files. .SH /etc/dkms/framework.conf This configuration file controls how the overall DKMS framework handles. It is sourced in every time the dkms command is run. Mainly it can currently be used to set different default values for the variables. .B $dkms_tree , .B $source_tree and .B $install_tree 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" set in its .B dkms.conf file. The service works quite simply and if multiple versions of a module are in your system's DKMS tree, it will not do anything and instead explain that manual intervention is required. .SH MODULES.CONF / MODPROBE.CONF CHANGES Changes that your module will make to .I /etc/modules.conf or .I /etc/modprobe.conf should be specified with the .B MODULES_CONF_ALIAS_TYPE[#] , the .B MODULES_CONF_OBSOLETES[#] and the .B MODULES_CONF[#] directive arrays. These arrays should also be used even if your distro uses .I /etc/sysconfig/kernel to track kernel modules. When the first module is installed upon the first kernel within the user's system, these entries in .B MODULES_CONF[#] are automatically added to .I /etc/modules.conf and if .B REMAKE_INITRD is specified, then the user's initrd is then remade. Subsequently, as your modules are then later removed from the user's system, until the final module/version combination is removed from the final kernel version, those references in .I modules.conf will remain. Once the last module/version combination is removed, those references are then removed. As modules/versions are removed and initrds are remade, one of three things will happen if you have specified a .B MODULES_CONF_ALIAS_TYPE. If no original_module exists for that kernel, and no .B MODULES_CONF_OBSOLETES modules are found in that kernel too, the .I modules.conf alias references will temporarily be removed so that the initrd will successfully remake. Once the initrd is remade, however; those references are then automatically put back into .I modules.conf (unless you are removing the last instance of the module on the last kernel). However, if no original_module exists, but there is an OBSOLETE module found within that kernel, the alias reference is temporarily shifted to point to the OBSOLETE module so that the initrd can be remade. After it is remade, it then automatically puts back the alias reference (unless you are removing the last instance of the module on the last kernel). Lastly, if an original_module does exist for the kernel version, then .I modules.conf is not touched and all references persist (even if you are removing the last instance of the module on the last kernel). Certain module installations might not only require adding references to .I modules.conf but also require removing conflicting references that might exist in the user's system. If this is the case, the .B MODULES_CONF_OBSOLETES[#] directive should be utilized to remove these references. More information about this directive can be found in the .B DKMS.CONF section of this man page. Note that the end state of your modules.conf file very much depends on what kernel modules exist in the final kernel you remove your DKMS module from. This is an imperfect system caused by the fact that there is only one modules.conf file for every kernel on your system even though various kernels use different modules. In a perfect world, there would be one modules.conf file for every kernel (just like System.map). .SH CREATING RPMS WHICH UTILIZE DKMS See the .I sample.spec file packaged with .B DKMS as an example for what your RPM spec file might look like. Creating RPMs which utilize .B dkms is a fairly straight\-forward process. The RPM need only to install the source into .I /usr/src/\-/ and then employ .B dkms itself to do all the work of installation. As such, the RPM should first untar the source into this directory. From here, within the RPM .I .spec file, a .B dkms add should be called (remember to use the \-\-rpm_safe_upgrade flag during the add) followed by a .B dkms build followed by a .B dkms install. Your .I dkms.conf file should be placed within the .I /usr/src/\-/ directory. Under the removal parts of the .I .spec file, all that needs to be called is a: dkms remove \-m \-v \-\-all \-\-rpm_safe_upgrade. Use of the .B \-\-rpm_safe_upgrade flag is imperative for making sure DKMS and RPM play nicely together in all scenarios of using the \-Uvh flag with RPM to upgrade dkms enabled packages. It will only function if used during both the add .B and remove actions within the same RPM spec file. Its use makes sure that when upgrading between different releases of an RPM for the same , DKMS does not do anything dumb (eg. it ensures a smooth upgrade from megaraid\-2.09-5.noarch.rpm to megaraid\-2.09\-6.noarch.rpm). It should be noted that a binary RPM which contains source is not a traditional practice. However, given the benefits of .B dkms it hopefully will become so. As the RPM created which utilizes .B dkms is not architecture specific, .B BuildArch: noarch should be specified in the .I .spec file to indicate that the package can work regardless of the system architecture. Also note that DKMS RPM upgrades (\-U option) will automatically work because of the structure of the .B dkms tree. Lastly, as a matter of convention, you should name your RPM: \-\-dkms.noarch.rpm. The word .B dkms as part of the rpm\-version signifies that the RPM works within the DKMS framework. .SH AUTHOR Gary Lerhaupt .SH WEBPAGE .I https://github.com/dell-oss/dkms .SH WHITE\-PAPERS .I http://linux.dell.com/dkms/dkms\-ols2004.pdf .I http://www.dell.com/downloads/global/power/1q04\-ler.pdf .I http://www.linuxjournal.com/article.php?sid=6896 .SH MAILING\-LIST dkms\-devel@dell.com .I http://lists.us.dell.com/mailman/listinfo/dkms\-devel .SH REFERENCES Kernel Module Packages .I http://kerneldrivers.org Novell Kernel Module Packages .I http://www.suse.de/~agruen/KMPM Fedora Kernel Module Packages .I http://fedoraproject.org/wiki/Extras/KernelModuleProposal dkms-2.3/dkms.bash-completion000066400000000000000000000045201276161124300162640ustar00rootroot00000000000000# bash completion for dkms # Copied from the Mandriva dkms package # This function complete on available kernels # _kernels() { COMPREPLY=( $( cd /lib/modules && compgen -d -- "$cur" ) ) } # complete on full directory names under $1 _subdirectories() { COMPREPLY=( $( cd $1 && compgen -d -- "$cur" ) ) } # complete on $2 part of filenames matching pattern $1 under /usr/src _filename_parts() { COMPREPLY=( $( command ls -F /usr/src/ 2>/dev/null | grep -E '^'$1'/$' \ | sed -r -e 's/^([^-]+)-(.+)\/$/\'$2'/' | grep "^$cur" ) ) } _dkms() { local cur prev command module i COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} if [[ $COMP_CWORD -eq 1 ]] ; then COMPREPLY=( $( compgen -W "add autoinstall remove build install uninstall \ match mkdriverdisk mktarball ldtarball mkrpm mkdeb mkdsc mkkmp \ status" -- $cur ) ) else prev=${COMP_WORDS[COMP_CWORD-1]} command=${COMP_WORDS[1]} case $prev in -m) if [ "$command" = 'add' ]; then _filename_parts '.*-.*' 1 else _subdirectories /var/lib/dkms fi return 0 ;; -v) for (( i=1; i < COMP_CWORD; i++ )); do if [[ "${COMP_WORDS[i]}" == -m ]]; then module=${COMP_WORDS[i+1]} break fi done if [ -n "$module" ]; then if [ "$command" = 'add' ]; then _filename_parts "$module-.*" 2 else _subdirectories /var/lib/dkms/$module fi return 0 fi ;; -k) _kernels return 0 ;; -@\(c|-spec|-archive|-config\)) _filedir return 0 ;; --kernelsourcedir) _filedir -d return 0 ;; esac if [[ "$cur" == -* ]]; then case $command in add) options='-c --rpm_safe_upgrade' ;; remove) options='--rpm_safe_upgrade' ;; build) options='--config' ;; mkdriverdisk) options='-d --distro -r --release --size' ;; ldtarball) options='--archive --force' ;; mktarball) options='--source-only --binaries-only' ;; mkrpm) options='--source-only' ;; mkkmp) options='--spec' ;; match) options='--templatekernel' ;; esac options="$options -m -v -k -a --arch -q --quiet -V \ --version --all --no-prepare-kernel \ --no-clean-kernel --kernelsourcedir \ --directive" COMPREPLY=( $( compgen -W "$options" -- $cur ) ) fi fi } complete -F _dkms dkms dkms-2.3/dkms.service000066400000000000000000000003751276161124300146440ustar00rootroot00000000000000[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 dkms-2.3/dkms.spec000066400000000000000000001165511276161124300141420ustar00rootroot00000000000000%if 0%{?rhel} == 5 %define _sharedstatedir /var/lib %endif Summary: Dynamic Kernel Module Support Framework Name: dkms Version: [INSERT_VERSION_HERE] Release: 1%{?dist} License: GPLv2+ Group: System Environment/Base BuildArch: noarch URL: https://github.com/dell/dkms 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. %prep %setup -q %build %triggerpostun -- %{name} < 1.90.00-1 for dir in `find %{_localstatedir}/%{name} -type d -maxdepth 1 -mindepth 1`; do mv -f $dir %{_localstatedir}/lib/%{name} done [ -e %{_sysconfdir}/dkms_framework.conf ] && ! [ -e %{_sysconfdir}/%{name}/framework.conf ] && mkdir %{_sysconfdir}/%{name} && cp -a %{_sysconfdir}/dkms_framework.conf %{_sysconfdir}/%{name}/framework.conf arch_used="" [ `uname -m` == "x86_64" ] && [ `cat /proc/cpuinfo | grep -c "Intel"` -gt 0 ] && arch_used="ia32e" || arch_used=`uname -m` echo "" echo "ALERT! ALERT! ALERT!" echo "" echo "You are using a version of DKMS which does not support multiple system" echo "architectures. Your DKMS tree will now be modified to add this support." echo "" echo "The upgrade will assume all built modules are for arch: $arch_used" current_kernel=`uname -r` dkms_tree="%{_localstatedir}/lib/%{name}" source_tree="%{_prefix}/src" tmp_location="/tmp" dkms_frameworkconf="%{_sysconfdir}/%{name}/framework.conf" . $dkms_frameworkconf 2>/dev/null echo "" echo "Fixing directories." for directory in `find $dkms_tree -type d -name "module" -mindepth 3 -maxdepth 4`; do dir_to_fix=`echo $directory | sed 's#/module$##'` echo "Creating $dir_to_fix/$arch_used..." mkdir $dir_to_fix/$arch_used mv -f $dir_to_fix/* $dir_to_fix/$arch_used 2>/dev/null done echo "" echo "Fixing symlinks." for symlink in `find $dkms_tree -type l -name "kernel*" -mindepth 2 -maxdepth 2`; do symlink_kernelname=`echo $symlink | sed 's#.*/kernel-##'` dir_of_symlink=`echo $symlink | sed 's#/kernel-.*$##'` cd $dir_of_symlink read_link="$symlink" while [ -L "$read_link" ]; do read_link=`ls -l $read_link | sed 's/.*-> //'` done if [ `echo $read_link | sed 's#/# #g' | wc -w | awk {'print $1'}` -lt 3 ]; then echo "Updating $symlink..." ln -sf $read_link/$arch_used kernel-$symlink_kernelname-$arch_used rm -f $symlink fi cd - done echo "" %install rm -rf $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) %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} # these dirs are for plugins - owned by other packages %{_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 %dir %{_sysconfdir}/kernel %dir %{_sysconfdir}/kernel/postinst.d %dir %{_sysconfdir}/kernel/prerm.d %endif %changelog * Mon Sep 22 2014 Mario Limonciello - Merge with the spec file that has been adopted for RHEL/Fedora/CentOS. * Sat Aug 22 2009 Matt Domsch - 2.1.0.0-1 - update to latest upstream - drop Requires: lsb. avoid calling rpm (recursively) if possible. - add recognition for Oracle Enterprise Linux, Oracle VM, Scientific Linux, and VMware 3.x * Fri Jul 24 2009 Fedora Release Engineering - 2.0.21.1-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild * Wed Apr 15 2009 Matt Domsch - 2.0.21.1-2 - add Requires: lsb * Tue Apr 14 2009 Matt Domsch 2.0.21.1-1 - update to latest upstream * Tue Feb 24 2009 Fedora Release Engineering - 2.0.19.1-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild * Wed May 28 2008 Matt Domsch 2.0.19.1 - depmod on uninstall before mkinitrd, depmod fix & cleanups - find_module_from_ko() could incorrectly return multiple values * Tue Mar 25 2008 Matt Domsch 2.0.19 - fix dkms.spec file/dir ownerships yet again * Thu Mar 20 2008 Matt Domsch 2.0.18 - don't include dist/ in tarball - use /etc/kernel/{prerm,postinst}.d/dkms in RPMs now too - mkrpm: display rpmbuild log on error, write RPMs to $dkms_tree/$module/$module_version/rpm - clarify license in spec to GPLv2+ * Fri Feb 15 2008 Matt Domsch 2.0.17.6 - call udevadm trigger instead of udevtrigger for newer udev (Launchpad #192241) - omit installed-weak modules from remove --all (Red Hat BZ#429410) * Wed Oct 10 2007 Matt Domsch 2.0.17.5 - call udevtrigger if we install a module for the currently running kernel - uninstall from /extra before DEST_MODULE_LOCATION (Red Hat BZ#264981) - Run depmod after uninstall * Wed Sep 19 2007 Matt Domsch 2.0.17.4 - upgrade to latest upstream * Wed Jun 20 2007 Matt Domsch 2.0.16.2 - updated for Ubuntu support, other bugfixes. * Tue Mar 20 2007 Matt Domsch 2.0.16.1 - spec file cleanups per re-review in Fedora - add bash completion, rpmbuild check, pinit, pass-arch patches from Mandriva. These are generic. The other Mandriva patches appear to be distro-specific. - Look for /etc/sysconfig/module-init-tools to get some values. * Tue Feb 27 2007 Matt Domsch 2.0.16 - fix override_dest_module_location() for historical distro versions - don't run weak-modules if it doesn't exist * Mon Feb 26 2007 Matt Domsch 2.0.15 - release with no changes * Fri Feb 23 2007 Matt Domsch 2.0.14.1 - After upgrading from older DKMS versions to 2.0.14, any previously installed modules wouldn't show status properly, and wouldn't uninstall properly, due to the new policy of using /extras/ and /updates/. Needed to take that into account and look in both places. - SuSE puts weak-modules in /usr/lib/module-init-tools not /sbin. * Thu Feb 22 2007 Matt Domsch 2.0.14 - RHEL5 weak module status report fixed * Mon Feb 19 2007 Matt Domsch 2.0.13.2 - RHEL5 weak module recognition with new state installed-weak - autoinstaller recognizes installed-weak and doesn't rebuild - RHEL5 and SLES10 and higher weak module code expects modules to go into /lib/modules/$kern/{extra,updates} respectively, so force that. * Mon Feb 5 2007 Matt Domsch - patch from http://qa.mandriva.com/show_bug.cgi?id=27985 assigns new modprobe.conf alias ordinals starting at zero. * Fri Jan 12 2007 Matt Domsch 2.0.13.1 - properly create driver disks for Fedora Core 6 and RHEL5 - make .iso, .tar, and floppy .img driver disks for Red Hat and SuSE - set CLEAN properly even if MAKE[] isn't set. - fix install.sh buglet installing the manpage * Thu Jun 29 2006 Matt Domsch - cleanups to match Fedora Extras spec file * Thu Jun 29 2006 Matt Domsch 2.0.13 - bump to 2.0.13 * Wed Jun 28 2006 Matt Domsch 2.0.12.1-1 - fix version comparison awk pattern matching invocation and a line continuation * Mon Jun 26 2006 Matt Domsch 2.0.12-1 - bump to 2.0.12 * Wed Jun 14 2006 Matt Domsch 2.0.11.1-1 - fix version comparison for all 2.6 kernels * Mon Apr 10 2006 Matt Domsch - add README.dkms to doc * Wed Mar 29 2006 Matt Domsch 2.0.11-1 - use -n to all head and tail calls * Tue Mar 28 2006 Matt Domsch 2.0.10.1-1 - fix munging of /etc/sysconfig/kernel INITRD_MODULES= line so it doesn't move already-present entries to the end * Thu Mar 16 2006 Matt Domsch 2.0.10-1 - bump to 2.0.10 * Wed Mar 15 2006 Matt Domsch 2.0.9.3-1 - add PRE_INSTALL dkms.conf directive * Tue Mar 14 2006 Matt Domsch 2.0.9.2-1 - add SuSE Kernel Module Package (mkkmp) support * Tue Dec 13 2005 Matt Domsch 2.0.9.1-1 - patch from Eric Devolder enables mkinitrd for Debian Sarge - include debian/ directory in upstream tarball * Thu Dec 8 2005 Matt Domsch 2.0.9-1 - fix DF28947 (remove word 'only') from a printed message - gzip -9 dkms.8 manpage * Wed Dec 7 2005 Matt Domsch 2.0.8.3 - look to DKMS_DIRECTIVE* environment variables to override dkms.conf settings - don't create/remove (unused) /var/lock/subsys/dkms files in autoinstaller * Mon Nov 7 2005 Gary Lerhaupt 2.0.8.2 - Multi driver suse driver disk support (thanks to Sreenivas.Bagalkote@engenio.com) - Cleanup tempdir when ldtarball fails * Mon Nov 7 2005 Gary Lerhaupt 2.0.8.1 - mkrpm now is built with -ba, not -bb (creates source RPM) * Fri Nov 4 2005 Gary Lerhaupt 2.0.8 - In dkms_autoinstaller added -no-clean-kernel to builds of multiple modules to avoid mrproper * Wed Oct 19 2005 Gary Lerhaupt 2.0.7 - Repackaged 2.0.6.2 as 2.0.7 * Wed Oct 19 2005 Gary Lerhaupt 2.0.6.2 - Updated dkms_mkkerneldoth to know about VMWare kernel * Sun Oct 9 2005 Gary Lerhaupt 2.0.6.1 - Changed root check on ldtarball to only care about root if it sees --force * Fri Sep 2 2005 Gary Lerhaupt 2.0.6 - renamed 2.0.5.9 to 2.0.6 * Mon Jul 25 2005 Gary Lerhaupt 2.0.5.9 - FIXED BUG, when only some modules have original_modules, ARCHIVE_PREF3 wasn't getting reset causing big problems * Mon Jul 18 2005 Gary Lerhaupt 2.0.5.8 - DKMS install now moves out original modules, does not copy them out * Tue Jun 7 2005 Gary Lerhaupt 2.0.5.7 - Get rid of grep error when looking for RH file on non RH distro (Matt Domsch) * Wed May 11 2005 Gary Lerhaupt 2.0.5.6 - handle obsolete modules in /etc/sysconfig/kernel * Fri Apr 29 2005 Gary Lerhaupt 2.0.5.5 - dkms remove now properly removes modules_conf_aliases (thanks Matthew Melvin) * Wed Apr 20 2005 Gary Lerhaupt 2.0.5.4 - Mktarball fails if it can't find dkms_dbversion * Tue Mar 15 2005 Gary Lerhaupt 2.0.5.3 - More spec cleanups * Mon Mar 14 2005 Gary Lerhaupt 2.0.5.2 - Tweaked spec to follow http://fedoraproject.org/wiki/PackagingGuidelines * Thu Mar 03 2005 Gary Lerhaupt 2.0.5.1 - Added --size for alternate driver disk image sizes * Tue Jan 25 2005 Gary Lerhaupt 2.0.5 - Repackaged as 2.0.5 * Mon Jan 17 2005 Gary Lerhaupt 2.0.4.3 - Allow MAKE_MATCH[0] to decide if MAKE[0] will be used - Add Taroon check in template-dkms-mkrpm.spec for ia32e detection * Mon Dec 20 2004 Gary Lerhaupt 2.0.4.2 - John Hull's patch for no SuSE 2.6 kernel preparation * Wed Dec 15 2004 Gary Lerhaupt 2.0.4.1 - Red Hat driver disks can now have modules.pcimap and pci.ids files * Mon Dec 13 2004 Gary Lerhaupt 2.0.4 - bumped revision * Fri Dec 10 2004 Gary Lerhaupt 2.0.3.3 - Added quotes to $kernel_config when checking variable - Tweak the multiowned arch detection workaround to deal with no ownership * Mon Dec 6 2004 Gary Lerhaupt 2.0.3.2 - Fix to template-spec so that ia32e check doesn't require kernel sources * Wed Dec 1 2004 Gary Lerhaupt 2.0.3.1 - Jeffrey Kirsher's workaround for arch detection on multiowned /lib/modules * Mon Nov 22 2004 Gary Lerhaupt 2.0.3 - Issues regressed. Bumped to non-testing version. * Fri Nov 19 2004 Gary Lerhaupt 2.0.2.5 - DKMS ldtarball arch fix for changed Andreas 2.0.2 code - Workaround for Red Hat's new source symlink in 2.6.9 - All 'cd -' now output to /dev/null * Sat Oct 2 2004 Gary Lerhaupt 2.0.2 - Added --verbose which invoke_command uses - Fixed it so mrproper doesn't get run > 2.6.6 * Tue Sep 28 2004 Gary Lerhaupt 2.0.1.2-1 - Charles Duffy's fix for multiple rpms owning /lib/modules/kernel... - Andreas Gruenbacher's removal of IFS usage - Andreas Gruenbacher's reorganizing prepare check into prepare_kernel - Andreas Gruenbacher's patch to cut down on line length by using $base_dir - fixed $base_dir so it gets set after setup_kernels_arches * Sun Sep 12 2004 Andreas Gruenbacher - patch to remove tick usage - patch to rewrite version comparison code - patch to switch to usage of case, remove use of grep -c, remove use of IFS - patch to change handling of stderr * Fri Sep 10 2004 Gary Lerhaupt - Fixed remove so you can remove modules in added state * Thu Sep 9 2004 Gary Lerhaupt - Removed "module ignored" message from dkms_autoinstaller * Thu Aug 26 2004 Gary Lerhaupt 2.0.0-1 - Output to stderr is now >> and not > - Added kludge to allow redhat1 driver disks with BOOT kernel modules - Allow cross arch building on 2.6 if --kernelsourcedir is passed - Generic make commands now respect --kernelsourcedir - Bumped dkms_dbversion to 2.0.0 * Thu Aug 19 2004 Gary Lerhaupt 1.96.02-1 - Fixed suse driver disks for i386 * Thu Aug 12 2004 Gary Lerhaupt 1.96.01-1 - Look for /etc/SuSEconfig also to know if its a SuSE box - If no make command, set the clean command * Wed Aug 11 2004 Gary Lerhaupt 1.95.32-1 - Added suse mkdriverdisk support - Updated man page * Tue Aug 10 2004 Gary Lerhaupt 1.95.25-1 - Added provides: dkms-minimal for Mandrake - Added -r, --release for use in SuSE driver disks * Fri Aug 06 2004 Gary Lerhaupt 1.95.24-1 - Fixed kernelsourcedir error message. - dkms_autoinstaller now excepts a kernel parameter * Tue Jul 27 2004 Gary Lerhaupt 1.95.19-1 - Created a set_kernel_source_dir function to remove dup code * Mon Jul 26 2004 Gary Lerhaupt 1.95.18-1 - Added John Hull's SuSE support patches (mkinitrd, config prep) * Fri Jul 23 2004 Gary Lerhaupt 1.95.11-1 - Split modulesconf_modify to separate add and remove functions - Added support for /etc/modprobe.conf * Thu Jul 15 2004 Gary Lerhaupt 1.95.10-1 - Remove coreutils as a dependency to avoid RH21 error. * Wed Jul 14 2004 Gary Lerhaupt 1.95.09-1 - DKMS ldtarball now check dbversion and wont load future tarballs * Mon Jul 12 2004 Gary Lerhaupt 1.95.06-1 - Buchan Milne's Mandrake prep support patch - Buchan Milne's macro additions to template-dkms-mkrpm.spec - Buchan Milne's typo corrections in mkrpm - Buchan Milne's change to how mkrpm works (mktarball happen in rpm prep) * Tue Jul 06 2004 Gary Lerhaupt 1.94.16-1 - Added a dependency on modutils for usage of modinfo - Added version sanity check - dkms_autoinstaller now check for sanity of version - Changed conversion algorithm for /var/dkms to /var/lib/dkms - Changed all warning to get to stderr - set_module_suffix doesn't use version_checker because its too slow * Thu Jul 01 2004 Gary Lerhaupt 1.94.06-1 - Reworked version checking to handle non-digit characters - Added coreutils as a dependency - Create a tempdir in mkdriverdisk, whoops (thanks Charles Duffy) * Wed Jun 30 2004 Gary Lerhaupt 1.94.03-1 - dkms_dbversion belongs in /var/lib/dkms (thanks Thomas Palmieri) - Added a version checking subroutine - Removed gt2dot4 variable in favor of kernel version checking - MAKE is no longer required. If none specified, it uses a default. * Thu Jun 24 2004 Gary Lerhaupt 1.94.01-1 - Buchan Milne's optimization of the arch detection code * Wed Jun 23 2004 Gary Lerhaupt 1.93.14-1 - Fixed bug when find finds more than one thing (thanks Paul Howarth) - Changed arch detection code to first try RPM which always will get it right (thanks Vladimir Simonov) * Tue Jun 22 2004 Gary Lerhaupt 1.93.12-1 - Initial mkrpm is working - Added --source-only option to mktarball - mkrpm handles --source-only - Updated manpage * Fri Jun 17 2004 Gary Lerhaupt 1.93.04-1 - Started adding mkrpm * Wed Jun 16 2004 Gary Lerhaupt 1.93.01-1 - Fixed dkms_autoinstaller bugs (thanks Vladimir Simonov) - Fixed paths in the tarball's install.sh * Tue Jun 15 2004 Gary Lerhaupt 1.92.33-1 - kernelver/arch handling for mktarball * Mon Jun 14 2004 Gary Lerhaupt 1.92.26-1 - Added support for RH v2 driver disks (they support multiple arches) * Fri Jun 11 2004 Gary Lerhaupt 1.92.24-1 - Continue rework of kernelver/arch handling - Added PATH fix (thanks Andrey Ulanov ) - config_contents should not be local (thanks Andrey Ulanov) - If no config in /configs, just use .config (thanks Andrey Ulanov) - match now pays attention to --kernelsourcedir * Wed Jun 09 2004 Gary Lerhaupt 1.92.06-1 - Started coding new kernelver arch CLI handling * Mon Jun 07 2004 Gary Lerhaupt 1.92.04-1 - Added STRIP[] directive. By default dkms now runs strip -g on all built modules. - Fix set_module_suffix in dkms build - Changed /etc/dkms_framework.conf to /etc/dkms/framework.conf - Added reload into dkms_autoinstaller to limit Mandrake error messages - Moved /var/dkms to /var/lib/dkms !!!!!!!!!!!!!!!! * Fri Jun 04 2004 Gary Lerhaupt 1.92.01-1 - PRE_BUILD, POST_BUILD, POST_ADD, etc all now allow their scripts to accept parameters * Thu Jun 03 2004 Gary Lerhaupt 1.91.18-1 - Added --installtree option to specify different install location besides /lib/modules - Took Charles Duffy's advice and removed brackets on error messages * Wed Jun 02 2004 Gary Lerhaupt 1.91.14-1 - Added set_module_suffix function * Tue Jun 01 2004 Gary Lerhaupt 1.91.12-1 - Added a PRE_BUILD dkms.conf directive. * Thu May 27 2004 Gary Lerhaupt 1.91.11-1 - Added build time check for gcc and make if there is a build failure - You can now specify --archive to mktarball to control the naming of the made tarball (thanks Vladimir Simonov) * Wed May 26 2004 Gary Lerhaupt 1.91.07-1 - Removed rpm dependency on gcc (thanks Vladimir Simonov) - Re-implemented dkms status recursively * Mon May 24 2004 Gary Lerhaupt 1.91.01-1 - Added local variable declarations to local variables * Fri May 21 2004 Gary Lerhaupt 1.90.46-1 - Vladimir Simonov's invoke_command improvements for keeping /tmp clean * Thu May 20 2004 Gary Lerhaupt 1.90.45-1 - Pass --targetarch to dkms_mkkerneldoth (thanks to Vladimir Simonov ) - Moved arch detection into a function called detect_arch * Wed May 19 2004 Gary Lerhaupt 1.90.44-1 - Bug fixes on arch support - Updated man page * Tue May 18 2004 Gary Lerhaupt 1.90.32-1 - Completing arch awareness and transition scripts - Created upgrade_dkms_archify.sh to update DKMS trees for arch support * Mon May 17 2004 Gary Lerhaupt 1.90.06-1 - Continued adding arch awareness * Thu May 13 2004 Gary Lerhaupt 1.90.01-1 - Started adding arch awareness into the DKMS tree * Fri May 07 2004 Gary Lerhaupt 1.10-1 - bumped the revision * Thu May 06 2004 Gary Lerhaupt 1.09.21-1 - Improved readability of install and uninstall text to the screen - You can now specify multiple actions in the same command * Wed May 05 2004 Gary Lerhaupt 1.09.05-1 - Added arch_used as part of the filename of a tarball created by mktarball - If multiple original modules exist in a single kernel, the one in /updates is preferred - Changed multiple original module handling to move out and store all collisions * Mon May 03 2004 Gary Lerhaupt 1.09.01-1 - Changed 2.6 prep prepare-all target usage to make modules_prepare - Changed 2.6 make command to always use M= as this is fixed in 2.6.6-rc3-bk5 * Fri Apr 30 2004 Gary Lerhaupt 1.09-1 - If module build exit status is bad, die accordingly - 2.6 kernel prep changes (not quite there yet, still broken) * Thu Apr 29 2004 Gary Lerhaupt 1.08.06-1 - Added BUILD_EXCLUSIVE_KERNEL & BUILD_EXCLUSIVE_ARCH directives for dkms.conf - Tweaked dkms_autoinstaller to more gracefully handle a build failure * Tue Apr 27 2004 Gary Lerhaupt 1.08.02-1 - Got rid of make clean warning if not present * Tue Apr 20 2004 Gary Lerhaupt 1.08.01-1 - Fixed error message when compiling with --no-prepare-kernel * Tue Apr 13 2004 Gary Lerhaupt 1.08-1 - Fixed the format of rhdd-6.1 for Red Hat driver disks - Update man page with new white paper info * Thu Apr 1 2004 Gary Lerhaupt 1.07-1 - Added work-around to recognize ia32e kernel config instead of x86_64 - Got rid of start and stop functions which were no-ops anyway * Thu Mar 25 2004 Gary Lerhaupt 1.06-1 - Added a fix to keep the driver disk filename from being so long that it breaks * Mon Feb 09 2004 Gary Lerhaupt 1.05-1 - Added a fix to resolve RHEL21 depmod errors when an obsolete reference is found * Thu Jan 15 2004 Gary Lerhaupt 1.02-1 - Fixed mkinitrd for ia64 * Tue Dec 09 2003 Gary Lerhaupt 1.00.01-1 - Fixed /usr/share/doc/dkms- mode to 755 * Mon Dec 01 2003 Gary Lerhaupt 1.00-1 - Bumped version to 1.00 * Mon Nov 24 2003 Gary Lerhaupt 0.99.02-1 - Add -t vfat to loopback mount during creation of driver disk * Fri Nov 21 2003 Gary Lerhaupt 0.99.01-1 - Only edit /etc/modules.conf if remake_initrd is set or if this is the last uninstall and no original module exists - Added MODULES_CONF_OBSOLETE_ONLY array directive in dkms.conf - Updated man page * Wed Nov 19 2003 Gary Lerhaupt 0.46.05-1 - Fixed a bug in mktarball to limit the tarball name to less than 255 chars * Tue Nov 18 2003 Gary Lerhaupt 0.46.04-1 - Binary only tarballs now contain a copy of dkms.conf so that they can be force loaded * Mon Nov 17 2003 Gary Lerhaupt 0.45.03-1 - Updated man page, recommended rpm naming: --dkms.noarch.rpm * Thu Nov 13 2003 Gary Lerhaupt 0.45.02-1 - dkms_autoinstaller is now installed to /etc/init.d for cross-distro happiness * Fri Nov 07 2003 Gary Lerhaupt 0.45.01-1 - Added kernel config prepping for hugemem kernel (thanks Amit Bhutani) - modules.conf only now gets changed during install or uninstall of active module * Tue Nov 03 2003 Gary Lerhaupt 0.44.05-1 - Changed MODULES_CONF_ALIAS_TYPE to an array in dkms.conf - Added MODULES_CONF_OBSOLETES array in dkms.conf - Reworked modules_conf_modify to make use of OBSOLETES logic - Updated man page * Fri Oct 31 2003 Gary Lerhaupt 0.42.03-1 - Added --binaries-only option to mktarball - Updated man page * Thu Oct 30 2003 Gary Lerhaupt 0.41.15-1 - If depmod or mkinitrd fail during install, automatically go back to built state - Warn heavily if mkinitrd fails during uninstall * Wed Oct 29 2003 Gary Lerhaupt 0.41.11-1 - Removed paths from dkms calls in sample.spec - Fixed typo of KERNELRELEASE * Wed Oct 29 2003 Gary Lerhaupt 0.41.10-1 - Added Red Hat specific kernel prep to avoid make dep (Thanks Matt Domsch) - Added dkms_mkkerneldoth script to support RH kernel prep - Moved dkms from /sbin/ to /usr/sbin - Fixed typo which caused original_module not to get replaced on uninstall - No longer edit Makefiles, just specify KERNELVERSION=$kernel_version on the command line - Removed unnecessary depmod during uninstall * Thu Oct 23 2003 Gary Lerhaupt 0.40.16-1 - Fixed mkdriverdisk to copy rhdd-6.1 file into driver disk image * Wed Oct 22 2003 Gary Lerhaupt 0.40.15-1 - Changed expected driver disk filename from module-info to modinfo to work on legacy RH OSs * Tue Oct 14 2003 Gary Lerhaupt 0.40.14-1 - Unset all arrays before using them. duh. * Tue Oct 07 2003 Gary Lerhaupt 0.40.12-1 - Fixed bug in autoinstaller where it wasn't looking for dkms.conf through source symlink * Thu Oct 02 2003 Gary Lerhaupt 0.40.11-1 - Added --rpm_safe_upgrade flag - Updated the man page and sample.spec * Wed Oct 01 2003 Gary Lerhaupt 0.40.05-1 - No longer copy dkms.conf into /var/dkms tree, just go to the source_tree so as to reduce duplication - Got rid of --post-add, --post-build, --post-install and --post-remove - Replaced the above with DKMS directives POST_ADD, POST_BUILD, POST_INSTALL, POST_REMOVE - Fixed ldtarball and mktarball to no longer look for these duplicate files - Added a sample.conf for /usr/share/doc - Updated dkms_dbversion to 1.01 from 1.00 due to these changes - Update the man page * Tue Sep 30 2003 Gary Lerhaupt 0.39.17-1 - Added diff checking in status command in case modules are overwritten by someone else - Fixed already built error message in build_module - Changed build-arch to noarch - Updated sample.spec - Change dest_module_location to not get prefaced by /lib/modules/$kernel_version - When saving old initrd, copy it instead of moving it in case new one doesn't build - Only create source symlink during loadtarball if --force or if it doesn't exist - Decide to completely remove during remove_module after doing find with maxdepth of 0 not 1 * Mon Sep 29 2003 Gary Lerhaupt 0.39.08-1 - Reworked mktarball format to remove dependence on /var/dkms and /usr/src - Reworked ldtarball to match new tarball format - Ldtarball now uses --archive=tarball-location flag instead of --config flag - Ldtarball can now load any old source tarball as long as it contains a good dkms.conf - Added --kernelsourcedir cli option to provide alternate location for kernel source - Driver disk files are now looked for in /redhat_driver_disk - Added $tmp_location specifiable in /etc/dkms_framework.conf to specify your /tmp dir (default /tmp) - Updated man page * Thu Sep 25 2003 Gary Lerhaupt 0.38.03-1 - Fixed tmp_dir_name typo in ldtarball - Fixed mkdriverdisk to correctly create kernel/module structure - Don't expect a rhdd-6.1 file for RH driver disk, dkms will create it - Remove mkdriverdisk warning on non BOOT kernels - Moved driver_disk directory location to underneath $module_version - mkdriverdisk can now accept multiple kernel versions - Updated man page with info about $dkms_tree and $source_tree as dkms.conf variables * Wed Sep 24 2003 Gary Lerhaupt 0.37.10-1 - Don't allow installs of modules onto non-existant kernels - Suppressed stderr on some commands - Fixed brain-dead bug for REMAKE INITRD - During uninstall, dont remake initrd if it was not installed - ldtarball into unique tempdir and delete it when finished * Tue Sep 23 2003 Gary Lerhaupt 0.37.04-1 - Changed PATCH to array based system (added PATCH_MATCH array) - PATCHes can now be matched against regular expressions, not just substrings - Changed MODULES_CONF to array based system - CHANGED MAKE to array based system (added MAKE_MATCH array) - MAKEs can now be matched against regular expressions, not just substrings. - Updated man page * Mon Sep 22 2003 Gary Lerhaupt 0.36.10-1 - Changed autoinstaller bootup priority from 08 to 04 - Changed invoke_command routine to use mktemp for better security - Changed invoke_command in dkms_autoinstaller too * Fri Sep 19 2003 Gary Lerhaupt 0.36.05-1 - Continued bug testing and fixing new features * Wed Sep 17 2003 Gary Lerhaupt 0.36.02-1 - Got rid of MODULE_NAME: replaced with BUILT_MODULE_NAME, DEST_MODULE_NAME arrays - Got rid of LOCATION: replaced with BUILT_MODULE_LOCATION, DEST_MODULE_LOCATION arrays - Update man page * Tue Sep 16 2003 Gary Lerhaupt 0.36.01-1 - Fixed the setting of the gt2dot4 variable * Wed Sep 10 2003 Gary Lerhaupt 0.35.02-1 - Added PACKAGE_NAME, PACKAGE_VERSION requirements to dkms.conf for gmodconfig use - Fixed creation of /var/dkms before cp of dkms_dbversion in install.sh * Mon Sep 08 2003 Gary Lerhaupt 0.34.10-1 - Continued adding autoinstall stuff - Updated man page * Fri Sep 05 2003 Gary Lerhaupt 0.34.01-1 - Added dkms_autoinstaller service (builds module on boot if AUTOINSTALL="yes" in dkms.conf) - DKMS usage no longer sent to std_err - Added --no-prepare-kernel cli option * Fri Aug 08 2003 Gary Lerhaupt 0.33.02-1 - Fixed quote bugs in match (Reported by: John Hull ) - Added Fred Treasure to the AUTHORS list - Added dkms_dbversion file to DKMS tree to track architecture of dkms db layout * Thu Jul 03 2003 Gary Lerhaupt 0.32.04-1 - Added mkinitrd support for SuSE (etc_sysconfig_kernel_modify) - Added generic make command for kernel >2.4 (make -C SUBDIRS= modules) - Fixed kernel prepare to do Red Hat/Generic by default - Only do make dep if < 2.5 * Tue Jun 03 2003 Gary Lerhaupt 0.31.04-1 - Modified the Red Hat prep routine to be smaller and more robust (including summit support) - Added sample.spec to the sources for /usr/share/doc - If you save a .config before make mrproper, return it right afterwards - Updated the man page * Fri May 30 2003 Gary Lerhaupt 0.30.17-1 - Added a remake_initrd function to keep SuSE from doing wrong things - If you know the correct right steps for rebuilding SuSE initrds, please let me know! - Updated man page * Thu May 29 2003 Gary Lerhaupt 0.30.15-1 - Added a native readlink function to make sure it exists - Added a mkdir -p to $location to make sure it exists - Added --directive * Wed May 28 2003 Gary Lerhaupt 0.30.05-1 - Added kernel preparation support for SLES/United Linux (Many thanks to: Fred Treasure ) * Tue May 20 2003 Gary Lerhaupt 0.29.09-1 - On remove, to remove all kernel versions you must now specify --all - Added grep, cpio and gzip to the Requires of the RPM - Added cleaning kernel tree (make mrproper) after last build completes - Before prepare kernel, the current .config is stored in memory to be restored later - Added a verbose warning to the status command to remind people it only shows DKMS modules - Added /etc/dkms_framwork.conf for controlling source_tree and dkms_tree - Added the undocumented --dkmstree and --sourcetree options for cli control of these vars - When looking for original modules, dkms now employs the find command to expand search past $location - Updated man page * Wed May 14 2003 Gary Lerhaupt 0.28.05-1 - Fixed a typo in the man page. * Tue May 05 2003 Gary Lerhaupt 0.28.04-1 - Fixed ldtarball/mktarball to obey source_tree & dkms_tree (Reported By: Jordan Hargrave ) - Added DKMS mailing list to man page * Tue Apr 29 2003 Gary Lerhaupt 0.27.05-1 - Changed NEEDED_FOR_BOOT to REMAKE_INITRD as this makes more sense - Redid handling of modifying modules.conf - Added MODULE_CONF_ALIAS_TYPE to specs * Mon Apr 28 2003 Gary Lerhaupt 0.26.12-1 - Started adding ldtarball support - added the --force option - Update man page * Thu Apr 24 2003 Gary Lerhaupt 0.26.05-1 - Started adding mktarball support - Fixed up the spec file to use the tarball * Tue Mar 25 2003 Gary Lerhaupt 0.25.14-1 - Continued integrating mkdriverdisk - Updated man page * Mon Mar 24 2003 Gary Lerhaupt 0.25.03-1 - Added renaming ability to modules after builds (MODULE_NAME="beforename.o:aftername.o") - Started adding mkdriverdisk support - Added distro parameter for use with mkdriverdisk - Now using readlink to determine symlink pointing location - Added redhat BOOT config to default location of config files - Fixed a bug in read_conf that caused the wrong make subdirective to be used - Remove root requirement for build action * Wed Mar 19 2003 Gary Lerhaupt 0.23.19-1 - Fixed archiving of original modules (Reported by: Kris Jordan ) * Wed Mar 12 2003 Gary Lerhaupt 0.23.18-1 - Added kernel specific patching ability * Mon Mar 10 2003 Gary Lerhaupt 0.23.16-1 - Removed the sourcing in of /etc/init.d/functions as it was unused anyway - Implemented generic patching support - Updated man page - Fixed timing of the creation of DKMS built infrastructure in case of failure * Fri Mar 07 2003 Gary Lerhaupt 0.23.11-1 - Builds now occur in /var/dkms/$module/$module_version/build and not in /usr/src - Fixed the logging of the kernel_config * Thu Mar 06 2003 Gary Lerhaupt 0.23.01-1 - Started adding patch support - Redid reading implementation of modules_conf entries in dkms.conf (now supports more than 5) - Updated man page * Tue Mar 04 2003 Gary Lerhaupt 0.22.06-1 - Module names are not just assumed to end in .o any longer (you must specify full module name) - At exit status to invoke_command when bad exit status is returned * Fri Feb 28 2003 Gary Lerhaupt 0.22.03-1 - Changed the way variables are handled in dkms.conf, %kernelver to $kernelver * Mon Feb 24 2003 Gary Lerhaupt 0.22.02-1 - Fixed a typo in install * Tue Feb 11 2003 Gary Lerhaupt 0.22.01-1 - Fixed bug in remove which made it too greedy - Updated match code * Mon Feb 10 2003 Gary Lerhaupt 0.21.16-1 - Added uninstall action - Updated man page * Fri Feb 07 2003 Gary Lerhaupt 0.20.06-1 - Added --config option to specify where alternate .config location exists - Updated the man page to indicate the new option. - Updated the spec to allow for software versioning printout - Added -V which prints out the current dkms version and exits * Thu Jan 09 2003 Gary Lerhaupt 0.19.01-1 - Added GPL stuffs * Mon Dec 09 2002 Gary Lerhaupt 0.18.04-1 - Added support for multiple modules within the same install - Added postadd and fixed up the man page * Fri Dec 06 2002 Gary Lerhaupt 0.17.01-1 - Cleaned up the spec file. * Fri Nov 22 2002 Gary Lerhaupt - Fixed a bug in finding MAKE subdirectives * Thu Nov 21 2002 Gary Lerhaupt - Fixed make.log path error when module make fails - Fixed invoke_command to work under RH8.0 - DKMS now edits kernel makefile to get around RH8.0 problems * Wed Nov 20 2002 Gary Lerhaupt - Reworked the implementation of -q, --quiet * Tue Nov 19 2002 Gary Lerhaupt - Version 0.16: added man page * Mon Nov 18 2002 Gary Lerhaupt - Version 0.13: added match option - Version 0.14: dkms is no longer a SysV service - Added depmod after install and remove - Version 0.15: added MODULES_CONF directives in dkms.conf * Fri Nov 15 2002 Gary Lerhaupt - Version 0.12: added the -q (quiet) option * Thu Nov 14 2002 Gary Lerhaupt - Version 0.11: began coding the status function * Wed Nov 13 2002 Gary Lerhaupt - Changed the name to DKMS - Moved original_module to its own separate directory structure - Removal now does a complete clean up * Mon Nov 11 2002 Gary Lerhaupt - Split build into build and install - dkds.conf is now sourced in - added kernelver variable to dkds.conf * Fri Nov 8 2002 Gary Lerhaupt - Added date to make.log - Created the prepare_kernel function * Thu Nov 7 2002 Gary Lerhaupt - Barebones implementation complete * Wed Oct 30 2002 Gary Lerhaupt - Initial coding dkms-2.3/dkms_apport.py000077500000000000000000000075201276161124300152230ustar00rootroot00000000000000#!/usr/bin/python3 # # Dynamic Kernel Module Support (DKMS) # Copyright (C) 2009 Dell, Inc. # by Mario Limonciello # # 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 # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # import apport from apport.hookutils import * import sys import subprocess, optparse from datetime import datetime optparser = optparse.OptionParser('%prog [options]') optparser.add_option('-m', help="Specify the DKMS module to find the package for", action='store', type='string', dest='module') optparser.add_option('-v', help="Specify the DKMS version to find the package for", action='store', type='string', dest='version') optparser.add_option('-k', help="Specify the kernel version", action='store', type='string', dest='kernel') options=optparser.parse_args()[0] if not options.module or not options.version: 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: 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: 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') report = apport.Report('Package') report['Package'] = package try: report['SourcePackage'] = apport.packaging.get_source(package) except ValueError: sys.stderr.write('ERROR (dkms apport): unable to determine source package for %s\n' % package) sys.exit(3) try: version = packaging.get_version(package) except ValueError: version = '(not installed)' if version is None: version = '(not installed)' if report['SourcePackage'] == 'fglrx-installer': fglrx_make_log = os.path.join('/var','lib','dkms',options.module,options.version,'build','make.sh.log') attach_file_if_exists(report, fglrx_make_log, 'FglrxBuildLog') report['PackageVersion'] = version report['Title'] = "%s %s: %s kernel module failed to build" % (package, version, options.module) attach_file_if_exists(report, make_log, 'DKMSBuildLog') if 'DKMSBuildLog' in report: this_year = str(datetime.today().year) if 'Segmentation fault' in report['DKMSBuildLog']: sys.stderr.write('ERROR (dkms apport): There was a segmentation fault when trying to build the module\n') sys.exit(1) for line in report['DKMSBuildLog'].split('\n'): if ': error:' in line: report['DuplicateSignature'] = 'dkms:%s:%s:%s' % (package, version, line.strip()) break if options.kernel: report['DKMSKernelVersion'] = options.kernel with open(apport.fileutils.make_report_path(report), 'wb') as f: report.write(f) dkms-2.3/dkms_autoinstaller000077500000000000000000000031411276161124300161500ustar00rootroot00000000000000#!/bin/sh # # 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: 3 4 5 # Default-Stop: 0 1 2 6 # Required-Start: $local_fs # Short-Description: DKMS kernel modules installer service # Description: A service to automatically install DKMS modules for new kernels. ### END INIT INFO 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 alias log_daemon_msg=/bin/echo log_end_msg() { if [ "$1" = "0" ]; then echo " Done. "; else echo " Failed. "; fi } alias log_action_begin_msg=log_daemon_msg alias log_action_end_msg=log_end_msg fi exec="/usr/sbin/dkms" prog=${exec##*/} test -f $exec || exit 0 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog case "$1" in 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 dkms-2.3/dkms_common.postinst000066400000000000000000000214711276161124300164370ustar00rootroot00000000000000#!/bin/sh # Copyright (C) 2002-2005 Flavio Stanchina # Copyright (C) 2005-2006 Aric Cyr # Copyright (C) 2007 Mario Limonciello # Copyright (C) 2009 Alberto Milone set -e uname_s=$(uname -s) _get_kernel_dir() { KVER=$1 case ${uname_s} in Linux) DIR="/lib/modules/$KVER/build" ;; GNU/kFreeBSD) DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;; esac echo $DIR } _check_kernel_dir() { DIR=$(_get_kernel_dir $1) case ${uname_s} in Linux) test -e $DIR/include ;; GNU/kFreeBSD) test -e $DIR/kern && test -e $DIR/conf/kmod.mk ;; *) return 1 ;; esac return $? } # Check the existence of a kernel named as $1 _is_kernel_name_correct() { CORRECT="no" KERNEL_NAME=$1 for kernel in /boot/config-*; do KERNEL=${kernel#*-} if [ "${KERNEL}" = "${KERNEL_NAME}" ]; then CORRECT="yes" break fi done echo $CORRECT } # Get the most recent kernel on Debian based systems. This keeps # into account both the version and the ABI. If the current kernel # is the most recent kernel then the function will print a null string. _get_newest_kernel_debian() { NEWEST_KERNEL= NEWEST_VERSION= NEWEST_ABI= for kernel in /boot/config-*; do KERNEL=${kernel#*-} KERNEL_VERSION=${KERNEL%%-*} ABI=${KERNEL#*-} ABI=${ABI%%-*} if [ -z "$NEWEST_KERNEL" ]; then # The 1st time get a version which is bigger than $1 COMPARE_TO=$1 else # Get the biggest version COMPARE_TO="$NEWEST_VERSION-$NEWEST_ABI" fi # if $kernel is greater than $COMPARE_TO if [ `dpkg --compare-versions "$KERNEL_VERSION-$ABI" gt "$COMPARE_TO" && echo "yes" || \ echo "no"` = "yes" ]; then NEWEST_KERNEL=$KERNEL NEWEST_VERSION=$KERNEL_VERSION NEWEST_ABI=$ABI fi done echo "$NEWEST_KERNEL" } # Get the most recent kernel in Rhel based systems. If the current kernel # is the most recent kernel then the function will print a null string. _get_newest_kernel_rhel() { NEWEST_KERNEL= LAST_INSTALLED_KERNEL=$(rpm -q --whatprovides kernel --last | grep kernel -m1 | cut -f1 -d' ') LIK_FORMATTED_NAME=$(rpm -q $LAST_INSTALLED_KERNEL --queryformat="%{VERSION}-%{RELEASE}.%{ARCH}\n") if [ `echo $LIK_FORMATTED_NAME | grep 2.6 >/dev/null` ]; then # Fedora and Suse NEWEST_KERNEL=$LIK_FORMATTED_NAME else # Hack for Mandriva where $LIK_FORMATTED_NAME is broken LIK_NAME=$(rpm -q $LAST_INSTALLED_KERNEL --queryformat="%{NAME}\n") LIK_TYPE=${LIK_NAME#kernel-} LIK_TYPE=${LIK_TYPE%%-*} LIK_STRIPPED=${LIK_NAME#kernel-} LIK_STRIPPED=${LIK_STRIPPED#$LIK_TYPE-} LIK_STRIPPED_BASE=${LIK_STRIPPED%%-*} LIK_STRIPPED_END=${LIK_STRIPPED#$LIK_STRIPPED_BASE-} LIK_FINAL=$LIK_STRIPPED_BASE-$LIK_TYPE-$LIK_STRIPPED_END NEWEST_KERNEL=$LIK_FINAL fi echo $NEWEST_KERNEL } # Get the newest kernel on Debian and Rhel based systems. get_newest_kernel() { NEWEST_KERNEL= # Try Debian first as rpm can be installed in Debian based distros if [ -e /usr/bin/dpkg ]; then # If DEB based CURRENT_KERNEL=$1 CURRENT_VERSION=${CURRENT_KERNEL%%-*} CURRENT_ABI=${CURRENT_KERNEL#*-} CURRENT_FLAVOUR=${CURRENT_ABI#*-} CURRENT_ABI=${CURRENT_ABI%%-*} NEWEST_KERNEL=$(_get_newest_kernel_debian "$CURRENT_VERSION-$CURRENT_ABI") elif [ `which rpm >/dev/null` ]; then # If RPM based NEWEST_KERNEL=$(_get_newest_kernel_rhel) fi # Make sure that kernel name that we extracted corresponds to an installed # kernel if [ -n "$NEWEST_KERNEL" ] && [ `_is_kernel_name_correct $NEWEST_KERNEL` = "no" ]; then NEWEST_KERNEL= fi echo $NEWEST_KERNEL } NAME=$1 VERSION=$2 TARBALL_ROOT=$3 ARCH=$4 UPGRADE=$5 if [ -z "$NAME" ] || [ -z "$VERSION" ]; then echo "Need NAME, and VERSION defined" echo "ARCH is optional" exit 1 fi # 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 if [ -e "/var/lib/dkms/$NAME/$VERSION" ]; then echo "Removing old $NAME-$VERSION DKMS files..." dkms remove -m $NAME -v $VERSION --all fi #Load new files, by source package and by tarball if [ -f "$TARBALL_ROOT/$NAME-$VERSION.dkms.tar.gz" ]; then if ! dkms ldtarball --archive "$TARBALL_ROOT/$NAME-$VERSION.dkms.tar.gz"; then echo "" echo "" echo "Unable to load DKMS tarball $TARBALL_ROOT/$NAME-$VERSION.dkms.tar.gz." echo "Common causes include: " echo " - You must be using DKMS 2.1.0.0 or later to support binaries only" echo " distribution specific archives." echo " - Corrupt distribution specific archive" echo "" echo "" exit 2 fi elif [ -d "/usr/src/$NAME-$VERSION" ]; then echo "Loading new $NAME-$VERSION DKMS files..." dkms add -m $NAME -v $VERSION > /dev/null fi # On 1st installation, let us look for a directory # in /lib/modules which matches `uname -r`. If none # is found it is possible that buildd is being used # and that uname -r is giving us the name of the # kernel used by the buildd machine. # # If this is the case we try to build the kernel # module for each kernel which has a directory in # /lib/modules. Furthermore we will have to tell # DKMS which architecture it should build the module # for (e.g. if the buildd machine is using a # 2.6.24-23-xen 64bit kernel). # # NOTE: if the headers are not installed then the # module won't be built, as usual # 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 [ -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 "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 amd64) ARCH="x86_64" ;; lpia|i?86) ARCH="i686" ;; esac fi echo "Building for architecture $ARCH" ARCH="-a $ARCH" fi for KERNEL in $KERNELS; do dkms_status=`dkms status -m $NAME -v $VERSION -k $KERNEL $ARCH` if [ `echo $KERNEL | grep -c "BOOT"` -gt 0 ]; then echo "" echo "Module build and install for $KERNEL was skipped as " echo "it is a BOOT variant" continue fi #if the module isn't yet built, try to build it if [ `echo $dkms_status | grep -c ": built"` -eq 0 ]; then if [ ! -L /var/lib/dkms/$NAME/$VERSION/source ]; then echo "This package appears to be a binaries-only package" echo " you will not be able to build against kernel $KERNEL" echo " since the package source was not provided" continue fi if _check_kernel_dir $KERNEL; then echo "Building initial module for $KERNEL" set +e dkms build -m $NAME -v $VERSION -k $KERNEL $ARCH > /dev/null case $? in 9) set -e echo "Skipped." continue ;; 0) set -e echo "Done." ;; *) exit $? ;; esac dkms_status=`dkms status -m $NAME -v $VERSION -k $KERNEL $ARCH` else echo "Module build for kernel $KERNEL was skipped since the" echo "kernel headers for this kernel does not seem to be installed." fi fi #if the module is built (either pre-built or just now), install it if [ `echo $dkms_status | grep -c ": built"` -eq 1 ] && [ `echo $dkms_status | grep -c ": installed"` -eq 0 ]; then dkms install -m $NAME -v $VERSION -k $KERNEL $ARCH fi done dkms-2.3/dkms_dbversion000066400000000000000000000000061276161124300152470ustar00rootroot000000000000002.0.0 dkms-2.3/dkms_find-provides000077500000000000000000000044471276161124300160450ustar00rootroot00000000000000#! /bin/sh # heavily based upon find-suggests.ksyms by Andreas Gruenbacher . # with modifications by Michael Brown # # -- added module versioning info to modalias() symbols # -- removed code which inspects spec files. IFS=$'\n' print_modaliases() { declare class=$1 variants=$2 pos=$3 if [ -n "$variants" ]; then echo "${class:0:pos}[$variants]${class:pos+1}" else [ -z "$class" ] || echo "$class" fi } combine_modaliases() { declare tag class variants pos n read class while read tag; do for ((n=0; n<${#class}; n++)); do if [ "*" != "${class:n:1}" -a \ "${class:0:n}" = "${tag:0:n}" -a \ "${class:n+1}" = "${tag:n+1}" ] && ( [ -z "$pos" ] || [ $n = $pos ] ); then variants="${variants:-${class:n:1}}${tag:n:1}" pos=$n break fi done if [ $n -eq ${#class} ]; then print_modaliases "$class" "$variants" "$pos" variants= pos= class=$tag fi done print_modaliases "$class" "$variants" "$pos" } get_modinfo() { module=$1 # | head -n1 because some modules have *two* version tags. *cough*b44*cough* modver=$(/sbin/modinfo -F version "$module"| head -n1) modver=${modver// /_} # only add version tag if it has a version if [ -n "$modver" ]; then /sbin/modinfo -F alias "$module" \ | sed -nre "s,(.+),modalias(\\1) = $modver,p" else /sbin/modinfo -F alias "$module" \ | sed -nre "s,(.+),modalias(\\1),p" fi } tmp=${TMPDIR:-/tmp} TMPDIR=$(mktemp -d ${tmp}/dkms-findprovides-$$-$RANDOM-XXXXXX) trap "rm -rf $TMPDIR >/dev/null 2>&1" QUIT EXIT HUP INT TERM modlist= for cand in $(grep -E '(/lib/modules/.+\.ko$|tgz$|tbz$|tar\.(gz|bz2)$)') $*; do if echo $cand | grep -q -E '/lib/modules/.+\.ko$' > /dev/null 2>&1; then modlist="$modlist $cand" fi [ -f $cand ] || continue opts=x if gzip -t $cand >/dev/null 2>&1; then opts=${opts}z elif bzip2 -t $cand >/dev/null 2>&1; then opts=${opts}j fi tar ${opts}f $cand -C $TMPDIR > /dev/null 2>&1 done for module in $(find $TMPDIR -name \*.ko) $modlist; do if echo $module | grep -q -E '.ko$' >/dev/null 2>&1; then # it is a straight module get_modinfo $module continue fi done \ | sort -u \ | combine_modaliases dkms-2.3/dkms_framework.conf000066400000000000000000000016121276161124300162010ustar00rootroot00000000000000## This configuration file modifies the behavior of ## DKMS (Dynamic Kernel Module Support) and is sourced ## in by DKMS every time it is run. ## Source Tree Location (default: /usr/src) # source_tree="/usr/src" ## DKMS Tree Location (default: /var/lib/dkms) # dkms_tree="/var/lib/dkms" ## Install Tree Location (default: /lib/modules) # install_tree="/lib/modules" ## tmp Location (default: /tmp) # tmp_location="/tmp" ## 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="" dkms-2.3/dkms_mkkerneldoth000066400000000000000000000053101276161124300157460ustar00rootroot00000000000000#!/bin/bash # # Generate a header that defines the kernel we care about. # # Version 1.0 # # Adapted from Red Hat's initscripts package # Licensed under the GNU GPL kernel_version=`uname -r` output_file="/boot/kernel.h" target_arch="" # Parse command line arguments action_flag="" while [ $# -gt 0 ]; do case $1 in --targetarch*|-a) if echo $1 | grep '=' >/dev/null ; then target_arch=`echo $1 | sed 's/^.*=//'` else target_arch="$2" shift fi ;; --kernelver*|-k) if echo $1 | grep '=' >/dev/null ; then kernel_version=`echo $1 | sed 's/^.*=//'` else kernel_version="$2" shift fi ;; --output*|-o) if echo $1 | grep '=' >/dev/null ; then output_file=`echo $1 | sed 's/^.*=//'` else output_file="$2" shift fi ;; esac shift done KERNEL_TYPE=`echo ${kernel_version} | sed 's_^.*\(BOOT\|smp\|enterprise\|bigmem\|hugemem\|debug\|vmnix\)$_-\1_;t;s_.*__;'` KERNEL_RELEASE=`echo ${kernel_version} | sed 's|BOOT\|smp\|enterprise\|bigmem\|hugemem\|debug||g'` if [ -n "${target_arch}" ]; then KERNEL_ARCH="${target_arch}" else rpm -q kernel$KERNEL_TYPE-$KERNEL_RELEASE >/dev/null 2>&1 && KERNEL_ARCH=`rpm -q --qf '%{ARCH}' kernel$KERNEL_TYPE-$KERNEL_RELEASE 2>/dev/null` || KERNEL_ARCH=`uname -m` fi if [ -n "$KERNEL_ARCH" ]; then ENTERPRISE='0' SMP='0' UP='0' BIGMEM='0' HUGEMEM='0' BOOT='0' DEBUG='0' VMNIX='0' case "$KERNEL_TYPE" in -BOOT) BOOT='1' if [ "${KERNEL_ARCH}" = "i686" ] || [ "${KERNEL_ARCH}" = "i586" ] || [ "${KERNEL_ARCH}" = "athlon" ]; then KERNEL_ARCH="i386" fi ;; -smp) SMP='1';; -enterprise) ENTERPRISE='1';; -bigmem) BIGMEM='1';; -hugemem) HUGEMEM='1';; -vmnix) VMNIX='1';; *) UP='1';; esac cat > ${output_file} << EOF /* This file is automatically generated at boot time. */ #ifndef __BOOT_KERNEL_H_ #define __BOOT_KERNEL_H_ /* Kernel type $KERNEL_ARCH$KERNEL_TYPE */ #ifndef __MODULE_KERNEL_$KERNEL_ARCH #define __MODULE_KERNEL_$KERNEL_ARCH 1 #endif #ifndef __BOOT_KERNEL_ENTERPRISE #define __BOOT_KERNEL_ENTERPRISE $ENTERPRISE #endif #ifndef __BOOT_KERNEL_BIGMEM #define __BOOT_KERNEL_BIGMEM $BIGMEM #endif #ifndef __BOOT_KERNEL_HUGEMEM #define __BOOT_KERNEL_HUGEMEM $HUGEMEM #endif #ifndef __BOOT_KERNEL_SMP #define __BOOT_KERNEL_SMP $SMP #endif #ifndef __BOOT_KERNEL_UP #define __BOOT_KERNEL_UP $UP #endif #ifndef __BOOT_KERNEL_BOOT #define __BOOT_KERNEL_BOOT $BOOT #endif #ifndef __BOOT_KERNEL_DEBUG #define __BOOT_KERNEL_DEBUG $DEBUG #endif #ifndef __BOOT_KERNEL_VMNIX #define __BOOT_KERNEL_VMNIX $VMNIX #endif #endif EOF fi dkms-2.3/dkms_upgrade_add_arch_support.sh000077500000000000000000000041371276161124300207310ustar00rootroot00000000000000#!/bin/bash # This script upgrades DKMS version <1.90 to the new DKMS structure which # accounts for system architecture. # # Along with using this script to update your DKMS tree, you must also # update to a version of DKMS >=1.90. # # DKMS v2.0 will be the first stable release to have arch support. # bail if no dkms dkms_version=$(dkms -V 2>/dev/null) || exit dkms_version=(${dkms_version//./ }) # do nothing if we are already new enough ((${dkms_version[2]} > 1 || \ (${dkms_version[2]} == 1 && ${dkms_version[3]} >= 90) )) && exit mv /var/dkms /var/lib/dkms arch_used=$(uname -m) [[ $arch_used = x86_64 ]] && (($(grep -c "Intel" /proc/cpuinfo > 0 && \ $(ls /lib/modules/$kernel_test/build/configs 2>/dev/null | \ grep -c "ia32e") > 0)) && arch_used="ia32e" echo "" echo "ALERT! ALERT! ALERT!" echo "" echo "You are using a version of DKMS which does not support multiple system" echo "architectures. Your DKMS tree will now be modified to add this support." echo "" echo "The upgrade will assume all built modules are for arch: $arch_used" # Set important variables current_kernel=$(uname -r) dkms_tree="/var/lib/dkms" source_tree="/usr/src" tmp_location="/tmp" dkms_frameworkconf="/etc/dkms_framework.conf" # Source in /etc/dkms_framework.conf . $dkms_frameworkconf 2>/dev/null # Add the arch dirs echo "" echo "Fixing directories." for directory in $(find $dkms_tree -type d -name "module" -mindepth 3 -maxdepth 4); do dir_to_fix=${directory%module} echo "Creating $dir_to_fix/$arch_used..." mkdir $dir_to_fix/$arch_used mv -f $dir_to_fix/* $dir_to_fix/$arch_used 2>/dev/null done # Fix symlinks echo "" echo "Fixing symlinks." for symlink in $(find $dkms_tree -type l -name "kernel*" -mindepth 2 -maxdepth 2); do symlink_kernelname=${symlink/*\/kernel-//} dir_of_symlink=${symlink/\/kernel-*//} cd $dir_of_symlink split_symlink=$(readlink -e "$symlink") split_symlink=(${split_symlink//\// }) if ((${#split_symlink[@]} < 3)); then echo "Updating $symlink..." ln -sf $read_link/$arch_used kernel-$symlink_kernelname-$arch_used rm -f $symlink fi cd - done echo ""dkms-2.3/kernel_postinst.d_dkms000077500000000000000000000021401276161124300167250ustar00rootroot00000000000000#!/bin/bash # We're passed the version of the kernel being installed inst_kern=$1 uname_s=$(uname -s) _get_kernel_dir() { KVER=$1 case ${uname_s} in Linux) DIR="/lib/modules/$KVER/build" ;; GNU/kFreeBSD) DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;; esac echo $DIR } _check_kernel_dir() { DIR=$(_get_kernel_dir $1) case ${uname_s} in Linux) test -e $DIR/include ;; GNU/kFreeBSD) test -e $DIR/kern && test -e $DIR/conf/kmod.mk ;; *) return 1 ;; esac return $? } case "${uname_s}" in Linux) header_pkg="linux-headers-$inst_kern" kernel="Linux" ;; GNU/kFreeBSD) header_pkg="kfreebsd-headers-$inst_kern" kernel="kFreeBSD" ;; esac if [ -x /usr/lib/dkms/dkms_autoinstaller ]; then exec /usr/lib/dkms/dkms_autoinstaller start $inst_kern > /dev/null fi if ! _check_kernel_dir $inst_kern ; then echo "dkms: WARNING: $kernel headers are missing, which may explain the above failures." >&2 echo " please install the $header_pkg package to fix this." >&2 fi dkms-2.3/kernel_prerm.d_dkms000077500000000000000000000011661276161124300161760ustar00rootroot00000000000000#!/bin/bash # We're passed the version of the kernel being installed inst_kern=$1 if [ -x /usr/sbin/dkms ]; then while read line; do name=`echo "$line" | awk '{print $1}' | sed 's/,$//'` vers=`echo "$line" | awk '{print $2}' | sed 's/,$//'` arch=`echo "$line" | awk '{print $4}' | sed 's/:$//'` echo "dkms: removing: $name $vers ($inst_kern) ($arch)" >&2 dkms remove -m $name -v $vers -k $inst_kern -a $arch done < <(dkms status -k $inst_kern 2>/dev/null | grep ": installed") fi rmdir --ignore-fail-on-non-empty \ "/lib/modules/$inst_kern/updates/dkms" \ "/lib/modules/$inst_kern/updates" 2>/dev/null exit 0 dkms-2.3/lsb_release000077500000000000000000000370711276161124300145350ustar00rootroot00000000000000#!/bin/sh # # lsb_release - collect LSB conformance status about a system # # Copyright (C) 2000, 2002, 2004 Free Standards Group, Inc. # Originally by Dominique MASSONIE # # 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 # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # * Changes in 2.0 # - Support LSB 2.0 module layout (Mats Wichmann) # The LSB_VERSION is now a colon-separated field of supported module versions # An /etc/lsb-release.d is searched for modules beyond the core. # Only the filenames in this directory is looked at, those names are added # to LSB_VERSION. This allows module support to be handled easily by # package install/removal without a need to edit lsb-release on the fly. # - Correct license: FSG == Free Standards Group, Inc. # # * Changes in 1.4 # - "awk" not needed anymore (Loic Lefort) # - fixed bug #121879 reported by Chris D. Faulhaber, # some shells doesn't support local variables # - fixed a bug when single parameter sets many args including -s # - function DisplayProgramVersion (undocumented) now exits script like Usage # - cosmetic changes in comments/outputs # # * Changes in 1.3 # - No changes in script, only in build infrastructure # # * Changes in 1.2 # - Fixed more bash'isms # - LSB_VERSION is no longer required in /etc/lsb-release file # # * Changes in 1.1 # - removed some bash-ism and typos # Notice: script remains broken with ash because of awk issues # - changed licence to FSG - "Free Software Group, Inc" # - fixed problem with --short single arg call # - changed Debian specifics, codename anticipates release num # # Description: # Collect information from sourceable /etc/lsb-release file (present on # LSB-compliant systems) : LSB_VERSION, DISTRIB_ID, DISTRIB_RELEASE, # DISTRIB_CODENAME, DISTRIB_DESCRIPTION (all optional) # Then (if needed) find and add names from /etc/lsb-release.d # Then (if needed) find and parse the /etc/[distro]-release file ############################################################################### # DECLARATIONS ############################################################################### # This script version SCRIPTVERSION="2.0" # Defines the data files INFO_ROOT="/etc" # directory of config files INFO_LSB_FILE="lsb-release" # where to get LSB version INFO_LSB_DIR="lsb-release.d" # where to get LSB addon modules INFO_DISTRIB_SUFFIX="release" # - ALTERNATE_DISTRIB_FILE="/etc/debian_version" # for Debian [based distrib] ALTERNATE_DISTRIB_NAME="Debian" # " CHECKFIRST="/etc/redhat-release" # check it before file search # Defines our exit codes EXIT_STATUS="0" # default = Ok :) ERROR_UNKNOWN="10" # unknown error ERROR_USER="1" # program misuse ERROR_PROGRAM="2" # internal error ERROR_NOANSWER="3" # all required info not available # typically non LSB compliant distro! # Defines our messages MSG_LSBVER="LSB Version:\t" MSG_DISTID="Distributor ID:\t" MSG_DISTDESC="Description:\t" MSG_DISTREL="Release:\t" MSG_DISTCODE="Codename:\t" MSG_NA="n/a" MSG_NONE="(none)" MSG_RESULT="" # contains the result in case short output selected # Description string delimiter DESCSTR_DELI="release" ############################################################################### # FUNCTIONS ############################################################################### # Display Program Version for internal use (needed by help2man) DisplayProgramVersion() { echo "FSG `basename $0` v$SCRIPTVERSION" echo echo "Copyright (C) 2000, 2002, 2004 Free Standards Group, Inc." echo "This is free software; see the source for copying conditions. There\ is NO" echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR\ PURPOSE." echo echo "Originally written by Dominique MASSONIE." exit $EXIT_STATUS } # defines the Usage for lsb_release Usage() { echo "FSG `basename $0` v$SCRIPTVERSION prints certain LSB (Linux\ Standard Base) and" echo "Distribution information." echo echo "Usage: `basename $0` [OPTION]..." echo "With no OPTION specified defaults to -v." echo echo "Options:" echo " -v, --version" echo " Display the version of the LSB specification against which the distribution is compliant." echo " -i, --id" echo " Display the string id of the distributor." echo " -d, --description" echo " Display the single line text description of the distribution." echo " -r, --release" echo " Display the release number of the distribution." echo " -c, --codename" echo " Display the codename according to the distribution release." echo " -a, --all" echo " Display all of the above information." echo " -s, --short" echo " Use short output format for information requested by other options (or version if none)." echo " -h, --help" echo " Display this message." exit $EXIT_STATUS } # Handles the enhanced args (i.e. --something) EnhancedGetopt() { getopt -T >/dev/null 2>&1 # is getopt the enhanced one ? if [ $? = 4 ] then # Yes, advanced args ALLOWED OPT=$(getopt -o acdhirsvp \ --long all,codename,description,help,id,release,short,version,program_version \ -n 'lsb_release' \ -- "$@") else # No, advanced args NOT allowed # convert (if needed) the enhanced options into basic ones MYARGS=$(echo "$@" | sed -e "/--/s/-\(-[[:alnum:]]\)[[:alnum:]]*/\1/g") OPT=$(getopt -o acdhirsvp \ -n 'lsb_release' \ -- "$MYARGS") fi if [ $? != 0 ] then exit $ERROR_PROGRAM fi NB_ARG="" # enabled if many args set in one parameter (i.e. -dris) eval set -- "$OPT" while true ; do case "$1" in -a|--all) ARG_A="y"; NB_ARG="y"; shift;; -c|--codename) ARG_C="y"; NB_ARG="y"; shift;; -d|--description) ARG_D="y"; NB_ARG="y"; shift;; -i|--id) ARG_I="y"; NB_ARG="y"; shift;; -r|--release) ARG_R="y"; NB_ARG="y"; shift;; -s|--short) ARG_S="y"; shift;; -v|--version) ARG_V="y"; NB_ARG="y"; shift;; -p|--program_version) DisplayProgramVersion;; -h|--help) Usage;; --) shift; break;; *) EXIT_STATUS=$ERROR_USER Usage;; esac done } # Get/Init LSB infos (maybe Distrib infos too) GetLSBInfo() { # if we found LSB_VERSION, continue to look in directory if [ -d "$INFO_ROOT/$INFO_LSB_DIR" ] then for tag in "$INFO_ROOT/$INFO_LSB_DIR/"* do LSB_VERSION=$LSB_VERSION:`basename $tag` done fi } # Get the whole distrib information string (from ARG $1 file) InitDistribInfo() { ## Notice: Debian has a debian_version file ## (at least) Mandrake has two files, a mandrake and a redhat one FILENAME=$1 # CHECKFIRST or finds' result in GetDistribInfo() or "" if [ -z "$FILENAME" ] then if [ -f "$ALTERNATE_DISTRIB_FILE" ] then # For Debian only [ -z "$DISTRIB_ID" ] && DISTRIB_ID="$ALTERNATE_DISTRIB_NAME" [ -z "$DISTRIB_RELEASE" ] \ && DISTRIB_RELEASE=$(cat $ALTERNATE_DISTRIB_FILE) [ -z "$DISTRIB_CODENAME" ] && [ "$DISTRIB_RELEASE" = "2.1" ] \ && DISTRIB_CODENAME="Slink" [ -z "$DISTRIB_CODENAME" ] && [ "$DISTRIB_RELEASE" = "2.2" ] \ && DISTRIB_CODENAME="Potato" # [ -z "$DISTRIB_CODENAME" ] && [ "$DISTRIB_RELEASE" = "2.3" ] \ # && DISTRIB_CODENAME="Woody" [ -z "$DISTRIB_CODENAME" ] && DISTRIB_CODENAME=$DISTRIB_RELEASE # build the DISTRIB_DESCRIPTION string (never need to be parsed) [ -z "$DISTRIB_DESCRIPTION" ] \ && DISTRIB_DESCRIPTION="$DISTRIB_ID $DESCSTR_DELI $DISTRIB_REL\ EASE ($DISTRIB_CODENAME)" else # Only for nothing known compliant distrib :( [ -z "$DISTRIB_ID" ] && DISTRIB_ID=$MSG_NA [ -z "$DISTRIB_RELEASE" ] && DISTRIB_RELEASE=$MSG_NA [ -z "$DISTRIB_CODENAME" ] && DISTRIB_CODENAME=$MSG_NA [ -z "$DISTRIB_DESCRIPTION" ] && DISTRIB_DESCRIPTION=$MSG_NONE EXIT_STATUS=$ERROR_NOANSWER fi else NO="" # is Description string syntax correct ? if [ -z "$DISTRIB_DESCRIPTION" ] \ || [ -n "$(echo $DISTRIB_DESCRIPTION | \ sed -e "s/.*$DESCSTR_DELI.*//")" ] then TMP_DISTRIB_DESC=$(head -n 1 $FILENAME 2>/dev/null) [ -z "$DISTRIB_DESCRIPTION" ] \ && DISTRIB_DESCRIPTION=$TMP_DISTRIB_DESC else TMP_DISTRIB_DESC=$DISTRIB_DESCRIPTION fi if [ -z "$TMP_DISTRIB_DESC" ] # head or lsb-release init then # file contains no data DISTRIB_DESCRIPTION=$MSG_NONE NO="y" else # Do simple check [ -n "$(echo $TMP_DISTRIB_DESC | \ sed -e "s/.*$DESCSTR_DELI.*//")" ] \ && NO="y" fi if [ -n "$NO" ] then # does not contain "release" delimiter [ -z "$DISTRIB_ID" ] && DISTRIB_ID=$MSG_NA [ -z "$DISTRIB_RELEASE" ] && DISTRIB_RELEASE=$MSG_NA [ -z "$DISTRIB_CODENAME" ] && DISTRIB_CODENAME=$MSG_NA fi fi } # Check missing and requested infos, then find the file and get infos GetDistribInfo() { NO="" # /etc/lsb-release data are enough to reply what is requested? [ -n "$ARG_D" ] && [ -z "$DISTRIB_DESCRIPTION" ] && NO="y" [ -z "$NO" ] && [ -n "$ARG_I" ] && [ -z "$DISTRIB_ID" ] && NO="y" [ -z "$NO" ] && [ -n "$ARG_R" ] && [ -z "$DISTRIB_RELEASE" ] && NO="y" [ -z "$NO" ] && [ -n "$ARG_C" ] && [ -z "$DISTRIB_CODENAME" ] && NO="y" if [ -n "$NO" ] then if [ ! -f "$CHECKFIRST" ] then CHECKFIRST=$(find $INFO_ROOT/ -maxdepth 1 \ -name \*$INFO_DISTRIB_SUFFIX \ -and ! -name $INFO_LSB_FILE \ -and -type f \ 2>/dev/null \ | head -n 1 ) # keep one of the files found (if many) fi InitDistribInfo $CHECKFIRST fi } # Display version of LSB against which distribution is compliant DisplayVersion() { if [ -z "$ARG_S" ] then echo -e "$MSG_LSBVER$LSB_VERSION" # at least "n/a" else MSG_RESULT="$MSG_RESULT${MSG_RESULT:+ }$LSB_VERSION" fi } # Display string id of distributor ( i.e. a single word! ) DisplayID() { if [ -z "$DISTRIB_ID" ] then ## Linux could be part of the distro name (i.e. Turbolinux) or a separate word ## set before, after... ## also expect a delimiter ( i.e. "release" ) if [ -n "$(echo $TMP_DISTRIB_DESC | sed "s/.*$DESCSTR_DELI.*//")" ] then DISTRIB_ID=$MSG_NA else DISTRIB_ID=$(echo " $TMP_DISTRIB_DESC" \ | sed -e "s/[[:blank:]][Ll][Ii][Nn][Uu][Xx][[:blank:]]/ /g" \ -e "s/\(.*\)[[:blank:]]$DESCSTR_DELI.*/\1/" -e "s/[[:blank:]]//g") fi fi if [ -z "$ARG_S" ] then echo -e "$MSG_DISTID$DISTRIB_ID" else MSG_RESULT="$MSG_RESULT${MSG_RESULT:+ }$DISTRIB_ID" fi } # Diplay single line text description of distribution DisplayDescription() { if [ -z "$DISTRIB_DESCRIPTION" ] then # should not be empty since GetDistribInfo called on Initialization ! EXIT_STATUS=$ERROR_PROGRAM fi if [ -z "$ARG_S" ] then echo -e "$MSG_DISTDESC$DISTRIB_DESCRIPTION" else MSG_RESULT="$MSG_RESULT${MSG_RESULT:+ }\"$DISTRIB_DESCRIPTION\"" fi } # Display release number of distribution. DisplayRelease() { if [ -z "$DISTRIB_RELEASE" ] then # parse the "$DISTRIB_DESCRIPTION" string DISTRIB_RELEASE=$(echo "$TMP_DISTRIB_DESC" | \ sed -e "s/.*$DESCSTR_DELI[[:blank:]]*\([[:digit:]][[:graph:]]*\).*/\1/" ) [ "$DISTRIB_RELEASE" = "$TMP_DISTRIB_DESC" ] \ || [ -z "$DISTRIB_RELEASE" ] \ && DISTRIB_RELEASE=$MSG_NA fi if [ -z "$ARG_S" ] then echo -e "$MSG_DISTREL$DISTRIB_RELEASE" else MSG_RESULT="$MSG_RESULT${MSG_RESULT:+ }$DISTRIB_RELEASE" fi } # Display codename according to distribution version. DisplayCodename() { if [ -z "$DISTRIB_CODENAME" ] then # parse the "$DISTRIB_DESCRIPTION" string DISTRIB_CODENAME=$(echo "$TMP_DISTRIB_DESC" | \ sed -e "s/.*$DESCSTR_DELI.*(\(.*\)).*/\1/") [ "$DISTRIB_CODENAME" = "$TMP_DISTRIB_DESC" ] \ || [ -z "$DISTRIB_CODENAME" ] \ && DISTRIB_CODENAME=$MSG_NA fi if [ -z "$ARG_S" ] then echo -e "$MSG_DISTCODE$(echo "$DISTRIB_CODENAME" | \ tr -d "[:blank:]")" # Remove blanks else MSG_RESULT="$MSG_RESULT${MSG_RESULT:+ }$(echo "$DISTRIB_CODENAME" | \ tr -d "[:blank:]")" fi } ############################################################################### # MAIN ############################################################################### # Check if any prog argument if [ -z "$1" ] then ARG_V="y" # default set to Display LSB Version (not Usage) else EnhancedGetopt "$@" # Parse program args if [ -n "$ARG_S" ] && [ -z "$NB_ARG" ] then ARG_V="y" # set also default for --short when single arg fi fi # Update args to All if requested if [ -n "$ARG_A" ] then [ -z "$ARG_C" ] && ARG_C="y" [ -z "$ARG_D" ] && ARG_D="y" [ -z "$ARG_I" ] && ARG_I="y" [ -z "$ARG_R" ] && ARG_R="y" [ -z "$ARG_V" ] && ARG_V="y" fi # Initialization GetLSBInfo GetDistribInfo # Display requested infos (order as follow) [ -n "$ARG_V" ] && DisplayVersion [ -n "$ARG_I" ] && DisplayID [ -n "$ARG_D" ] && DisplayDescription [ -n "$ARG_R" ] && DisplayRelease [ -n "$ARG_C" ] && DisplayCodename [ -n "$ARG_S" ] && echo "$MSG_RESULT" exit $EXIT_STATUS dkms-2.3/sample-suse-10-mkkmp.spec000066400000000000000000000022301276161124300167610ustar00rootroot00000000000000# norootforbuild Name: novell-example BuildRequires: kernel-source kernel-syms License: GPL Group: System/Kernel Summary: Example Kernel Module Package Version: 1.1 Release: 0 Source0: %name-%version.tar.bz2 BuildRoot: %{_tmppath}/%{name}-%{version}-build %suse_kernel_module_package kdump um %description This is an example Kernel Module Package. %package KMP Summary: Example Kernel Module Group: System/Kernel %description KMP This is one of the sub-packages for a specific kernel. All the sub-packages will share the same summary, group, and description. %prep %setup set -- * mkdir source mv "$@" source/ mkdir obj %build export EXTRA_CFLAGS='-DVERSION=\"%version\"' for flavor in %flavors_to_build; do rm -rf obj/$flavor cp -r source obj/$flavor make -C /usr/src/linux-obj/%_target_cpu/$flavor modules \ M=$PWD/obj/$flavor done %install export INSTALL_MOD_PATH=$RPM_BUILD_ROOT export INSTALL_MOD_DIR=updates for flavor in %flavors_to_build; do make -C /usr/src/linux-obj/%_target_cpu/$flavor modules_install \ M=$PWD/obj/$flavor done %changelog * Sat Jan 28 2006 - agruen@suse.de - Initial package. dkms-2.3/sample-suse-9-mkkmp.spec000066400000000000000000000054671276161124300167300ustar00rootroot00000000000000#neededforbuild kernel-source kernel-syms # Change either of these definitions to define flavor. If flavor is # non-nil, this defines a single-flavor driver package, otherwise # this driver package will be multi-flavor. (Note that commenting out # one of these definitions will not work due to some very strange # RPM behavior!) %define flavor %{nil} %define XXflavor default %define driver_version 1.1 %define kver %(rpm -q --qf '%{VERSION}-%{RELEASE}' kernel-source) %define arch %(echo %_target_cpu | sed -e 's/i.86/i386/') Name: novell-kmp License: GPL Group: System/Kernel Autoreqprov: on Summary: An example module package %if "%flavor" == "" Version: %(echo %driver_version-%kver | tr - _) Requires: kernel = %kver %else Version: %(echo %driver_version-%kver-%flavor | tr - _) Requires: kernel-%flavor = %kver %endif Release: 0 Source0: novell-kmp-%driver_version.tar.bz2 Source1: depmod.sh Source2: mkinitrd.sh BuildRoot: %{_tmppath}/%{name}-%{version}-build %description Driver test %prep # Make sure to include a %setup statement in the %prep section: # without, the ``%post -f ...'' and ``%postun -f ...'' statements # will silently fail and produce empty scripts. %setup -n novell-kmp-%driver_version mkdir source mv * source/ || : mkdir obj %build export EXTRA_CFLAGS='-DVERSION=\"%driver_version\"' %if "%flavor" == "" flavors=$(ls /usr/src/linux-obj/%arch) %else flavors=%flavor %endif for flavor in $flavors; do if [ $flavor = um ]; then # User Mode Linux is an exception for many external kernel modules; # we may choose to skip it here. continue fi rm -rf obj-$flavor cp -r source obj/$flavor make -C /usr/src/linux-obj/%arch/$flavor modules M=$PWD/obj/$flavor done %install export INSTALL_MOD_PATH=$RPM_BUILD_ROOT export INSTALL_MOD_DIR=updates for flavor in $(ls obj/); do make -C /usr/src/linux-obj/%arch/$flavor modules_install \ M=$PWD/obj/$flavor done set -- $(ls $RPM_BUILD_ROOT/lib/modules) KERNELRELEASES=$* set -- $(find $RPM_BUILD_ROOT/lib/modules -type f -name '*.ko' \ | sed -e 's:.*/::' -e 's:\.ko$::' | sort -u) MODULES=$* ( cat <<-EOF # IMPORTANT: Do not change the KERNELRELEASES definition; it will be # replaced during driver reuse! KERNELRELEASES="$KERNELRELEASES" MODULES="$MODULES" EOF cat %_sourcedir/depmod.sh cat %_sourcedir/mkinitrd.sh ) > post_postun.sh mkdir -p $RPM_BUILD_ROOT/var/lib/YaST2/download # Insert your download location here: echo "ftp://ftp.suse.com/pub/suse;SUSE/Novell" \ > $RPM_BUILD_ROOT/var/lib/YaST2/download/%name %post -f post_postun.sh %postun -f post_postun.sh %files %defattr(-, root, root) /lib/modules/* %dir /var/lib/YaST2 %dir /var/lib/YaST2/download %config(noreplace) /var/lib/YaST2/download/%name %changelog * Thu Dec 01 2005 - agruen@suse.de - Initial package. dkms-2.3/sample.conf000066400000000000000000000012071276161124300144470ustar00rootroot00000000000000PACKAGE_VERSION="2.10.1" # Items below here should not have to change with each driver version PACKAGE_NAME="megaraid2" MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" CLEAN="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build clean" BUILT_MODULE_NAME[0]="megaraid2" DEST_MODULE_LOCATION[0]="/kernel/drivers/scsi/" MODULES_CONF_ALIAS_TYPE[0]="scsi_hostadapter" MODULES_CONF_OBSOLETES[0]="megaraid,megaraid_2002" REMAKE_INITRD="yes" PATCH[0]="rhel21.patch" PATCH_MATCH[0]="2\.4\.9\-e\." PATCH[1]="rhel3.patch" PATCH_MATCH[1]="2\.4\.21\-.*\.EL" dkms-2.3/sample.spec000066400000000000000000000100041276161124300144470ustar00rootroot00000000000000%define module megaraid2 %define version 2.10.1 Summary: megaraid2 dkms package Name: %{module} Version: %{version} Release: 2dkms Vendor: LSI License: GPL Packager: Ganesh Viswanathan Group: System Environment/Base BuildArch: noarch Requires: dkms >= 1.00 Requires: bash # There is no Source# line for dkms.conf since it has been placed # into the source tarball of SOURCE0 Source0: %{module}-%{version}-src.tar.gz Source1: %{module}-%{version}-kernel2.4.9-e.3-all.tgz Source2: %{module}-%{version}-kernel2.4.20-16.9-all.tgz Source3: %{module}-%{version}-kernel2.4.20-9-all.tgz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root/ %description This package contains LSI's megaraid2 module wrapped for the DKMS framework. %prep rm -rf %{module}-%{version} mkdir %{module}-%{version} cd %{module}-%{version} tar xvzf $RPM_SOURCE_DIR/%{module}-%{version}-src.tar.gz %install if [ "$RPM_BUILD_ROOT" != "/" ]; then rm -rf $RPM_BUILD_ROOT fi mkdir -p $RPM_BUILD_ROOT/usr/src/%{module}-%{version}/ mkdir -p $RPM_BUILD_ROOT/usr/src/%{module}-%{version}/patches mkdir -p $RPM_BUILD_ROOT/usr/src/%{module}-%{version}/redhat_driver_disk cp -rf %{module}-%{version}/* $RPM_BUILD_ROOT/usr/src/%{module}-%{version} install -m 644 $RPM_SOURCE_DIR/%{module}-%{version}-kernel2.4.9-e.3-all.tgz $RPM_BUILD_ROOT/usr/src/%{module}-%{version} install -m 644 $RPM_SOURCE_DIR/%{module}-%{version}-kernel2.4.20-9-all.tgz $RPM_BUILD_ROOT/usr/src/%{module}-%{version} install -m 644 $RPM_SOURCE_DIR/%{module}-%{version}-kernel2.4.20-16.9-all.tgz $RPM_BUILD_ROOT/usr/src/%{module}-%{version} %clean if [ "$RPM_BUILD_ROOT" != "/" ]; then rm -rf $RPM_BUILD_ROOT fi %files %defattr(-,root,root) /usr/src/%{module}-%{version}/ %pre %post dkms add -m %{module} -v %{version} --rpm_safe_upgrade # Load tarballs as necessary loaded_tarballs="" for kernel_name in 2.4.9-e.3; do if [ `uname -r | grep -c "$kernel_name"` -gt 0 ] && [ `uname -m | grep -c "i*86"` -gt 0 ]; then echo -e "" echo -e "Loading/Installing pre-built modules for $kernel_name." dkms ldtarball --archive=/usr/src/%{module}-%{version}/%{module}-%{version}-kernel${kernel_name}-all.tgz >/dev/null dkms install -m %{module} -v %{version} -k ${kernel_name} >/dev/null 2>&1 dkms install -m %{module} -v %{version} -k ${kernel_name}smp >/dev/null 2>&1 dkms install -m %{module} -v %{version} -k ${kernel_name}enterprise >/dev/null 2>&1 loaded_tarballs="true" fi done for kernel_name in 2.4.20-9 2.4.20-16.9; do if [ `uname -r | grep -c "$kernel_name"` -gt 0 ] && [ `uname -m | grep -c "i*86"` -gt 0 ]; then echo -e "" echo -e "Loading/Installing pre-built modules for $kernel_name." dkms ldtarball --archive=/usr/src/%{module}-%{version}/%{module}-%{version}-kernel${kernel_name}-all.tgz >/dev/null dkms install -m %{module} -v %{version} -k ${kernel_name} >/dev/null 2>&1 dkms install -m %{module} -v %{version} -k ${kernel_name}smp >/dev/null 2>&1 dkms install -m %{module} -v %{version} -k ${kernel_name}bigmem >/dev/null 2>&1 loaded_tarballs="true" fi done # If we haven't loaded a tarball, then try building it for the current kernel if [ -z "$loaded_tarballs" ]; then if [ `uname -r | grep -c "BOOT"` -eq 0 ] && [ -e /lib/modules/`uname -r`/build/include ]; then dkms build -m %{module} -v %{version} dkms install -m %{module} -v %{version} elif [ `uname -r | grep -c "BOOT"` -gt 0 ]; then echo -e "" echo -e "Module build for the currently running kernel was skipped since you" echo -e "are running a BOOT variant of the kernel." else echo -e "" echo -e "Module build for the currently running kernel was skipped since the" echo -e "kernel headers for this kernel do not seem to be installed." fi fi exit 0 %preun echo -e echo -e "Uninstall of megaraid2 module (version %{version}) beginning:" dkms remove -m %{module} -v %{version} --all --rpm_safe_upgrade exit 0 dkms-2.3/template-dkms-mkdeb/000077500000000000000000000000001276161124300161465ustar00rootroot00000000000000dkms-2.3/template-dkms-mkdeb/Makefile000066400000000000000000000012731276161124300176110ustar00rootroot00000000000000#/usr/bin/make SRC = $(DESTDIR)/usr/src SHARE = $(DESTDIR)/usr/share/$(NAME)-dkms all: clean: install: #source tree ifeq ("$(wildcard $(NAME)-$(VERSION))", "$(NAME)-$(VERSION)") install -d "$(SRC)" cp -a $(NAME)-$(VERSION) $(SRC) chmod 644 -R "$(SRC)/$(NAME)-$(VERSION)" endif #tarball, possibly with binaries ifeq ("$(wildcard $(NAME)-$(VERSION).dkms.tar.gz)", "$(NAME)-$(VERSION).dkms.tar.gz") install -d "$(SHARE)" install -m 644 $(NAME)-$(VERSION).dkms.tar.gz "$(SHARE)" endif #postinst, only if we are supporting legacy mode ifeq ("$(wildcard common.postinst)", "common.postinst") install -d "$(SHARE)" install -m 755 $(PREFIX)/usr/lib/dkms/common.postinst $(SHARE)/postinst endif dkms-2.3/template-dkms-mkdeb/debian/000077500000000000000000000000001276161124300173705ustar00rootroot00000000000000dkms-2.3/template-dkms-mkdeb/debian/README.Debian000066400000000000000000000002261276161124300214310ustar00rootroot00000000000000MODULE_NAME DKMS module for Debian This package was automatically generated by the DKMS system, for distribution on Debian based operating systems. dkms-2.3/template-dkms-mkdeb/debian/changelog000066400000000000000000000002751276161124300212460ustar00rootroot00000000000000DEBIAN_PACKAGE-dkms (MODULE_VERSION) stable; urgency=low * Automatically packaged by DKMS. -- Dynamic Kernel Modules Support Team DATE_STAMP dkms-2.3/template-dkms-mkdeb/debian/compat000066400000000000000000000000021276161124300205660ustar00rootroot000000000000007 dkms-2.3/template-dkms-mkdeb/debian/control000066400000000000000000000005411276161124300207730ustar00rootroot00000000000000Source: DEBIAN_PACKAGE-dkms Section: misc Priority: optional Maintainer: Dynamic Kernel Modules Support Team Build-Depends: debhelper (>= 7), dkms Standards-Version: 3.8.1 Package: DEBIAN_PACKAGE-dkms Architecture: all Depends: dkms (>= 1.95), ${misc:Depends} Description: DEBIAN_PACKAGE driver in DKMS format. dkms-2.3/template-dkms-mkdeb/debian/copyright000066400000000000000000000001061276161124300213200ustar00rootroot00000000000000 This copyright has not been completed by the author of this package. dkms-2.3/template-dkms-mkdeb/debian/dirs000066400000000000000000000000101276161124300202430ustar00rootroot00000000000000usr/src dkms-2.3/template-dkms-mkdeb/debian/postinst000066400000000000000000000023211276161124300211740ustar00rootroot00000000000000#!/bin/sh # Copyright (C) 2002-2005 Flavio Stanchina # Copyright (C) 2005-2006 Aric Cyr # Copyright (C) 2007 Mario Limonciello # Copyright (C) 2009 Alberto Milone set -e NAME=MODULE_NAME PACKAGE_NAME=$NAME-dkms DEB_NAME=$(echo $PACKAGE_NAME | sed 's,_,-,') CVERSION=`dpkg-query -W -f='${Version}' $DEB_NAME | awk -F "-" '{print $1}' | cut -d\: -f2` ARCH=`dpkg --print-architecture` dkms_configure () { for POSTINST in /usr/lib/dkms/common.postinst "/usr/share/$PACKAGE_NAME/postinst"; do if [ -f "$POSTINST" ]; then "$POSTINST" "$NAME" "$CVERSION" "/usr/share/$PACKAGE_NAME" "$ARCH" "$2" return $? fi echo "WARNING: $POSTINST does not exist." >&2 done echo "ERROR: DKMS version is too old and $PACKAGE_NAME was not" >&2 echo "built with legacy DKMS support." >&2 echo "You must either rebuild $PACKAGE_NAME with legacy postinst" >&2 echo "support or upgrade DKMS to a more current version." >&2 return 1 } case "$1" in configure) dkms_configure ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. #DEBHELPER# exit 0 dkms-2.3/template-dkms-mkdeb/debian/prerm000066400000000000000000000005501276161124300204400ustar00rootroot00000000000000#!/bin/sh NAME=MODULE_NAME VERSION=MODULE_VERSION set -e case "$1" in remove|upgrade|deconfigure) if [ "`dkms status -m $NAME`" ]; then dkms remove -m $NAME -v $VERSION --all fi ;; failed-upgrade) ;; *) echo "prerm called with unknown argument \`$1'" >&2 exit 1 ;; esac #DEBHELPER# exit 0 dkms-2.3/template-dkms-mkdeb/debian/rules000066400000000000000000000015611276161124300204500ustar00rootroot00000000000000#!/usr/bin/make -f # -*- makefile -*- # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 DEB_NAME=DEBIAN_PACKAGE NAME=MODULE_NAME VERSION=MODULE_VERSION configure: configure-stamp configure-stamp: dh_testdir touch configure-stamp build: build-stamp build-stamp: configure-stamp dh_testdir $(MAKE) touch $@ clean: dh_testdir dh_testroot rm -f build-stamp configure-stamp -$(MAKE) clean dh_clean install: build dh_testdir dh_testroot dh_prep dh_installdirs $(MAKE) DESTDIR=$(CURDIR)/debian/$(DEB_NAME)-dkms NAME=$(NAME) VERSION=$(VERSION) install binary-arch: build install binary-indep: build install dh_testdir dh_testroot dh_link dh_strip dh_compress dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install configure dkms-2.3/template-dkms-mkdsc000077700000000000000000000000001276161124300216552template-dkms-mkdebustar00rootroot00000000000000dkms-2.3/template-dkms-mkrpm.spec000066400000000000000000000053411276161124300170710ustar00rootroot00000000000000%{?!module_name: %{error: You did not specify a module name (%%module_name)}} %{?!version: %{error: You did not specify a module version (%%version)}} %{?!kernel_versions: %{error: You did not specify kernel versions (%%kernel_version)}} %{?!packager: %define packager DKMS } %{?!license: %define license Unknown} %{?!_dkmsdir: %define _dkmsdir /var/lib/dkms} %{?!_srcdir: %define _srcdir %_prefix/src} %{?!_datarootdir: %define _datarootdir %{_datadir}} Summary: %{module_name} %{version} dkms package Name: %{module_name} Version: %{version} License: %license Release: 1dkms BuildArch: noarch Group: System/Kernel Requires: dkms >= 1.95 BuildRequires: dkms BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root/ %description Kernel modules for %{module_name} %{version} in a DKMS wrapper. %prep if [ "%mktarball_line" != "none" ]; then /usr/sbin/dkms mktarball -m %module_name -v %version %mktarball_line --archive `basename %{module_name}-%{version}.dkms.tar.gz` cp -af %{_dkmsdir}/%{module_name}/%{version}/tarball/`basename %{module_name}-%{version}.dkms.tar.gz` %{module_name}-%{version}.dkms.tar.gz fi %install if [ "$RPM_BUILD_ROOT" != "/" ]; then rm -rf $RPM_BUILD_ROOT fi mkdir -p $RPM_BUILD_ROOT/%{_srcdir} mkdir -p $RPM_BUILD_ROOT/%{_datarootdir}/%{module_name} if [ -d %{_sourcedir}/%{module_name}-%{version} ]; then cp -Lpr %{_sourcedir}/%{module_name}-%{version} $RPM_BUILD_ROOT/%{_srcdir} fi if [ -f %{module_name}-%{version}.dkms.tar.gz ]; then install -m 644 %{module_name}-%{version}.dkms.tar.gz $RPM_BUILD_ROOT/%{_datarootdir}/%{module_name} fi if [ -f %{_sourcedir}/common.postinst ]; then install -m 755 %{_sourcedir}/common.postinst $RPM_BUILD_ROOT/%{_datarootdir}/%{module_name}/postinst fi %clean if [ "$RPM_BUILD_ROOT" != "/" ]; then rm -rf $RPM_BUILD_ROOT fi %post 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 $? fi echo "WARNING: $POSTINST does not exist." done echo -e "ERROR: DKMS version is too old and %{module_name} was not" echo -e "built with legacy DKMS support." echo -e "You must either rebuild %{module_name} with legacy postinst" echo -e "support or upgrade DKMS to a more current version." exit 1 %preun echo -e echo -e "Uninstall of %{module_name} module (version %{version}) beginning:" dkms remove -m %{module_name} -v %{version} --all --rpm_safe_upgrade exit 0 %files %defattr(-,root,root) %{_srcdir} %{_datarootdir}/%{module_name}/ %changelog * %(date "+%a %b %d %Y") %packager %{version}-%{release} - Automatic build by DKMS dkms-2.3/template-dkms-redhat-kmod.spec000066400000000000000000000023321276161124300201370ustar00rootroot00000000000000%{?!module_name: %{error: You did not specify a module name (%%module_name)}} %{?!version: %{error: You did not specify a module version (%%version)}} Name: %{module_name} Version: %{version} Release: 1%{?dist} Summary: %{module_name}-%{version} RHEL6 Driver Update Program package Group: System/Kernel License: Unkown Source0: %{module_name}-%{version}.tar.bz2 BuildRoot: %(mktemp -ud %{_tmppath}/%{module_name}-%{version}-%{release}-XXXXXX) BuildRequires: %kernel_module_package_buildreqs %kernel_module_package default %description %{module_name}-%{version} RHEL6 Driver Update package. %prep %setup set -- * mkdir source mv "$@" source/ mkdir obj %build for flavor in %flavors_to_build; do rm -rf obj/$flavor cp -r source obj/$flavor make -C %{kernel_source $flavor} M=$PWD/obj/$flavor done %install export INSTALL_MOD_PATH=$RPM_BUILD_ROOT export INSTALL_MOD_DIR=extra/%{name} for flavor in %flavors_to_build ; do make -C %{kernel_source $flavor} modules_install \ M=$PWD/obj/$flavor done %clean rm -rf $RPM_BUILD_ROOT %changelog * Sun Jun 15 2010 Prudhvi Tella - DKMS template for RHEL6 Driver Update package. * Sun Mar 28 2010 Jon Masters - Example RHEL6 Driver Update package. dkms-2.3/test/000077500000000000000000000000001276161124300132765ustar00rootroot00000000000000dkms-2.3/test/README000066400000000000000000000000361276161124300141550ustar00rootroot00000000000000A sample module to test dkms. dkms-2.3/test/dkms_test-1.0/000077500000000000000000000000001276161124300155675ustar00rootroot00000000000000dkms-2.3/test/dkms_test-1.0/Makefile000066400000000000000000000002371276161124300172310ustar00rootroot00000000000000obj-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 dkms-2.3/test/dkms_test-1.0/dkms.conf000066400000000000000000000005751276161124300174030ustar00rootroot00000000000000 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" dkms-2.3/test/dkms_test-1.0/dkms_test.c000066400000000000000000000010021276161124300177210ustar00rootroot00000000000000#include #include #include #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);