--- loader2/urlinstall.c | 88 +++++++++++++++++++++++++++++++++---------------- loader2/urls.c | 24 +++----------- loader2/urls.h | 3 +- 3 files changed, 65 insertions(+), 50 deletions(-) diff --git a/loader2/urlinstall.c b/loader2/urlinstall.c index 5998cc6..f715c4b 100644 --- a/loader2/urlinstall.c +++ b/loader2/urlinstall.c @@ -49,16 +49,13 @@ /* boot flags */ extern uint64_t flags; -static int loadSingleUrlImage(struct iurlinfo * ui, char * file, +static int loadSingleUrlImage(struct iurlinfo * ui, char *path, char * dest, char * mntpoint, char * device, int silentErrors) { int fd; int rc = 0; - char filepath[1024]; char *ehdrs = NULL; - snprintf(filepath, sizeof(filepath), "%s", file); - if (ui->protocol == URL_METHOD_HTTP) { char *arch = getProductArch(); char *name = getProductName(); @@ -70,7 +67,7 @@ static int loadSingleUrlImage(struct iurlinfo * ui, char * file, VERSION, arch, name); } - fd = urlinstStartTransfer(ui, filepath, ehdrs); + fd = urlinstStartTransfer(ui, path, ehdrs); if (fd == -2) { if (ehdrs) free (ehdrs); @@ -79,9 +76,9 @@ static int loadSingleUrlImage(struct iurlinfo * ui, char * file, else if (fd < 0) { if (!silentErrors) { newtWinMessage(_("Error"), _("OK"), - _("Unable to retrieve %s://%s/%s/%s."), + _("Unable to retrieve %s://%s/%s."), (ui->protocol == URL_METHOD_FTP ? "ftp" : "http"), - ui->address, ui->prefix, filepath); + ui->address, path); } if (ehdrs) free (ehdrs); @@ -105,15 +102,30 @@ static void copyErrorFn (char *msg) { } static int loadUrlImages(struct iurlinfo * ui) { - char *stage2img; - char tmpstr1[1024], tmpstr2[1024]; + char *stage2img, *buf, *path, *tmp; int rc; - /* setupRamdisk();*/ + /* We assume that if stage2= was given, it's pointing at a stage2 image + * file. Trim the filename off the end, and that's the directory where + * updates.img and friends must live. + */ + if (FL_STAGE2(flags)) { + /* Has to have a / in it somewhere, since it has to be a path name. */ + if (!strrchr(ui->prefix, '/')) + return 1; + else + path = strndup(ui->prefix, strrchr(ui->prefix, '/') - ui->prefix); + + if (!path) + return 1; + } + else + rc = asprintf(&path, "%s/images", ui->prefix); /* grab the updates.img before netstg1.img so that we minimize our * ramdisk usage */ - if (!loadSingleUrlImage(ui, "images/updates.img", + rc = asprintf(&buf, "%s/%s", path, "updates.img"); + if (!loadSingleUrlImage(ui, buf, "/tmp/updates-disk.img", "/tmp/update-disk", "/dev/loop7", 1)) { copyDirectory("/tmp/update-disk", "/tmp/updates", copyWarnFn, @@ -123,9 +135,12 @@ static int loadUrlImages(struct iurlinfo * ui) { unlink("/tmp/update-disk"); } + free(buf); + /* grab the product.img before netstg1.img so that we minimize our * ramdisk usage */ - if (!loadSingleUrlImage(ui, "images/product.img", + rc = asprintf(&buf, "%s/%s", path, "product.img"); + if (!loadSingleUrlImage(ui, buf, "/tmp/product-disk.img", "/tmp/product-disk", "/dev/loop7", 1)) { copyDirectory("/tmp/product-disk", "/tmp/product", copyWarnFn, @@ -135,20 +150,32 @@ static int loadUrlImages(struct iurlinfo * ui) { unlink("/tmp/product-disk"); } - /* require 128MB for use of graphical stage 2 due to size of image */ - if (totalMemory() < GUI_STAGE2_RAM) { - stage2img = "minstg2.img"; - logMessage(WARNING, "URLINSTALL falling back to non-GUI stage2 " - "due to insufficient RAM"); - } else { - stage2img = "stage2.img"; - } + free(buf); - snprintf(tmpstr1, sizeof(tmpstr1), "images/%s", stage2img); - snprintf(tmpstr2, sizeof(tmpstr2), "/tmp/%s", stage2img); + if (!FL_STAGE2(flags)) { + /* require 128MB for use of graphical stage 2 due to size of image */ + if (totalMemory() < GUI_STAGE2_RAM) { + stage2img = "minstg2.img"; + logMessage(WARNING, "URLINSTALL falling back to non-GUI stage2 " + "due to insufficient RAM"); + } else { + stage2img = "stage2.img"; + } + + rc = asprintf(&buf, "%s/%s", path, stage2img); + rc = asprintf(&tmp, "/tmp/%s", stage2img); + rc = loadSingleUrlImage(ui, buf, tmp, + "/mnt/runtime", "/dev/loop0", 0); + } + else { + /* We already covered the case of ui->prefix not having a / in it + * at the beginning, so don't worry about it here. + */ + rc = asprintf(&tmp, "/tmp/%s", strrchr(ui->prefix, '/')); + rc = loadSingleUrlImage(ui, ui->prefix, tmp, "/mnt/runtime", + "/dev/loop0", 0); + } - rc = loadSingleUrlImage(ui, tmpstr1, tmpstr2, - "/mnt/runtime", "/dev/loop0", 0); if (rc) { if (rc != 2) newtWinMessage(_("Error"), _("OK"), @@ -156,10 +183,11 @@ static int loadUrlImages(struct iurlinfo * ui) { return 1; } + free(buf); + free(path); + /* now verify the stamp... */ if (!verifyStamp("/mnt/runtime")) { - char * buf; - rc = asprintf(&buf, _("The %s installation tree in that directory does " "not seem to match your boot media."), getProductName()); @@ -171,7 +199,6 @@ static int loadUrlImages(struct iurlinfo * ui) { } return 0; - } char * mountUrlImage(struct installMethod * method, @@ -186,8 +213,6 @@ char * mountUrlImage(struct installMethod * method, enum { URL_STAGE_MAIN, URL_STAGE_SECOND, URL_STAGE_FETCH, URL_STAGE_DONE } stage = URL_STAGE_MAIN; - /* JKFIXME: we used to do another ram check here... keep it? */ - memset(&ui, 0, sizeof(ui)); while (stage != URL_STAGE_DONE) { @@ -199,6 +224,7 @@ char * mountUrlImage(struct installMethod * method, if (!url) { logMessage(ERROR, "missing url specification"); + flags &= ~LOADER_FLAGS_STAGE2; loaderData->method = -1; break; } @@ -211,6 +237,7 @@ char * mountUrlImage(struct installMethod * method, dir = 1; break; } else if (urlMainSetupPanel(&ui, &needsSecondary)) { + flags &= ~LOADER_FLAGS_STAGE2; return NULL; } @@ -254,6 +281,7 @@ char * mountUrlImage(struct installMethod * method, unlink("/tmp/cdrom"); stage = URL_STAGE_MAIN; + flags &= ~LOADER_FLAGS_STAGE2; dir = -1; if (loaderData->method >= 0) @@ -278,6 +306,8 @@ char * mountUrlImage(struct installMethod * method, if (loaderData->method >= 0) { loaderData->method = -1; } + + flags &= ~LOADER_FLAGS_STAGE2; } else { stage = URL_STAGE_DONE; dir = 1; diff --git a/loader2/urls.c b/loader2/urls.c index f730133..b828de1 100644 --- a/loader2/urls.c +++ b/loader2/urls.c @@ -161,31 +161,18 @@ char *convertUIToURL(struct iurlinfo *ui) { /* extraHeaders only applicable for http and used for pulling ks from http */ /* see ftp.c:httpGetFileDesc() for details */ /* set to NULL if not needed */ -int urlinstStartTransfer(struct iurlinfo * ui, char * filename, +int urlinstStartTransfer(struct iurlinfo * ui, char *path, char *extraHeaders) { - char * buf; int fd, port; int family = -1; - char * finalPrefix; struct in_addr addr; struct in6_addr addr6; char *hostname, *portstr; struct hostent *host; - if (!strcmp(ui->prefix, "/")) - finalPrefix = ""; - else - finalPrefix = ui->prefix; - - buf = alloca(strlen(finalPrefix) + strlen(filename) + 20); - if (*filename == '/') - sprintf(buf, "%s%s", finalPrefix, filename); - else - sprintf(buf, "%s/%s", finalPrefix, filename); - logMessage(INFO, "transferring %s://%s%s to a fd", ui->protocol == URL_METHOD_FTP ? "ftp" : "http", - ui->address, buf); + ui->address, path); splitHostname(ui->address, &hostname, &portstr); if (portstr == NULL) @@ -219,14 +206,14 @@ int urlinstStartTransfer(struct iurlinfo * ui, char * filename, return -2; } - fd = ftpGetFileDesc(ui->ftpPort, addr6, family, buf); + fd = ftpGetFileDesc(ui->ftpPort, addr6, family, path); if (fd < 0) { close(ui->ftpPort); if (hostname) free(hostname); return -1; } } else { - fd = httpGetFileDesc(hostname, port, buf, extraHeaders); + fd = httpGetFileDesc(hostname, port, path, extraHeaders); if (fd < 0) { if (portstr) free(portstr); return -1; @@ -234,8 +221,7 @@ int urlinstStartTransfer(struct iurlinfo * ui, char * filename, } if (!FL_CMDLINE(flags)) - winStatus(70, 3, _("Retrieving"), "%s %s...", _("Retrieving"), - filename); + winStatus(70, 3, _("Retrieving"), "%s %s...", _("Retrieving"), path); if (hostname) free(hostname); return fd; diff --git a/loader2/urls.h b/loader2/urls.h index 6fcf182..046ee72 100644 --- a/loader2/urls.h +++ b/loader2/urls.h @@ -40,8 +40,7 @@ char *convertUIToURL(struct iurlinfo *ui); int setupRemote(struct iurlinfo * ui); int urlMainSetupPanel(struct iurlinfo * ui, char * doSecondarySetup); int urlSecondarySetupPanel(struct iurlinfo * ui); -int urlinstStartTransfer(struct iurlinfo * ui, char * filename, - char *extraHeaders); +int urlinstStartTransfer(struct iurlinfo * ui, char *path, char *extraHeaders); int urlinstFinishTransfer(struct iurlinfo * ui, int fd); #endif -- 1.5.3.7 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list