[Dnsmasq-discuss] Announce: dnsmasq-2.84 - sort and semantic versioning

M. Buecher maddes+debian at maddes.net
Tue Jan 26 16:55:20 UTC 2021



On 2021-01-26 17:41, M. Buecher wrote:
> On 2021-01-26 00:43, Lonnie Abelbeck wrote:
>>> On Jan 25, 2021, at 5:21 PM, Lonnie Abelbeck 
>>> <lists at lonnie.abelbeck.com> wrote:
>>> 
>>> 
>>>> Get it here:
>>>> 
>>>> http://www.thekelleys.org.uk/dnsmasq/dnsmasq-2.84.tar.gz
>>> 
>>> The version string generated is "2.84rc2"
>>> 
>>> $ cat dnsmasq-2.84/VERSION
>>> (HEAD -> master, tag: v2.84rc2, tag: v2.84, origin/master, 
>>> origin/HEAD)
>> 
>> This patch solves the problem:
>> 
>> --- dnsmasq-2.84/bld/get-version.orig	2021-01-25 17:35:04.882908877 
>> -0600
>> +++ dnsmasq-2.84/bld/get-version	2021-01-25 17:35:58.658467974 -0600
>> @@ -28,7 +28,7 @@
>>       vers=`cat $1/VERSION | sed 's/[(), ]/,/ g' | tr ',' '\n' | grep 
>> ^v[0-9]`
>> 
>>       if [ $? -eq 0 ]; then
>> -         echo "${vers}" | sort -r | head -n 1 | sed 's/^v//'
>> +         echo "${vers}" | sort | head -n 1 | sed 's/^v//'
>>       else
>>           cat $1/VERSION
>>       fi
> 
> Actually sort is not good at sorting semantic versions [1].
> In some cases '-r' will work (2.84, 2.83-post1, 2.83) and in others it
> won't (2.84-rc1, 2.84, 2.83). Same applies for sort without '-r'.
> 
> [1] https://semver.org/
> 
> Just my two cents
> Maddes

Forgot to reference the details for sort's -V|--version-sort option at 
https://www.gnu.org/software/coreutils/manual/coreutils.html#Implementation-Details
Other wrote scripts in other languages like php, Python, etc., e.g. 
https://gist.github.com/andkirby/54204328823febad9d34422427b1937b




More information about the Dnsmasq-discuss mailing list