Fix 2 bugs in releases logic and mark 4.9 longterm

The release of stable-4.10.1 uncovered two bugs in the logic.

1. The hacky sorting routine we used to compare versions and find out
   the latest incorrectly sorted 4.9 before 4.10. This is fixed by using
   real version comparison routines from distutils.
2. The way we compared longterm releases caused 4.10 to be marked as
   longterm because 4.1 is longterm, and we matched on substring. We're
   now adding an extra dot during comparison to make sure this doesn't
   reoccur.

Also, finally mark 4.9 as longterm now that 4.10 is stable.

Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
diff --git a/pelicanconf.py b/pelicanconf.py
index ef32d58..1eef9c0 100644
--- a/pelicanconf.py
+++ b/pelicanconf.py
@@ -24,7 +24,7 @@
 sys.path.append('./')
 from plugins import releases
 
-LONGTERM_KERNELS = ('4.4', '4.1', '3.18', '3.16', '3.14', '3.12', '3.10', '3.4', '3.2')
+LONGTERM_KERNELS = ('4.9', '4.4', '4.1', '3.18', '3.16', '3.14', '3.12', '3.10', '3.4', '3.2')
 EOL_KERNELS = ('3.14', '3.18', '3.19', '4.0', '4.2', '4.3', '4.5', '4.6', '4.7', '4.8')
 
 GIT_MAINLINE = '/mnt/git-repos/repos/pub/scm/linux/kernel/git/torvalds/linux.git'
diff --git a/plugins/releases.py b/plugins/releases.py
index 1313767..93ca3ca 100755
--- a/plugins/releases.py
+++ b/plugins/releases.py
@@ -24,6 +24,8 @@
 
 from git import Repo
 
+from distutils.version import StrictVersion
+
 from pelican import signals, utils
 
 from feedgenerator import Rss201rev2Feed
@@ -100,7 +102,7 @@
             # does it match a longterm release?
             ignore = False
             for ver in LONGTERM_KERNELS:
-                if tagref.name.find(ver) == 1:
+                if tagref.name.find(ver+'.') == 1:
                     # this is a long-term release, ignore
                     ignore = True
                     continue
@@ -120,9 +122,7 @@
 
             seen.append(regex)
 
-        # hackish, but works -- we make numbers a float and sort by them
-        # e.g. v4.0.1 vs v3.19.2 becomes a comparison of .401 and .3192
-        stable = sorted(stable, key=lambda tagged: float('.' + tagged[0].replace('.', '')[1:]), reverse=True)
+        stable = sorted(stable, key=lambda x: StrictVersion(x[0][1:]), reverse=True)
 
         releases = []