diff -ur t/distro-info-0.14build1/distro-info-util.c distro-info-0.14build1/distro-info-util.c
--- t/distro-info-0.14build1/distro-info-util.c 2014-10-21 02:06:31.000000000 -0600
+++ distro-info-0.14build1/distro-info-util.c 2016-04-06 10:58:19.275234269 -0600
@@ -587,6 +587,8 @@
#endif
#ifdef UBUNTU
bool filter_latest = false;
+ bool lts_option = false;
+ bool devel_option = false;
#endif
const struct option long_options[] = {
@@ -661,7 +663,12 @@
selected_filters++;
filter_cb = filter_devel;
#ifdef UBUNTU
+ devel_option = true;
select_cb = select_latest_created;
+ if (unlikely(lts_option)) {
+ filter_cb = filter_lts_with_devel;
+ selected_filters--;
+ }
#endif
#ifdef DEBIAN
select_cb = select_first;
@@ -722,8 +729,15 @@
case 'L':
// Only long option --lts is used
selected_filters++;
- filter_cb = filter_lts;
- select_cb = select_latest_release;
+ lts_option = true;
+ if (unlikely(devel_option)) {
+ select_cb = select_latest_created;
+ filter_cb = filter_lts_with_devel;
+ selected_filters--;
+ } else {
+ select_cb = select_latest_release;
+ filter_cb = filter_lts;
+ }
break;
#endif
diff -ur t/distro-info-0.14build1/python/distro_info.py distro-info-0.14build1/python/distro_info.py
--- t/distro-info-0.14build1/python/distro_info.py 2014-10-21 01:58:51.000000000 -0600
+++ distro-info-0.14build1/python/distro_info.py 2016-04-06 11:02:46.011241098 -0600
@@ -213,13 +213,15 @@
def __init__(self):
super(UbuntuDistroInfo, self).__init__("Ubuntu")
- def lts(self, date=None, result="codename"):
+ def lts(self, date=None, result="codename", devel_ok=False):
"""Get latest long term support (LTS) Ubuntu distribution based on the
given date."""
if date is None:
date = self._date
distros = [x for x in self._rows if x["version"].find("LTS") >= 0 and
- date >= x["release"] and
+ (date >= x["release"] or
+ devel_ok and
+ date >= x["created"]) and
date <= x["eol"]]
if not distros:
raise DistroDataOutdated()
diff -ur t/distro-info-0.14build1/python/distro_info_test/test_distro_info.py distro-info-0.14build1/python/distro_info_test/test_distro_info.py
--- t/distro-info-0.14build1/python/distro_info_test/test_distro_info.py 2014-10-21 01:58:51.000000000 -0600
+++ distro-info-0.14build1/python/distro_info_test/test_distro_info.py 2016-04-06 10:59:20.935235847 -0600
@@ -124,6 +124,14 @@
"""Test: Get latest long term support (LTS) Ubuntu distribution."""
self.assertEqual(self._distro_info.lts(self._date), "lucid")
+ def test_lts_devel(self):
+ """Test: Get latest long term support (LTS) Ubuntu distribution."""
+ mydate = datetime.date(2014, 3, 1)
+ self.assertEqual(
+ self._distro_info.lts(mydate, devel_ok=True), "trusty")
+ self.assertEqual(
+ self._distro_info.lts(mydate, devel_ok=False), "precise")
+
def test_stable(self):
"""Test: Get latest stable Ubuntu distribution."""
self.assertEqual(self._distro_info.stable(self._date), "maverick")
diff -ur t/distro-info-0.14build1/ubuntu-distro-info.c distro-info-0.14build1/ubuntu-distro-info.c
--- t/distro-info-0.14build1/ubuntu-distro-info.c 2014-10-21 01:58:51.000000000 -0600
+++ distro-info-0.14build1/ubuntu-distro-info.c 2016-04-06 11:03:32.679242293 -0600
@@ -34,4 +34,9 @@
released(date, distro) && !eol(date, distro);
}
+static bool filter_lts_with_devel(const date_t *date, const distro_t *distro) {
+ return strstr(distro->version, "LTS") != NULL &&
+ created(date, distro) && !eol(date, distro);
+}
+
#include "distro-info-util.c"