Package: choose-mirror Version: 2.62 Severity: wishlist Tags: patch User: debian-bsd@lists.debian.org Usertags: jessie kfreebsd
Hi, When installing kfreebsd or hurd in Expert mode, choose-mirror offers to install "jessie - stable" and "stretch - testing" even though the architecture being installed isn't part of those releases. I've attached a patch that adds support for the Architectures: header, to not mention a release if it doesn't include the current arch. Thanks. -- System Information: Debian Release: jessie/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'oldstable') Architecture: kfreebsd-amd64 (x86_64) Kernel: kFreeBSD 9.0-2-amd64-xenhvm-ipsec Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash
diff --git a/choose-mirror.c b/choose-mirror.c index 65885f6..b7d4019 100644 --- a/choose-mirror.c +++ b/choose-mirror.c @@ -300,9 +300,9 @@ static int get_release(struct release_t *release, const char *name) { char *command; FILE *f = NULL; char *wget_options, *hostname, *directory; - char line[80]; + char line[BUFFER_LENGTH]; char *p; - char buf[SUITE_LENGTH]; + char buf[BUFFER_LENGTH]; hostname = add_protocol("hostname"); debconf_get(debconf, hostname); @@ -321,7 +321,7 @@ static int get_release(struct release_t *release, const char *name) { } wget_options = get_wget_options(); - command = xasprintf("wget %s %s://%s%s/dists/%s/Release -O - | grep -E '^(Suite|Codename):'", + command = xasprintf("wget %s %s://%s%s/dists/%s/Release -O - | grep -E '^(Suite|Codename|Architectures):'", wget_options, protocol, hostname, directory, name); di_log(DI_LOG_LEVEL_DEBUG, "command: %s", command); f = popen(command, "r"); @@ -337,12 +337,14 @@ static int get_release(struct release_t *release, const char *name) { if (line[strlen(line) - 1] == '\n') line[strlen(line) - 1] = '\0'; if ((value = strstr(line, ": ")) != NULL) { - strncpy(buf, value + 2, SUITE_LENGTH - 1); - buf[SUITE_LENGTH - 1] = '\0'; + strncpy(buf, value + 2, BUFFER_LENGTH - 1); + buf[BUFFER_LENGTH - 1] = '\0'; if (strncmp(line, "Codename:", 9) == 0) release->name = strdup(buf); if (strncmp(line, "Suite:", 6) == 0) release->suite = strdup(buf); + if (strncmp(line, "Architectures:", 14) == 0) + release->archs = strdup(buf); } } if (release->name != NULL && strcmp(release->name, name) == 0) @@ -354,6 +356,14 @@ static int get_release(struct release_t *release, const char *name) { !(release->status & IS_VALID)) log_invalid_release(name, "Suite or Codename"); + /* Does the release include this arch? */ + if (release->archs != NULL && strstr(release->archs, ARCH_TEXT) == NULL) { + /* No: disregard this release */ + log_invalid_release(name, "Architectures"); + release->status &= ~IS_VALID; + release->name = NULL; + } + /* Cross-validate the Release file */ if (release->status & IS_VALID) if (! cross_validate_release(release)) diff --git a/mirrors.h b/mirrors.h index e592b7a..f73aefb 100644 --- a/mirrors.h +++ b/mirrors.h @@ -17,6 +17,12 @@ struct mirror_t { */ #define MANUAL_ENTRY "manual" +/* + * Allow to read the full Architectures: line from a Release file, + * which is up to 123 bytes long at time of writing. + */ +#define BUFFER_LENGTH 256 + #define SUITE_LENGTH 32 /* Stack of suites */ @@ -43,6 +49,7 @@ static const char suites[][SUITE_LENGTH] = { struct release_t { char *name; char *suite; + char *archs; int status; };