tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: OS_VERSION on Linux

Greg Troxel <> wrote:
> Michael Forney <> writes:
> > In the end, there is a discrepancy between how pkg_install normalizes
> > the version (truncating at the first [^0-9.]), and how pkgsrc
> > normalizes the version (truncating at the first '-'). To reconcile
> > these two, I propose we change OS_VERSION on Linux to
> >
> >   OS_VERSION:=	${OS_VERSION:C/[^0-9.].*$//}
> >
> > Does this seem like the right resolution?
> Yes, except that the right resolution includes documenting the notion of
> matching transforms in both places and one of them having a per-OS
> comment that says what the normalization is.  (I am the software
> engineering extremist here, having found that comments help my future
> self after I have forgotten.)

How about something like the following for mk/ I'm not
sure what comment to add to pkg_install, or where to add it
( or maybe add/perform.c:normalise_platform?).

Currently, NUMERIC_VERSION_ONLY is set for Cygwin, DragonFly,
FreeBSD, and Linux. In mk/, we have ${OS_VERSION:C/-.*$//}
for DragonFly, FreeBSD, and Linux, and ${_OS_VERSION:C/\(.*\)//}
for Cygwin. It is theoretically possible to have the same issue on
those other operating systems, but I'm not familiar enough with
their versioning schemes to know if it could happen in practice.

RCS file: /cvsroot/pkgsrc/mk/,v
retrieving revision 1.408
diff -u -r1.408
---	7 Jun 2020 05:59:30 -0000	1.408
+++	8 Oct 2020 22:19:37 -0000
@@ -210,7 +210,11 @@
 .elif ${OPSYS} == "Linux"
+# `uname -r` may contain a distribution-specific suffix, or '+' to
+# indicate additional commits. pkg_install only considers leading
+# digits or '.' on Linux, so strip everything after that to avoid
+# a discrepancy.
+OS_VERSION:=		${OS_VERSION:C/[^0-9.].*$//}
 LOWER_OPSYS?=		linux
 .  if exists(/etc/lsb-release)
 CHROMEOS_RELEASE_NAME!=	awk -F = '$$1 == "CHROMEOS_RELEASE_NAME" { print $$2 }' /etc/lsb-release

Home | Main Index | Thread Index | Old Index