View | Details | Raw Unified | Return to bug 251316 | Differences between
and this patch

Collapse All | Expand All

(-)b/bin/freebsd-version/freebsd-version.1 (-2 / +18 lines)
Lines 25-31 Link Here
25
.\"
25
.\"
26
.\" $FreeBSD$
26
.\" $FreeBSD$
27
.\"
27
.\"
28
.Dd October 1, 2021
28
.Dd August 10, 2022
29
.Dt FREEBSD-VERSION 1
29
.Dt FREEBSD-VERSION 1
30
.Os
30
.Os
31
.Sh NAME
31
.Sh NAME
Lines 33-39 Link Here
33
.Nd print the version and patch level of the installed system
33
.Nd print the version and patch level of the installed system
34
.Sh SYNOPSIS
34
.Sh SYNOPSIS
35
.Nm
35
.Nm
36
.Op Fl kru
36
.Op Fl kruv
37
.Op Fl j Ar jail
37
.Op Fl j Ar jail
38
.Sh DESCRIPTION
38
.Sh DESCRIPTION
39
The
39
The
Lines 61-66 Print the version and patch level of the installed userland. Link Here
61
These are hardcoded into
61
These are hardcoded into
62
.Nm
62
.Nm
63
during the build.
63
during the build.
64
.It Fl v
65
Enable printing out verbose information for kernel and/or userland.
66
It's a representation of
67
.Pa "__FreeBSD_version" .
68
Those are also know as
69
.Pa OSRELDATE
70
or
71
.Pa OSVERSION .
72
More information about it is documented in the Porter's Handbook.
64
.It Fl j Ar jail
73
.It Fl j Ar jail
65
Print the version and patch level of the installed userland in the
74
Print the version and patch level of the installed userland in the
66
given jail specified by
75
given jail specified by
Lines 113-118 To determine the version of the currently running userland: Link Here
113
/bin/freebsd-version -u
122
/bin/freebsd-version -u
114
.Ed
123
.Ed
115
.Pp
124
.Pp
125
To print out a more verbose output of the command above:
126
.Bd -literal -offset indent
127
/bin/freebsd-version -uv
128
.Ed
129
.Pp
116
To inspect a system being repaired using a live CD:
130
To inspect a system being repaired using a live CD:
117
.Bd -literal -offset indent
131
.Bd -literal -offset indent
118
mount -rt ufs /dev/ada0p2 /mnt
132
mount -rt ufs /dev/ada0p2 /mnt
Lines 131-133 The Link Here
131
.Nm
145
.Nm
132
utility and this manual page were written by
146
utility and this manual page were written by
133
.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .
147
.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .
148
The verbose information output was added and documented by
149
.An Vinicius Zavam Aq Mt egypcio@FreeBSD.org .
(-)b/bin/freebsd-version/freebsd-version.sh.in (-5 / +17 lines)
Lines 39-44 LOADER_RE2='^\([A-Z_a-z][0-9A-Z_a-z]*="[-./0-9A-Z_a-z]\{1,\}"\).*$' Link Here
39
KERNEL_RE='^@@TYPE@@ \([-.0-9A-Za-z]\{1,\}\) .*$'
39
KERNEL_RE='^@@TYPE@@ \([-.0-9A-Za-z]\{1,\}\) .*$'
40
40
41
progname=${0##*/}
41
progname=${0##*/}
42
progverbose=0
42
43
43
#
44
#
44
# Print an error message and exit.
45
# Print an error message and exit.
Lines 67-87 kernel_version() { Link Here
67
	if [ ! -f "$kernfile" -o ! -r "$kernfile" ] ; then
68
	if [ ! -f "$kernfile" -o ! -r "$kernfile" ] ; then
68
		error "unable to locate kernel"
69
		error "unable to locate kernel"
69
	fi
70
	fi
70
	what -qs "$kernfile" | sed -n "s/$KERNEL_RE/\\1/p"
71
	if [ $progverbose -gt 0 ] ; then
72
		what -qs "$kernfile" | awk -F':' '{ print $1 }' | cut -d' ' -f2-
73
	else
74
		what -qs "$kernfile" | sed -n "s/$KERNEL_RE/\\1/p"
75
	fi
71
}
76
}
72
77
73
#
78
#
74
# Print the version of the currently running kernel.
79
# Print the version of the currently running kernel.
75
#
80
#
76
running_version() {
81
running_version() {
77
	sysctl -n kern.osrelease
82
	out=$(sysctl -n kern.osrelease)
83
	[ $progverbose -gt 0 ] && out="${out} $(sysctl -n kern.osreldate)"
84
	echo "$out"
78
}
85
}
79
86
80
#
87
#
81
# Print the hardcoded userland version.
88
# Print the hardcoded userland version.
82
#
89
#
83
userland_version() {
90
userland_version() {
84
	echo $USERLAND_VERSION
91
	out=$USERLAND_VERSION
92
	[ $progverbose -gt 0 ] && out="${USERLAND_VERSION} $(uname -U)"
93
	echo "$out"
85
}
94
}
86
95
87
#
96
#
Lines 97-103 jail_version() { Link Here
97
# Print a usage string and exit.
106
# Print a usage string and exit.
98
#
107
#
99
usage() {
108
usage() {
100
	echo "usage: $progname [-kru] [-j jail]" >&2
109
	echo "usage: $progname [-kruv] [-j jail]" >&2
101
	exit 1
110
	exit 1
102
}
111
}
103
112
Lines 107-113 usage() { Link Here
107
main() {
116
main() {
108
	# parse command-line arguments
117
	# parse command-line arguments
109
	local OPTIND=1 OPTARG option
118
	local OPTIND=1 OPTARG option
110
	while getopts "kruj:" option ; do
119
	while getopts "kruvj:" option ; do
111
		case $option in
120
		case $option in
112
		k)
121
		k)
113
			opt_k=1
122
			opt_k=1
Lines 118-123 main() { Link Here
118
		u)
127
		u)
119
			opt_u=1
128
			opt_u=1
120
			;;
129
			;;
130
		v)
131
			progverbose=1
132
			;;
121
		j)
133
		j)
122
			if [ $opt_j ] ; then
134
			if [ $opt_j ] ; then
123
				jail="$jail $OPTARG"
135
				jail="$jail $OPTARG"

Return to bug 251316