diff --git a/distro-info-util.c b/distro-info-util.c index 6374f92..0c026e6 100644 --- a/distro-info-util.c +++ b/distro-info-util.c @@ -536,7 +536,7 @@ #endif "--all, --devel, " #ifdef UBUNTU - "--lts, " + "--latest, --lts, " #endif #ifdef DEBIAN "--oldstable, " @@ -568,6 +568,9 @@ #ifdef DEBIAN char *alias_codename = NULL; #endif +#ifdef UBUNTU + bool filter_latest = false; +#endif const struct option long_options[] = { {"help", no_argument, NULL, 'h' }, @@ -587,13 +590,14 @@ {"testing", no_argument, NULL, 't' }, #endif #ifdef UBUNTU + {"latest", no_argument, NULL, 'l' }, {"lts", no_argument, NULL, 'L' }, #endif {NULL, 0, NULL, '\0' } }; #ifdef UBUNTU - const char *short_options = "hadscrfy::"; + const char *short_options = "hadscrfly::"; #endif #ifdef DEBIAN const char *short_options = "hadscrfoty::"; @@ -674,6 +678,13 @@ return EXIT_SUCCESS; #ifdef UBUNTU + case 'l': + selected_filters++; + filter_latest = true; + filter_cb = filter_devel; + select_cb = select_latest_created; + break; + case 'L': // Only long option --lts is used selected_filters++; @@ -828,6 +839,11 @@ filter_data(distro_list, date, date_index, just_days, filter_cb, print_cb); } else { selected = get_distro(distro_list, date, filter_cb, select_cb); +#ifdef UBUNTU + if(selected == NULL && filter_latest) { + selected = get_distro(distro_list, date, filter_stable, select_latest_release); + } +#endif if(selected == NULL) { fprintf(stderr, NAME ": " OUTDATED_ERROR "\n"); return_value = EXIT_FAILURE; diff --git a/doc/ubuntu-distro-info.1 b/doc/ubuntu-distro-info.1 index 454f2bb..ede1f9d 100644 --- a/doc/ubuntu-distro-info.1 +++ b/doc/ubuntu-distro-info.1 @@ -50,6 +50,10 @@ \fB\-d\fR, \fB\-\-devel\fR latest development version .TP +\fB\-l\fR, \fB\-\-latest\fR +prints the latest development version. In case of outdated distribution data, +the latest stable version will be printed. +.TP \fB\-\-lts\fR latest long term support (LTS) version .TP diff --git a/test-ubuntu-distro-info b/test-ubuntu-distro-info index 71d3f8d..d8dc9e8 100755 --- a/test-ubuntu-distro-info +++ b/test-ubuntu-distro-info @@ -41,6 +41,11 @@ testDevel() { success "--date 2011-01-10 --devel" "natty" success "--date 2010-05-10 -d --codename" "maverick" +} + +testLatest() { + success "--date 2011-01-10 --latest" "natty" + success "--date 2010-05-10 -l --codename" "maverick" } testLTS() { @@ -178,7 +183,7 @@ } testExactlyOne() { - local result='ubuntu-distro-info: You have to select exactly one of --all, --devel, --lts, --stable, --supported, --unsupported.' + local result='ubuntu-distro-info: You have to select exactly one of --all, --devel, --latest, --lts, --stable, --supported, --unsupported.' failure "" "$result" failure "--date=2009-01-10 -sad" "$result" } @@ -207,6 +212,7 @@ failure "--date 1970-10-03 --lts" "ubuntu-distro-info: $outdated_e" failure "--date ${future_year}-10-03 -s" "ubuntu-distro-info: $outdated_e" failure "--date ${future_year}-10-03 -d" "ubuntu-distro-info: $outdated_e" + failure "--date ${future_year}-10-03 -l" "ubuntu-distro-info: $outdated_e" } testInvalidDate() {