ubuntu-distro-info: Add --latest option.
The --latest options returns the development version or the latest stable if the
distribution data is outdated and no development version is known.
Benjamin Drung
9 years ago
535 | 535 | #endif |
536 | 536 | "--all, --devel, " |
537 | 537 | #ifdef UBUNTU |
538 | "--lts, " | |
538 | "--latest, --lts, " | |
539 | 539 | #endif |
540 | 540 | #ifdef DEBIAN |
541 | 541 | "--oldstable, " |
567 | 567 | #ifdef DEBIAN |
568 | 568 | char *alias_codename = NULL; |
569 | 569 | #endif |
570 | #ifdef UBUNTU | |
571 | bool filter_latest = false; | |
572 | #endif | |
570 | 573 | |
571 | 574 | const struct option long_options[] = { |
572 | 575 | {"help", no_argument, NULL, 'h' }, |
586 | 589 | {"testing", no_argument, NULL, 't' }, |
587 | 590 | #endif |
588 | 591 | #ifdef UBUNTU |
592 | {"latest", no_argument, NULL, 'l' }, | |
589 | 593 | {"lts", no_argument, NULL, 'L' }, |
590 | 594 | #endif |
591 | 595 | {NULL, 0, NULL, '\0' } |
592 | 596 | }; |
593 | 597 | |
594 | 598 | #ifdef UBUNTU |
595 | const char *short_options = "hadscrfy::"; | |
599 | const char *short_options = "hadscrfly::"; | |
596 | 600 | #endif |
597 | 601 | #ifdef DEBIAN |
598 | 602 | const char *short_options = "hadscrfoty::"; |
673 | 677 | return EXIT_SUCCESS; |
674 | 678 | |
675 | 679 | #ifdef UBUNTU |
680 | case 'l': | |
681 | selected_filters++; | |
682 | filter_latest = true; | |
683 | filter_cb = filter_devel; | |
684 | select_cb = select_latest_created; | |
685 | break; | |
686 | ||
676 | 687 | case 'L': |
677 | 688 | // Only long option --lts is used |
678 | 689 | selected_filters++; |
827 | 838 | filter_data(distro_list, date, date_index, just_days, filter_cb, print_cb); |
828 | 839 | } else { |
829 | 840 | selected = get_distro(distro_list, date, filter_cb, select_cb); |
841 | #ifdef UBUNTU | |
842 | if(selected == NULL && filter_latest) { | |
843 | selected = get_distro(distro_list, date, filter_stable, select_latest_release); | |
844 | } | |
845 | #endif | |
830 | 846 | if(selected == NULL) { |
831 | 847 | fprintf(stderr, NAME ": " OUTDATED_ERROR "\n"); |
832 | 848 | return_value = EXIT_FAILURE; |
49 | 49 | \fB\-d\fR, \fB\-\-devel\fR |
50 | 50 | latest development version |
51 | 51 | .TP |
52 | \fB\-l\fR, \fB\-\-latest\fR | |
53 | prints the latest development version. In case of outdated distribution data, | |
54 | the latest stable version will be printed. | |
55 | .TP | |
52 | 56 | \fB\-\-lts\fR |
53 | 57 | latest long term support (LTS) version |
54 | 58 | .TP |
40 | 40 | testDevel() { |
41 | 41 | success "--date 2011-01-10 --devel" "natty" |
42 | 42 | success "--date 2010-05-10 -d --codename" "maverick" |
43 | } | |
44 | ||
45 | testLatest() { | |
46 | success "--date 2011-01-10 --latest" "natty" | |
47 | success "--date 2010-05-10 -l --codename" "maverick" | |
43 | 48 | } |
44 | 49 | |
45 | 50 | testLTS() { |
177 | 182 | } |
178 | 183 | |
179 | 184 | testExactlyOne() { |
180 | local result='ubuntu-distro-info: You have to select exactly one of --all, --devel, --lts, --stable, --supported, --unsupported.' | |
185 | local result='ubuntu-distro-info: You have to select exactly one of --all, --devel, --latest, --lts, --stable, --supported, --unsupported.' | |
181 | 186 | failure "" "$result" |
182 | 187 | failure "--date=2009-01-10 -sad" "$result" |
183 | 188 | } |
206 | 211 | failure "--date 1970-10-03 --lts" "ubuntu-distro-info: $outdated_e" |
207 | 212 | failure "--date ${future_year}-10-03 -s" "ubuntu-distro-info: $outdated_e" |
208 | 213 | failure "--date ${future_year}-10-03 -d" "ubuntu-distro-info: $outdated_e" |
214 | failure "--date ${future_year}-10-03 -l" "ubuntu-distro-info: $outdated_e" | |
209 | 215 | } |
210 | 216 | |
211 | 217 | testInvalidDate() { |