xref: /linux/scripts/ver_linux (revision ff5cd9accbc724a793904c6e401040c85be89748)
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
162ca46ed2SAlexander Kapshuk	vernum = "[0-9]+([.]?[0-9]+)+"
17*ff5cd9acSAlexander Kapshuk	libc = "libc[.]so[.][0-9]+$"
18*ff5cd9acSAlexander Kapshuk	libcpp = "(libg|stdc)[+]+[.]so[.][0-9]+$"
192ca46ed2SAlexander Kapshuk
204169bc43SAlexander Kapshuk	printversion("GNU C", version("gcc -dumpversion"))
214169bc43SAlexander Kapshuk	printversion("GNU Make", version("make --version"))
224169bc43SAlexander Kapshuk	printversion("Binutils", version("ld -v"))
234169bc43SAlexander Kapshuk	printversion("Util-linux", version("mount --version"))
244169bc43SAlexander Kapshuk	printversion("Mount", version("mount --version"))
254169bc43SAlexander Kapshuk	printversion("Module-init-tools", version("depmod -V"))
264169bc43SAlexander Kapshuk	printversion("E2fsprogs", version("tune2fs"))
274169bc43SAlexander Kapshuk	printversion("Jfsutils", version("fsck.jfs -V"))
284169bc43SAlexander Kapshuk	printversion("Reiserfsprogs", version("reiserfsck -V"))
294169bc43SAlexander Kapshuk	printversion("Reiser4fsprogs", version("fsck.reiser4 -V"))
304169bc43SAlexander Kapshuk	printversion("Xfsprogs", version("xfs_db -V"))
314169bc43SAlexander Kapshuk	printversion("Pcmciautils", version("pccardctl -V"))
324169bc43SAlexander Kapshuk	printversion("Pcmcia-cs", version("cardmgr -V"))
334169bc43SAlexander Kapshuk	printversion("Quota-tools", version("quota -V"))
344169bc43SAlexander Kapshuk	printversion("PPP", version("pppd --version"))
354169bc43SAlexander Kapshuk	printversion("Isdn4k-utils", version("isdnctrl"))
364169bc43SAlexander Kapshuk	printversion("Nfs-utils", version("showmount --version"))
37faade961SBhaskar Chowdhury	printversion("Bison", version("bison --version"))
38faade961SBhaskar Chowdhury	printversion("Flex", version("flex --version"))
399b9e7d36SAlexander Kapshuk
40*ff5cd9acSAlexander Kapshuk	while ("ldconfig -p 2>/dev/null" | getline > 0) {
41*ff5cd9acSAlexander Kapshuk		if ($NF ~ libc && !seen[ver = version("readlink " $NF)]++)
429b9e7d36SAlexander Kapshuk			printversion("Linux C Library", ver)
43*ff5cd9acSAlexander Kapshuk		else if ($NF ~ libcpp && !seen[ver = version("readlink " $NF)]++)
44*ff5cd9acSAlexander Kapshuk			printversion("Linux C++ Library", ver)
4534fe3cfdSAlexander Kapshuk	}
469b9e7d36SAlexander Kapshuk
474169bc43SAlexander Kapshuk	printversion("Dynamic linker (ldd)", version("ldd --version"))
484169bc43SAlexander Kapshuk	printversion("Procps", version("ps --version"))
494169bc43SAlexander Kapshuk	printversion("Net-tools", version("ifconfig --version"))
504169bc43SAlexander Kapshuk	printversion("Kbd", version("loadkeys -V"))
514169bc43SAlexander Kapshuk	printversion("Console-tools", version("loadkeys -V"))
524169bc43SAlexander Kapshuk	printversion("Oprofile", version("oprofiled --version"))
534169bc43SAlexander Kapshuk	printversion("Sh-utils", version("expr --v"))
544169bc43SAlexander Kapshuk	printversion("Udev", version("udevadm --version"))
554169bc43SAlexander Kapshuk	printversion("Wireless-tools", version("iwconfig --version"))
569b9e7d36SAlexander Kapshuk
579b9e7d36SAlexander Kapshuk	while ("sort /proc/modules" | getline > 0) {
589b9e7d36SAlexander Kapshuk		mods = mods sep $1
599b9e7d36SAlexander Kapshuk		sep = " "
609b9e7d36SAlexander Kapshuk	}
619b9e7d36SAlexander Kapshuk	printversion("Modules Loaded", mods)
629b9e7d36SAlexander Kapshuk}
639b9e7d36SAlexander Kapshuk
649b9e7d36SAlexander Kapshukfunction version(cmd,    ver) {
654169bc43SAlexander Kapshuk	cmd = cmd " 2>&1"
669b9e7d36SAlexander Kapshuk	while (cmd | getline > 0) {
672ca46ed2SAlexander Kapshuk		if (match($0, vernum)) {
689b9e7d36SAlexander Kapshuk			ver = substr($0, RSTART, RLENGTH)
699b9e7d36SAlexander Kapshuk			break
709b9e7d36SAlexander Kapshuk		}
719b9e7d36SAlexander Kapshuk	}
729b9e7d36SAlexander Kapshuk	close(cmd)
739b9e7d36SAlexander Kapshuk	return ver
749b9e7d36SAlexander Kapshuk}
759b9e7d36SAlexander Kapshuk
769b9e7d36SAlexander Kapshukfunction printversion(name, value,  ofmt) {
779b9e7d36SAlexander Kapshuk	if (value != "") {
789b9e7d36SAlexander Kapshuk		ofmt = "%-20s\t%s\n"
799b9e7d36SAlexander Kapshuk		printf(ofmt, name, value)
809b9e7d36SAlexander Kapshuk	}
819b9e7d36SAlexander Kapshuk}
82