diff options
author | Chris Lumens <clumens@redhat.com> | 2008-08-13 18:00:59 -0400 |
---|---|---|
committer | Chris Lumens <clumens@redhat.com> | 2008-08-13 18:06:26 -0400 |
commit | 18cd13922234ec66a4655e5239db568da75eae49 (patch) | |
tree | 44a96eec843199691d9e2e801fe0462cbf929443 | |
parent | 00e1bbedde5dc08abc31cfafb8834d670599d1e3 (diff) | |
download | anaconda-18cd13922234ec66a4655e5239db568da75eae49.tar.gz anaconda-18cd13922234ec66a4655e5239db568da75eae49.tar.xz anaconda-18cd13922234ec66a4655e5239db568da75eae49.zip |
Correctly handle typos in the stage2 location when inferred from repo=.
When we are given repo= but have to infer a location for the stage2 image,
we need to deal with typos. When we try to get the stage2 image, the user
has a chance to correct things in the UI. However, this does not change
the repo= parameter we used to make our stage2 guess. While we can't be
sure what the user really meant to do, we can at least try to trim off the
/images/whatever portion of the path that was constructed by the UI.
-rw-r--r-- | loader2/hdinstall.c | 6 | ||||
-rw-r--r-- | loader2/loader.c | 29 | ||||
-rw-r--r-- | loader2/loader.h | 2 | ||||
-rw-r--r-- | loader2/nfsinstall.c | 13 | ||||
-rw-r--r-- | loader2/urlinstall.c | 7 |
5 files changed, 57 insertions, 0 deletions
diff --git a/loader2/hdinstall.c b/loader2/hdinstall.c index eaf3da98f..4a577eb59 100644 --- a/loader2/hdinstall.c +++ b/loader2/hdinstall.c @@ -180,6 +180,9 @@ char * mountHardDrive(struct installMethod * method, if (!kspartition || !ksdirectory) { logMessage(ERROR, "missing partition or directory specification"); loaderData->method = -1; + + if (loaderData->inferredStage2) + loaderData->invalidRepoParam = 1; } else { /* if we start with /dev, strip it (#121486) */ char *kspart = kspartition; @@ -191,6 +194,9 @@ char * mountHardDrive(struct installMethod * method, logMessage(ERROR, "unable to find %s installation images on hd", getProductName()); loaderData->method = -1; + + if (loaderData->inferredStage2) + loaderData->invalidRepoParam = 1; } else { free(kspartition); free(ksdirectory); diff --git a/loader2/loader.c b/loader2/loader.c index 7ed1042cc..378e5299d 100644 --- a/loader2/loader.c +++ b/loader2/loader.c @@ -1185,6 +1185,15 @@ static char *doLoaderMain(struct loaderData_s *loaderData, logMessage(INFO, "no stage2= given, assuming %s", tmp); setStage2LocFromCmdline(tmp, loaderData); free(tmp); + + /* If we had to infer a stage2= location, but the repo= parameter + * we based this guess on was wrong, we need to correct the typo + * in both places. Unfortunately we can't really know what the + * user meant, so the best we can do is take the results of + * running stage2= through the UI and chop off any /images/whatever + * path that's at the end of it. + */ + loaderData->inferredStage2 = 1; } } @@ -1525,7 +1534,27 @@ static char *doLoaderMain(struct loaderData_s *loaderData, logMessage(INFO, "got stage2 at url %s", url); step = STEP_DONE; dir = 1; + + if (loaderData->invalidRepoParam) { + char *newInstRepo; + + /* Doesn't contain /images? Let's not even try. */ + if (strstr(url, "/images") == NULL) + break; + + if (asprintf(&newInstRepo, "%.*s", + (int) (strstr(url, "/images")-url), url) == -1) { + logMessage(CRITICAL, "%s: %d: %m", __func__, __LINE__); + abort(); + } + + free(loaderData->instRepo); + loaderData->instRepo = newInstRepo; + logMessage(INFO, "reset repo= parameter to %s", + loaderData->instRepo); + } } + break; } diff --git a/loader2/loader.h b/loader2/loader.h index e18a1cbda..ac28f1363 100644 --- a/loader2/loader.h +++ b/loader2/loader.h @@ -138,6 +138,8 @@ struct loaderData_s { size_t fw_search_pathz_len; moduleInfoSet modInfo; + + int inferredStage2, invalidRepoParam; }; /* 64 bit platforms, definitions courtesy of glib */ diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c index efde32a1c..836ef9704 100644 --- a/loader2/nfsinstall.c +++ b/loader2/nfsinstall.c @@ -138,6 +138,10 @@ char * mountNfsImage(struct installMethod * method, if (!host || !directory) { logMessage(ERROR, "missing host or directory specification"); + + if (loaderData->inferredStage2) + loaderData->invalidRepoParam = 1; + loaderData->method = -1; break; } else { @@ -182,6 +186,9 @@ char * mountNfsImage(struct installMethod * method, if (loaderData->method >= 0) loaderData->method = -1; + if (loaderData->inferredStage2) + loaderData->invalidRepoParam = 1; + break; } @@ -241,6 +248,9 @@ char * mountNfsImage(struct installMethod * method, if (loaderData->method >= 0) loaderData->method = -1; + if (loaderData->inferredStage2) + loaderData->invalidRepoParam = 1; + break; } @@ -257,6 +267,9 @@ char * mountNfsImage(struct installMethod * method, if (loaderData->method >= 0) loaderData->method = -1; + if (loaderData->inferredStage2) + loaderData->invalidRepoParam = 1; + break; } diff --git a/loader2/urlinstall.c b/loader2/urlinstall.c index 48d1cb73d..0f0e70c31 100644 --- a/loader2/urlinstall.c +++ b/loader2/urlinstall.c @@ -204,6 +204,10 @@ char *mountUrlImage(struct installMethod *method, char *location, loaderData->method = -1; free(loaderData->stage2Data); loaderData->stage2Data = NULL; + + if (loaderData->inferredStage2) + loaderData->invalidRepoParam = 1; + break; } @@ -248,6 +252,9 @@ char *mountUrlImage(struct installMethod *method, char *location, if (loaderData->method >= 0) loaderData->method = -1; + + if (loaderData->inferredStage2) + loaderData->invalidRepoParam = 1; } else { stage = URL_STAGE_DONE; } |