summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2008-09-26 11:13:11 +0000
committerOlivier Blin <oblin@mandriva.com>2008-09-26 11:13:11 +0000
commitec6932547196dc9c1e654f8f16552b11fec8cc44 (patch)
treea48a22132c23a44ba1ef9662c83b880ad1665851
parent842d2b8b436641c1552c6785561fc324b1e71368 (diff)
downloaddrakx-backup-do-not-use-ec6932547196dc9c1e654f8f16552b11fec8cc44.tar
drakx-backup-do-not-use-ec6932547196dc9c1e654f8f16552b11fec8cc44.tar.gz
drakx-backup-do-not-use-ec6932547196dc9c1e654f8f16552b11fec8cc44.tar.bz2
drakx-backup-do-not-use-ec6932547196dc9c1e654f8f16552b11fec8cc44.tar.xz
drakx-backup-do-not-use-ec6932547196dc9c1e654f8f16552b11fec8cc44.zip
automatically find compressed stage2 with automatic=method:disk
-rw-r--r--mdk-stage1/NEWS2
-rw-r--r--mdk-stage1/disk.c63
2 files changed, 65 insertions, 0 deletions
diff --git a/mdk-stage1/NEWS b/mdk-stage1/NEWS
index 05fd79458..24a188c10 100644
--- a/mdk-stage1/NEWS
+++ b/mdk-stage1/NEWS
@@ -1,3 +1,5 @@
+- automatically find compressed stage2 with automatic=method:disk
+
1.31:
- usbkbd is dead, using usbhid instead
diff --git a/mdk-stage1/disk.c b/mdk-stage1/disk.c
index b682872e1..acdc1efaf 100644
--- a/mdk-stage1/disk.c
+++ b/mdk-stage1/disk.c
@@ -42,6 +42,62 @@
#include "disk.h"
+static enum return_type try_automatic_with_partition(char *dev) {
+ enum return_type results;
+ int mounted;
+ wait_message("Trying to access " DISTRIB_NAME " disk (partition %s)", dev);
+ mounted = !try_mount(dev, MEDIA_LOCATION);
+ remove_wait_message();
+ if (mounted && !access(MEDIA_LOCATION "/" COMPRESSED_LOCATION_REL, R_OK)) {
+ results = try_with_directory(MEDIA_LOCATION, "disk", "disk-iso");
+ if (results == RETURN_OK) {
+ if (!KEEP_MOUNTED)
+ umount(MEDIA_LOCATION);
+ return RETURN_OK;
+ }
+ }
+ if (mounted)
+ umount(MEDIA_LOCATION);
+ return RETURN_ERROR;
+}
+
+static enum return_type try_automatic_with_disk(char *disk, char *model) {
+ char * parts[50];
+ char * parts_comments[50];
+ enum return_type results;
+ char **dev;
+ wait_message("Trying to access " DISTRIB_NAME " disk (drive %s)", model);
+ if (list_partitions(disk, parts, parts_comments)) {
+ stg1_error_message("Could not read partitions information.");
+ return RETURN_ERROR;
+ }
+ remove_wait_message();
+ dev = parts;
+ while (dev && *dev) {
+ results = try_automatic_with_partition(*dev);
+ if (results == RETURN_OK) {
+ return RETURN_OK;
+ }
+ dev++;
+ }
+ return RETURN_ERROR;
+}
+
+static enum return_type try_automatic(char ** medias, char ** medias_models)
+{
+ char ** model = medias_models;
+ char ** ptr = medias;
+ while (ptr && *ptr) {
+ enum return_type results;
+ results = try_automatic_with_disk(*ptr, *model);
+ if (results == RETURN_OK)
+ return RETURN_OK;
+ ptr++;
+ model++;
+ }
+ return RETURN_ERROR;
+}
+
static enum return_type try_with_device(char *dev_name)
{
char * questions_location[] = { "Directory or ISO images directory or ISO image", NULL };
@@ -122,6 +178,13 @@ enum return_type disk_prepare(void)
int count = get_disks(&medias, &medias_models);
+ if (IS_AUTOMATIC) {
+ results = try_automatic(medias, medias_models);
+ if (results != RETURN_ERROR)
+ return results;
+ unset_automatic();
+ }
+
if (count == 0) {
if (!already_probed_ide_generic) {
already_probed_ide_generic = 1;