diff -Nru distro-info-0.14build1/debian/changelog distro-info-0.14ubuntu1/debian/changelog --- distro-info-0.14build1/debian/changelog 2015-07-22 06:37:33.000000000 +0000 +++ distro-info-0.14ubuntu1/debian/changelog 2016-04-06 17:17:09.000000000 +0000 @@ -1,3 +1,10 @@ +distro-info (0.14ubuntu1) xenial; urgency=medium + + * Allow --lts and --devel to be used together, to get the currnet LTS, "even + if it's under development". + + -- LaMont Jones Wed, 06 Apr 2016 11:16:15 -0600 + distro-info (0.14build1) wily; urgency=medium * No-change rebuild for python3.5 transition diff -Nru distro-info-0.14build1/distro-info-util.c distro-info-0.14ubuntu1/distro-info-util.c --- distro-info-0.14build1/distro-info-util.c 2014-10-21 08:06:31.000000000 +0000 +++ distro-info-0.14ubuntu1/distro-info-util.c 2016-04-06 16:58:19.000000000 +0000 @@ -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 -Nru distro-info-0.14build1/python/distro_info.py distro-info-0.14ubuntu1/python/distro_info.py --- distro-info-0.14build1/python/distro_info.py 2014-10-21 07:58:51.000000000 +0000 +++ distro-info-0.14ubuntu1/python/distro_info.py 2016-04-06 17:02:46.000000000 +0000 @@ -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 -Nru distro-info-0.14build1/python/distro_info_test/test_distro_info.py distro-info-0.14ubuntu1/python/distro_info_test/test_distro_info.py --- distro-info-0.14build1/python/distro_info_test/test_distro_info.py 2014-10-21 07:58:51.000000000 +0000 +++ distro-info-0.14ubuntu1/python/distro_info_test/test_distro_info.py 2016-04-06 16:59:20.000000000 +0000 @@ -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 -Nru distro-info-0.14build1/ubuntu-distro-info.c distro-info-0.14ubuntu1/ubuntu-distro-info.c --- distro-info-0.14build1/ubuntu-distro-info.c 2014-10-21 07:58:51.000000000 +0000 +++ distro-info-0.14ubuntu1/ubuntu-distro-info.c 2016-04-06 17:03:32.000000000 +0000 @@ -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"