git: 634a770a5e16 - main - /etc/rc.d/motd: Update to accommodate changes in uname(1) and newvers.sh

From: Xin LI <delphij_at_FreeBSD.org>
Date: Tue, 23 May 2023 05:06:17 UTC
The branch main has been updated by delphij:

URL: https://cgit.FreeBSD.org/src/commit/?id=634a770a5e16b424c096b74ac33a145e766dd7af

commit 634a770a5e16b424c096b74ac33a145e766dd7af
Author:     Xin LI <delphij@FreeBSD.org>
AuthorDate: 2023-05-23 04:23:57 +0000
Commit:     Xin LI <delphij@FreeBSD.org>
CommitDate: 2023-05-23 05:05:35 +0000

    /etc/rc.d/motd: Update to accommodate changes in uname(1) and newvers.sh
    
    The recent changes to the uname(1) command removed trailing spaces for
    better POSIX conformance, but it broke the regular expression used by
    the motd script which expected it.  This commit addresses this by removing
    the requirement, as it is no longer present.
    
    Additionally, a recent change in newvers.sh introduced a new format for
    uname -v, which omited the build number and build dates to improve
    reproducible build support.  This commit adds support for this new format.
    
    Reported-by:    Jamie Landeg-Jones <jamie@catflap.org>
    Reviewed-by:    imp
    MFC after:      2 weeks
    Differential Revision: https://reviews.freebsd.org/D40225
---
 libexec/rc/rc.d/motd | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libexec/rc/rc.d/motd b/libexec/rc/rc.d/motd
index d9dd60a0f59a..e27cf273741d 100755
--- a/libexec/rc/rc.d/motd
+++ b/libexec/rc/rc.d/motd
@@ -45,7 +45,8 @@ motd_start()
 	fi
 
 	T=`mktemp -t motd`
-	uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T}
+	uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\)$,\1 (\3) #\2,' \
+	    -e 's,^\([^ ]*\) \([^ ]*\) \([^ ]*\) \([^ ]*\)$,\1 \2 (\4) \3,' > ${T}
 	cat "${TEMPLATE}" >> ${T}
 
 	install -C -o root -g wheel -m "${PERMS}" "$T" "${TARGET}"