NetBSD-Bugs archive

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

toolchain/51457: Incorrect postinstall version-number sort options



>Number:         51457
>Category:       toolchain
>Synopsis:       Incorrect postinstall version-number sort options
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 01 23:55:00 +0000 2016
>Originator:     Michael Plass
>Release:        7.99.36
>Organization:
>Environment:
NetBSD mipi 7.99.36 NetBSD 7.99.36 (RPI2.201608220040Z) evbarm

>Description:
The command
  postinstall fix obsolete_stand
uses a pipeline that includes the step
  sort -t. -r -k1n -k2n -k3n
intended to put the highest three-part version number on the first
line of the output.

But, for example,

$ printf '7.9.1\n7.9.0\n7.9.10\n7.10.1\n' | sort -t. -r -k1n -k2n -k3n
7.9.10
7.9.1
7.9.0
7.10.1

see http://mail-index.netbsd.org/netbsd-users/2016/05/28/msg018532.html
for an explanation why.

The mis-sorting can cause the wrong collection of kernel modules to
be deleted.

To make it worse, other systems interpret these options
differently. The same command on FreeBSD 11 gives

7.9.0
7.9.1
7.9.10
7.10.1

and on OS X (El Capitan),

7.10.1
7.9.0
7.9.1
7.9.10

The latter agrees with a very old GNU/Linux system.

The portability matters, since the script is invoked on the host system 
during a cross-build of 'release'.



>How-To-Repeat:

>Fix:
A better set of options is suggested by

$ printf '7.9.1\n7.9.0\n7.9.10\n7.10.1\n' | sort -t. -r -n -k1,1 -k2,2 -k3,3
7.10.1
7.9.10
7.9.1
7.9.0

which gives the desired output on all the tested platforms.

It might be appropriate to spell the command $SORT in the postinstall
script, but I have not checked the details.



Home | Main Index | Thread Index | Old Index