tags 353556 + patch thanks The attached patch will check if the architecture is supported by reading the index.html file for the binary-$arch directory and checking if there is a reference to a Packages.gz file in that. If the arch is not supported, the wget will return 404 and the check will fail. The patch is a bit ugly in that this is now the third function that will determine mirror, suite, etc and perform a wget. It is probably possible to restructure this, but that exceeds my C skills. The patch adds a new error template.
Index: debian/choose-mirror.templates-in
===================================================================
--- debian/choose-mirror.templates-in (revision 34996)
+++ debian/choose-mirror.templates-in (working copy)
@@ -35,6 +35,12 @@
The specified Debian archive mirror is either not available, or does not
have a valid Release file on it. Please try a different mirror.
+Template: mirror/noarch
+Type: error
+_Description: Architecture not supported
+ The specified Debian archive mirror does not seem to support your
+ architecture. Please try a different mirror.
+
Template: debian-installer/choose-mirror/title
Type: text
# main-menu
Index: choose-mirror.c
===================================================================
--- choose-mirror.c (revision 34996)
+++ choose-mirror.c (working copy)
@@ -457,6 +457,60 @@
return ret;
}
+/* Check if the mirror carries the architecture that's being installed. */
+int check_arch (void) {
+ char *command;
+ FILE *f = NULL;
+ char *hostname, *directory, *suite = NULL;
+ int valid = 0;
+
+ hostname = add_protocol("hostname");
+ debconf_get(debconf, hostname);
+ free(hostname);
+ hostname = strdup(debconf->value);
+ directory = add_protocol("directory");
+ debconf_get(debconf, directory);
+ free(directory);
+ directory = strdup(debconf->value);
+
+ /* As suite has been determined previously, this should not fail */
+ debconf_get(debconf, DEBCONF_BASE "suite");
+ if (strlen(debconf->value) > 0) {
+ suite = strdup(debconf->value);
+
+ asprintf(&command, "wget -q %s://%s%s/dists/%s/main/binary-%s/ -O - | grep Packages.gz",
+ protocol, hostname, directory, suite, ARCH_TEXT);
+ di_log(DI_LOG_LEVEL_DEBUG, "command: %s", command);
+ f = popen(command, "r");
+ free(command);
+
+ if (f != NULL) {
+ char buf[SUITE_LENGTH];
+ if (fgets(buf, SUITE_LENGTH - 1, f))
+ if (strlen(buf) > 1)
+ valid = 1;
+ }
+ pclose(f);
+ }
+
+ free(hostname);
+ free(directory);
+ if (suite)
+ free(suite);
+
+ if (valid) {
+ return 0;
+ }
+ else {
+ di_log(DI_LOG_LEVEL_DEBUG, "Architecture not supported by selected mirror");
+ debconf_input(debconf, "critical", DEBCONF_BASE "noarch");
+ if (debconf_go(debconf) == 30)
+ exit(10); /* back up to menu */
+ else
+ return 1; /* back to beginning of questions */
+ }
+}
+
int main (void) {
/* Use a state machine with a function to run in each state */
int state = 0;
@@ -471,6 +525,7 @@
validate_mirror,
choose_suite,
get_codename,
+ check_arch,
NULL,
};
Index: Makefile
===================================================================
--- Makefile (revision 34996)
+++ Makefile (working copy)
@@ -1,7 +1,9 @@
USE_HTTP=1
#USE_FTP=1
-CFLAGS=-Wall -g -D_GNU_SOURCE
+DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
+
+CFLAGS=-Wall -g -D_GNU_SOURCE -DARCH_TEXT='"$(DEB_HOST_ARCH)"'
templates=debian/choose-mirror.templates-in
ifeq (1,${USE_HTTP})
Attachment:
pgpeRs7X1FWwd.pgp
Description: PGP signature