fanf: (dotat)
[personal profile] fanf

So I have a toy DNS server which runs bleeding edge BIND 9 with a bunch of patches which I have submitted upstream, or which are work in progress, or just stupid. It gets upgraded a lot.

My build and install script puts the version number, git revision, and an install counter into the name of the install directory. So, when I deploy a custom hack which segfaults, I can just flip a symlink and revert to the previous less incompetently modified version.

More recently I have added an auto-upgrade feature to my BIND rc script. This was really simple, stupid: it just used the last install directory from the ls lexical sort. (You can tell it is newish because it could not possibly have coped with the BIND 9.9 -> 9.10 transition.)

It broke today.

BIND 9.11 has been released! Yay! I have lots of patches in it!

Unfortunately 9.11.0 sorts lexically before 9.11.0rc3. So my dumb auto update script refused to update. This can only happen in the transition period between a major release and the version bump on the master branch for the next pre-alpha version. This is a rare edge case for code only I will ever use.

But, I fixed it!

And I learned several cool things in the process!

I started off by wondering if I could plug dpkg --compare-versions into a sorting algorithm. But then I found that GNU sort has a -V version comparison mode. Yay! ls | sort -V!

But what is its version comparison algorithm? Is it as good as dpkg's? The coreutils documentation refers to the gnulib filevercmp() function. This appears not to exist, but gnulib does have a strverscmp() function cloned from glibc.

So look at the glibc man page for strverscmp(). It is a much simpler algorithm than dpkg, but adequate for my purposes. And, I see, built in to GNU ls! (I should have spotted this when reading the coreutils docs, because that uses ls -v as an example!)

Problem solved!

Add an option in ls | tail -1 so it uses ls -v and my script upgrades from 9.11.0rc3 to 9.11.0 without manual jiggery pokery!

And I learned about some GNU carnival organ bells and whistles!

But ... have I seen something like this before?

If you look at the isc.org BIND distribution server, its listing is sorted by version number, not lexically, i.e. 10 sorts after 9 not after 1.

They are using the Apache mod_autoindex IndexOptions VersionSort directive, which works the same as GNU version number sorting.

Nice!

It's pleasing to see widespread support for version number comparisons, even if they aren't properly thought-through elaborate battle hardened dpkg version number comparisons.

Date: 2016-10-06 04:15 am (UTC)
ext_8103: (Default)
From: [identity profile] ewx.livejournal.com
Version string comparison reminds me of string comparison in the QL's BASIC. Page 42 of https://books.google.co.uk/books?id=VYQ4AAAAIAAJ&pg=PA40&lpg=PA40&dq=superbasic+string+comparison&source=bl&ots=Hc2jxl5SwD&sig=09EdhlDpmBTDPKji6vpu48C0vr0&hl=en&sa=X&redir_esc=y#v=onepage&q=superbasic%20string%20comparison&f=false describes it. Briefly, instead comparing strings like strcmp, it would look inside the string for numbers, and compare those numerically. So "a99" < "a100". Very handy if that's what you wanted, but I don't think there was any way to escape it if you didn't...

Pictures from community networks

Date: 2016-10-17 05:13 am (UTC)
From: (Anonymous)
New adult blog website
growing a weed plant sissy ass training sissy chatroom
http://sissyabuse.blogporn.in/?blog.baby
average plasitc surgery cost women dildos sissy spacek movies how do the makeup maid costume plus size فیلم دانلود رایگان سکسی heavy flannel nightgowns oral anhd facial surgery group
Page generated Aug. 20th, 2017 07:59 am
Powered by Dreamwidth Studios