~ubuntu-core-dev/choose-mirror/ubuntu

« back to all changes in this revision

Viewing changes to choose-mirror.c

  • Committer: Mathieu Trudel-Lapierre
  • Date: 2015-10-27 16:41:16 UTC
  • Revision ID: mathieu.trudel-lapierre@canonical.com-20151027164116-t3h0hejulpqpqt7a
* Resynchronise with Debian.  Remaining changes:
  - Use Ubuntu mirrors.
  - Ubuntu branding.
  - Set default country to GB.
  - Never ask mirror/suite, mark it untranslatable, and give it
    appropriate choices for Ubuntu.
  - Pick CC.archive.ubuntu.com (for the country selected in the installer)
    as the default mirror. For ports architectures (armel, powerpc) use
    ports.ubuntu.com instead.
  - Drop the priorities of the country/mirror questions to medium if we're
    installing from a CD that includes the base system.
  - Support setting OVERRIDE_BASE_INSTALLABLE in the environment to force
    choose-mirror to assume that the base system is installable.
  - Skip mirror validation if the base system is installable and we're
    installing from a mirror in the masterlist.
  - Don't check if archive.ubuntu.com is reachable before asking for a
    proxy.
  - Allow preseeding the default CC.archive.ubuntu.com setup by preseeding
    mirror/http/mirror to CC.archive.ubuntu.com, and likewise for
    mirror/ftp/mirror.
  - Force xgettext to use UTF-8 encoding when generating templates files,
    to cope with Côte d'Ivoire.
  - Only default mirror/country to the value of debian-installer/country
    if the latter has any mirrors; otherwise, fall through to defaulting
    to GB.
  - Exclude all-countries mirrors such as ports.ubuntu.com when
    determining whether there is a mirror in the country specified in
    debian-installer/country.
  - If the selected country has no mirror (excluding all-countries
    mirrors), then fall back to the default.

Show diffs side-by-side

added added

removed removed

Lines of Context:
264
264
 
265
265
        free(t_release.name);
266
266
        free(t_release.suite);
 
267
        free(t_release.archs);
267
268
 
268
269
        return ret;
269
270
}
318
319
        char *command;
319
320
        FILE *f = NULL;
320
321
        char *wget_options, *hostname, *directory;
321
 
        char line[80];
 
322
        char line[BUFFER_LENGTH];
322
323
        char *p;
323
 
        char buf[SUITE_LENGTH];
 
324
        char buf[BUFFER_LENGTH];
324
325
 
325
326
        if (base_on_cd && ! manual_entry) {
326
327
                /* We have the base system on the CD, so instead of trying
361
362
        }
362
363
 
363
364
        wget_options = get_wget_options();
364
 
        command = xasprintf("wget %s %s://%s%s/dists/%s/Release -O - | grep -E '^(Suite|Codename):'",
 
365
        command = xasprintf("wget %s %s://%s%s/dists/%s/Release -O - | grep -E '^(Suite|Codename|Architectures):'",
365
366
                            wget_options, protocol, hostname, directory, name);
366
367
        di_log(DI_LOG_LEVEL_DEBUG, "command: %s", command);
367
368
        f = popen(command, "r");
377
378
                        if (line[strlen(line) - 1] == '\n')
378
379
                                line[strlen(line) - 1] = '\0';
379
380
                        if ((value = strstr(line, ": ")) != NULL) {
380
 
                                strncpy(buf, value + 2, SUITE_LENGTH - 1);
381
 
                                buf[SUITE_LENGTH - 1] = '\0';
 
381
                                strncpy(buf, value + 2, BUFFER_LENGTH - 1);
 
382
                                buf[BUFFER_LENGTH - 1] = '\0';
382
383
                                if (strncmp(line, "Codename:", 9) == 0)
383
384
                                        release->name = strdup(buf);
384
385
                                if (strncmp(line, "Suite:", 6) == 0)
385
386
                                        release->suite = strdup(buf);
 
387
                                if (strncmp(line, "Architectures:", 14) == 0)
 
388
                                        release->archs = strdup(buf);
386
389
                        }
387
390
                }
388
391
                if (release->name != NULL && strcmp(release->name, name) == 0)
394
397
                    !(release->status & IS_VALID))
395
398
                        log_invalid_release(name, "Suite or Codename");
396
399
 
 
400
                /* Does the release include this arch? */
 
401
                if (release->archs != NULL && strstr(release->archs, ARCH_TEXT) == NULL) {
 
402
                        /* No:  disregard this release */
 
403
                        log_invalid_release(name, "Architectures");
 
404
                        release->status &= ~IS_VALID;
 
405
                        free(release->archs);
 
406
                        free(release->name);
 
407
                        release->name = NULL;
 
408
                }
 
409
 
397
410
                /* Cross-validate the Release file */
398
411
                if (release->status & IS_VALID)
399
412
                        if (! cross_validate_release(release))
498
511
                free(default_suite);
499
512
                free(release.name);
500
513
                free(release.suite);
 
514
                free(release.archs);
501
515
 
502
516
                debconf_input(debconf, "critical", DEBCONF_BASE "bad");
503
517
                if (debconf_go(debconf) == 30)
764
778
        } else {
765
779
                /* check if manually entered mirror is basically ok */
766
780
                debconf_get(debconf, host);
767
 
                if (debconf->value == NULL || strcmp(debconf->value, "") == 0 ||
768
 
                    strchr(debconf->value, '/') != NULL)
 
781
                if (debconf->value == NULL || strcmp(debconf->value, "") == 0)
769
782
                        valid = 0;
 
783
                else {
 
784
                        const char *host_value = debconf->value;
 
785
                        char *scheme_end = strstr(host_value, "://");
 
786
                        if (scheme_end != NULL) {
 
787
                                host_value = scheme_end + sizeof("://") - 1;
 
788
                                debconf_set(debconf, host, host_value);
 
789
                        }
 
790
                        if (strchr(host_value, '/') != NULL)
 
791
                                valid = 0;
 
792
                }
770
793
                debconf_get(debconf, dir);
771
794
                if (debconf->value == NULL || strcmp(debconf->value, "") == 0)
772
795
                        valid = 0;
1033
1056
        for (i=0; releases[i].name != NULL; i++) {
1034
1057
                free(releases[i].name);
1035
1058
                free(releases[i].suite);
 
1059
                free(releases[i].archs);
1036
1060
        }
1037
1061
 
1038
1062
        return (state >= 0) ? 0 : 10; /* backed all the way out */