Fri Jul 22 09:14:43 2022 UTC ()
mk: When calculating OPSYS_VERSION, use the userland version (/etc/release)
on NetBSD, rather than the kernel version. Should resolve building
packages with workarounds for -9 on a -9 userland and CURRENT kernel.

Thanks to Hauke Fath for the hint.


(nia)
diff -r1.422 -r1.423 pkgsrc/mk/bsd.prefs.mk

cvs diff -r1.422 -r1.423 pkgsrc/mk/bsd.prefs.mk (expand / switch to unified diff)

--- pkgsrc/mk/bsd.prefs.mk 2022/06/07 10:04:25 1.422
+++ pkgsrc/mk/bsd.prefs.mk 2022/07/22 09:14:43 1.423
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: bsd.prefs.mk,v 1.422 2022/06/07 10:04:25 jperkin Exp $ 1# $NetBSD: bsd.prefs.mk,v 1.423 2022/07/22 09:14:43 nia Exp $
2# 2#
3# This file includes the mk.conf file, which contains the user settings. 3# This file includes the mk.conf file, which contains the user settings.
4# 4#
5# Packages should include this file before any of the .if directives, as 5# Packages should include this file before any of the .if directives, as
6# well as before modifying variables like CFLAGS, LDFLAGS, and so on. 6# well as before modifying variables like CFLAGS, LDFLAGS, and so on.
7# Otherwise the behavior may be unexpected. 7# Otherwise the behavior may be unexpected.
8# 8#
9# When mk.conf is included by this file, the following variables are 9# When mk.conf is included by this file, the following variables are
10# defined: 10# defined:
11# 11#
12# ACCEPTABLE_LICENSES 12# ACCEPTABLE_LICENSES
13# This variable is set to the list of Open Source licenses. See 13# This variable is set to the list of Open Source licenses. See
14# mk/license.mk for details. 14# mk/license.mk for details.
@@ -103,28 +103,34 @@ OS_VARIANT?= # empty @@ -103,28 +103,34 @@ OS_VARIANT?= # empty
103.if !defined(OS_VERSION) 103.if !defined(OS_VERSION)
104_OS_VERSION_CMD= ${UNAME} -r 104_OS_VERSION_CMD= ${UNAME} -r
105OS_VERSION= ${_OS_VERSION_CMD:sh} 105OS_VERSION= ${_OS_VERSION_CMD:sh}
106MAKEFLAGS+= OS_VERSION=${OS_VERSION:Q} 106MAKEFLAGS+= OS_VERSION=${OS_VERSION:Q}
107.endif 107.endif
108 108
109# 109#
110# OPSYS_VERSION differs from OS_VERSION in that it should always evaluate to 110# OPSYS_VERSION differs from OS_VERSION in that it should always evaluate to
111# an integer, allowing arithmetic expressions to simplify make(1) tests. The 111# an integer, allowing arithmetic expressions to simplify make(1) tests. The
112# default command is likely correct for most OS, those that need to can set 112# default command is likely correct for most OS, those that need to can set
113# it to a custom command in the later OPSYS-specific section. 113# it to a custom command in the later OPSYS-specific section.
114# 114#
115.if !defined(OPSYS_VERSION) 115.if !defined(OPSYS_VERSION)
 116. if ${OPSYS} == "NetBSD" && exists(/etc/release)
 117_OPSYS_VERSION_CMD= head -1 /etc/release | \
 118 sed -e "s,^NetBSD ,,g" | \
 119 awk -F. '{major=int($$1); minor=int($$2); if (minor>=100) minor=99; patch=int($$3); if (patch>=100) patch=99; printf "%02d%02d%02d", major, minor, patch}'
 120. else
116_OPSYS_VERSION_CMD= ${UNAME} -r | \ 121_OPSYS_VERSION_CMD= ${UNAME} -r | \
117 awk -F. '{major=int($$1); minor=int($$2); if (minor>=100) minor=99; patch=int($$3); if (patch>=100) patch=99; printf "%02d%02d%02d", major, minor, patch}' 122 awk -F. '{major=int($$1); minor=int($$2); if (minor>=100) minor=99; patch=int($$3); if (patch>=100) patch=99; printf "%02d%02d%02d", major, minor, patch}'
 123. endif
118OPSYS_VERSION= ${_OPSYS_VERSION_CMD:sh} 124OPSYS_VERSION= ${_OPSYS_VERSION_CMD:sh}
119MAKEFLAGS+= OPSYS_VERSION=${OPSYS_VERSION:Q} 125MAKEFLAGS+= OPSYS_VERSION=${OPSYS_VERSION:Q}
120.endif 126.endif
121 127
122# Preload these for architectures not in all variations of bsd.own.mk, 128# Preload these for architectures not in all variations of bsd.own.mk,
123# which do not match their GNU names exactly. 129# which do not match their GNU names exactly.
124GNU_ARCH.aarch64eb?= aarch64_be 130GNU_ARCH.aarch64eb?= aarch64_be
125GNU_ARCH.coldfire?= m5407 131GNU_ARCH.coldfire?= m5407
126GNU_ARCH.arm26?= arm 132GNU_ARCH.arm26?= arm
127GNU_ARCH.arm32?= arm 133GNU_ARCH.arm32?= arm
128GNU_ARCH.amd64?= x86_64 134GNU_ARCH.amd64?= x86_64
129GNU_ARCH.earm?= arm 135GNU_ARCH.earm?= arm
130GNU_ARCH.earmhf?= arm 136GNU_ARCH.earmhf?= arm