[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[PATCH] Strip urlinstall.c down to just looking for the stage2 image.
- From: Chris Lumens <clumens redhat com>
- To: anaconda-devel-list redhat com
- Cc:
- Subject: [PATCH] Strip urlinstall.c down to just looking for the stage2 image.
- Date: Tue, 17 Jun 2008 11:45:43 -0400
---
loader2/ftp.c | 9 +--
loader2/ftp.h | 2 +-
loader2/urlinstall.c | 200 ++++++++++++++++++++------------------------------
loader2/urls.c | 98 +-----------------------
loader2/urls.h | 2 +-
5 files changed, 89 insertions(+), 222 deletions(-)
diff --git a/loader2/ftp.c b/loader2/ftp.c
index c636596..ce6deb5 100644
--- a/loader2/ftp.c
+++ b/loader2/ftp.c
@@ -253,14 +253,13 @@ static int getHostAddress(const char * host, void * address, int family) {
}
int ftpOpen(char *host, int family, char *name, char *password,
- char *proxy, int port) {
+ int port) {
static int sock;
struct in_addr addr;
struct in6_addr addr6;
struct sockaddr_in destPort;
struct sockaddr_in6 destPort6;
struct passwd * pw;
- char * buf;
int rc = 0;
if (port < 0) port = IPPORT_FTP;
@@ -280,12 +279,6 @@ int ftpOpen(char *host, int family, char *name, char *password,
}
}
- if (proxy) {
- if (asprintf(&buf, "%s %s", name, host) != -1)
- name = buf;
- host = proxy;
- }
-
if (family == AF_INET)
rc = getHostAddress(host, &addr, AF_INET);
else if (family == AF_INET6)
diff --git a/loader2/ftp.h b/loader2/ftp.h
index 8753e95..c1e7fcb 100644
--- a/loader2/ftp.h
+++ b/loader2/ftp.h
@@ -42,7 +42,7 @@ const char * ftpStrerror(int ftpErrno, urlprotocol protocol);
#define FTPERR_UNKNOWN -100
int ftpOpen(char * host, int family, char * name, char * password,
- char * proxy, int port);
+ int port);
int ftpGetFile(int sock, char * remotename, int dest);
int ftpGetFileDesc(int sock, struct in6_addr host, int family,
char * remotename);
diff --git a/loader2/urlinstall.c b/loader2/urlinstall.c
index 7e34d48..dd2d89f 100644
--- a/loader2/urlinstall.c
+++ b/loader2/urlinstall.c
@@ -102,27 +102,16 @@ static void copyErrorFn (char *msg) {
}
static int loadUrlImages(struct iurlinfo * ui) {
- char *stage2img, *buf, *path, *tmp;
+ char *buf, *path, *dest;
int rc;
- /* 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.
+ /* Figure out the path where updates.img and product.img files are
+ * kept. Since ui->prefix points to a stage2 image file, we just need
+ * to trim off the file name and look in the same directory.
*/
- 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);
+ path = strndup(ui->prefix, strrchr(ui->prefix, '/') - ui->prefix);
- /* grab the updates.img before netstg1.img so that we minimize our
+ /* grab the updates.img before stage2.img so that we minimize our
* ramdisk usage */
rc = asprintf(&buf, "%s/%s", path, "updates.img");
if (!loadSingleUrlImage(ui, buf,
@@ -140,7 +129,7 @@ static int loadUrlImages(struct iurlinfo * ui) {
free(buf);
- /* grab the product.img before netstg1.img so that we minimize our
+ /* grab the product.img before stage2.img so that we minimize our
* ramdisk usage */
rc = asprintf(&buf, "%s/%s", path, "product.img");
if (!loadSingleUrlImage(ui, buf,
@@ -155,33 +144,9 @@ static int loadUrlImages(struct iurlinfo * ui) {
free(buf);
- 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);
- free(buf);
- }
- 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);
- }
-
- free(tmp);
- free(path);
+ rc = asprintf(&dest, "/tmp/stage2.img");
+ rc = loadSingleUrlImage(ui, ui->prefix, dest, "/mnt/runtime", "/dev/loop0", 0);
+ free(dest);
if (rc) {
if (rc != 2)
@@ -205,98 +170,95 @@ static int loadUrlImages(struct iurlinfo * ui) {
return 0;
}
-char * mountUrlImage(struct installMethod * method,
- char * location, struct loaderData_s * loaderData) {
- int rc;
- char *url;
+char *mountUrlImage(struct installMethod *method, char *location,
+ struct loaderData_s *loaderData) {
struct iurlinfo ui;
- char needsSecondary = ' ';
- char * cdurl = NULL;
+ char *url = NULL;
+ int rc;
- enum { URL_STAGE_MAIN, URL_STAGE_SECOND, URL_STAGE_FETCH,
+ enum { URL_STAGE_MAIN, URL_STAGE_FETCH,
URL_STAGE_DONE } stage = URL_STAGE_MAIN;
memset(&ui, 0, sizeof(ui));
while (stage != URL_STAGE_DONE) {
switch(stage) {
- case URL_STAGE_MAIN:
- if (loaderData->method == METHOD_URL && loaderData->stage2Data) {
- url = ((struct urlInstallData *)loaderData->stage2Data)->url;
- logMessage(INFO, "URL_STAGE_MAIN - url is %s", url);
-
- if (!url) {
- logMessage(ERROR, "missing url specification");
- flags &= ~LOADER_FLAGS_STAGE2;
- loaderData->method = -1;
+ case URL_STAGE_MAIN: {
+ /* If the stage2= parameter was given (or inferred from repo=)
+ * then use that configuration info to fetch the image. This
+ * could also have come from kickstart. Else, we need to show
+ * the UI.
+ */
+ if (loaderData->method == METHOD_URL && loaderData->stage2Data) {
+ url = ((struct urlInstallData *) loaderData->stage2Data)->url;
+ logMessage(INFO, "URL_STAGE_MAIN: url is %s", url);
+
+ if (!url) {
+ logMessage(ERROR, "missing URL specification");
+ loaderData->method = -1;
+ free(loaderData->stage2Data);
+ loaderData->stage2Data = NULL;
+ break;
+ }
+
+ /* explode url into ui struct */
+ convertURLToUI(url, &ui);
+
+ /* ks info was adequate, lets skip to fetching image */
+ stage = URL_STAGE_FETCH;
break;
+ } else {
+ char *substr;
+
+ if (urlMainSetupPanel(&ui))
+ return NULL;
+
+ /* If the user-provided URL points at a repo instead of
+ * a stage2 image, fix it up now.
+ */
+ substr = strstr(ui.prefix, ".img");
+ if (!substr || (substr && *(substr+4) != '\0')) {
+ char *stage2img;
+
+ /* Pick the right stage2 image depending on the
+ * amount of memory.
+ */
+ 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(&ui.prefix, "%s/images/%s", ui.prefix, stage2img);
+ }
}
- /* explode url into ui struct */
- convertURLToUI(url, &ui);
-
- /* ks info was adequate, lets skip to fetching image */
- stage = URL_STAGE_FETCH;
- break;
- } else {
- flags &= ~LOADER_FLAGS_STAGE2;
-
- if (urlMainSetupPanel(&ui, &needsSecondary))
- return NULL;
+ stage = URL_STAGE_FETCH;
+ break;
}
- /* got required information from user, proceed */
- stage = (needsSecondary != ' ') ? URL_STAGE_SECOND :
- URL_STAGE_FETCH;
- break;
+ case URL_STAGE_FETCH: {
+ if (FL_TESTING(flags)) {
+ stage = URL_STAGE_DONE;
+ break;
+ }
- case URL_STAGE_SECOND:
- rc = urlSecondarySetupPanel(&ui);
- if (rc) {
- stage = URL_STAGE_MAIN;
- } else {
- stage = URL_STAGE_FETCH;
- }
- break;
+ if (loadUrlImages(&ui)) {
+ stage = URL_STAGE_MAIN;
+
+ if (loaderData->method >= 0)
+ loaderData->method = -1;
+ } else {
+ stage = URL_STAGE_DONE;
+ }
- case URL_STAGE_FETCH:
- if (FL_TESTING(flags)) {
- stage = URL_STAGE_DONE;
break;
}
- /* See if we have a stage2 on a local CD before trying to pull
- * one over the network. However, passing stage2= overrides
- * this check.
- */
- if (!FL_STAGE2(flags))
- cdurl = findAnacondaCD(location);
-
- if (cdurl) {
- logMessage(INFO, "Detected stage 2 image on CD");
- winStatus(50, 3, _("Media Detected"),
- _("Local installation media detected..."), 0);
- sleep(3);
- newtPopWindow();
-
- stage = URL_STAGE_DONE;
- } else {
- /* need to find stage 2 on remote site */
- if (loadUrlImages(&ui)) {
- stage = URL_STAGE_MAIN;
- if (loaderData->method >= 0) {
- loaderData->method = -1;
- }
-
- flags &= ~LOADER_FLAGS_STAGE2;
- } else {
- stage = URL_STAGE_DONE;
- }
- }
- break;
-
- case URL_STAGE_DONE:
- break;
+ case URL_STAGE_DONE:
+ break;
}
}
diff --git a/loader2/urls.c b/loader2/urls.c
index 43006ac..fae48a3 100644
--- a/loader2/urls.c
+++ b/loader2/urls.c
@@ -199,7 +199,7 @@ int urlinstStartTransfer(struct iurlinfo * ui, char *path,
ui->ftpPort = ftpOpen(hostname, family,
ui->login ? ui->login : "anonymous",
ui->password ? ui->password : "rhinstall@",
- NULL, port);
+ port);
if (ui->ftpPort < 0) {
if (hostname) free(hostname);
return -2;
@@ -258,9 +258,9 @@ char * addrToIp(char * hostname) {
return NULL;
}
-int urlMainSetupPanel(struct iurlinfo * ui, char * doSecondarySetup) {
+int urlMainSetupPanel(struct iurlinfo * ui) {
newtComponent form, okay, cancel, urlEntry;
- newtComponent answer, text, proxyCheckbox;
+ newtComponent answer, text;
char *url = "";
char * reflowedText = NULL;
int width, height;
@@ -269,11 +269,6 @@ int urlMainSetupPanel(struct iurlinfo * ui, char * doSecondarySetup) {
char * buf = NULL;
int r;
- if (ui && (ui->login || ui->password || ui->proxy || ui->proxyPort))
- *doSecondarySetup = '*';
- else
- *doSecondarySetup = ' ';
-
/* Populate the UI with whatever initial value we've got. */
if (ui && ui->prefix)
url = convertUIToURL(ui);
@@ -291,17 +286,13 @@ int urlMainSetupPanel(struct iurlinfo * ui, char * doSecondarySetup) {
urlEntry = newtEntry(22, 8, url, 60, (const char **) &url,
NEWT_ENTRY_SCROLL);
- proxyCheckbox = newtCheckbox(-1, -1, _("Configure proxy"), *doSecondarySetup,
- NULL, doSecondarySetup);
- grid = newtCreateGrid(1, 4);
+ grid = newtCreateGrid(1, 3);
newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, text,
0, 0, 0, 1, 0, 0);
newtGridSetField(grid, 0, 1, NEWT_GRID_COMPONENT, urlEntry,
0, 0, 0, 1, 0, 0);
- newtGridSetField(grid, 0, 2, NEWT_GRID_COMPONENT, proxyCheckbox,
- 0, 0, 0, 1, 0, 0);
- newtGridSetField(grid, 0, 3, NEWT_GRID_SUBGRID, buttons,
+ newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, buttons,
0, 0, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
form = newtForm(NULL, NULL, 0);
@@ -353,87 +344,8 @@ int urlMainSetupPanel(struct iurlinfo * ui, char * doSecondarySetup) {
chptr++;
*chptr = '\0';
- if (*doSecondarySetup != '*') {
- if (ui->proxy)
- free(ui->proxy);
- if (ui->proxyPort)
- free(ui->proxyPort);
-
- ui->proxy = ui->proxyPort = NULL;
- }
-
- newtFormDestroy(form);
- newtPopWindow();
-
- return 0;
-}
-
-int urlSecondarySetupPanel(struct iurlinfo * ui) {
- newtComponent form, okay, cancel, answer, text;
- newtComponent proxyEntry = NULL;
- newtComponent proxyPortEntry = NULL;
- char * proxy, * proxyPort;
- newtGrid buttons, entryGrid, grid;
- char * reflowedText = NULL;
- int width, height;
-
- reflowedText = newtReflowText(
- _("If you are using a HTTP proxy server "
- "enter the name of the HTTP proxy server to use."),
- 47, 5, 5, &width, &height);
-
- text = newtTextbox(-1, -1, width, height, NEWT_TEXTBOX_WRAP);
- newtTextboxSetText(text, reflowedText);
- free(reflowedText);
-
- proxyEntry = newtEntry(-1, -1, ui->proxy, 24, (const char **) &proxy,
- NEWT_ENTRY_SCROLL);
- proxyPortEntry = newtEntry(-1, -1, ui->proxyPort, 6,
- (const char **) &proxyPort, NEWT_FLAG_SCROLL);
-
- entryGrid = newtCreateGrid(2, 2);
- newtGridSetField(entryGrid, 0, 0, NEWT_GRID_COMPONENT,
- newtLabel(-1, -1, _("Proxy Name:")),
- 0, 0, 2, 0, NEWT_ANCHOR_LEFT, 0);
- newtGridSetField(entryGrid, 1, 0, NEWT_GRID_COMPONENT, proxyEntry,
- 0, 0, 0, 0, 0, 0);
- newtGridSetField(entryGrid, 0, 1, NEWT_GRID_COMPONENT,
- newtLabel(-1, -1, _("Proxy Port:")),
- 0, 0, 2, 0, NEWT_ANCHOR_LEFT, 0);
- newtGridSetField(entryGrid, 1, 1, NEWT_GRID_COMPONENT, proxyPortEntry,
- 0, 0, 0, 0, 0, 0);
-
- buttons = newtButtonBar(_("OK"), &okay, _("Back"), &cancel, NULL);
-
- grid = newtCreateGrid(1, 3);
- newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, text, 0, 0, 0, 0, 0, 0);
- newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, entryGrid,
- 0, 1, 0, 0, 0, 0);
- newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, buttons,
- 0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
-
- form = newtForm(NULL, NULL, 0);
- newtGridAddComponentsToForm(grid, form, 1);
- newtGridWrappedWindow(grid, _("Further Setup"));
- newtGridFree(grid, 1);
-
- answer = newtRunForm(form);
- if (answer == cancel) {
- newtFormDestroy(form);
- newtPopWindow();
-
- return LOADER_BACK;
- }
-
- if (strlen(proxy))
- ui->proxy = strdup(proxy);
- if (strlen(proxyPort))
- ui->proxyPort = strdup(proxyPort);
-
newtFormDestroy(form);
newtPopWindow();
return 0;
}
-
-/* vim:set shiftwidth=4 softtabstop=4: */
diff --git a/loader2/urls.h b/loader2/urls.h
index 046ee72..75761ac 100644
--- a/loader2/urls.h
+++ b/loader2/urls.h
@@ -38,7 +38,7 @@ int convertURLToUI(char *url, struct iurlinfo *ui);
char *convertUIToURL(struct iurlinfo *ui);
int setupRemote(struct iurlinfo * ui);
-int urlMainSetupPanel(struct iurlinfo * ui, char * doSecondarySetup);
+int urlMainSetupPanel(struct iurlinfo * ui);
int urlSecondarySetupPanel(struct iurlinfo * ui);
int urlinstStartTransfer(struct iurlinfo * ui, char *path, char *extraHeaders);
int urlinstFinishTransfer(struct iurlinfo * ui, int fd);
--
1.5.5.1
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]