summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-11-05 13:47:20 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-11-05 13:47:20 +0000
commit7df683409a22ecfdf576fb307ce9f015a4ac53d9 (patch)
treeaf40f8bf1da79b62168a7121b3a72ee9ece5d483 /mdk-stage1
parent0d10d6526b04ab7cecb3052d3a9cfcd19f9213b3 (diff)
downloaddrakx-7df683409a22ecfdf576fb307ce9f015a4ac53d9.tar
drakx-7df683409a22ecfdf576fb307ce9f015a4ac53d9.tar.gz
drakx-7df683409a22ecfdf576fb307ce9f015a4ac53d9.tar.bz2
drakx-7df683409a22ecfdf576fb307ce9f015a4ac53d9.tar.xz
drakx-7df683409a22ecfdf576fb307ce9f015a4ac53d9.zip
create choose_iso_in_directory() out of try_with_directory()
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/directory.c131
1 files changed, 69 insertions, 62 deletions
diff --git a/mdk-stage1/directory.c b/mdk-stage1/directory.c
index fdefac5f1..e1535c6e3 100644
--- a/mdk-stage1/directory.c
+++ b/mdk-stage1/directory.c
@@ -45,78 +45,85 @@ char * extract_list_directory(char * direct)
return strdup(tmp);
}
-enum return_type try_with_directory(char *directory, char *method_live, char *method_iso) {
- char location_full[500];
- char * loopdev = NULL;
- struct stat statbuf;
+static enum return_type choose_iso_in_directory(char *directory, char *location_full)
+{
+ char **file;
+ char *stage2_isos[100] = { "Use directory as a mirror tree", "-----" };
+ int stage2_iso_number = 2;
- unlink(IMAGE_LOCATION);
- strcpy(location_full, directory);
+ log_message("\"%s\" exists and is a directory, looking for iso files", directory);
-#ifndef MANDRAKE_MOVE
- if (!stat(directory, &statbuf) && S_ISDIR(statbuf.st_mode)) {
- char **file;
- char *stage2_isos[100] = { "Use directory as a mirror tree", "-----" };
- int stage2_iso_number = 2;
+ for (file = list_directory(directory); *file; file++) {
+ char isofile[500];
+ char * loopdev = NULL;
- log_message("\"%s\" exists and is a directory, looking for iso files", directory);
+ if (strstr(*file, ".iso") != *file + strlen(*file) - 4)
+ /* file doesn't end in .iso, skipping */
+ continue;
+
+ strcpy(isofile, directory);
+ strcat(isofile, "/");
+ strcat(isofile, *file);
- for (file = list_directory(directory); *file; file++) {
- char isofile[500];
+ if (lomount(isofile, IMAGE_LOCATION, &loopdev, 0)) {
+ log_message("unable to mount iso file \"%s\", skipping", isofile);
+ continue;
+ }
- if (strstr(*file, ".iso") != *file + strlen(*file) - 4)
- /* file doesn't end in .iso, skipping */
- continue;
-
- strcpy(isofile, directory);
- strcat(isofile, "/");
- strcat(isofile, *file);
+ if (image_has_stage2()) {
+ log_message("stage2 installer found in ISO image \"%s\"", isofile);
+ stage2_isos[stage2_iso_number++] = strdup(*file);
+ } else {
+ log_message("ISO image \"%s\" doesn't contain stage2 installer", isofile);
+ }
- if (lomount(isofile, IMAGE_LOCATION, &loopdev, 0)) {
- log_message("unable to mount iso file \"%s\", skipping", isofile);
- continue;
- }
+ umount(IMAGE_LOCATION);
+ del_loop(loopdev);
+ }
- if (image_has_stage2()) {
- log_message("stage2 installer found in ISO image \"%s\"", isofile);
- stage2_isos[stage2_iso_number++] = strdup(*file);
- } else {
- log_message("ISO image \"%s\" doesn't contain stage2 installer", isofile);
+ stage2_isos[stage2_iso_number] = NULL;
+
+ if (stage2_iso_number > 2) {
+ enum return_type results;
+ do {
+ results = ask_from_list("Please choose the ISO image to be used to install the "
+ DISTRIB_NAME " Distribution.",
+ stage2_isos, file);
+ if (results == RETURN_BACK) {
+ return RETURN_BACK;
+ } else if (results == RETURN_OK) {
+ if (!strcmp(*file, stage2_isos[0])) {
+ /* use directory as a mirror tree */
+ continue;
+ } else if (!strcmp(*file, stage2_isos[1])) {
+ /* the separator has been selected */
+ results = RETURN_ERROR;
+ continue;
+ } else {
+ /* use selected ISO image */
+ strcat(location_full, "/");
+ strcat(location_full, *file);
+ log_message("installer will use ISO image \"%s\"", location_full);
+ }
}
+ } while (results == RETURN_ERROR);
+ } else {
+ log_message("no ISO image found in \"%s\" directory", location_full);
+ }
+}
- umount(IMAGE_LOCATION);
- del_loop(loopdev);
- }
- stage2_isos[stage2_iso_number] = NULL;
-
- if (stage2_iso_number > 2) {
- enum return_type results;
- do {
- results = ask_from_list("Please choose the ISO image to be used to install the "
- DISTRIB_NAME " Distribution.",
- stage2_isos, file);
- if (results == RETURN_BACK) {
- return RETURN_BACK;
- } else if (results == RETURN_OK) {
- if (!strcmp(*file, stage2_isos[0])) {
- /* use directory as a mirror tree */
- continue;
- } else if (!strcmp(*file, stage2_isos[1])) {
- /* the separator has been selected */
- results = RETURN_ERROR;
- continue;
- } else {
- /* use selected ISO image */
- strcat(location_full, "/");
- strcat(location_full, *file);
- log_message("installer will use ISO image \"%s\"", location_full);
- }
- }
- } while (results == RETURN_ERROR);
- } else {
- log_message("no ISO image found in \"%s\" directory", location_full);
- }
+enum return_type try_with_directory(char *directory, char *method_live, char *method_iso) {
+ char location_full[500];
+ char * loopdev = NULL;
+ struct stat statbuf;
+
+ unlink(IMAGE_LOCATION);
+ strcpy(location_full, directory);
+
+#ifndef MANDRAKE_MOVE
+ if (!stat(directory, &statbuf) && S_ISDIR(statbuf.st_mode)) {
+ choose_iso_in_directory(directory, location_full);
}
#endif