Module Name:    src
Committed By:   agc
Date:           Sat Jun  4 15:27:11 UTC 2016

Modified Files:
        src/distrib/sets/lists/base: mi
        src/distrib/sets/lists/man: mi
        src/doc: CHANGES
        src/usr.bin: Makefile
Added Files:
        src/usr.bin/sys_info: Makefile README sys_info.1 sys_info.sh

Log Message:
Following positive feedback on tech-userlevel, move the sys_info
script from othersrc to usr.bin/sys_info

        The sys_info script is a small script which will show the version
        information for installed utilities.  It also works on the kernel, and
        on most libraries.

        Its use is as follow:

                [19:41:13] agc@netbsd-002 ...external/bsd/sys_info [4568] > 
./sys_info -a
                awk-20121220
                bind-9.10.3pl3
                bzip2-1.0.6
                calendar-20160601
                ftpd-20110904
                g++-4.8.5
                gcc-4.8.5
                grep-2.5.1anb1
                gzip-20150113
                bozohttpd-20151231
                NetBSD-7.99.26
                netpgp-3.99.17
                netpgpverify-20160214
                ntp-4.2.8pl5
                openssl-1.0.1r
                sqlite3-3.12.2
                openssh-7.1
                opensshd-7.1
                tcsh-6.19.00
                xz-5.2.1
                [19:41:20] agc@netbsd-002 ...external/bsd/sys_info [4569] > 
./sys_info ntp ssh netpgp
                ntp-4.2.8pl5
                openssh-7.1
                netpgp-3.99.17
                [19:41:31] agc@netbsd-002 ...external/bsd/sys_info [4570] > 
./sys_info ntp ssh netbsd
                ntp-4.2.8pl5
                openssh-7.1
                NetBSD-7.99.26
                [19:41:38] agc@netbsd-002 ...external/bsd/sys_info [4571] >

        The -a option can be given to the script to print out the information
        on all known components.

        The sys_info script also works on libraries, returning their
        "versions" as given by the shared object version numbers.

                [19:45:06] agc@netbsd-002 ...external/bsd/sys_info [4572] > 
./sys_info libevent libXfont libc netbsd
                libevent-4.0
                libXfont-3.0
                libc-12.200
                NetBSD-7.99.26
                [19:45:27] agc@netbsd-002 ...external/bsd/sys_info [4573] >

        Alistair Crooks
        Wed Jun  1 19:44:01 PDT 2016


To generate a diff of this commit:
cvs rdiff -u -r1.1125 -r1.1126 src/distrib/sets/lists/base/mi
cvs rdiff -u -r1.1524 -r1.1525 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.2169 -r1.2170 src/doc/CHANGES
cvs rdiff -u -r1.224 -r1.225 src/usr.bin/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/sys_info/Makefile \
    src/usr.bin/sys_info/README src/usr.bin/sys_info/sys_info.1 \
    src/usr.bin/sys_info/sys_info.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/base/mi
diff -u src/distrib/sets/lists/base/mi:1.1125 src/distrib/sets/lists/base/mi:1.1126
--- src/distrib/sets/lists/base/mi:1.1125	Wed Jun  1 08:17:39 2016
+++ src/distrib/sets/lists/base/mi	Sat Jun  4 15:27:11 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1125 2016/06/01 08:17:39 pgoyette Exp $
+# $NetBSD: mi,v 1.1126 2016/06/04 15:27:11 agc Exp $
 #
 # Note:	Don't delete entries from here - mark them as "obsolete" instead,
 #	unless otherwise stated below.
@@ -911,6 +911,7 @@
 ./usr/bin/string2key				base-krb5-bin		kerberos
 ./usr/bin/su					base-util-bin
 ./usr/bin/sum					base-util-bin
+./usr/bin/sys_info				base-util-bin
 ./usr/bin/sysstat				base-util-bin
 ./usr/bin/systat				base-util-bin
 ./usr/bin/tabs					base-util-bin

Index: src/distrib/sets/lists/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1524 src/distrib/sets/lists/man/mi:1.1525
--- src/distrib/sets/lists/man/mi:1.1524	Sun May  1 10:21:01 2016
+++ src/distrib/sets/lists/man/mi	Sat Jun  4 15:27:11 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1524 2016/05/01 10:21:01 nonaka Exp $
+# $NetBSD: mi,v 1.1525 2016/06/04 15:27:11 agc Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -541,6 +541,7 @@
 ./usr/share/man/cat1/sum.0			man-util-catman		.cat
 ./usr/share/man/cat1/sup.0			man-sup-catman		.cat
 ./usr/share/man/cat1/suspend.0			man-util-catman		.cat
+./usr/share/man/cat1/sys_info.0			man-util-catman		.cat
 ./usr/share/man/cat1/sysstat.0			man-util-catman		.cat
 ./usr/share/man/cat1/systat.0			man-util-catman		.cat
 ./usr/share/man/cat1/systrace.0			man-obsolete		obsolete
@@ -3677,6 +3678,7 @@
 ./usr/share/man/html1/sum.html			man-util-htmlman	html
 ./usr/share/man/html1/sup.html			man-sup-htmlman		html
 ./usr/share/man/html1/suspend.html		man-util-htmlman	html
+./usr/share/man/html1/sys_info.html		man-util-htmlman	html
 ./usr/share/man/html1/sysstat.html		man-util-htmlman	html
 ./usr/share/man/html1/systat.html		man-util-htmlman	html
 ./usr/share/man/html1/tabs.html			man-util-htmlman	html
@@ -6465,6 +6467,7 @@
 ./usr/share/man/man1/sum.1			man-util-man		.man
 ./usr/share/man/man1/sup.1			man-sup-man		.man
 ./usr/share/man/man1/suspend.1			man-util-man		.man
+./usr/share/man/man1/sys_info.1			man-util-man		.man
 ./usr/share/man/man1/sysstat.1			man-util-man		.man
 ./usr/share/man/man1/systat.1			man-util-man		.man
 ./usr/share/man/man1/systrace.1			man-obsolete		obsolete

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2169 src/doc/CHANGES:1.2170
--- src/doc/CHANGES:1.2169	Fri Jun  3 20:41:04 2016
+++ src/doc/CHANGES	Sat Jun  4 15:27:11 2016
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2169 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2170 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -316,3 +316,5 @@ Changes from NetBSD 7.0 to NetBSD 8.0:
 		there [christos 20160527]
 	zoneinfo: Import tzdata2016d. [agc 20160531]
 	ntp: Import ntp 4.2.8p8. [christos 20160603]
+	sys_info: Import a script to return version information for system
+		libraries and utilities [agc 20160604]

Index: src/usr.bin/Makefile
diff -u src/usr.bin/Makefile:1.224 src/usr.bin/Makefile:1.225
--- src/usr.bin/Makefile:1.224	Sun Jan 24 17:08:16 2016
+++ src/usr.bin/Makefile	Sat Jun  4 15:27:11 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.224 2016/01/24 17:08:16 christos Exp $
+#	$NetBSD: Makefile,v 1.225 2016/06/04 15:27:11 agc Exp $
 #	from: @(#)Makefile	8.3 (Berkeley) 1/7/94
 
 .include <bsd.own.mk>
@@ -25,7 +25,8 @@ SUBDIR= apply asa at audio audiocfg \
 	renice rev revoke rfcomm_sppd rlogin rpcgen rpcinfo rs rsh \
 	rup ruptime rusers rwall rwho \
 	script sdiff sdpquery sed seq shar shlock \
-	showmount shuffle sockstat sort sortinfo spell split stat su systat \
+	showmount shuffle sockstat sort sortinfo \
+	spell split stat su sys_info systat \
 	tabs tail talk tcopy tee telnet tftp tic time timeout tip touch \
 	tpfmt tput \
 	tr true tset tsort tty ul uname unexpand unifdef \

Added files:

Index: src/usr.bin/sys_info/Makefile
diff -u /dev/null src/usr.bin/sys_info/Makefile:1.1
--- /dev/null	Sat Jun  4 15:27:11 2016
+++ src/usr.bin/sys_info/Makefile	Sat Jun  4 15:27:11 2016
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2016/06/04 15:27:11 agc Exp $
+
+SCRIPTS=	sys_info
+SCRIPTSDIR=	/usr/bin
+MAN=		sys_info.1
+CLEANFILES+=	${SCRIPTS}
+
+.include <bsd.prog.mk>
Index: src/usr.bin/sys_info/README
diff -u /dev/null src/usr.bin/sys_info/README:1.1
--- /dev/null	Sat Jun  4 15:27:11 2016
+++ src/usr.bin/sys_info/README	Sat Jun  4 15:27:11 2016
@@ -0,0 +1,52 @@
+The sys_info script is a small script which will show the version
+information for installed utilities.  It also works on the kernel, and
+on most libraries.
+
+Its use is as follow:
+
+	[19:41:13] agc@netbsd-002 ...external/bsd/sys_info [4568] > ./sys_info -a
+	awk-20121220
+	bind-9.10.3pl3
+	bzip2-1.0.6
+	calendar-20160601
+	ftpd-20110904
+	g++-4.8.5
+	gcc-4.8.5
+	grep-2.5.1anb1
+	gzip-20150113
+	bozohttpd-20151231
+	NetBSD-7.99.26
+	netpgp-3.99.17
+	netpgpverify-20160214
+	ntp-4.2.8pl5
+	openssl-1.0.1r
+	sqlite3-3.12.2
+	openssh-7.1
+	opensshd-7.1
+	tcsh-6.19.00
+	xz-5.2.1
+	[19:41:20] agc@netbsd-002 ...external/bsd/sys_info [4569] > ./sys_info ntp ssh netpgp
+	ntp-4.2.8pl5
+	openssh-7.1
+	netpgp-3.99.17
+	[19:41:31] agc@netbsd-002 ...external/bsd/sys_info [4570] > ./sys_info ntp ssh netbsd
+	ntp-4.2.8pl5
+	openssh-7.1
+	NetBSD-7.99.26
+	[19:41:38] agc@netbsd-002 ...external/bsd/sys_info [4571] >
+
+The -a option can be given to the script to print out the information
+on all known components.
+
+The sys_info script also works on libraries, returning their
+"versions" as given by the shared object version numbers.
+
+	[19:45:06] agc@netbsd-002 ...external/bsd/sys_info [4572] > ./sys_info libevent libXfont libc netbsd
+	libevent-4.0
+	libXfont-3.0
+	libc-12.200
+	NetBSD-7.99.26
+	[19:45:27] agc@netbsd-002 ...external/bsd/sys_info [4573] >
+
+Alistair Crooks
+Wed Jun  1 19:44:01 PDT 2016
Index: src/usr.bin/sys_info/sys_info.1
diff -u /dev/null src/usr.bin/sys_info/sys_info.1:1.1
--- /dev/null	Sat Jun  4 15:27:11 2016
+++ src/usr.bin/sys_info/sys_info.1	Sat Jun  4 15:27:11 2016
@@ -0,0 +1,66 @@
+.\" $NetBSD: sys_info.1,v 1.1 2016/06/04 15:27:11 agc Exp $
+.\"
+.\" Copyright (c) 2016 Alistair Crooks <a...@netbsd.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd June 1, 2016
+.Dt SYS_INFO 1
+.Os
+.Sh NAME
+.Nm sys_info
+.Nd script to show versioning information
+.Sh SYNOPSIS
+.Nm
+.Op Fl av
+.Op Ar
+.Sh DESCRIPTION
+The
+.Nm
+script displays version numbers for system components.
+It is useful for finding out the installed versions of
+the components of a system.
+The
+.Nm
+utility uses a combination of ways to retrieve version
+information from the installed utilities.
+.Sh OPTIONS
+The following options are available:
+.Bl -tag -width inits
+.It Fl a
+Show the version numbers of all components.
+.It Fl v
+Perform the operations in a verbose manner.
+.El
+.Sh SEE ALSO
+.Xr awk 1 ,
+.Xr strings 1
+.Sh HISTORY
+The
+.Nm
+program was first seen in
+.Nx 8 .
+.Sh AUTHORS
+The
+.Nm
+script was written by
+.An Alistair Crooks Aq Mt a...@netbsd.org .
Index: src/usr.bin/sys_info/sys_info.sh
diff -u /dev/null src/usr.bin/sys_info/sys_info.sh:1.1
--- /dev/null	Sat Jun  4 15:27:11 2016
+++ src/usr.bin/sys_info/sys_info.sh	Sat Jun  4 15:27:11 2016
@@ -0,0 +1,146 @@
+#! /bin/sh
+
+# $NetBSD: sys_info.sh,v 1.1 2016/06/04 15:27:11 agc Exp $
+
+# Copyright (c) 2016 Alistair Crooks <a...@netbsd.org>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-/usr/lib:/usr/X11R7/lib}
+
+# print out the version for the given argument
+getversion() {
+	case "$1" in
+	awk)
+		awk --version | awk '{ print $1 "-" $3 }'
+		;;
+	bind|named)
+		named -v | awk '{ gsub("-", "", $2); gsub("P", "pl", $2); print tolower($1) "-" $2 }'
+		;;
+	bzip2)
+		bzip2 --help 2>&1 | awk '{ sub(",", "", $7); print "bzip2-" $7; exit }'
+		;;
+	calendar)
+		v=$(calendar -v 2>/dev/null || true)
+		case "${v}" in
+		"")	echo "calendar-20150701" ;;
+		*)	echo ${v} ;;
+		esac
+		;;
+	ftpd)
+		strings -a /usr/libexec/ftpd | awk '$1 == "NetBSD-ftpd" { print "ftpd-" $2 }'
+		;;
+	g++|c++)
+		g++ --version | awk '{ print $1 "-" $4; exit }'
+		;;
+	gcc|cc)
+		gcc --version | awk '{ print $1 "-" $4; exit }'
+		;;
+	grep)
+		grep --version | awk '{ print $1 "-" $4 $5; exit }'
+		;;
+	gzip)
+		gzip --version 2>&1 | awk '{ print $2 "-" $3 }'
+		;;
+	httpd|bozohttpd)
+		v=$(/usr/libexec/httpd -G 2>/dev/null || true)
+		case "${v}" in
+		"")
+			strings -a /usr/libexec/httpd | awk -F/ '$1 == "bozohttpd" && NF == 2 { print $1 "-" $2; exit }'
+			;;
+		*)
+			echo bozohttpd-${v##*/}
+			;;
+		esac
+		;;
+	lib*)
+		dlist=$(echo ${LD_LIBRARY_PATH} | awk '{ gsub(":", " "); print }')
+		for d in ${dlist}; do
+			if [ -e ${d}/$1.so ]; then
+				ls -al ${d}/$1.so | awk '{ sub(".*/", "", $11); sub("\\.so\\.", "-", $11); print $11 }'
+				break
+			fi
+		done
+		;;
+	netbsd)
+		uname -sr | awk '{ print $1 "-" $2 }'
+		;;
+	netpgp)
+		netpgp -V | awk '{ sub("/.*", "", $3); print "netpgp-" $3; exit }'
+		;;
+	netpgpverify)
+		netpgpverify -v | awk '{ print $1 "-" $3 }'
+		;;
+	ntp)
+		ntpq --version | awk '{ sub("-.", ""); sub("p", "pl", $2); print "ntp-" $2 }'
+		;;
+	openssl)
+		openssl version 2>/dev/null | awk '{ print tolower($1) "-" $2 }'
+		;;
+	sqlite|sqlite3)
+		sqlite3 --version | awk '{ print "sqlite3-" $1 }'
+		;;
+	ssh|openssh)
+		ssh -V 2>&1 | awk '{ sub("_", "-", $1); print tolower($1) }'
+		;;
+	sshd)
+		sshd -V 2>&1 | awk '/OpenSSH/ { sub("_", "D-", $1); print tolower($1) }'
+		;;
+	tcsh)
+		tcsh -c 'echo $version' | awk '{ print $1 "-" $2 }'
+		;;
+	unbound)
+		case $(uname -s) in
+		FreeBSD)
+			unbound-control -h | awk '/^Version/ { print "unbound-" $2 }'
+			;;
+		esac
+		;;
+	xz)
+		xz --version | awk '{ print $1 "-" $4; exit }'
+		;;
+	esac
+}
+
+all=false
+while [ $# -gt 0 ]; do
+	case "$1" in
+	-a)	all=true ;;
+	-v)	set -x ;;
+	*)	break ;;
+	esac
+	shift
+done
+
+# if we want to do every one, then let's get the arguments
+# not really scalable
+if ${all}; then
+	args='awk bind bzip2 calendar ftpd g++ gcc grep gzip httpd netbsd netpgp'
+	args="${args} netpgpverify ntp openssl sqlite ssh sshd tcsh unbound xz"
+	set -- ${args}
+fi
+
+while [ $# -gt 0 ]; do
+	getversion $1
+	shift
+done

Reply via email to