Bug#70588: modconf: Add autodetection based on libdetect (PATCH provided)
Package: modconf
Version: 0.2.26.14
Severity: wishlist
This rather simple patch provides an extra menu option called
'Autodetect the modules' which uses libdetect in order to automatically
gather the list of needed modules.
This doesn't work (yet) for ISA cards, but it should work well for
reasonable recent (and supported) hardware.
The patch is against modconf-0.2.27.
Stelian.
-----------8<------- cut here --------8<----------------------
diff -uNr modconf-0.2.27.orig/Makefile modconf-0.2.27/Makefile
--- modconf-0.2.27.orig/Makefile Wed Apr 19 21:12:15 2000
+++ modconf-0.2.27/Makefile Tue Aug 29 13:06:12 2000
@@ -2,7 +2,7 @@
LANGS=C cs de eo es fr hr it ja pl sv
EVALTARGETS=$(addprefix eval_, $(LANGS))
-all: modconf.8.gz descr.gz $(EVALTARGETS) #eval.gz
+all: modconf.8.gz descr.gz $(EVALTARGETS) autodetect #eval.gz
install: all
install -d -m 755 $(DESTDIR)/usr/sbin
@@ -12,6 +12,7 @@
install -m 644 modules/dialog $(DESTDIR)/usr/share/modconf
install -m 644 modules/util $(DESTDIR)/usr/share/modconf
install -m 644 modules/params $(DESTDIR)/usr/share/modconf
+ install -m 755 -s autodetect $(DESTDIR)/usr/share/modconf
install -d -m 755 $(DESTDIR)/usr/share/man/man8
install -m 644 modconf.8.gz $(DESTDIR)/usr/share/man/man8
@@ -51,8 +52,12 @@
#eval.gz: eval
# cat eval| sed -e 's/"$$/";/'| gzip -9 >eval.gz
+autodetect: modules/autodetect.c
+ gcc $(CFLAGS) -o modules/autodetect.o -c modules/autodetect.c
+ gcc $(LDFLAGS) -o autodetect modules/autodetect.o /usr/lib/libdetect.a -lisapnp $(LIBS)
+
clean:
- -rm -f debian/*~ *~ descr.gz descr eval.gz modconf.8.gz eval_*
+ -rm -f debian/*~ *~ descr.gz descr eval.gz modconf.8.gz eval_* autodetect modules/autodetect.o
-rm -rf build
.PHONY: count clean
diff -uNr modconf-0.2.27.orig/debian/control modconf-0.2.27/debian/control
--- modconf-0.2.27.orig/debian/control Sat Jan 29 22:21:54 2000
+++ modconf-0.2.27/debian/control Tue Aug 29 12:57:38 2000
@@ -5,7 +5,8 @@
Standards-Version: 3.0.1.1
Package: modconf
-Architecture: all
+Architecture: any
Depends: whiptail, modutils (>= 2.1.85-14)
+Suggests: libdetect0
Description: Device Driver Configuration
Modconf provides a GUI for installing and configuring device driver modules.
diff -uNr modconf-0.2.27.orig/debian/rules modconf-0.2.27/debian/rules
--- modconf-0.2.27.orig/debian/rules Sat Jan 29 22:21:54 2000
+++ modconf-0.2.27/debian/rules Tue Aug 29 13:00:00 2000
@@ -25,6 +25,12 @@
-rm -f build-stamp
binary-indep: checkroot build
+# There are no architecture-independent files to be uploaded
+# generated by this package. If there were any they would be
+# made here.
+ $(checkdir)
+
+binary-arch: checkroot build
$(checkdir)
-rm -rf debian/tmp
make install DESTDIR=`pwd`/debian/tmp
@@ -40,12 +46,6 @@
chown -R root.root debian/tmp
chmod -R go=rX debian/tmp
dpkg --build debian/tmp ..
-
-binary-arch: checkroot build
-# There are no architecture-dependent files to be uploaded
-# generated by this package. If there were any they would be
-# made here.
- $(checkdir)
define checkdir
test -f debian/rules
diff -uNr modconf-0.2.27.orig/modconf modconf-0.2.27/modconf
--- modconf-0.2.27.orig/modconf Sun Aug 6 19:57:09 2000
+++ modconf-0.2.27/modconf Tue Aug 29 13:02:09 2000
@@ -37,6 +37,10 @@
ModuleContentsDir=$2
shift
;;
+ --detectdir)
+ DetectDir=$2
+ shift
+ ;;
--helpdir)
ModuleHelpDir=$2
shift
@@ -89,6 +93,11 @@
echo '"$msg_Exit" "$msg_Finished_these" \' >> $TempFile
echo '" " " " \' >> $TempFile
+ if [ -x $libdir/autodetect ]; then
+ echo '"$msg_Auto" "$msg_Autodetect_modules" \' >> $TempFile
+ echo '" " " " \' >> $TempFile
+ fi
+
for directory in $dir_descrs; do
if [ ! -d $Dir_Prefix/$directory -a $Source = mounted ]; then
continue;
@@ -126,6 +135,9 @@
;;
"$msg_Exit")
return 0;;
+ "$msg_Auto")
+ autodetect_modules
+ ;;
*)
module_directory_menu "$directory" \
"$msg_Select_modules_l" "`eval echo \\\"$msg_Select_modules\\\"`"
@@ -146,6 +158,12 @@
libdir=$Target/usr/share/modconf
else
libdir=/usr/share/modconf
+fi
+
+if [ -d $Target/usr/share/detect ]; then
+ detectdir=$Target/usr/share/detect
+else
+ detectdir=/usr/share/detect
fi
. $libdir/params
diff -uNr modconf-0.2.27.orig/modconf.8 modconf-0.2.27/modconf.8
--- modconf-0.2.27.orig/modconf.8 Sat Jan 29 22:21:53 2000
+++ modconf-0.2.27/modconf.8 Tue Aug 29 13:03:12 2000
@@ -8,6 +8,7 @@
[--source [floppy|mounted]]
[--target destination]
[--libdir path]
+[--detectdir path]
[--restrict-section section]*
[--exclude-section section]*
[--load-before module]*
@@ -43,6 +44,18 @@
and
.I descr.gz
files are to be found on the system (default: /usr/lib/module_help).
+Do not include a trailing "/" after the directory name.
+.TP
+.I \--detectdir path
+Indicates where the libdetect lists
+.I isa.lst
+,
+.I pci.lst
+,
+.I pcmcia.lst
+and
+.I usb.lst
+are to be found on the system (default: /usr/share/detect).
Do not include a trailing "/" after the directory name.
.TP
.I \--restrict-section section*
diff -uNr modconf-0.2.27.orig/modules/autodetect.c modconf-0.2.27/modules/autodetect.c
--- modconf-0.2.27.orig/modules/autodetect.c Thu Jan 1 01:00:00 1970
+++ modconf-0.2.27/modules/autodetect.c Tue Aug 29 13:03:31 2000
@@ -0,0 +1,202 @@
+/*
+ * modconf autodetect.c
+ * Copyright (C) 2000 Stelian Pop, Alcôve
+ *
+ * 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
+ */
+
+#include <limits.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <malloc.h>
+#include <detect.h>
+
+#define ISA_NAME "isa.lst"
+#define PCI_NAME "pci.lst"
+#define PCMCIA_NAME "pcmcia.lst"
+#define USB_NAME "usb.lst"
+
+void detect_found(char *device, char *bus, char *vendor, char *model,
+ char *module, char *options) {
+
+ if ( module != NULL &&
+ strcmp(module, s_ignore) &&
+ strcmp(module, s_not_available) &&
+ strcmp(module, s_none) &&
+ strcmp(module, s_unknown) ) {
+
+ printf("%s\n", module);
+ }
+}
+
+int main(int argc, char *argv[]) {
+
+ struct cards_lst *cards = (struct cards_lst *)NULL;
+ struct bus_lst *bus = (struct bus_lst *)NULL;
+ /* struct cpu_info *cpu = (struct cpu_info *)NULL; */
+ /* struct memory_info *memory = (struct memory_info *)NULL; */
+ struct identf_info *ideinterface = (struct identf_info *)NULL;
+ struct scsintf_info *scsiinterface = (struct scsintf_info *)NULL;
+ struct usbntf_info *usbinterface = (struct usbntf_info *)NULL;
+ /* struct floppy_info *floppy = (struct floppy_info *)NULL; */
+ /* struct disk_info *disk = (struct disk_info *)NULL; */
+ /* struct cdrom_info *cdrom = (struct cdrom_info *)NULL; */
+ /* struct tape_info *tape = (struct tape_info *)NULL; */
+ struct ethernet_info *ethernet = (struct ethernet_info *)NULL;
+ struct modem_info *modem = (struct modem_info *)NULL;
+ struct isdn_info *isdn = (struct isdn_info *)NULL;
+ /* struct video_info *video = (struct video_info *)NULL; */
+ struct tvcard_info *tvcard = (struct tvcard_info *)NULL;
+ struct soundcard_info *sound = (struct soundcard_info *)NULL;
+ /* struct printer_info *printer = (struct printer_info *)NULL; */
+ /* struct scanner_info *scanner = (struct scanner_info *)NULL; */
+ /* struct webcam_info *webcam = (struct webcam_info *)NULL; */
+ /* struct mouse_info *mouse = (struct mouse_info *)NULL; */
+ struct joystick_info *joystick = (struct joystick_info *)NULL;
+ /* struct serial_info *serial = (struct serial_info *)NULL; */
+ /* struct parallel_info *parallel = (struct parallel_info *)NULL; */
+ /* struct gameport_info *gameport = (struct gameport_info *)NULL; */
+ struct others_info *others = (struct others_info *)NULL;
+
+ char isa_lst[PATH_MAX], pci_lst[PATH_MAX],
+ pcmcia_lst[PATH_MAX], usb_lst[PATH_MAX];
+
+ if (argc != 2) {
+ printf("%s: missing lst directory\n", argv[0]);
+ exit(1);
+ }
+
+ snprintf(isa_lst, PATH_MAX, "%s/%s", argv[1], ISA_NAME);
+ isa_lst[PATH_MAX - 1] = '\0';
+ snprintf(pci_lst, PATH_MAX, "%s/%s", argv[1], PCI_NAME);
+ pci_lst[PATH_MAX - 1] = '\0';
+ snprintf(pcmcia_lst, PATH_MAX, "%s/%s", argv[1], PCMCIA_NAME);
+ pcmcia_lst[PATH_MAX - 1] = '\0';
+ snprintf(usb_lst, PATH_MAX, "%s/%s", argv[1], USB_NAME);
+ usb_lst[PATH_MAX - 1] = '\0';
+
+ debug = 0;
+
+ sync();
+
+ cards = init_lst(isa_lst, pci_lst, pcmcia_lst, usb_lst);
+ /*
+ * Normally we should use:
+ * bus = init_bus(cards);
+ * but this calls isa_detect which does not work!
+ */
+ bus = (struct bus_lst *)malloc(sizeof(struct bus_lst));
+ if (!bus)
+ exit(1);
+ bus->pci = pci_detect(cards);
+ bus->pcmcia = pcmcia_detect(cards);
+ bus->usb = usb_detect(cards);
+ bus->ide = ide_detect();
+ bus->scsi = scsi_detect();
+ bus->parallel = parallel_detect();
+ bus->serial = serial_detect(cards);
+
+ ideinterface = ideinterface_detect(bus);
+ for(; ideinterface; ideinterface = ideinterface->next)
+ detect_found(device2str(IDEINTERFACE),
+ bus2str(ideinterface->bus),
+ ideinterface->vendor,
+ ideinterface->model,
+ ideinterface->module,
+ NULL);
+
+ scsiinterface = scsiinterface_detect(bus);
+ for(; scsiinterface; scsiinterface = scsiinterface->next)
+ detect_found(device2str(SCSIINTERFACE),
+ bus2str(scsiinterface->bus),
+ scsiinterface->vendor,
+ scsiinterface->model,
+ scsiinterface->module,
+ NULL);
+
+ usbinterface = usbinterface_detect(bus);
+ for(; usbinterface; usbinterface = usbinterface->next)
+ detect_found(device2str(USBINTERFACE),
+ bus2str(usbinterface->bus),
+ usbinterface->vendor,
+ usbinterface->model,
+ usbinterface->module,
+ NULL);
+
+ ethernet = ethernet_detect(bus);
+ for(; ethernet; ethernet = ethernet->next)
+ detect_found(device2str(ETHERNETCARD),
+ bus2str(ethernet->bus),
+ ethernet->vendor,
+ ethernet->model,
+ ethernet->module,
+ NULL);
+
+ sound = soundcard_detect(bus);
+ for(; sound; sound = sound->next)
+ detect_found(device2str(SOUNDCARD),
+ bus2str(sound->bus),
+ sound->vendor,
+ sound->model,
+ sound->module,
+ options2str(sound->options));
+
+ tvcard = tvcard_detect(bus);
+ for(; tvcard; tvcard = tvcard->next)
+ detect_found(device2str(TVCARD),
+ bus2str(tvcard->bus),
+ tvcard->vendor,
+ tvcard->model,
+ tvcard->module,
+ NULL);
+
+ joystick = joystick_detect(bus);
+ for(; joystick; joystick = joystick->next)
+ detect_found(device2str(JOYSTICK),
+ bus2str(joystick->bus),
+ joystick->vendor,
+ joystick->model,
+ joystick->module,
+ NULL);
+
+ modem = modem_detect(bus);
+ for(; modem; modem = modem->next)
+ detect_found(device2str(MODEM),
+ bus2str(modem->bus),
+ modem->vendor,
+ modem->model,
+ modem->module,
+ NULL);
+
+ isdn = isdn_detect(bus);
+ for(; isdn; isdn = isdn->next)
+ detect_found(device2str(ISDN),
+ bus2str(isdn->bus),
+ isdn->vendor,
+ isdn->model,
+ isdn->module,
+ NULL);
+
+ others = others_detect(bus);
+ for(; others; others=others->next)
+ detect_found(device2str(OTHERS),
+ bus2str(others->bus),
+ others->vendor,
+ others->model,
+ others->module,
+ NULL);
+
+ return 0;
+}
diff -uNr modconf-0.2.27.orig/modules/util modconf-0.2.27/modules/util
--- modconf-0.2.27.orig/modules/util Thu Aug 10 10:12:06 2000
+++ modconf-0.2.27/modules/util Tue Aug 29 13:04:41 2000
@@ -530,3 +530,66 @@
update_modules
}
+
+autodetect_modules () {
+ local detect_list1 detect_list2 detect_list3
+ local allmodules module i j result
+
+ # We first build the list of all the detected modules...
+ detect_list1=`$libdir/autodetect $detectdir`
+
+ # We need to remove those who are not present on this system
+ # because the module was not build
+ allmodules=""
+ if [ "$Source" = "floppy" ]; then
+ for i in $dir_descrs; do
+ eval "module=$`echo dir_content_$i`"
+ allmodules="$allmodules $module"
+ done
+ else
+ allmodules=`echo $Dir_Prefix/*/*.o`
+ fi
+ detect_list2=""
+ for i in $detect_list1; do
+ result=""
+ for j in $allmodules; do
+ module=$(basemodulename $j)
+ case "$module" in
+ $i*)
+ result=$module
+ break
+ ;;
+ esac
+ done
+ if [ "$result" != "" ]; then
+ detect_list2="$detect_list2 $result"
+ fi
+ done
+
+ # We need to remove now those who are already installed
+ detect_list3=""
+ build_lists
+ for i in $detect_list2; do
+ if ! module_is_installed $i; then
+ detect_list3="$detect_list3 $i"
+ fi
+ done
+
+ # Did we have any module remaining on the list now ?
+ if [ "$detect_list3" = "" ]; then
+ msgBox "$msg_Autodetect_nothing" "$msg_Problem"
+ else
+ msgBox "$detect_list3" "$msg_Autodetect_list"
+ if yesNoBox "$msg_Autodetect_installall" "$msg_Install"; then
+ for i in $detect_list3; do
+ install_module "$i"
+ done
+ else
+ for i in $detect_list3; do
+ if yesNoBox "$msg_Install_l" "$i"; then
+ install_module "$i"
+ fi
+ done
+ fi
+ fi
+}
diff -uNr modconf-0.2.27.orig/template/eval_C.fixed modconf-0.2.27/template/eval_C.fixed
--- modconf-0.2.27.orig/template/eval_C.fixed Sun Aug 6 22:34:06 2000
+++ modconf-0.2.27/template/eval_C.fixed Tue Aug 29 13:05:11 2000
@@ -84,6 +84,12 @@
dir_descr_scsi="Drivers for SCSI controller cards and classes of SCSI devices"
dir_descr_video="Drivers for Video4Linux"
+msg_Auto="Auto"
+msg_Autodetect_modules="Autodetect the modules"
+msg_Autodetect_list="These modules were autodetected:"
+msg_Autodetect_nothing="No module was autodetected"
+msg_Autodetect_installall="Install all those modules?"
+
# This module gets four different names otherwise
summary_sb="100% Sound Blaster compatibles (SB16/32/64, ESS, Jazz16) support"
diff -uNr modconf-0.2.27.orig/template/eval_fr.fixed modconf-0.2.27/template/eval_fr.fixed
--- modconf-0.2.27.orig/template/eval_fr.fixed Sun Aug 6 22:29:51 2000
+++ modconf-0.2.27/template/eval_fr.fixed Tue Aug 29 13:05:43 2000
@@ -259,3 +259,9 @@
dir_descr_net="Pilotes pour les carte d'interface réseau et protocoles réseaux"
dir_descr_pcmcia="Cartes PCMCIA"
dir_descr_scsi="Pilotes des cartes SCSI et des classes de périphériques SCSI"
+
+msg_Auto="Auto"
+msg_Autodetect_modules="Autodetection des modules"
+msg_Autodetect_list="Ces modules ont été autodetectés:"
+msg_Autodetect_nothing="Aucun module n'a été autodetecté"
+msg_Autodetect_installall="Installer tous ces modules?"
-----------8<------- cut here --------8<----------------------
-- System Information
Debian Release: 2.2
Kernel Version: Linux wiliam 2.2.14 #1 SMP Mon Jan 17 20:56:03 CET 2000 i686 unknown
Versions of the packages modconf depends on:
ii modutils 2.3.11-6 Linux module utilities.
ii whiptail 0.50-7 Displays user-friendly dialog boxes from she
Reply to: