Codebase list distro-info / 943e726
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
3 changed file(s) with 29 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
535535 #endif
536536 "--all, --devel, "
537537 #ifdef UBUNTU
538 "--lts, "
538 "--latest, --lts, "
539539 #endif
540540 #ifdef DEBIAN
541541 "--oldstable, "
567567 #ifdef DEBIAN
568568 char *alias_codename = NULL;
569569 #endif
570 #ifdef UBUNTU
571 bool filter_latest = false;
572 #endif
570573
571574 const struct option long_options[] = {
572575 {"help", no_argument, NULL, 'h' },
586589 {"testing", no_argument, NULL, 't' },
587590 #endif
588591 #ifdef UBUNTU
592 {"latest", no_argument, NULL, 'l' },
589593 {"lts", no_argument, NULL, 'L' },
590594 #endif
591595 {NULL, 0, NULL, '\0' }
592596 };
593597
594598 #ifdef UBUNTU
595 const char *short_options = "hadscrfy::";
599 const char *short_options = "hadscrfly::";
596600 #endif
597601 #ifdef DEBIAN
598602 const char *short_options = "hadscrfoty::";
673677 return EXIT_SUCCESS;
674678
675679 #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
676687 case 'L':
677688 // Only long option --lts is used
678689 selected_filters++;
827838 filter_data(distro_list, date, date_index, just_days, filter_cb, print_cb);
828839 } else {
829840 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
830846 if(selected == NULL) {
831847 fprintf(stderr, NAME ": " OUTDATED_ERROR "\n");
832848 return_value = EXIT_FAILURE;
4949 \fB\-d\fR, \fB\-\-devel\fR
5050 latest development version
5151 .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
5256 \fB\-\-lts\fR
5357 latest long term support (LTS) version
5458 .TP
4040 testDevel() {
4141 success "--date 2011-01-10 --devel" "natty"
4242 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"
4348 }
4449
4550 testLTS() {
177182 }
178183
179184 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.'
181186 failure "" "$result"
182187 failure "--date=2009-01-10 -sad" "$result"
183188 }
206211 failure "--date 1970-10-03 --lts" "ubuntu-distro-info: $outdated_e"
207212 failure "--date ${future_year}-10-03 -s" "ubuntu-distro-info: $outdated_e"
208213 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"
209215 }
210216
211217 testInvalidDate() {