Module Name: src Committed By: agc Date: Thu Sep 21 01:15:45 UTC 2017
Modified Files: src/usr.bin/sys_info: sys_info.1 sys_info.sh Log Message: Update sys_info to 20170920 + add a -d <destdir> option, which allows the versions of programs in a directory tree rooted at "<destdir>" to be reported on, rather than the programs and libraries rooted under /. This is useful, for example, for finding out the versions of utilities and libraries after a build.sh run: % sys_info awk-20121220 bind-9.10.5pl2 bozohttpd-20170201 bzip2-1.0.6 calendar-20160601 dhcpcd-7.0.0-rc1 dtc-1.4.4 ftpd-20110904 g++-5.4.0 gcc-5.4.0 grep-2.5.1anb1 gzip-20170803 libc-12.208 ... % sys_info -d /data/8/build/dest/x86_64 awk-20121220 bind-9.10.5pl1 bozohttpd-20170201 bzip2-1.0.6 calendar-20160601 dhcpcd-7.0.0-rc1 ftpd-20110904 g++-5.4.0 gcc-5.4.0 grep-2.5.1anb1 gzip-20150113 libc-12.207 ... % To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.bin/sys_info/sys_info.1 cvs rdiff -u -r1.14 -r1.15 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/usr.bin/sys_info/sys_info.1 diff -u src/usr.bin/sys_info/sys_info.1:1.6 src/usr.bin/sys_info/sys_info.1:1.7 --- src/usr.bin/sys_info/sys_info.1:1.6 Sun Aug 27 20:39:26 2017 +++ src/usr.bin/sys_info/sys_info.1 Thu Sep 21 01:15:45 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: sys_info.1,v 1.6 2017/08/27 20:39:26 wiz Exp $ +.\" $NetBSD: sys_info.1,v 1.7 2017/09/21 01:15:45 agc Exp $ .\" .\" Copyright (c) 2016 Alistair Crooks <a...@netbsd.org> .\" All rights reserved. @@ -23,7 +23,7 @@ .\" (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 August 23, 2017 +.Dd September 20, 2017 .Dt SYS_INFO 1 .Os .Sh NAME @@ -31,9 +31,10 @@ .Nd script to show system version information .Sh SYNOPSIS .Nm -.Op Fl v .Op Fl L Ar lib-path .Op Fl P Ar path +.Op Fl d Ar destination-dir +.Op Fl v .Op Ar component No ... .Sh DESCRIPTION The @@ -66,6 +67,15 @@ via is used. To use the current value of $PATH from the caller, use: .Dl -P \*q$PATH\*q +.It Fl d +This option provides a destination directory, used +as the root directory of an alternative set of programs +and libraries. +This can be useful for finding versions of utilities +and libraries rooted in the file system directory, +such as the destination directory from a +.Dv build.sh +run. .It Fl v Show the commands used to obtain the version information for each component Index: src/usr.bin/sys_info/sys_info.sh diff -u src/usr.bin/sys_info/sys_info.sh:1.14 src/usr.bin/sys_info/sys_info.sh:1.15 --- src/usr.bin/sys_info/sys_info.sh:1.14 Sat Sep 9 14:12:09 2017 +++ src/usr.bin/sys_info/sys_info.sh Thu Sep 21 01:15:45 2017 @@ -1,6 +1,6 @@ #! /bin/sh -# $NetBSD: sys_info.sh,v 1.14 2017/09/09 14:12:09 jmcneill Exp $ +# $NetBSD: sys_info.sh,v 1.15 2017/09/21 01:15:45 agc Exp $ # Copyright (c) 2016 Alistair Crooks <a...@netbsd.org> # All rights reserved. @@ -26,7 +26,7 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -SYS_INFO_VERSION=20170909 +SYS_INFO_VERSION=20170920 PATH=$(sysctl -n user.cs_path) export PATH @@ -110,10 +110,10 @@ getversion() { run "named -v | awk '{ gsub(\"-\", \"\", \$2); gsub(\"P\", \"pl\", \$2); print tolower(\$1) \"-\" \$2 }'" $all || return 0 ;& bozohttpd|httpd) - v=$(run "/usr/libexec/httpd -G" 2>/dev/null) + v=$(run "${destdir}/usr/libexec/httpd -G" 2>/dev/null) case "${v}" in "") - run "strings -a /usr/libexec/httpd | awk -F/ '\$1 == \"bozohttpd\" && NF == 2 { print \$1 \"-\" \$2; exit }'" + run "strings -a ${destdir}/usr/libexec/httpd | awk -F/ '\$1 == \"bozohttpd\" && NF == 2 { print \$1 \"-\" \$2; exit }'" ;; *) printf '%s\n' "bozohttpd-${v##*/}" @@ -207,8 +207,8 @@ getversion() { fi $all || return 0 ;& tzdata) - if [ -f /usr/share/zoneinfo/TZDATA_VERSION ]; then - run "cat /usr/share/zoneinfo/TZDATA_VERSION" + if [ -f ${destdir}/usr/share/zoneinfo/TZDATA_VERSION ]; then + run "cat ${destdir}/usr/share/zoneinfo/TZDATA_VERSION" else run "printf '%s\n' tzdata-too-old-to-matter" fi @@ -221,7 +221,7 @@ getversion() { fi $all || return 0 ;& [uU]ser[lL]and|release) - run "sed </etc/release -e 's/ /-/g' -e 's/^/userland-/' -e 1q" + run "sed <${destdir}/etc/release -e 's/ /-/g' -e 's/^/userland-/' -e 1q" $all || return 0 ;& xz) run "xz --version | awk '{ print \$1 \"-\" \$4; exit }'" @@ -240,14 +240,18 @@ getversion() { } verbose=false +destdir="" # check if we have our only option -while getopts "L:P:v" a; do +while getopts "L:P:d:v" a; do case "$a" in - v) verbose=true;; L) LIBRARY_PATH=${OPTARG};; P) PATH=${OPTARG};; + d) PATH=${OPTARG}/bin:${OPTARG}/sbin:${OPTARG}/usr/bin:${OPTARG}/usr/sbin + LIBRARY_PATH=${OPTARG}/usr/lib:${OPTARG}/usr.X11R7/lib + destdir=${OPTARG};; + v) verbose=true;; \?) printf >&2 '%s\n' \ - "Usage: $0 [-v] [-L lib-path] [-P path] [component ...]" + "Usage: $0 [-P path] [-L libdirs] [-d destdir] [-v] [system...]" exit 2 esac done