public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] new bug report script
@ 2001-01-07  7:48 Matthias Juchem
  2001-01-07  7:56 ` Ulrich Drepper
  2001-01-07 13:58 ` Alan Cox
  0 siblings, 2 replies; 25+ messages in thread
From: Matthias Juchem @ 2001-01-07  7:48 UTC (permalink / raw)
  To: alan; +Cc: linux-kernel

Hi Alan,

could you please consider this patch for inclusion in your tree?

This is a patch against 2.4.0. It introduces a new bug reporting script
(scripts/bugreport.pl) that tries to simplify bug reporting for users. I
have also added a small hint to this script to REPORTING-BUGS.

To all: Please have a look at the script and give me your feedback so that
I can fix the errors and improve the script.

Kind regards,
 Matthias


diff -urN linux-2.4.0-vanilla/REPORTING-BUGS linux-2.4.0-mod/REPORTING-BUGS
--- linux-2.4.0-vanilla/REPORTING-BUGS	Mon Aug 21 17:57:35 2000
+++ linux-2.4.0-mod/REPORTING-BUGS	Sun Jan  7 08:20:21 2001
@@ -25,7 +25,16 @@
 overlook things, and easier for the developers to find the pieces of
 information they're really interested in. Don't feel you have to follow it.

-   First run the ver_linux script included as scripts/ver_linux or
+There are two possibilities:
+ a) use the new problem reporting script
+ b) collect the information and write the report by hand
+
+a)  The problem reporting script resides under scripts/bugreport.pl
+Use it like this: "perl bugreport.pl filename", where filename is where the
+report is written to. This results (hopefully) in a usable problem report that
+you can add additional info to.
+
+b)  First run the ver_linux script included as scripts/ver_linux or
 at <URL:ftp://ftp.sai.msu.su/pub/Linux/ver_linux> It checks out
 the version of some important subsystems.  Run it with the command
 "sh scripts/ver_linux"
diff -urN linux-2.4.0-vanilla/scripts/bugreport.pl linux-2.4.0-mod/scripts/bugreport.pl
--- linux-2.4.0-vanilla/scripts/bugreport.pl	Thu Jan  1 01:00:00 1970
+++ linux-2.4.0-mod/scripts/bugreport.pl	Sun Jan  7 08:23:13 2001
@@ -0,0 +1,401 @@
+#!/usr/bin/perl -w
+
+# bugreport.pl
+# created by Matthias Juchem <matthias@brightice.de> Januar 2001
+#
+# collects system information and tries to help with generating bug
+# reports for linux-kernel
+# - prompts for general information about the problem
+# - acquires system information from various programs and from /proc
+# - runs the oops through ksymoops
+#
+# For notes view bottom of file
+
+use strict;
+use FileHandle;
+use IPC::Open2;
+
+##################### variables ##############################################
+
+# bug report
+my $summary;         my $description;  my $keywords;
+my $oops;            my $other_notes;  my $example;
+
+# program versions
+my $v_kernel;        my $v_gcc;        my $v_modules;
+my $v_make;          my $v_binutils;   my $v_libc5;
+my $v_libc6;         my $v_libcpp;     my $v_ldd;
+my $v_procps;        my $v_procinfo;   my $v_psmisc;
+my $v_mount;         my $v_nettools;   my $v_pppd;
+my $v_kbd;           my $v_shutils;    my $v_utillinux;
+my $v_e2fsprogs;     my $v_bash;
+
+# other sys info
+my $loaded_modules;  my $cpuinfo;      my $iomem;
+my $ioports;         my $scsi;         my $pci;
+
+##################### forward declarations ###################################
+
+sub init();          # get system info to initialize variables with
+sub enter_report();  # gather information about bug
+sub print_report($); # parameter: filename for output
+sub getline($$);     # read a line from STDIN, params: prompt, default value
+sub gettext($);      # read multiple lines from STDIN, param: prompt
+sub readfile($);     # returna content of file one line, param: filename
+sub exists_prog($);  # returns full path of programm or empty string
+
+##################### main ###################################################
+
+{
+    print "\nbugreport.pl - Linux Kernel Problem Report Generator v0.1\n";
+    print "=========================================================\n";
+    print "       written by Matthias Juchem <matthias\@brightice.de>\n\n";
+
+    # check euid
+    if ( $> != 0 ) {
+	print "\nThis script should be run as root.\n\n";
+	exit 1;
+    }
+
+    # check output filename
+    my $filename;
+    if ( not ( $filename = shift )) {
+	print "\nPlease specify a file for output.\n\n";
+	exit 2;
+    }
+
+    init();
+    enter_report();
+    print_report($filename);
+
+    print <<"EOF";
+Please spend a few minutes on reading the generated problem report, check the
+version string that look strange and include further information as you like.
+
+If you think the report is good, send it to the maintainer (see MAINTAINERS)
+of the corresponding subsystem and a copy to <linux-kernel\@vger.kernel.org>.
+
+Any bug reports and comments _for_this_script_ go to <matthias\@brightice.de>.
+Thank you.
+
+EOF
+
+}
+
+##################### subroutines ############################################
+
+sub print_report($) {
+    my $fn = shift;
+
+    print( "\nPlease wait while the report is being generated and written to",
+	   " the specified\nfile (",$fn,")...\n" );
+    # run the oops through ksymoops
+    if ( exists_prog("ksymoops") ) {
+        #open2( \*READER, \*WRITER, "ksymoops -V -k /proc/ksyms -l /proc/modules -o /lib/modules/2.4.0/ -m /usr/src/linux/System.map" );
+	open2( \*READER, \*WRITER, "ksymoops" );
+	WRITER->autoflush();
+	my @output;
+	print WRITER $oops;
+	close WRITER;
+	@output = <READER>;
+	close READER;
+	$oops = join ' ', @output;
+    } else {
+	$oops = "ksymoops not found";
+    }
+
+    open OUTPUT, ">$fn";
+    print OUTPUT <<"EOF";
+Linux Kernel Problem Report
+==============================================================================
+1. One line summary of the problem
+----------------------------------------------
+$summary
+
+2. Full description of the problem
+----------------------------------------------
+$description
+
+3. Keywords
+----------------------------------------------
+$keywords
+
+4. Kernel version
+----------------------------------------------
+$v_kernel
+
+5. Oops message with symbolic info
+----------------------------------------------
+$oops
+
+6. Example that triggers the problem
+----------------------------------------------
+$example
+
+7. System information
+----------------------------------------------
+a) software
+ GNU C                  $v_gcc
+ Modutils               $v_modules
+ GNU make               $v_make
+ Binutils               $v_binutils
+ Linux libc5 C Library  $v_libc5
+ Linux libc6 C Library  $v_libc6
+ Dynamic linker         $v_ldd
+ Linux C++ library      $v_libcpp
+ Procps                 $v_procps
+ Procinfo               $v_procinfo
+ Psmisc                 $v_psmisc
+ Net-tools              $v_nettools
+ PPP                    $v_pppd
+ Kdb                    $v_kbd
+ Sh-utils               $v_shutils
+ Util-linux             $v_utillinux
+ E2fsprogs              $v_e2fsprogs
+ Bash                   $v_bash
+
+b) loaded modules
+$loaded_modules
+
+c) /proc/cpuinfo
+$cpuinfo
+
+d) /proc/ioports
+$ioports
+
+e) /proc/iomem
+$iomem
+
+f) PCI information
+$pci
+
+g) SCSI information
+$scsi
+
+h) further information (from /proc and other)
+
+8. Other notes, patches, fixes, workarounds...
+----------------------------------------------
+$other_notes
+EOF
+
+    print "   ...ok, done.\n\n\n";
+
+    close OUTPUT;
+}
+
+sub init() {
+    # gcc
+    if (exists_prog("gcc")) {
+	( $v_gcc = `gcc --version` ) =~ s/\n+$//;
+    } else {
+	$v_gcc = "not found";
+    }
+
+    # modules
+    if (exists_prog("insmod")) {
+	( $v_modules = `insmod -V 2>&1` ) =~ m/insmod version (\S+)/;
+	$v_modules = $1;
+    } else {
+	$v_modules = "not found";
+    }
+
+    # make
+    if (exists_prog("make")) {
+	( $v_make = `make --version` ) =~ m/GNU Make version (\S+),/;
+	$v_make = $1;
+    } else {
+	$v_make = "not found";
+    }
+
+    # binutils
+    if (exists_prog("ld")) {
+	( $v_binutils = `ld -v` ) =~ m/\(with BFD (\S+)\)/;
+	$v_binutils = $1;
+    } else {
+	$v_binutils = "not found";
+    }
+
+    # c library 5
+    if ( -e "/lib/libc.so.5" ) {
+	( $v_libc5 = `/lib/libc.so.5`) =~ m/GNU C Library .+ version (\S+),/;
+	$v_libc5 = $1;
+    } else {
+	$v_libc5 = "not found";
+    }
+
+    # c library 6
+    if ( -e "/lib/libc.so.6" ) {
+	( $v_libc6 = `/lib/libc.so.6`) =~ m/GNU C Library .+ version (\S+),/;
+	$v_libc6 = $1;
+    } else {
+	$v_libc6 = "not found";
+    }
+
+    # ldd
+    if (exists_prog("ldd")) {
+	( $v_ldd = `ldd --version` ) =~ m/ldd \(GNU libc\) (\S+)/;
+	$v_ldd = $1;
+    } else {
+	$v_ldd = "not found";
+    }
+
+    # c++ library
+    ( $v_libcpp = `ls /usr/lib/libg++.so.*` ) =~ m/.so.(\S+)\n/;
+    $v_libcpp = $1;
+
+    # procps
+    if (exists_prog("ps")) {
+	( $v_procps = `ps --version` ) =~ m/version (\S+)\n/;
+	$v_procps = $1;
+    } else {
+	$v_procps = "not found";
+    }
+
+    # procinfo
+    if ( exists_prog("procinfo") ) {
+	( $v_procinfo = `procinfo -v` ) =~ m/version (\S+) /;
+	$v_procinfo = $1;
+    } else {
+	$v_procinfo = "not found";
+    }
+
+    # psmisc
+    if (exists_prog("pstree")) {
+	( $v_psmisc = `pstree -V 2>&1` ) =~ m/version (\S+)\n/;
+	$v_psmisc = $1;
+    } else {
+	$v_psmisc = "not found";
+    }
+
+    # util-linux
+    ( $v_utillinux = `mount --version` ) =~ m/mount-(\S+)\n/;
+    $v_utillinux = $1;
+
+    # nettools
+    ( $v_nettools = `hostname -V 2>&1` ) =~ m/tools (\S+)\n/;
+    $v_nettools = $1;
+
+    # pppd
+    ( $v_pppd = `pppd -V 2>&1`) =~ m/pppd version (\S+)\n/;
+    $v_pppd = $1;
+
+    # kbd
+    ( $v_kbd = `loadkeys -h 2>&1`) =~ m/loadkeys version (\S+)\n/;
+    $v_kbd = $1;
+
+    # shutils
+    ( $v_shutils = `expr --v 2>&1`) =~ m/\(GNU sh-utils\) (\S+)\n/;
+    $v_shutils = $1;
+
+    # e2fsprogs
+    ( $v_e2fsprogs = `tune2fs 2>&1`) =~ m/tune2fs (\S+),/;
+    $v_e2fsprogs = $1;
+
+    # bash
+    ( $v_bash = `bash --version`) =~ m/GNU bash, version (\S+) /;
+    $v_bash = $1;
+
+
+    # loaded modules
+    ( $loaded_modules = readfile( "/proc/modules") ) =~ s/ .*$|\n$//mg;
+    $loaded_modules =~ s/\n/ /g;
+
+    # pci info
+    if ( exists_prog("lspci") ) {
+	chomp ( $pci = join '', `lspci -vvv` );
+    } else {
+	$pci = "not found";
+    }
+
+    # /proc: cpuinfo, iomem, ioports, version, scsi
+    $cpuinfo = readfile("/proc/cpuinfo");
+    $iomem   = readfile("/proc/iomem");
+    $ioports = readfile("/proc/ioports");
+    $v_kernel= readfile("/proc/version");
+    $scsi    = readfile("/proc/scsi/scsi");
+}
+
+sub enter_report() {
+    $summary     = getline( "One line summary of the problem", "" );
+    $description = gettext( "Full description of the problem" );
+    $keywords    = getline( "Keywords", "modules, vm" );
+    $oops        = gettext( "Oops message" );
+    $example     = gettext( "Example that triggers the problem" );
+    $other_notes = gettext( "Other notes, patches, fixes, ..." );
+}
+
+sub getline($$) {
+    my $prompt =shift;
+    my $default=shift;
+    my $result ='';
+
+    while ( $result eq "" ) {
+	print $prompt, " [$default]: ";
+	$result = <STDIN>;
+	chomp $result;
+	if ($result eq "" ) {
+	    $result = $default;
+	}
+    }
+    return $result;
+}
+
+sub gettext($) {
+    my $prompt =shift;
+    my $result ='';
+
+    print "\n";
+    while ( $result eq "" ) {
+	print $prompt, " (use EOF after last line): \n";
+	while (<STDIN>) {
+	    m/^EOF$/ and last;
+	    $result = $result.$_
+	}
+	chomp $result;
+    }
+    return $result;
+}
+
+sub readfile($) {
+    my $fname  = shift;
+    my $result = '';
+
+    if ( -f $fname ) {
+	open FH, "<$fname" or die "unable to open $fname";
+	while (<FH>) {
+	    $result = $result.$_;
+	}
+	close FH;
+	chomp $result;
+    } else {
+	$result = "not found";
+    }
+    return $result;
+}
+
+sub exists_prog($) {
+    my $prog  = shift;
+    my $found = 0;
+    my $result= '';
+
+    foreach my $dir (split /:/, $ENV{'PATH'} ) {
+	$found and last;
+	$result = $dir.'/'.$prog;
+	( -e $result ) and $found = 1;
+    }
+    $found or $result = '';
+    return $result;
+}
+
+__END__
+
+01/07/2001
+-This script needs testing. I have tested it on SuSE 7.0 (updated to 2.4.0)
+ and on Mandrake 6.1, so there might be small problems with other
+ distributions.
+-The script assumes that all called programs are in the path. If a program is
+ not found, 'not found' is printed in the problem report.
+-ksymoops uses the default parameters. If the kernel and the modules are
+ installed or compiled in different locations, there certainly are problems
+ with ksymoops. This is going to be fixed.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-07  7:48 [PATCH] new bug report script Matthias Juchem
@ 2001-01-07  7:56 ` Ulrich Drepper
  2001-01-07  8:01   ` Matthias Juchem
  2001-01-07  9:00   ` [PATCH] " Matthias Juchem
  2001-01-07 13:58 ` Alan Cox
  1 sibling, 2 replies; 25+ messages in thread
From: Ulrich Drepper @ 2001-01-07  7:56 UTC (permalink / raw)
  To: Matthias Juchem; +Cc: alan, linux-kernel

Matthias Juchem <matthias@gandalf.math.uni-mannheim.de> writes:

> +    # c library 5
> +    if ( -e "/lib/libc.so.5" ) {
> +	( $v_libc5 = `/lib/libc.so.5`) =~ m/GNU C Library .+ version (\S+),/;
> +	$v_libc5 = $1;
> +    } else {
> +	$v_libc5 = "not found";
> +    }

This is wrong.  You cannot execute libc.so.5.  This only works with
glibc.

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-07  7:56 ` Ulrich Drepper
@ 2001-01-07  8:01   ` Matthias Juchem
  2001-01-07  8:16     ` Ulrich Drepper
  2001-01-07  9:43     ` Brett
  2001-01-07  9:00   ` [PATCH] " Matthias Juchem
  1 sibling, 2 replies; 25+ messages in thread
From: Matthias Juchem @ 2001-01-07  8:01 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: linux-kernel

On 6 Jan 2001, Ulrich Drepper wrote:

> This is wrong.  You cannot execute libc.so.5.  This only works with
> glibc.

I already thought of something like that (I was not able to test it...).
Can you tell me a reliable way to get the version other than just looking
for the version appended to the file name?
Or is the file name scheme reliable (/lib/libc.so.5.x.y)?

Regards,
 Matthias

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-07  8:01   ` Matthias Juchem
@ 2001-01-07  8:16     ` Ulrich Drepper
  2001-01-07 13:42       ` Paul Gortmaker
  2001-01-07  9:43     ` Brett
  1 sibling, 1 reply; 25+ messages in thread
From: Ulrich Drepper @ 2001-01-07  8:16 UTC (permalink / raw)
  To: Matthias Juchem; +Cc: linux-kernel

Matthias Juchem <matthias@gandalf.math.uni-mannheim.de> writes:

> Or is the file name scheme reliable (/lib/libc.so.5.x.y)?

Yes, since this was how HJ named the releases.  You have to find out
which version is actually used (there might be several .so files
there).

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH] Re: [PATCH] new bug report script
  2001-01-07  7:56 ` Ulrich Drepper
  2001-01-07  8:01   ` Matthias Juchem
@ 2001-01-07  9:00   ` Matthias Juchem
  2001-01-07  9:06     ` Ulrich Drepper
  1 sibling, 1 reply; 25+ messages in thread
From: Matthias Juchem @ 2001-01-07  9:00 UTC (permalink / raw)
  To: alan; +Cc: linux-kernel, Ulrich Drepper

Hi Alan.

My previous patch contained a few bugs (i.e. libc5 was not found). Here is
a patch that depends on the previous one.

Regards,
 Matthias

On 6 Jan 2001, Ulrich Drepper wrote:
> This is wrong.  You cannot execute libc.so.5.
[..]


--- scripts/bugreport.pl.orig	Sun Jan  7 09:57:42 2001
+++ scripts/bugreport.pl	Sun Jan  7 09:58:11 2001
@@ -47,7 +47,7 @@
 ##################### main ###################################################

 {
-    print "\nbugreport.pl - Linux Kernel Problem Report Generator v0.1\n";
+    print "\nbugreport.pl - Linux Kernel Problem Report Generator v0.2\n";
     print "=========================================================\n";
     print "       written by Matthias Juchem <matthias\@brightice.de>\n\n";

@@ -217,12 +217,14 @@
     }

     # c library 5
-    if ( -e "/lib/libc.so.5" ) {
-	( $v_libc5 = `/lib/libc.so.5`) =~ m/GNU C Library .+ version (\S+),/;
-	$v_libc5 = $1;
-    } else {
-	$v_libc5 = "not found";
+    opendir LIBDIR, "/lib" or die "/lib/ not found, very strange";
+    my @allfiles = readdir LIBDIR;
+    closedir LIBDIR;
+    $v_libc5 = 'not found';
+    foreach (sort @allfiles) {
+	m/libc.so.(5\S+)/ and $v_libc5 = $1;
     }
+    closedir LIBDIR;

     # c library 6
     if ( -e "/lib/libc.so.6" ) {
@@ -269,32 +271,60 @@
     }

     # util-linux
-    ( $v_utillinux = `mount --version` ) =~ m/mount-(\S+)\n/;
-    $v_utillinux = $1;
+    if (exists_prog("mount")) {
+	( $v_utillinux = `mount --version` ) =~ m/mount-(\S+)\n/;
+	$v_utillinux = $1;
+    } else {
+	$v_utillinux = "not found";
+    }

     # nettools
-    ( $v_nettools = `hostname -V 2>&1` ) =~ m/tools (\S+)\n/;
-    $v_nettools = $1;
+    if (exists_prog("hostname")) {
+	( $v_nettools = `hostname -V 2>&1` ) =~ m/tools (\S+)\n/;
+	$v_nettools = $1;
+    } else {
+	$v_nettools = "not found";
+    }

     # pppd
-    ( $v_pppd = `pppd -V 2>&1`) =~ m/pppd version (\S+)\n/;
-    $v_pppd = $1;
+    if (exists_prog("pppd")) {
+	( $v_pppd = `pppd --version /dev/tty 2>&1`) =~ m/pppd version (\S+)/;
+	$v_pppd = $1;
+    } else {
+	$v_pppd = "not found";
+    }

     # kbd
-    ( $v_kbd = `loadkeys -h 2>&1`) =~ m/loadkeys version (\S+)\n/;
-    $v_kbd = $1;
+    if (exists_prog("loadkeys")) {
+	( $v_kbd = `loadkeys -h 2>&1`) =~ m/loadkeys version (\S+)\n/;
+	$v_kbd = $1;
+    } else {
+	$v_kbd = "not found";
+    }

     # shutils
-    ( $v_shutils = `expr --v 2>&1`) =~ m/\(GNU sh-utils\) (\S+)\n/;
-    $v_shutils = $1;
+    if (exists_prog("expr")) {
+	( $v_shutils = `expr --v 2>&1`) =~ m/\(GNU sh-utils\) (\S+)\n/;
+	$v_shutils = $1;
+    } else {
+	$v_shutils = "not found";
+    }

     # e2fsprogs
-    ( $v_e2fsprogs = `tune2fs 2>&1`) =~ m/tune2fs (\S+),/;
-    $v_e2fsprogs = $1;
+    if (exists_prog("tune2fs")) {
+	( $v_e2fsprogs = `tune2fs 2>&1`) =~ m/tune2fs (\S+),/;
+	$v_e2fsprogs = $1;
+    } else {
+	$v_e2fsprogs = "not found";
+    }

     # bash
-    ( $v_bash = `bash --version`) =~ m/GNU bash, version (\S+) /;
-    $v_bash = $1;
+    if (exists_prog("bash")) {
+	( $v_bash = `bash --version`) =~ m/GNU bash, version (\S+) /;
+	$v_bash = $1;
+    } else {
+	$v_bash = "not found";
+    }


     # loaded modules

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] Re: [PATCH] new bug report script
  2001-01-07  9:00   ` [PATCH] " Matthias Juchem
@ 2001-01-07  9:06     ` Ulrich Drepper
  2001-01-07  9:19       ` Matthias Juchem
  2001-01-07 12:38       ` Matthias Juchem
  0 siblings, 2 replies; 25+ messages in thread
From: Ulrich Drepper @ 2001-01-07  9:06 UTC (permalink / raw)
  To: Matthias Juchem; +Cc: alan, linux-kernel

Matthias Juchem <matthias@gandalf.math.uni-mannheim.de> writes:

>      # c library 5
> -    if ( -e "/lib/libc.so.5" ) {
> -	( $v_libc5 = `/lib/libc.so.5`) =~ m/GNU C Library .+ version (\S+),/;
> -	$v_libc5 = $1;
> -    } else {
> -	$v_libc5 = "not found";
> +    opendir LIBDIR, "/lib" or die "/lib/ not found, very strange";
> +    my @allfiles = readdir LIBDIR;
> +    closedir LIBDIR;
> +    $v_libc5 = 'not found';
> +    foreach (sort @allfiles) {
> +	m/libc.so.(5\S+)/ and $v_libc5 = $1;
>      }
> +    closedir LIBDIR;

This won't work everywhere either.  Red Hat systems (maybe others)
have libc5 out of the way in a separate subdir.  Your best bet is to
use ldconfig:

  /sbin/ldconfig -p|grep libc.so.5

which produces something like

          libc.so.5 (libc5) => /usr/i486-linux-libc5/lib/libc.so.5

and then look in that directory (/usr/i486-linux-libc5/lib).

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] Re: [PATCH] new bug report script
  2001-01-07  9:06     ` Ulrich Drepper
@ 2001-01-07  9:19       ` Matthias Juchem
  2001-01-07 12:38       ` Matthias Juchem
  1 sibling, 0 replies; 25+ messages in thread
From: Matthias Juchem @ 2001-01-07  9:19 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: linux-kernel

On 7 Jan 2001, Ulrich Drepper wrote:

> have libc5 out of the way in a separate subdir.  Your best bet is to
> use ldconfig:
>
>   /sbin/ldconfig -p|grep libc.so.5
>

Hmm, ok. Well, I was reading the Changes document when doing this first
and did not use my head. This document advises to deduct the version
number from 'ls -l /lib/libc*'.

I will fix this so that ldconfig is used for the libraries. That
would be the best.

BTW, can you tell me what the console-tools are? They are checked in the
ver_linux script but I have never heard of them. Are they a replacement
for kbd?

Furthermore, is the name of RedHat's gcc for the kernel always 'kgcc'?

TIA,
 Matthias

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-07  8:01   ` Matthias Juchem
  2001-01-07  8:16     ` Ulrich Drepper
@ 2001-01-07  9:43     ` Brett
  2001-01-07  9:44       ` Matthias Juchem
  2001-01-07 11:16       ` Kurt Roeckx
  1 sibling, 2 replies; 25+ messages in thread
From: Brett @ 2001-01-07  9:43 UTC (permalink / raw)
  To: Matthias Juchem; +Cc: Ulrich Drepper, linux-kernel

On Sun, 7 Jan 2001, Matthias Juchem wrote:

> On 6 Jan 2001, Ulrich Drepper wrote:
> 
> > This is wrong.  You cannot execute libc.so.5.  This only works with
> > glibc.
> 
> I already thought of something like that (I was not able to test it...).
> Can you tell me a reliable way to get the version other than just looking
> for the version appended to the file name?
> Or is the file name scheme reliable (/lib/libc.so.5.x.y)?
> 

Taking a guess here....

strings /lib/libc* | grep "release version"

I'm not sure how reliable this method is either :)

	/ Brett

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-07  9:43     ` Brett
@ 2001-01-07  9:44       ` Matthias Juchem
  2001-01-07 11:21         ` David Ford
  2001-01-07 11:16       ` Kurt Roeckx
  1 sibling, 1 reply; 25+ messages in thread
From: Matthias Juchem @ 2001-01-07  9:44 UTC (permalink / raw)
  To: Brett; +Cc: linux-kernel

On Sun, 7 Jan 2001, Brett wrote:

> Taking a guess here....
>
> strings /lib/libc* | grep "release version"
>
> I'm not sure how reliable this method is either :)
>

I guess if you use a development version the above returns nothing. If I'm
right, a pre-release libc was recommended for use with 2.2.0 (I'm not
sure).

Matthias

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-07  9:43     ` Brett
  2001-01-07  9:44       ` Matthias Juchem
@ 2001-01-07 11:16       ` Kurt Roeckx
  1 sibling, 0 replies; 25+ messages in thread
From: Kurt Roeckx @ 2001-01-07 11:16 UTC (permalink / raw)
  To: Brett; +Cc: Matthias Juchem, Ulrich Drepper, linux-kernel

On Sun, Jan 07, 2001 at 08:43:12PM +1100, Brett wrote:
> 
> Taking a guess here....
> 
> strings /lib/libc* | grep "release version"
> 
> I'm not sure how reliable this method is either :)

That returns nothing here.

I do find this in it:
"@(#) The Linux C library 5.4.46"


Kurt

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-07  9:44       ` Matthias Juchem
@ 2001-01-07 11:21         ` David Ford
  0 siblings, 0 replies; 25+ messages in thread
From: David Ford @ 2001-01-07 11:21 UTC (permalink / raw)
  To: Matthias Juchem; +Cc: Brett, linux-kernel

On Sun, 7 Jan 2001, Matthias Juchem wrote:
> I guess if you use a development version the above returns nothing. If I'm
> right, a pre-release libc was recommended for use with 2.2.0 (I'm not
> sure).

Here is a random idea.

get the pathname of the library(ies) then this sed expression:

sed \
 '/C [lL]ibrary /!d; s/[^0-9]*\([0-9.]*\).*/\1/' \
 /lib/libc.so.6

For me it returns either 5.4.46 or 2.2 depending on what filename is fed to it.


exp: the first regexp heavily filters the input data for the second so
significantly less cpu is spent for the real matching.

/C [lL]ibrary /!d  -- match example: "C Library "

match #1:	[^0-9]*
  match everything until we hit a digit
match #2:	\([0-9.]*\)
  match all digits and '.' and use pattern space #1
match #3:	.*
  match the remainder

We're left with pattern space #1 holding the assumed library version number.

This is done with sed version GNU 3.02.80, some versions differ, buyer beware.

$ sed '/C [lL]ibrary /!d; s/[^0-9]*\([0-9.]*\).*/\1/' /lib/libc.so.6
2.2
$ sed '/C [lL]ibrary /!d; s/[^0-9]*\([0-9.]*\).*/\1/' /lib/libc.so.5
5.4.46
$ 


-d

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] Re: [PATCH] new bug report script
  2001-01-07  9:06     ` Ulrich Drepper
  2001-01-07  9:19       ` Matthias Juchem
@ 2001-01-07 12:38       ` Matthias Juchem
  1 sibling, 0 replies; 25+ messages in thread
From: Matthias Juchem @ 2001-01-07 12:38 UTC (permalink / raw)
  To: Ulrich Drepper, David Ford; +Cc: linux-kernel

Hi there,

what do you think of this fragment ?
to me, it looks sort of large, but I wanted to cover all cases..
i'm going to optimize it a little bit.


    $v_libc5 = '';
    $v_libc6 = '';

    # first, find the path of the concerning lib with the highest version
    if ( exists_prog("ldconfig") ) {
	my @ldc_out = `ldconfig -p`;
	my $found=0;
	foreach ( sort @ldc_out) {
	    m/libc\.so\.5|libc\.so\.6/ or next;
	    s/^.* \=\> //;   # i do not want the first part
	    chomp;
	    if ( m/libc\.so\.5/ ) {
		$v_libc5 = $_;
		$found = $found | 1;
	    }
	    if ( m/libc\.so\.6/ ) {
		$v_libc6 = $_;
		$found = $found | 2;
	    }
	}
	if ( ($found)%2==0 ) {
	    # path for libc5 found, extract directory name
	    my @tokens = split /\//, $v_libc5;
	    pop @tokens;
	    $v_libc5 = join '/', @tokens;
	    opendir LIBDIR, $v_libc5;
	    my @allfiles = readdir LIBDIR;
	    closedir LIBDIR;
	    $v_libc5 = 'not found';
	    foreach (sort @allfiles) {
		m/libc.so.(5\S+)/ and $v_libc5 = $1;
	    }
	} else {
	    $v_libc5 = 'not found';
	}
	if ( ($found>>1)%2==1 ) {
	    # $v_libc6 should now contain the path of the lib file
	    if (-e $v_libc6) { # is it executable ?
		$v_libc6 = `$v_libc6`;
	    } elsif ( exists_prog("strings") ) {
		$v_libc6 = `strings $v_libc6`;
	    } else  {
		$v_libc6 = 'not found';
	    }
	    $v_libc6 =~ s/.*C [lL]ibrary.+version (\S+),.*/\1/s or
		$v_libc6 = 'not found';
	} else {
	    $v_libc6 = 'not found';
	}
    } else {
	$v_libc5 = 'not found';
	$v_libc6 = 'not found';
    }




-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-07  8:16     ` Ulrich Drepper
@ 2001-01-07 13:42       ` Paul Gortmaker
  2001-01-07 13:52         ` Matthias Juchem
  0 siblings, 1 reply; 25+ messages in thread
From: Paul Gortmaker @ 2001-01-07 13:42 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Matthias Juchem, linux-kernel

Ulrich Drepper wrote:
> 
> Matthias Juchem <matthias@gandalf.math.uni-mannheim.de> writes:
> 
> > Or is the file name scheme reliable (/lib/libc.so.5.x.y)?
> 
> Yes, since this was how HJ named the releases.  You have to find out
> which version is actually used (there might be several .so files
> there).

Can also do:

$ strings /lib/libc.so.5|grep Linux
@(#) The Linux C library 5.4.33
$ 

BTW, people have a nasty habit of tacking their entire .config file
onto bug reports to linux-kernel.  Can you mention "grep ^C .config"
somewhere in there (or have the script do it) since the number of
config options isn't going to decrease anytime soon...

Paul.


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-07 13:42       ` Paul Gortmaker
@ 2001-01-07 13:52         ` Matthias Juchem
  0 siblings, 0 replies; 25+ messages in thread
From: Matthias Juchem @ 2001-01-07 13:52 UTC (permalink / raw)
  To: Paul Gortmaker; +Cc: linux-kernel

On Sun, 7 Jan 2001, Paul Gortmaker wrote:

> BTW, people have a nasty habit of tacking their entire .config file
> onto bug reports to linux-kernel.  Can you mention "grep ^C .config"
> somewhere in there (or have the script do it) since the number of
> config options isn't going to decrease anytime soon...

I'll make the script do this.

Matthias

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-07  7:48 [PATCH] new bug report script Matthias Juchem
  2001-01-07  7:56 ` Ulrich Drepper
@ 2001-01-07 13:58 ` Alan Cox
  2001-01-07 14:00   ` Matthias Juchem
  1 sibling, 1 reply; 25+ messages in thread
From: Alan Cox @ 2001-01-07 13:58 UTC (permalink / raw)
  To: juchem; +Cc: alan, linux-kernel

> This is a patch against 2.4.0. It introduces a new bug reporting script
> (scripts/bugreport.pl) that tries to simplify bug reporting for users. I
> have also added a small hint to this script to REPORTING-BUGS.

The kernel doesnt require perl. I don't want to add a dependancy on perl
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-07 13:58 ` Alan Cox
@ 2001-01-07 14:00   ` Matthias Juchem
  2001-01-07 14:19     ` Alan Cox
  0 siblings, 1 reply; 25+ messages in thread
From: Matthias Juchem @ 2001-01-07 14:00 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel

On Sun, 7 Jan 2001, Alan Cox wrote:

> The kernel doesnt require perl. I don't want to add a dependancy on perl

Well, I wouldn't be a dependancy as you do not have to use it. Why not add
it as an option. I guess most of the installations have a perl
interpreter.

BTW:
# find . -name \*.pl
./drivers/scsi/script_asm.pl
./drivers/usb/serial/ezusb_convert.pl
./arch/ppc/treeboot/elf.pl
./arch/arm/lib/extractconstants.pl
./scripts/checkconfig.pl
./scripts/checkhelp.pl
./scripts/checkincludes.pl

Matthias

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-07 14:00   ` Matthias Juchem
@ 2001-01-07 14:19     ` Alan Cox
  2001-01-07 14:33       ` Matthias Juchem
  2001-01-07 15:02       ` Russell King
  0 siblings, 2 replies; 25+ messages in thread
From: Alan Cox @ 2001-01-07 14:19 UTC (permalink / raw)
  To: juchem; +Cc: Alan Cox, linux-kernel

> ./drivers/scsi/script_asm.pl
> ./drivers/usb/serial/ezusb_convert.pl
> ./arch/ppc/treeboot/elf.pl
> ./arch/arm/lib/extractconstants.pl
> ./scripts/checkconfig.pl
> ./scripts/checkhelp.pl
> ./scripts/checkincludes.pl

None of these are needed for normal build/use/bug reporting work. In fact
if you look at script_asm you'll see we go to great pains to ship prebuilt
files too

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-07 14:19     ` Alan Cox
@ 2001-01-07 14:33       ` Matthias Juchem
  2001-01-07 14:43         ` David Ford
  2001-01-07 15:02       ` Russell King
  1 sibling, 1 reply; 25+ messages in thread
From: Matthias Juchem @ 2001-01-07 14:33 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel

On Sun, 7 Jan 2001, Alan Cox wrote:

> None of these are needed for normal build/use/bug reporting work. In fact
> if you look at script_asm you'll see we go to great pains to ship prebuilt
> files too

Well, DocBook documentation isn't need for normal builds either and has
jade as dependency - something that can less often be found on GNU/Linux
in my opinion.
Why can't I assume that perl is installed? It can be found on every
standard Linux/Unix installation.
And besides, the bug report script doesn't replace anything the doesn't
need perl - ver_linux, REPORTING-BUGS and oops-tracing.txt are still there
for the more advanced user.
My script is intended for the one who likes to provide bug reports but is
too lazy to look up all the information or simply is not sure about what
to include.
Starting with my script to generate their reports, the users can customize
the reports and also write them by hand if they feel like doing so.

Matthias

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-07 14:33       ` Matthias Juchem
@ 2001-01-07 14:43         ` David Ford
  2001-01-07 14:49           ` Matthias Juchem
  2001-01-08  0:24           ` Keith Owens
  0 siblings, 2 replies; 25+ messages in thread
From: David Ford @ 2001-01-07 14:43 UTC (permalink / raw)
  To: Matthias Juchem; +Cc: Alan Cox, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 422 bytes --]

Matthias Juchem wrote:

> Why can't I assume that perl is installed? It can be found on every
> standard Linux/Unix installation.

No it can't.  Perl isn't on any of my distributions as part of the standard
installation.


> My script is intended for the one who likes to provide bug reports but is
> too lazy to look up all the information or simply is not sure about what
> to include.

Why can't it be done in sh?

-d


[-- Attachment #2: Card for David Ford --]
[-- Type: text/x-vcard, Size: 274 bytes --]

begin:vcard 
n:Ford;David
x-mozilla-html:TRUE
url:www.blue-labs.org
adr:;;;;;;
version:2.1
email;internet:david@blue-labs.org
title:Blue Labs Developer
note;quoted-printable:GPG key: http://www.blue-labs.org/david@nifty.key=0D=0A
x-mozilla-cpt:;9952
fn:David Ford
end:vcard

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-07 14:43         ` David Ford
@ 2001-01-07 14:49           ` Matthias Juchem
  2001-01-08  0:24           ` Keith Owens
  1 sibling, 0 replies; 25+ messages in thread
From: Matthias Juchem @ 2001-01-07 14:49 UTC (permalink / raw)
  To: David Ford; +Cc: Alan Cox, linux-kernel

On Sun, 7 Jan 2001, David Ford wrote:

> > Why can't I assume that perl is installed? It can be found on every
> > standard Linux/Unix installation.
>
> No it can't.  Perl isn't on any of my distributions as part of the standard
> installation.

Ok, I was wrong. I'm used to perl, I've seen perl on every Linux
installation and on almost every Unix installation I've been working
with.

> > My script is intended for the one who likes to provide bug reports but is
> > too lazy to look up all the information or simply is not sure about what
> > to include.
>
> Why can't it be done in sh?

I can be done in sh, surely. I only tried to promote my perl version
because I've done it in perl and nobody told me earlier that perl is not
liked in the kernel tree - and I've seen some perl scripts there.

I guess I'll have to convert the script to sh.


Matthias

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-07 14:19     ` Alan Cox
  2001-01-07 14:33       ` Matthias Juchem
@ 2001-01-07 15:02       ` Russell King
  1 sibling, 0 replies; 25+ messages in thread
From: Russell King @ 2001-01-07 15:02 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel

Alan Cox writes:
> > ./arch/arm/lib/extractconstants.pl
> 
> None of these are needed for normal build/use/bug reporting work. In fact
> if you look at script_asm you'll see we go to great pains to ship prebuilt
> files too

Whoops. ;(

I've already got a fix for this one though using grep and sed.
   _____
  |_____| ------------------------------------------------- ---+---+-
  |   |         Russell King        rmk@arm.linux.org.uk      --- ---
  | | | | http://www.arm.linux.org.uk/personal/aboutme.html   /  /  |
  | +-+-+                                                     --- -+-
  /   |               THE developer of ARM Linux              |+| /|\
 /  | | |                                                     ---  |
    +-+-+ -------------------------------------------------  /\\\  |
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-07 14:43         ` David Ford
  2001-01-07 14:49           ` Matthias Juchem
@ 2001-01-08  0:24           ` Keith Owens
  2001-01-08  1:26             ` Ulrich Drepper
  1 sibling, 1 reply; 25+ messages in thread
From: Keith Owens @ 2001-01-08  0:24 UTC (permalink / raw)
  To: Matthias Juchem, linux-kernel

On Sun, 07 Jan 2001 06:43:14 -0800, 
David Ford <david@linux.com> wrote:
>Matthias Juchem wrote:
>> My script is intended for the one who likes to provide bug reports but is
>> too lazy to look up all the information or simply is not sure about what
>> to include.
>
>Why can't it be done in sh?

In the dim, distant past I did a shell script that reads Changes,
extracts the lines which identify software versions and verifies that
your installed products were up to date.  I sent it to Linus several
times and got no response so I dropped it.  It was last run against
2.1.107, this is a quick and dirty upgrade against 2.4.0.  A lot of the
entries are there for historical reasons but are probably worth keeping
for reference.

The tricky bit with shell is handling the different output when the
script is run as sh -x script.  Use this script as a starting point if
you like it, if not, fold spindle and mutilate it.

--- check_linux_requirements ---

#!/bin/bash
#
#	Read Documentation/Changes, extract the required software levels
#	and check that the current system is up to date.  Developed for
#	2.1.107.  Will not work on 2.0.x because the Documentation/Changes
#	on 2.0.x systems does not include commands, at least up to 2.0.34.
#
#	Takes one optional parameter, the path to Documentation/Changes,
#	default is /usr/src/linux/Documentation/Changes.
#
#	This would be a lot easier in perl but users are not required to
#	have perl to install Linux.  awk was a possibility but some versions
#	of awk have been known to break on readline which I needed.  So shell
#	it is.
#
#	Keith Owens <kaos@ocs.com.au>.  GPL.  Sun Jun 28 21:20:10 EST 1998
#
#	Updated for 2.4.0 Keith Owens <kaos@ocs.com.au>.  Mon Jan  8 10:39:07 EST 2001
#
PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin	# may not have root's path

required() {
	state=0
	confirm=0

	# NOTE: This code expects to see a line containing
	# "Current Minimal Requirements" on its own, followed by '==='
	# fillowed by each requirement on its own line starting with 'o',
	# terminated by any line starting with at least '===='.

	# Requirement lines must start with "o ".
	# The command to get the version (if any) must be preceded by '#'.
	# The version number must appear just before '#' or as the last field
	# if there is no command.

	while read line
	do
		if [ $state -eq 0 -a "$line" = "Current Minimal Requirements" ]
		then
			state=1
		fi
		if [ $state -ge 1 ]
		then
			if  ( expr "$line" : "====" > /dev/null )
			then
				state=$[$state + 1]
				if [ $state -eq 3 ]
				then
					break	# end of requirements
				fi
			fi
			if  ( ! expr "$line" : "o" > /dev/null )
			then
				continue
			fi
			line=${line#"o "}
			set -- $line
			text=$1
			version1=
			command=
			shift
			while [ -n "$2" -a "$2" != "#" ]
			do
				text="$text $1"
				shift
			done
			version1="$1"
			shift
			if [ "$1" = "#" ]
			then
				shift
			fi
			if [ -n "$1" ]
			then
				# pppd checks for device or tty before printing version.
				# < /dev/null causes an error.
				if [ "$text" = "PPP" ]
				then
					command="$1 < /dev/ttyS0"
				else
					command="$1 < /dev/null"
				fi
			fi
			while [ -n "$2" ]
			do
				if [ "X$2" = "Xor" ]
				then
					command="$command ;"
				else
					command="$command $2"
				fi
				shift
			done
			eval "($command)" 2>&1 | \
				verify "$text" "$version1" "$command"
			if [ $? -ne 0 ]
			then
				confirm=$[$confirm + 1]
			fi
		fi
	done
	if [ $state -ne 3 ]
	then
		echo "No requirements detected, probably an old Documentation/Changes file"
		return 2
	fi
	if [ $confirm -ne 0 ]
	then
		echo "$confirm package(s) to be manually confirmed"
		return 1
	fi
	return 0
}

verify() {
	# Extract the version number from program output and verify it
	text="$1"
	textlc=`echo "$1" | tr '[A-Z]' '[a-z]'`
	version1="$2"
	version2=
	command="$3"
	echo "$text"
	echo -ne "\tRequired $version1"
	if [ -z "$command" ]
	then
		echo -e "\t*** No command, unable to verify ***"
		return 1
	fi

	# Amazing how many different ways there are for software to display
	# their version number.  Special cases galore.

	case "$textlc" in
	modutils)			type=1; field=3;;
	"gnu c")			type=1; field=1;;
	"binutils")			type=1; field=4;;
	"linux c library")		type=2;;
	"linux libc5 c library")	type=2;;
	"linux libc6 c library")	type=5;;
	"dynamic linker (ld.so)")	type=3;;
	"linux c++ library")		type=2;;
	"pcmcia-cs")			type=1; field=3;;
	"procps")			type=1; field=3;;
	"procinfo")			type=1; field=5;;
	"psmisc")			type=1; field=5;;
	"mount")			type=1; field=2;;
	"net-tools")			type=1; field=2;;
	"sh-utils")			type=1; field=4;;
	"autofs")			type=1; field=4;;
	"nfs")				type=1; field=-1;;	# last field on line
	"bash")				type=1; field=4;;
	"ncpfs")			type=1; field=3;;
	"ppp")				type=1; field=3;;
	"gnu make")			type=1; field=4;;
	"util-linux")			type=1; field=3;;
	"e2fsprogs")			type=1; field=2;;
	"isdn4k-utils")			type=1; field=-1;;	# last field on line??  Needs to be tested
	*)
		echo -e "\t*** Unknown software '$textlc', unable to verify ***"
		echo "	check_linux_requirements might need to be upgraded"
		return 1
		;;
	esac

	found_version=0
	command_not_found=0
	while read line
	do
		# If running under set -x, the first line is the command
		# preceded by "++ " which confuses some tests.  Ignore all
		# lines starting with "++ ".
		if [ `expr "$line" : "++ "` = 3 ]
		then
			continue
		fi
		# Treat "command not found" as warning, not error.  Not everybody
		# needs every package.
		if [ `expr "$line" : "${myname}:.*: command not found\$"` -ne 0 ]
		then
			command_not_found=1
			continue
		fi
		set -- $line	# tokenize
		case $type in
		1)
			# Version on the first line in a specific field,
			# possibly preceded by "some-text-".
			if [ "X$1" = "XUsage:" -o \
			     `expr "$line" : '.*installed suid root'` -ne 0 -o \
			     `expr "$line" : '.*invalid option'` -ne 0 ]
			then
				break	# some error message instead
			fi
			if [ $field -lt 0 ]
			then
				# field -n from end of line
				field=$[$# + $field + 1]
			fi
			eval "version2=\$$field"
			prefix=`expr "$version2" : '\([a-z]*-\)*'`
			if [ -n "$prefix" ]
			then
				version2=${version2#$prefix}	# strip prefix
			fi
			found_version=1
			;;
		2)
			# libxxx versions.  Take the last symbolic link,
			# extract the version number from the file it points to.
			# Special case for libc, if the link is for libc.so.6*,
			# treat the version as 6.xxx, otherwise it complains
			# that you are back level, 2.0.xx is less than 5.x.xx.
			if [ `expr "X$1" : 'Xl'` -eq 2 ]
			then
				while [ "X$2" != "X->" ]
				do
					shift
				done
				version2=`echo "$3" | tr -cd '[.0-9]' | \
					  sed -e 's/\.\.*/./g' |
					  sed -e 's/^\.//g' |
					  sed -e 's/\.$//g'`
				if [ `expr "$1" : '.*libc.so.6'` != '0' ]
				then
					version2="6.$version2"
				fi
			fi
			;;
		3)
			# Version on first line that starts with ldd, last
			# field on the line.
			# Two different ldd commands are issued so have to read
			# all input.  Different versions of ldd have different
			# number of tokens :(.
			# Exclude error lines from old versions of ldd complaining
			# about --version.
			if [ `expr "$line" : '.*illegal option'` -ne 0 -o \
			     `expr "$line" : '.*invalid option'` -ne 0 ]

			then
				continue	# some error message instead
			fi
			if [ `expr "$1" : 'ldd'` -ne 0 ]
			then
				while [ -n "$2" ]
				do
					shift
				done
				version2=$1
				found_version=1
			fi
			;;
		4)
			# Version on first line that starts with pppd, made
			# up of fields 3 and 6.
			if [ "X$1" = "Xpppd" ]
			then
				version2="$3.$6"
				found_version=1
			fi
			;;
		5)
			# glibc versions.  Take the last symbolic link,
			# extract the version number from the file it points to.
			if [ `expr "X$1" : 'Xl'` -eq 2 ]
			then
				while [ "X$2" != "X->" ]
				do
					shift
				done
				version2=`echo "$3" | tr -cd '[.0-9]' | \
					  sed -e 's/\.\.*/./g' |
					  sed -e 's/^\.//g' |
					  sed -e 's/\.$//g'`
			fi
			;;
		*) ;;
		esac
		if [ $found_version -eq 1 ]
		then
			break
		fi
	done
	if [ $type -eq 2 -a -n "$version2" ]
	then
		found_version=1		# take the *last* symlink
	fi
	if [ $found_version -ne 1 ]
	then
		if [ $command_not_found -eq 1 ]
		then
			echo -e "\tPackage probably not installed, ignored"
			return 0	# don't count as an error
		else
			echo -e "\t*** No version number found, cannot verify ***"
			return 1
		fi
	fi
	version2=`echo $version2 | sed -e 's:,$::'`
	echo -ne "\tActual $version2"
	if compare_version "$textlc" "$version1" "$version2" 
	then
		echo -e "\tOK"
		return 0
	else
		echo -e "\t*** Possibly back level ***"
		return 1
	fi
}

compare_version() {
	# Amazing how many different ways there are for software to create
	# their version number.  Special cases galore.  Best case, convert
	# special characters such as '.', '(', ')' etc. to spaces, insert a
	# space where the version goes from letter to number or vice versa,
	# tokenize, compare the tokens as numbers or strings, as required.
	# Very, very messy!

	split_version "$1" v1 "$2"
	split_version "$1" v2 "$3"

	if [ $v1_max -lt $v2_max ]
	then
		max=$v2_max
	else
		max=$v1_max
	fi

	n=1
	while [ $n -le $max ]
	do
		eval "v1_token=\$v1_$n"
		eval "v2_token=\$v2_$n"
		if [ `expr "$v1_token" : '[0-9][0-9]*$'` != "0" ]
		then
			v1_digit=1
		else
			v1_digit=0
		fi
		if [ `expr "$v2_token" : '[0-9][0-9]*$'` != "0" ]
		then
			v2_digit=1
		else
			v2_digit=0
		fi
		if [ $v1_digit -eq 1 -a $v2_digit -eq 1 ]
		then
			# Two numeric tokens, compare as numbers.  Nobody is
			# going to catch me thinking that 2.1.100 is less than
			# 2.1.99 :).
			if [ $v2_token -lt $v1_token ]
			then
				return 1	# possibly back level
			elif [ $v2_token -gt $v1_token ]
			then
				return 0	# forward level
			fi
		elif [ $v1_digit -eq 0 -a $v2_digit -eq 0 ]
		then
			# Two string tokens.  It only makes sense to compare
			# them if both are one character long.  Otherwise
			# assume mismatch if they are not equal.
			if [ `expr "$v1_token" : '.*'` = "1" -a \
			     `expr "$v2_token" : '.*'` = "1" ]
			then
				if [ `expr "X$v2_token" "<" "X$v1_token"` -eq 1 ]
				then
					return 1	# possibly back level
				elif [ `expr "X$v2_token" ">" "X$v1_token"` -eq 1 ]
				then
					return 0	# forward level
				fi
			elif [ "X$v2_token" != "X$v1_token" ]
			then
				return 1	# possibly back level
			fi
		else
			# Mixed numeric and string tokens, although the string
			# token can be null.  If the v1 token is null then
			# assume that v2 has a more recent patch level and
			# accept it, otherwise give up.
			if [ -z "$v1_token" ]
			then
				return 0	# assume v2 has a patch level
			else
				return 1	# possibly back level
			fi
		fi
		n=$[$n + 1]
	done
	
	return 0
}

split_version() {
	# Split a version number into tokens (see compare_version) and store
	# the tokens in $1_n.  $1_max is the number of tokens.

	textlc=$1
	prefix=$2
	set -- `echo "$3" |
		tr '[A-Z]' '[a-z]' | tr '[]:;.(),+=-[]' ' ' |
		sed -e 's/\([a-z]\)\([0-9]\)/\1 \2/g' |
		sed -e 's/\([0-9]\)\([a-z]\)/\1 \2/g'`;

	# Special case net-tools.  If there are exactly two tokens and the
	# second token is more than 2 digits, split it into two subtokens
	# after the second digit.  Otherwise 1.432 is greater than 1.45.
	# Will not work after net-tools 1.99, hopefully the version number
	# problem is fixed by then.

	if [ "X$textlc" = "Xnet-tools" \
	     -a -n "$2" -a -z "$3" -a \
	     `expr length "$2"` -gt 2 ]
	then
		st1=`expr "$2" : '\(..\)'`
		st2=`expr "$2" : '..\(.*\)'`
		set -- "$1" "$st1" "$st2"
	fi

	n=0
	while [ -n "$1" ]
	do
		n=$[$n + 1]
		eval "${prefix}_$n=$1"
		shift
	done
	eval "${prefix}_max=$n"
}

changes=${1:-/usr/src/linux/Documentation/Changes}
myname=$0

echo "Verifying your software environment against the levels required"
echo "in $changes."
echo "NOTE: There are so many different ways that software can display a"
echo "      version number and they change over time.  It is not guaranteed"
echo "      that this script always gets it right.  Please manually check"
echo "      anything that says \"Possibly back level\".  If this script is"
echo "      wrong, notify the author.   Otherwise it is time to upgrade."
echo

# Simple, no :)?
required < $changes
exit $?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-08  0:24           ` Keith Owens
@ 2001-01-08  1:26             ` Ulrich Drepper
  2001-01-08  1:40               ` Matthias Juchem
  0 siblings, 1 reply; 25+ messages in thread
From: Ulrich Drepper @ 2001-01-08  1:26 UTC (permalink / raw)
  To: Keith Owens; +Cc: Matthias Juchem, linux-kernel

Keith Owens <kaos@ocs.com.au> writes:

> 		5)
> 			# glibc versions.  Take the last symbolic link,
> 			# extract the version number from the file it points to.
> 			if [ `expr "X$1" : 'Xl'` -eq 2 ]
> 			then
> 				while [ "X$2" != "X->" ]
> 				do
> 					shift
> 				done
> 				version2=`echo "$3" | tr -cd '[.0-9]' | \
> 					  sed -e 's/\.\.*/./g' |
> 					  sed -e 's/^\.//g' |
> 					  sed -e 's/\.$//g'`
> 			fi
> 			;;

Why don't you, as the other script suggested, execute libc.so.6?
Symlinks can be missing or can be wrong.

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-08  1:26             ` Ulrich Drepper
@ 2001-01-08  1:40               ` Matthias Juchem
  2001-01-08  1:53                 ` Barry K. Nathan
  0 siblings, 1 reply; 25+ messages in thread
From: Matthias Juchem @ 2001-01-08  1:40 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Keith Owens, linux-kernel

On 7 Jan 2001, Ulrich Drepper wrote:

> Why don't you, as the other script suggested, execute libc.so.6?
> Symlinks can be missing or can be wrong.

I'll have a look at this shell script and take the best out of both to
make a new one.

BTW, lots of version dependencies found in older Changes document (i.e.
for 2.3.11) were removed now (2.4.0 shows only 9 where the old one had
22). Have the removed ones been completely unnecessary?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] new bug report script
  2001-01-08  1:40               ` Matthias Juchem
@ 2001-01-08  1:53                 ` Barry K. Nathan
  0 siblings, 0 replies; 25+ messages in thread
From: Barry K. Nathan @ 2001-01-08  1:53 UTC (permalink / raw)
  To: juchem; +Cc: Ulrich Drepper, Keith Owens, linux-kernel

Matthias Juchem wrote:
> BTW, lots of version dependencies found in older Changes document (i.e.
> for 2.3.11) were removed now (2.4.0 shows only 9 where the old one had
> 22). Have the removed ones been completely unnecessary?

Quoting from 2.4.0's Changes file:
[snip]
> trying life on the Bleeding Edge.  If upgrading from a pre-2.2.x
> kernel, please consult the Changes file included with 2.2.x kernels for
> additional information; most of that information will not be repeated
> here.  Basically, this document assumes that your system is already
> functional and running at least 2.2.x kernels.

Perhaps that accounts for the missing version dependencies...

-Barry K. Nathan <barryn@pobox.com>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2001-01-08  1:53 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-01-07  7:48 [PATCH] new bug report script Matthias Juchem
2001-01-07  7:56 ` Ulrich Drepper
2001-01-07  8:01   ` Matthias Juchem
2001-01-07  8:16     ` Ulrich Drepper
2001-01-07 13:42       ` Paul Gortmaker
2001-01-07 13:52         ` Matthias Juchem
2001-01-07  9:43     ` Brett
2001-01-07  9:44       ` Matthias Juchem
2001-01-07 11:21         ` David Ford
2001-01-07 11:16       ` Kurt Roeckx
2001-01-07  9:00   ` [PATCH] " Matthias Juchem
2001-01-07  9:06     ` Ulrich Drepper
2001-01-07  9:19       ` Matthias Juchem
2001-01-07 12:38       ` Matthias Juchem
2001-01-07 13:58 ` Alan Cox
2001-01-07 14:00   ` Matthias Juchem
2001-01-07 14:19     ` Alan Cox
2001-01-07 14:33       ` Matthias Juchem
2001-01-07 14:43         ` David Ford
2001-01-07 14:49           ` Matthias Juchem
2001-01-08  0:24           ` Keith Owens
2001-01-08  1:26             ` Ulrich Drepper
2001-01-08  1:40               ` Matthias Juchem
2001-01-08  1:53                 ` Barry K. Nathan
2001-01-07 15:02       ` Russell King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox