[PATCH 17/29] Rework how loading images works for URL installs.

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

 



Since every boot method now includes the full installation environment, we
don't have to go looking for install.img anymore.  Therefore, the method
configuration for URL installs only needs to (1) ask for where the packages
live, and (2) attempt to fetch updates.img and product.img from that
location.
---
 loader/loader.c     |   21 +++++++++++-----
 loader/method.h     |    4 +-
 loader/urlinstall.c |   63 +++++++++++++++++++++++++--------------------------
 loader/urlinstall.h |    4 +-
 4 files changed, 49 insertions(+), 43 deletions(-)

diff --git a/loader/loader.c b/loader/loader.c
index e38321b..894e6c7 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -129,10 +129,10 @@ static int init_sig = SIGUSR1; /* default to shutdown=halt */
 static const char *LANG_DEFAULT = "en_US.UTF-8";
 
 static struct installMethod installMethods[] = {
-    { N_("Local CD/DVD"), 0, DEVICE_CDROM, mountCdromImage },
-    { N_("Hard drive"), 0, DEVICE_DISK, mountHardDrive },
-    { N_("NFS directory"), 1, DEVICE_NETWORK, mountNfsImage },
-    { "URL", 1, DEVICE_NETWORK, mountUrlImage },
+    { N_("Local CD/DVD"), 0, DEVICE_CDROM, NULL, NULL },
+    { N_("Hard drive"), 0, DEVICE_DISK, NULL, NULL },
+    { N_("NFS directory"), 1, DEVICE_NETWORK, NULL, NULL },
+    { "URL", 1, DEVICE_NETWORK, promptForUrl, loadUrlImages},
 };
 static int numMethods = sizeof(installMethods) / sizeof(struct installMethod);
 
@@ -1302,8 +1302,6 @@ static void doLoaderMain(struct loaderData_s *loaderData,
 
             case STEP_METHOD: {
                 if (FL_ASKMETHOD(flags)) {
-                    loaderData->method = -1;
-
                     if (FL_CMDLINE(flags)) {
                         fprintf(stderr, "No method given for cmdline mode, aborting\n");
                         doExit(EXIT_FAILURE);
@@ -1330,17 +1328,25 @@ static void doLoaderMain(struct loaderData_s *loaderData,
                                  30, 10, 20, 6, installNames, &loaderData->method,
                                  _("OK"), _("Back"), NULL);
                 if (rc == 2) {
-                    loaderData->method = -1;
+                    flags |= LOADER_FLAGS_ASKMETHOD;
                 }
 
                 if (rc && (rc != 1)) {
                     step = STEP_KBD;
                     dir = -1;
                 } else {
+                    /* Now prompt for the method-specific config info. */
+                    rc = installMethods[validMethods[loaderData->method]].prompt(loaderData);
+
+                    /* Just go back to the method selection screen. */
+                    if (rc == LOADER_BACK)
+                        break;
+
                     class = installMethods[validMethods[loaderData->method]].type;
                     step = STEP_DRIVER;
                     dir = 1;
                 }
+
                 break;
             }
 
@@ -1523,6 +1529,7 @@ static void doLoaderMain(struct loaderData_s *loaderData,
                 /* FIXME - this is where we need to look for product.img,
                  * updates.img, etc.
                  */
+                installMethods[validMethods[loaderData->method]].findExtras(loaderData);
                 step = STEP_DONE;
                 break;
             }
diff --git a/loader/method.h b/loader/method.h
index 967ed5d..9d71ec3 100644
--- a/loader/method.h
+++ b/loader/method.h
@@ -35,8 +35,8 @@ struct installMethod {
     char * name;
     int network;
     enum deviceType type;
-    char * (*mountImage)(struct installMethod * method,
-                         char * location, struct loaderData_s * loaderData);
+    int (*prompt)(struct loaderData_s *loaderData);
+    int (*findExtras)(struct loaderData_s *loaderData);
 };
 
 int readStampFileFromIso(char *file, char **descr, char **timestamp);
diff --git a/loader/urlinstall.c b/loader/urlinstall.c
index 5920329..1c307cf 100644
--- a/loader/urlinstall.c
+++ b/loader/urlinstall.c
@@ -160,28 +160,17 @@ static void copyErrorFn (char *msg) {
    newtWinMessage(_("Error"), _("OK"), _(msg));
 }
 
-static int loadUrlImages(struct loaderData_s *loaderData, struct iurlinfo *ui) {
-    char *oldUrl, *path, *dest, *slash;
-    int rc;
-
-    oldUrl = strdup(ui->url);
-    free(ui->url);
+int loadUrlImages(struct loaderData_s *loaderData) {
+    char *url;
 
-    /* Figure out the path where updates.img and product.img files are
-     * kept.  Since ui->url points to a stage2 image file, we just need
-     * to trim off the file name and look in the same directory.
-     */
-    if ((slash = strrchr(oldUrl, '/')) == NULL)
+    if (!loaderData->instRepo)
         return 0;
 
-    if ((path = strndup(oldUrl, slash-oldUrl)) == NULL)
-        path = oldUrl;
-
     /* grab the updates.img before install.img so that we minimize our
      * ramdisk usage */
-    checked_asprintf(&ui->url, "%s/%s", path, "updates.img");
+    checked_asprintf(&url, "%s/images/%s", loaderData->instRepo, "updates.img");
 
-    if (!loadSingleUrlImage(loaderData, ui->url, "/tmp/updates-disk.img", "/tmp/update-disk", 1)) {
+    if (!loadSingleUrlImage(loaderData, url, "/tmp/updates-disk.img", "/tmp/update-disk", 1)) {
         copyDirectory("/tmp/update-disk", "/tmp/updates", copyWarnFn,
                       copyErrorFn);
         umount("/tmp/update-disk");
@@ -192,13 +181,13 @@ static int loadUrlImages(struct loaderData_s *loaderData, struct iurlinfo *ui) {
         unlink("/tmp/updates-disk.img");
     }
 
-    free(ui->url);
+    free(url);
 
     /* grab the product.img before install.img so that we minimize our
      * ramdisk usage */
-    checked_asprintf(&ui->url, "%s/%s", path, "product.img");
+    checked_asprintf(&url, "%s/images/%s", loaderData->instRepo, "product.img");
 
-    if (!loadSingleUrlImage(loaderData, ui->url, "/tmp/product-disk.img", "/tmp/product-disk", 1)) {
+    if (!loadSingleUrlImage(loaderData, url, "/tmp/product-disk.img", "/tmp/product-disk", 1)) {
         copyDirectory("/tmp/product-disk", "/tmp/product", copyWarnFn,
                       copyErrorFn);
         umount("/tmp/product-disk");
@@ -206,23 +195,33 @@ static int loadUrlImages(struct loaderData_s *loaderData, struct iurlinfo *ui) {
         unlink("/tmp/product-disk");
     }
 
-    free(ui->url);
-    ui->url = strdup(oldUrl);
+    free(url);
+    return 0;
+}
+
+int promptForUrl(struct loaderData_s *loaderData) {
+    char *url;
 
-    checked_asprintf(&dest, "/tmp/install.img");
+    do {
+        if (urlMainSetupPanel(loaderData) == LOADER_BACK) {
+            loaderData->instRepo = NULL;
+            return LOADER_BACK;
+        }
 
-    rc = loadSingleUrlImage(loaderData, ui->url, dest, "/mnt/runtime", 0);
-    free(dest);
-    free(oldUrl);
+        checked_asprintf(&url, "%s/.treeinfo", loaderData->instRepo);
 
-    if (rc) {
-        if (rc != 2) 
+        if (getFileFromUrl(url, "/tmp/.treeinfo", loaderData)) {
             newtWinMessage(_("Error"), _("OK"),
-                           _("Unable to retrieve the install image."));
-        return 1;
-    }
+                           _("The URL provided does not contain installation media."));
+            free(url);
+            continue;
+        }
 
-    return 0;
+        free(url);
+        break;
+    } while (1);
+
+    return LOADER_OK;
 }
 
 char *mountUrlImage(struct installMethod *method, char *location,
@@ -289,7 +288,7 @@ char *mountUrlImage(struct installMethod *method, char *location,
             }
 
             case URL_STAGE_FETCH: {
-                if (loadUrlImages(loaderData, &ui)) {
+                if (loadUrlImages(loaderData)) {
                     stage = URL_STAGE_MAIN;
 
                     if (loaderData->method >= 0)
diff --git a/loader/urlinstall.h b/loader/urlinstall.h
index 710b0ae..48bbb54 100644
--- a/loader/urlinstall.h
+++ b/loader/urlinstall.h
@@ -28,9 +28,9 @@ typedef struct iurlinfo urlInstallData;
 void setKickstartUrl(struct loaderData_s * loaderData, int argc,
 		     char ** argv);
 int kickstartFromUrl(char * url, struct loaderData_s * loaderData);
-char * mountUrlImage(struct installMethod * method,
-                     char * location, struct loaderData_s * loaderData);
 int getFileFromUrl(char * url, char * dest, struct loaderData_s * loaderData);
+int promptForUrl(struct loaderData_s *loaderData);
+int loadUrlImages(struct loaderData_s *loaderData);
 
 
 #endif
-- 
1.7.1.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux