xref: /linux/scripts/ver_linux (revision 2ca46ed207d5d4e3c7a183fe11e8a2d02f86e7c6)
18af11c1cSSaul Wold#!/usr/bin/awk -f
2b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
39b9e7d36SAlexander Kapshuk# Before running this script please ensure that your PATH is
49b9e7d36SAlexander Kapshuk# typical as you use for compilation/installation. I use
59b9e7d36SAlexander Kapshuk# /bin /sbin /usr/bin /usr/sbin /usr/local/bin, but it may
69b9e7d36SAlexander Kapshuk# differ on your system.
79b9e7d36SAlexander Kapshuk
89b9e7d36SAlexander KapshukBEGIN {
99b9e7d36SAlexander Kapshuk	usage = "If some fields are empty or look unusual you may have an old version.\n"
109b9e7d36SAlexander Kapshuk	usage = usage "Compare to the current minimal requirements in Documentation/Changes.\n"
119b9e7d36SAlexander Kapshuk	print usage
129b9e7d36SAlexander Kapshuk
139b9e7d36SAlexander Kapshuk	system("uname -a")
149b9e7d36SAlexander Kapshuk	printf("\n")
159b9e7d36SAlexander Kapshuk
16*2ca46ed2SAlexander Kapshuk	vernum = "[0-9]+([.]?[0-9]+)+"
17*2ca46ed2SAlexander Kapshuk
184169bc43SAlexander Kapshuk	printversion("GNU C", version("gcc -dumpversion"))
194169bc43SAlexander Kapshuk	printversion("GNU Make", version("make --version"))
204169bc43SAlexander Kapshuk	printversion("Binutils", version("ld -v"))
214169bc43SAlexander Kapshuk	printversion("Util-linux", version("mount --version"))
224169bc43SAlexander Kapshuk	printversion("Mount", version("mount --version"))
234169bc43SAlexander Kapshuk	printversion("Module-init-tools", version("depmod -V"))
244169bc43SAlexander Kapshuk	printversion("E2fsprogs", version("tune2fs"))
254169bc43SAlexander Kapshuk	printversion("Jfsutils", version("fsck.jfs -V"))
264169bc43SAlexander Kapshuk	printversion("Reiserfsprogs", version("reiserfsck -V"))
274169bc43SAlexander Kapshuk	printversion("Reiser4fsprogs", version("fsck.reiser4 -V"))
284169bc43SAlexander Kapshuk	printversion("Xfsprogs", version("xfs_db -V"))
294169bc43SAlexander Kapshuk	printversion("Pcmciautils", version("pccardctl -V"))
304169bc43SAlexander Kapshuk	printversion("Pcmcia-cs", version("cardmgr -V"))
314169bc43SAlexander Kapshuk	printversion("Quota-tools", version("quota -V"))
324169bc43SAlexander Kapshuk	printversion("PPP", version("pppd --version"))
334169bc43SAlexander Kapshuk	printversion("Isdn4k-utils", version("isdnctrl"))
344169bc43SAlexander Kapshuk	printversion("Nfs-utils", version("showmount --version"))
359b9e7d36SAlexander Kapshuk
369b9e7d36SAlexander Kapshuk	while (getline <"/proc/self/maps" > 0) {
3734fe3cfdSAlexander Kapshuk		if (/libc.*\.so$/) {
389b9e7d36SAlexander Kapshuk			n = split($0, procmaps, "/")
39*2ca46ed2SAlexander Kapshuk			if (match(procmaps[n], vernum)) {
409b9e7d36SAlexander Kapshuk				ver = substr(procmaps[n], RSTART, RLENGTH)
419b9e7d36SAlexander Kapshuk				printversion("Linux C Library", ver)
429b9e7d36SAlexander Kapshuk				break
439b9e7d36SAlexander Kapshuk			}
449b9e7d36SAlexander Kapshuk		}
4534fe3cfdSAlexander Kapshuk	}
469b9e7d36SAlexander Kapshuk
474169bc43SAlexander Kapshuk	printversion("Dynamic linker (ldd)", version("ldd --version"))
489b9e7d36SAlexander Kapshuk
499b9e7d36SAlexander Kapshuk	while ("ldconfig -p 2>/dev/null" | getline > 0) {
509b9e7d36SAlexander Kapshuk		if (/(libg|stdc)[+]+\.so/) {
519b9e7d36SAlexander Kapshuk			libcpp = $NF
529b9e7d36SAlexander Kapshuk			break
539b9e7d36SAlexander Kapshuk		}
549b9e7d36SAlexander Kapshuk	}
559b9e7d36SAlexander Kapshuk	printversion("Linux C++ Library", version("readlink " libcpp))
564169bc43SAlexander Kapshuk	printversion("Procps", version("ps --version"))
574169bc43SAlexander Kapshuk	printversion("Net-tools", version("ifconfig --version"))
584169bc43SAlexander Kapshuk	printversion("Kbd", version("loadkeys -V"))
594169bc43SAlexander Kapshuk	printversion("Console-tools", version("loadkeys -V"))
604169bc43SAlexander Kapshuk	printversion("Oprofile", version("oprofiled --version"))
614169bc43SAlexander Kapshuk	printversion("Sh-utils", version("expr --v"))
624169bc43SAlexander Kapshuk	printversion("Udev", version("udevadm --version"))
634169bc43SAlexander Kapshuk	printversion("Wireless-tools", version("iwconfig --version"))
649b9e7d36SAlexander Kapshuk
659b9e7d36SAlexander Kapshuk	while ("sort /proc/modules" | getline > 0) {
669b9e7d36SAlexander Kapshuk		mods = mods sep $1
679b9e7d36SAlexander Kapshuk		sep = " "
689b9e7d36SAlexander Kapshuk	}
699b9e7d36SAlexander Kapshuk	printversion("Modules Loaded", mods)
709b9e7d36SAlexander Kapshuk}
719b9e7d36SAlexander Kapshuk
729b9e7d36SAlexander Kapshukfunction version(cmd,    ver) {
734169bc43SAlexander Kapshuk	cmd = cmd " 2>&1"
749b9e7d36SAlexander Kapshuk	while (cmd | getline > 0) {
75*2ca46ed2SAlexander Kapshuk		if (match($0, vernum)) {
769b9e7d36SAlexander Kapshuk			ver = substr($0, RSTART, RLENGTH)
779b9e7d36SAlexander Kapshuk			break
789b9e7d36SAlexander Kapshuk		}
799b9e7d36SAlexander Kapshuk	}
809b9e7d36SAlexander Kapshuk	close(cmd)
819b9e7d36SAlexander Kapshuk	return ver
829b9e7d36SAlexander Kapshuk}
839b9e7d36SAlexander Kapshuk
849b9e7d36SAlexander Kapshukfunction printversion(name, value,  ofmt) {
859b9e7d36SAlexander Kapshuk	if (value != "") {
869b9e7d36SAlexander Kapshuk		ofmt = "%-20s\t%s\n"
879b9e7d36SAlexander Kapshuk		printf(ofmt, name, value)
889b9e7d36SAlexander Kapshuk	}
899b9e7d36SAlexander Kapshuk}
90