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

Bug#635053: Choose-mirror overrides mirror/suite and mirror/codename



Hello,

I just downloaded the latest git repository of choose-mirror and reviewed the code and found the second patch I applied against an older version of choose-mirror (2.29) by accident.

So I looked at the correction of return code and found that this was no longer needed for 2.37 and current git as set_codename always returns 0. I checked this on git head and the diff is the same as the first patch, so I am re-attaching it and I believe that this one should be good.

Sorry for the confusion.

Best regards,
Boleslaw Tokarski
diff --git a/choose-mirror.c b/choose-mirror.c
index 6841ff0..0236128 100644
--- a/choose-mirror.c
+++ b/choose-mirror.c
@@ -708,29 +708,34 @@ int set_codename (void) {
 	char *suite;
 	int i;
 
-	/* 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);
-
-		for (i=0; releases[i].name != NULL; i++) {
-			if (strcmp(releases[i].name, suite) == 0 ||
-			    strcmp(releases[i].suite, suite) == 0) {
-				char *codename;
-
-				if (releases[i].status & GET_CODENAME)
-					codename = releases[i].name;
-				else
-					codename = releases[i].suite;
-				debconf_set(debconf, DEBCONF_BASE "codename", codename);
-				di_log(DI_LOG_LEVEL_INFO,
-					"suite/codename set to: %s/%s",
-					suite, codename);
-				break;
+        /* If preseed specifies codename, omit the codename check */
+	debconf_get(debconf, DEBCONF_BASE "codename");
+	if ( ! strlen(debconf->value) > 0) {
+
+		/* 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);
+
+			for (i=0; releases[i].name != NULL; i++) {
+				if (strcmp(releases[i].name, suite) == 0 ||
+				    strcmp(releases[i].suite, suite) == 0) {
+					char *codename;
+
+					if (releases[i].status & GET_CODENAME)
+						codename = releases[i].name;
+					else
+						codename = releases[i].suite;
+					debconf_set(debconf, DEBCONF_BASE "codename", codename);
+					di_log(DI_LOG_LEVEL_INFO,
+						"suite/codename set to: %s/%s",
+						suite, codename);
+					break;
+				}
 			}
-		}
 
-		free(suite);
+			free(suite);
+		}
 	}
 
 	return 0;
diff --git a/debian/choose-mirror.postinst b/debian/choose-mirror.postinst
index 4a85a78..4689ab0 100644
--- a/debian/choose-mirror.postinst
+++ b/debian/choose-mirror.postinst
@@ -3,10 +3,12 @@
 
 anna-install apt-mirror-setup || true
 
-if [ -f /etc/lsb-release ]; then
-	. /etc/lsb-release
-	if [ -n "$DISTRIB_CODENAME" ]; then
-		db_set mirror/suite "$DISTRIB_CODENAME"
+if ! db_get mirror/suite || ! [ "$RET" ]; then
+	if [ -f /etc/lsb-release ]; then
+		. /etc/lsb-release
+		if [ -n "$DISTRIB_CODENAME" ]; then
+			db_set mirror/suite "$DISTRIB_CODENAME"
+		fi
 	fi
 fi
 

Reply to: