[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#424640: net-retriever: Should always use udebs from release corresponding to build



Frans Pop wrote:
> Attached are two patches that implement this.
> One patch is for the build system and will include two files in most D-I 
> initrds in a directory /.installer/:
> - default_release: contains the default release to use for the _target_
>   system; currently unused, but intended to replace the hardcoded
>   PREFERRED_DISTRIBUTION in choose-mirror which will mean one less thing
>   needed to update after a stable release
> - udebs_source: normally contains the codename of the release from which
>   udebs were taken when images were built; for daily built images this
>   will be set to "unstable"

Good design. Why put it in /.installer and not in /etc though?

Here's a choose-mirror patch. (untested)

-- 
see shy jo
Index: mirrors.h
===================================================================
--- mirrors.h	(revision 47012)
+++ mirrors.h	(working copy)
@@ -10,7 +10,8 @@
 };
 
 /* This is the codename of the preferred distribution; the one that the
- * current version of d-i is targeted at installing. */
+ * current version of d-i is targeted at installing. This is overridden
+ * by /.installer/default_release, unless the file is somehow missing. */
 #define PREFERRED_DISTRIBUTION "lenny"
 
 /* The two strings defined below must match the strings used in the
Index: choose-mirror.c
===================================================================
--- choose-mirror.c	(revision 47012)
+++ choose-mirror.c	(working copy)
@@ -4,6 +4,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <assert.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 #include "mirrors.h"
 #ifdef WITH_HTTP
 #include "mirrors_http.h"
@@ -138,6 +141,7 @@
 	int nbr_suites = sizeof(suites)/SUITE_LENGTH;
 	int i;
 	int ret = 0;
+	char buf[SUITE_LENGTH];
 
 	if (show_progress) {
 		debconf_progress_start(debconf, 0, 1,
@@ -166,8 +170,16 @@
 				suite = strdup(debconf->value);
 			}
 			else {
-				continue;
+				/* Read /.installer/default_release to
+				 * find the default suite to use. */
+				int i = open("/.installer/default_release", O_RDONLY);
+				if (i == -1 ||
+				    read(i, buf, SUITE_LENGTH - 1) == -1 ||
+				    close(i) == -1)
+					continue;
+				suite = strdup(buf);
 			}
+			
 		}
 		else {
 			suite = strdup(suites[i - 1]);
@@ -180,7 +192,6 @@
 		free(command);
 
 		if (f != NULL) {
-			char buf[SUITE_LENGTH];
 			if (fgets(buf, SUITE_LENGTH - 1, f)) {
 				if (buf[strlen(buf) - 1] == '\n')
 					buf[strlen(buf) - 1] = '\0';

Attachment: signature.asc
Description: Digital signature


Reply to: