[PATCH] generate module-info on the fly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The attached patch generates the module-info file on the fly from the module
lists in the kernel, so we don't need to keep updating a static file any
more.

Requires the kernel spec changes at:
	https://www.redhat.com/archives/fedora-kernel-list/2007-July/msg00109.html

Caveats:
1) module descriptions are read from the modules themselves. Ergo, they may be
   horribly ugly and inconsistent
2) it's possible this will miss a module or two in its initial incarnation

 loader2/Makefile  |    1 -
 scripts/mk-images |    8 +++++---
 utils/Makefile    |    1 +
 utils/genmodinfo  |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 60 insertions(+), 4 deletions(-)

Bill
Index: loader2/Makefile
===================================================================
RCS file: /usr/local/CVS/anaconda/loader2/Makefile,v
retrieving revision 1.63
diff -u -r1.63 Makefile
--- loader2/Makefile	22 Jun 2007 16:53:35 -0000	1.63
+++ loader2/Makefile	31 Jul 2007 19:10:03 -0000
@@ -135,7 +135,6 @@
 	if [ -f keymaps-$(ARCH) ]; then cp keymaps-$(ARCH) $(DESTDIR)/$(RUNTIMEDIR)/keymaps-override-$(ARCH) ; fi
 	install -m 644 unicode-linedraw-chars.txt $(DESTDIR)/$(RUNTIMEDIR)/loader
 	install -m 644 loader.tr $(DESTDIR)/$(RUNTIMEDIR)/loader
-	install -m 644 module-info $(DESTDIR)/$(RUNTIMEDIR)/loader
 
 dirbrowser: dirbrowser.c
 	gcc -DSTANDALONE -D_FORTIFY_SOURCE=2 -Wall -Werror -ggdb -o dirbrowser dirbrowser.c -lnewt -lslang
Index: scripts/mk-images
===================================================================
RCS file: /usr/local/CVS/anaconda/scripts/mk-images,v
retrieving revision 1.240
diff -u -r1.240 mk-images
--- scripts/mk-images	18 Jun 2007 17:33:26 -0000	1.240
+++ scripts/mk-images	31 Jul 2007 19:10:03 -0000
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/bash 
 LANG=C
 
 PATH=$PATH:/sbin:/usr/sbin
@@ -109,11 +109,12 @@
     TRIMPCIIDS=$IMGPATH/usr/lib/anaconda-runtime/trimpciids
     GETKEYMAPS=$IMGPATH/usr/lib/anaconda-runtime/getkeymaps
     GENINITRDSZ=$IMGPATH/usr/lib/anaconda-runtime/geninitrdsz
+    GENMODINFO=$IMGPATH/usr/lib/anaconda-runtime/genmodinfo
     KEYMAPS=$TMPDIR/keymaps-$BUILDARCH.$$
     SCREENFONT=$IMGPATH/usr/lib/anaconda-runtime/screenfont-${BASEARCH}.gz
     GETMODDEPS=$IMGPATH/usr/lib/anaconda-runtime/moddeps
     MODLIST=$IMGPATH/usr/lib/anaconda-runtime/modlist
-    MODINFO=$IMGPATH/usr/lib/anaconda-runtime/loader/module-info
+    MODINFO=$TMPDIR/modinfo-$BUILDARCH.$$
     FILTERMODDEPS=$IMGPATH/usr/lib/anaconda-runtime/filtermoddeps
     LOADERBINDIR=$IMGPATH/usr/lib/anaconda-runtime/loader
     BOOTDISKDIR=$IMGPATH/usr/lib/anaconda-runtime/boot
@@ -126,7 +127,7 @@
 
     touch $MODULESUSED
 
-    REQUIREMENTS="$TRIMMODALIAS $TRIMPCIIDS $PCIIDS $XDRIVERDESCS $GETMODDEPS $MODINFO
+    REQUIREMENTS="$TRIMMODALIAS $TRIMPCIIDS $PCIIDS $XDRIVERDESCS $GETMODDEPS $GENMODINFO
 		  $FILTERMODDEPS $LANGTABLE $GETKEYMAPS"
 
     dieLater=
@@ -816,8 +817,9 @@
 
     allmods=$(find $KERNELROOT/lib/modules/$version -name *.ko)
 
     rundepmod "$allmods" $MODDEPS
     find $KERNELROOT/lib/modules/$version > $CACHE
+    $GENMODINFO $KERNELROOT/lib/modules/$version > $MODINFO
 
     # make the boot images
     makeBootImages
Index: utils/Makefile
===================================================================
RCS file: /usr/local/CVS/anaconda/utils/Makefile,v
retrieving revision 1.85
diff -u -r1.85 Makefile
--- utils/Makefile	18 Jan 2007 21:42:01 -0000	1.85
+++ utils/Makefile	31 Jul 2007 19:10:03 -0000
@@ -57,6 +57,7 @@
 install: all
 	mkdir -p $(DESTDIR)/usr/bin
 	mkdir -p $(DESTDIR)/$(RUNTIMEDIR)
+	install -m755 genmodinfo $(DESTDIR)/$(RUNTIMEDIR)
 	install -m755 trimmodalias $(DESTDIR)/$(RUNTIMEDIR)
 	install -m755 trimpciids $(DESTDIR)/$(RUNTIMEDIR)
 	install -m755 moddeps $(DESTDIR)/$(RUNTIMEDIR)
Index: utils/genmodinfo
===================================================================
RCS file: utils/genmodinfo
diff -N utils/genmodinfo
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ utils/genmodinfo	31 Jul 2007 19:10:03 -0000
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+
+import commands
+import os
+import string
+import sys
+
+uname = os.uname()[2]
+
+if len(sys.argv) > 1:
+    path = sys.argv[1]
+else:
+    path = '/lib/modules/%s' % (uname,)
+    
+mods = {}
+for root, dirs, files in os.walk(path):
+    for file in files:
+        mods[file] = os.path.join(root,file)
+
+modules = { 'scsi_hostadapter' : [ 'block' ], 'eth' : [ 'networking'] }
+
+list = {}
+
+for modtype in modules.keys():
+    list[modtype] = {}
+    for file in modules[modtype]:
+        try:
+            f = open('%s/modules.%s' % (path,file),'r')
+        except:
+            continue
+        lines = f.readlines()
+        f.close()
+        for line in lines:
+            line = line.strip()
+            if mods.has_key(line):
+                desc = commands.getoutput("modinfo -F description %s" % (mods[line]))
+                modname = line[:-3]
+                if desc and len(desc) > 65:
+                    desc = desc[:65]
+                if not desc:
+                    desc = "%s driver" % (modname,)
+                modinfo = """
+%s
+        %s
+        "%s"
+""" % (modname, modtype, desc)
+                list[modtype][modname] = modinfo
+
+print "Version 0"
+for type in list.keys():
+    modlist = list[type].keys()
+    modlist.sort()
+    for m in modlist:
+        print list[type][m]

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux