summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2007-04-25 14:33:54 +0000
committerOlivier Blin <oblin@mandriva.com>2007-04-25 14:33:54 +0000
commit6a7d14240bef13eb6e5ec8039eab4a8fd6fc4439 (patch)
tree3a39756bb8e592fc3e58fbccf38c66818336d5cd
parent0400a495c630d7e09ed84357059c13303c687c38 (diff)
downloaddrakx-backup-do-not-use-6a7d14240bef13eb6e5ec8039eab4a8fd6fc4439.tar
drakx-backup-do-not-use-6a7d14240bef13eb6e5ec8039eab4a8fd6fc4439.tar.gz
drakx-backup-do-not-use-6a7d14240bef13eb6e5ec8039eab4a8fd6fc4439.tar.bz2
drakx-backup-do-not-use-6a7d14240bef13eb6e5ec8039eab4a8fd6fc4439.tar.xz
drakx-backup-do-not-use-6a7d14240bef13eb6e5ec8039eab4a8fd6fc4439.zip
remove huge unwanted commit
-rw-r--r--mdk-stage1/config-stage1.h4
-rw-r--r--mdk-stage1/frontend-common.c19
-rw-r--r--mdk-stage1/frontend.h1
-rw-r--r--mdk-stage1/network.c200
-rw-r--r--mdk-stage1/newt-frontend.c58
-rw-r--r--mdk-stage1/stdio-frontend.c10
-rw-r--r--mdk-stage1/tools.c9
-rw-r--r--mdk-stage1/tools.h1
8 files changed, 165 insertions, 137 deletions
diff --git a/mdk-stage1/config-stage1.h b/mdk-stage1/config-stage1.h
index f668a465b..616783abc 100644
--- a/mdk-stage1/config-stage1.h
+++ b/mdk-stage1/config-stage1.h
@@ -75,8 +75,8 @@
/* path to mirror list for net install */
#ifndef DISABLE_NETWORK
-#define MIRRORLIST_HOST "api.mandriva.com"
-#define MIRRORLIST_PATH "/mirrors"
+#define MIRRORLIST_HOST "www.mandrivalinux.com"
+#define MIRRORLIST_PATH "/mirrorsfull.list"
#endif
#endif
diff --git a/mdk-stage1/frontend-common.c b/mdk-stage1/frontend-common.c
index 6ea2984cd..a66db457a 100644
--- a/mdk-stage1/frontend-common.c
+++ b/mdk-stage1/frontend-common.c
@@ -14,7 +14,6 @@
#include <stdlib.h>
#include <stdarg.h>
-#include <string.h>
#include <probing.h>
@@ -44,21 +43,3 @@ void error_message(char *msg, ...)
verror_message(msg, args);
va_end(args);
}
-
-enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice)
-{
- int answer = 0;
- enum return_type results;
-
- results = ask_from_list_index(msg, elems, elems_comments, &answer);
-
- if (results == RETURN_OK)
- *choice = strdup(elems[answer]);
-
- return results;
-}
-
-enum return_type ask_from_list(char *msg, char ** elems, char ** choice)
-{
- return ask_from_list_comments(msg, elems, NULL, choice);
-}
diff --git a/mdk-stage1/frontend.h b/mdk-stage1/frontend.h
index 4c2558b4a..1737ee7e7 100644
--- a/mdk-stage1/frontend.h
+++ b/mdk-stage1/frontend.h
@@ -53,7 +53,6 @@ void end_progression(void);
#endif
enum return_type ask_yes_no(char *msg);
-enum return_type ask_from_list_index(char *msg, char ** elems, char ** elems_comments, int *answer);
enum return_type ask_from_list(char *msg, char ** elems, char ** choice);
enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice);
enum return_type ask_from_entries(char *msg, char ** questions, char *** answers, int entry_size, void (*callback_func)(char ** strings));
diff --git a/mdk-stage1/network.c b/mdk-stage1/network.c
index e4fdd4fe0..f02903c55 100644
--- a/mdk-stage1/network.c
+++ b/mdk-stage1/network.c
@@ -1,4 +1,5 @@
- Cottenceau (gc@mandrakesoft.com)
+/*
+ * Guillaume Cottenceau (gc@mandrakesoft.com)
*
* Copyright 2000 Mandrakesoft
*
@@ -742,138 +743,173 @@ static enum return_type get_http_proxy(char **http_proxy_host, char **http_proxy
}
-static int url_split(const char *url, const char *protocol, char **host, char **path)
+static int mirrorlist_entry_split(const char *entry, char *mirror[4]) /* mirror = { medium, protocol, host, path } */
{
- char *protocol_sep, *host_sep;
+ char *medium_sep, *protocol_sep, *host_sep, *path_sep;
- protocol_sep = strstr(url, "://");
- if (!protocol_sep) {
- log_message("NETWORK: no protocol in \"%s\"", url);
+ medium_sep = strchr(entry, ':');
+ if (!medium_sep || medium_sep == entry) {
+ log_message("NETWORK: no medium in \"%s\"", entry);
return -1;
}
- if (strncmp(protocol, url, protocol_sep - url))
+ mirror[0] = strndup(entry, medium_sep - entry);
+ entry = medium_sep + 1;
+
+ protocol_sep = strstr(entry, "://");
+ if (!protocol_sep || protocol_sep == entry) {
+ log_message("NETWORK: no protocol in \"%s\"", entry);
return -1;
+ }
- url = protocol_sep + 3;
- host_sep = strchr(url, '/');
- if (!host_sep || host_sep == url) {
- log_message("NETWORK: no hostname in \"%s\"", url);
+ mirror[1] = strndup(entry, protocol_sep - entry);
+ entry = protocol_sep + 3;
+
+ host_sep = strchr(entry, '/');
+ if (!host_sep || host_sep == entry) {
+ log_message("NETWORK: no hostname in \"%s\"", entry);
return -1;
}
- *host = strndup(url, host_sep - url);
- *path = strdup(host_sep);
+ mirror[2] = strndup(entry, host_sep - entry);
+ entry = host_sep;
+
+ path_sep = strstr(entry, "/media/main");
+ if (!path_sep || path_sep == entry) {
+ log_message("NETWORK: this path isn't valid : \"%s\"", entry);
+ return -1;
+ }
+
+ mirror[3] = strndup(entry, path_sep - entry);
return 0;
}
+
#define MIRRORLIST_MAX_ITEMS 500
-typedef char *mirrorlist_t[2][MIRRORLIST_MAX_ITEMS+1];
+#define MIRRORLIST_MAX_MEDIA 10
+
+static int choose_mirror_from_host_list(char *mirrorlist[][4], const char *protocol, char *medium, char **selected_host, char **filepath)
+{
+ enum return_type results;
+ char *hostlist[MIRRORLIST_MAX_ITEMS+1] = { "Specify the mirror manually", "-----" };
+ int hostlist_index = 2, mirrorlist_index;
+
+ /* select hosts matching medium and protocol */
+ for (mirrorlist_index = 0; mirrorlist[mirrorlist_index][0]; mirrorlist_index++) {
+ if (!strcmp(mirrorlist[mirrorlist_index][0], medium) &&
+ !strcmp(mirrorlist[mirrorlist_index][1], protocol)) {
+ hostlist[hostlist_index] = mirrorlist[mirrorlist_index][2];
+ hostlist_index++;
+ if (hostlist_index == MIRRORLIST_MAX_ITEMS)
+ break;
+ }
+ }
+ hostlist[hostlist_index] = NULL;
+
+ do {
+ results = ask_from_list("Please select a mirror from the list below.",
+ hostlist, selected_host);
+
+ if (results == RETURN_BACK) {
+ return RETURN_ERROR;
+ } else if (results == RETURN_OK) {
+ if (!strcmp(*selected_host, hostlist[0])) {
+ /* enter the mirror manually */
+ return RETURN_OK;
+ } else if (!strcmp(*selected_host, hostlist[1])) {
+ /* the separator has been selected */
+ results = RETURN_ERROR;
+ continue;
+ }
+ }
+
+ /* select the path according to medium, protocol and host */
+ for (mirrorlist_index = 0; mirrorlist[mirrorlist_index][0]; mirrorlist_index++) {
+ if (!strcmp(mirrorlist[mirrorlist_index][0], medium) &&
+ !strcmp(mirrorlist[mirrorlist_index][1], protocol) &&
+ !strcmp(mirrorlist[mirrorlist_index][2], *selected_host)) {
+ *filepath = mirrorlist[mirrorlist_index][3];
+ return RETURN_OK;
+ }
+ }
+
+ stg1_info_message("Unable to find the path for this mirror, please select another one");
+ results = RETURN_ERROR;
+
+ } while (results == RETURN_ERROR);
+
+ return RETURN_ERROR;
+}
-static enum return_type get_mirrorlist(mirrorlist_t mirrorlist, int start, char *version, const char *protocol, char *http_proxy_host, char *http_proxy_port) {
- int fd, size, line_pos = 0;
- char path[1024];
- char line[1024];
- char type[100] = DISTRIB_TYPE;
- int mirror_idx = start;
+static int choose_mirror_from_list(char *http_proxy_host, char *http_proxy_port, const char *protocol, char **selected_host, char **filepath)
+{
+ enum return_type results;
+ char *mirrorlist[MIRRORLIST_MAX_ITEMS+1][4];
+ int mirrorlist_number = 0;
+ char *medialist[MIRRORLIST_MAX_MEDIA+1] = { "Specify the mirror manually", "-----" };
+ int media_number = 2;
+ char *selected_medium;
+ int fd, size, line_pos = 0;
+ char line[500];
int use_http_proxy = http_proxy_host && http_proxy_port && !streq(http_proxy_host, "") && !streq(http_proxy_port, "");
- lowercase(type);
- snprintf(path, sizeof(path) -1, "%s/%s.%s.%s.list", MIRRORLIST_PATH, type, version, ARCH);
- fd = http_download_file(MIRRORLIST_HOST, path, &size, use_http_proxy ? "http" : NULL, http_proxy_host, http_proxy_port);
+ fd = http_download_file(MIRRORLIST_HOST, MIRRORLIST_PATH, &size, use_http_proxy ? "http" : NULL, http_proxy_host, http_proxy_port);
if (fd < 0) {
- log_message("HTTP: unable to get mirrors list from %s (%s)", MIRRORLIST_HOST, path);
+ log_message("HTTP: unable to get mirrors list");
return RETURN_ERROR;
}
while (read(fd, line + line_pos, 1) > 0) {
if (line[line_pos] == '\n') {
- char *url;
line[line_pos] = '\0';
line_pos = 0;
/* skip medium if it looks like an updates one */
- if (strstr(line, ",type=updates,"))
+ if (strstr(line, "updates"))
continue;
- url = strstr(line, ",url=");
- if (!url)
+ if (mirrorlist_entry_split(line, mirrorlist[mirrorlist_number]) < 0)
continue;
- url += 5;
- if (url_split(url, protocol, &mirrorlist[0][mirror_idx], &mirrorlist[1][mirror_idx]) < 0)
- continue;
+ /* add medium in media list if different from previous one */
+ if (media_number == 2 ||
+ strcmp(mirrorlist[mirrorlist_number][0], medialist[media_number-1])) {
+ medialist[media_number] = mirrorlist[mirrorlist_number][0];
+ media_number++;
+ }
- mirror_idx++;
+ mirrorlist_number++;
} else {
line_pos++;
}
- if (mirror_idx >= MIRRORLIST_MAX_ITEMS)
+ if (mirrorlist_number >= MIRRORLIST_MAX_ITEMS || media_number >= MIRRORLIST_MAX_MEDIA)
break;
}
close(fd);
- mirrorlist[0][mirror_idx] = NULL;
- mirrorlist[1][mirror_idx] = NULL;
-
- return RETURN_OK;
-}
-
-static int choose_mirror_from_host_list(mirrorlist_t mirrorlist, char **selected_host, char **filepath)
-{
- enum return_type results;
- int mirror_idx = 0;
-
- do {
- results = ask_from_list_index("Please select a mirror from the list below.",
- mirrorlist[0], NULL, &mirror_idx);
-
- if (results == RETURN_BACK) {
- return RETURN_ERROR;
- } else if (results == RETURN_OK) {
- if (mirror_idx == 0) {
- /* enter the mirror manually */
- return RETURN_OK;
- }
- *selected_host = strdup(mirrorlist[0][mirror_idx]);
- *filepath = strdup(mirrorlist[1][mirror_idx]);
- return RETURN_OK;
- }
- } while (results == RETURN_ERROR);
-
- return RETURN_ERROR;
-}
-
-
-static int choose_mirror_from_list(char *http_proxy_host, char *http_proxy_port, const char *protocol, char **selected_host, char **filepath)
-{
- enum return_type results;
- char *versions[] = { "Specify the mirror manually", DISTRIB_VERSION, "cooker", NULL };
- char *version = DISTRIB_VERSION;
+ mirrorlist[mirrorlist_number][0] = NULL;
+ medialist[media_number] = NULL;
do {
- results = ask_from_list("Please select a medium from the list below.", versions, &version);
+ results = ask_from_list("Please select a medium from the list below.",
+ medialist, &selected_medium);
if (results == RETURN_BACK) {
return RETURN_BACK;
} else if (results == RETURN_OK) {
- if (!strcmp(version, versions[0])) {
+ if (!strcmp(selected_medium, medialist[0])) {
/* enter the mirror manually */
return RETURN_OK;
+ } else if (!strcmp(selected_medium, medialist[1])) {
+ /* the separator has been selected */
+ results = RETURN_ERROR;
+ continue;
} else {
/* a medium has been selected */
- mirrorlist_t mirrorlist;
- mirrorlist[0][0] = "Specify the mirror manually";
- mirrorlist[1][0] = NULL;
-
- results = get_mirrorlist(mirrorlist, 1, version, protocol, http_proxy_host, http_proxy_port);
- if (results == RETURN_ERROR)
- return RETURN_ERROR;
-
- results = choose_mirror_from_host_list(mirrorlist, selected_host, filepath);
+ results = choose_mirror_from_host_list(mirrorlist, protocol, selected_medium, selected_host, filepath);
}
}
} while (results == RETURN_ERROR);
@@ -907,7 +943,7 @@ enum return_type intf_select_and_up()
sel_intf->is_up = 0;
num_interfaces++;
}
-
+
results = bringup_networking(sel_intf);
if (results == RETURN_OK)
diff --git a/mdk-stage1/newt-frontend.c b/mdk-stage1/newt-frontend.c
index 731818a0d..4bedda82b 100644
--- a/mdk-stage1/newt-frontend.c
+++ b/mdk-stage1/newt-frontend.c
@@ -172,39 +172,55 @@ void end_progression_raw(void)
}
-enum return_type ask_from_list_index(char *msg, char ** elems, char ** elems_comments, int * answer)
+enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice)
{
char * items[500];
- int rc;
+ int answer = 0, rc;
+ char ** sav_elems = elems;
+ int i;
- if (elems_comments) {
- int i;
-
- i = 0;
- while (elems && *elems) {
- int j = (*elems_comments) ? strlen(*elems_comments) : 0;
- items[i] = malloc(sizeof(char) * (strlen(*elems) + j + 4));
- strcpy(items[i], *elems);
- if (*elems_comments) {
- strcat(items[i], " (");
- strcat(items[i], *elems_comments);
- strcat(items[i], ")");
- }
- elems_comments++;
- i++;
- elems++;
- }
- items[i] = NULL;
+ i = 0;
+ while (elems && *elems) {
+ int j = (*elems_comments) ? strlen(*elems_comments) : 0;
+ items[i] = malloc(sizeof(char) * (strlen(*elems) + j + 4));
+ strcpy(items[i], *elems);
+ if (*elems_comments) {
+ strcat(items[i], " (");
+ strcat(items[i], *elems_comments);
+ strcat(items[i], ")");
+ }
+ elems_comments++;
+ i++;
+ elems++;
}
+ items[i] = NULL;
- rc = newtWinMenu("Please choose...", msg, 52, 5, 5, 7, elems_comments ? items : elems, answer, "Ok", "Cancel", NULL);
+ rc = newtWinMenu("Please choose...", msg, 52, 5, 5, 7, items, &answer, "Ok", "Cancel", NULL);
if (rc == 2)
return RETURN_BACK;
+ *choice = strdup(sav_elems[answer]);
+
return RETURN_OK;
}
+
+enum return_type ask_from_list(char *msg, char ** elems, char ** choice)
+{
+ int answer = 0, rc;
+
+ rc = newtWinMenu("Please choose...", msg, 52, 5, 5, 7, elems, &answer, "Ok", "Cancel", NULL);
+
+ if (rc == 2)
+ return RETURN_BACK;
+
+ *choice = strdup(elems[answer]);
+
+ return RETURN_OK;
+}
+
+
enum return_type ask_yes_no(char *msg)
{
int rc;
diff --git a/mdk-stage1/stdio-frontend.c b/mdk-stage1/stdio-frontend.c
index 7d3c6f14b..ffa306811 100644
--- a/mdk-stage1/stdio-frontend.c
+++ b/mdk-stage1/stdio-frontend.c
@@ -240,7 +240,7 @@ void end_progression_raw(void)
}
-enum return_type ask_from_list_index(char *msg, char ** elems, char ** elems_comments, int *answer)
+enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice)
{
int justify_number = 1;
void print_choice_number(int i) {
@@ -296,7 +296,7 @@ enum return_type ask_from_list_index(char *msg, char ** elems, char ** elems_com
return RETURN_BACK;
if (j >= 1 && j <= i) {
- *answer = j - 1;
+ *choice = strdup(sav_elems[j-1]);
return RETURN_OK;
}
@@ -304,6 +304,12 @@ enum return_type ask_from_list_index(char *msg, char ** elems, char ** elems_com
}
+enum return_type ask_from_list(char *msg, char ** elems, char ** choice)
+{
+ return ask_from_list_comments(msg, elems, NULL, choice);
+}
+
+
enum return_type ask_yes_no(char *msg)
{
int j;
diff --git a/mdk-stage1/tools.c b/mdk-stage1/tools.c
index 8fc6864b5..baba72b0d 100644
--- a/mdk-stage1/tools.c
+++ b/mdk-stage1/tools.c
@@ -612,12 +612,3 @@ int scall_(int retval, char * msg, char * file, int line)
log_perror(tmp);
return retval;
}
-
-void lowercase(char *s)
-{
- int i = 0;
- while (s[i]) {
- s[i] = tolower(s[i]);
- i++;
- }
-}
diff --git a/mdk-stage1/tools.h b/mdk-stage1/tools.h
index 78ed4b087..fd5236a93 100644
--- a/mdk-stage1/tools.h
+++ b/mdk-stage1/tools.h
@@ -60,7 +60,6 @@ char * floppy_device(void);
char * asprintf_(const char *msg, ...);
int scall_(int retval, char * msg, char * file, int line);
#define scall(retval, msg) scall_(retval, msg, __FILE__, __LINE__)
-void lowercase(char *s);
struct param_elem
{