xref: /openbmc/linux/scripts/ver_linux (revision 5d0e4d78)
1#!/usr/bin/awk -f
2# Before running this script please ensure that your PATH is
3# typical as you use for compilation/installation. I use
4# /bin /sbin /usr/bin /usr/sbin /usr/local/bin, but it may
5# differ on your system.
6
7BEGIN {
8	usage = "If some fields are empty or look unusual you may have an old version.\n"
9	usage = usage "Compare to the current minimal requirements in Documentation/Changes.\n"
10	print usage
11
12	system("uname -a")
13	printf("\n")
14
15	printversion("GNU C", version("gcc -dumpversion 2>&1"))
16	printversion("GNU Make", version("make --version 2>&1"))
17	printversion("Binutils", version("ld -v 2>&1"))
18	printversion("Util-linux", version("mount --version 2>&1"))
19	printversion("Mount", version("mount --version 2>&1"))
20	printversion("Module-init-tools", version("depmod -V  2>&1"))
21	printversion("E2fsprogs", version("tune2fs 2>&1"))
22	printversion("Jfsutils", version("fsck.jfs -V 2>&1"))
23	printversion("Reiserfsprogs", version("reiserfsck -V 2>&1"))
24	printversion("Reiser4fsprogs", version("fsck.reiser4 -V 2>&1"))
25	printversion("Xfsprogs", version("xfs_db -V 2>&1"))
26	printversion("Pcmciautils", version("pccardctl -V 2>&1"))
27	printversion("Pcmcia-cs", version("cardmgr -V 2>&1"))
28	printversion("Quota-tools", version("quota -V 2>&1"))
29	printversion("PPP", version("pppd --version 2>&1"))
30	printversion("Isdn4k-utils", version("isdnctrl 2>&1"))
31	printversion("Nfs-utils", version("showmount --version 2>&1"))
32
33	if (system("test -r /proc/self/maps") == 0) {
34		while (getline <"/proc/self/maps" > 0) {
35			n = split($0, procmaps, "/")
36			if (/libc.*so$/ && match(procmaps[n], /[0-9]+([.]?[0-9]+)+/)) {
37				ver = substr(procmaps[n], RSTART, RLENGTH)
38				printversion("Linux C Library", ver)
39				break
40			}
41		}
42	}
43
44	printversion("Dynamic linker (ldd)", version("ldd --version 2>&1"))
45
46	while ("ldconfig -p 2>/dev/null" | getline > 0) {
47		if (/(libg|stdc)[+]+\.so/) {
48			libcpp = $NF
49			break
50		}
51	}
52	if (system("test -r " libcpp) == 0)
53		printversion("Linux C++ Library", version("readlink " libcpp))
54
55	printversion("Procps", version("ps --version 2>&1"))
56	printversion("Net-tools", version("ifconfig --version 2>&1"))
57	printversion("Kbd", version("loadkeys -V 2>&1"))
58	printversion("Console-tools", version("loadkeys -V 2>&1"))
59	printversion("Oprofile", version("oprofiled --version 2>&1"))
60	printversion("Sh-utils", version("expr --v 2>&1"))
61	printversion("Udev", version("udevadm --version 2>&1"))
62	printversion("Wireless-tools", version("iwconfig --version 2>&1"))
63
64	if (system("test -r /proc/modules") == 0) {
65		while ("sort /proc/modules" | getline > 0) {
66			mods = mods sep $1
67			sep = " "
68		}
69		printversion("Modules Loaded", mods)
70	}
71}
72
73function version(cmd,    ver) {
74	while (cmd | getline > 0) {
75		if (!/ver_linux/ && match($0, /[0-9]+([.]?[0-9]+)+/)) {
76			ver = substr($0, RSTART, RLENGTH)
77			break
78		}
79	}
80	close(cmd)
81	return ver
82}
83
84function printversion(name, value,  ofmt) {
85	if (value != "") {
86		ofmt = "%-20s\t%s\n"
87		printf(ofmt, name, value)
88	}
89}
90