summaryrefslogtreecommitdiffstats
path: root/loader2
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2003-10-14 19:36:32 +0000
committerJeremy Katz <katzj@redhat.com>2003-10-14 19:36:32 +0000
commit60a8f9866e39b0eb0f5f0e15057f36679d007522 (patch)
treee86d39f59a06ada627d57addf02b31810730853d /loader2
parent6af42d3070c2528db2c3fb47a3613e150ef1c449 (diff)
downloadanaconda-60a8f9866e39b0eb0f5f0e15057f36679d007522.tar.gz
anaconda-60a8f9866e39b0eb0f5f0e15057f36679d007522.tar.xz
anaconda-60a8f9866e39b0eb0f5f0e15057f36679d007522.zip
read product path from the build stamp if possible, default to RedHat if not
available. basically notting's patch with some fixes and genhdlist handled
Diffstat (limited to 'loader2')
-rw-r--r--loader2/cdinstall.c15
-rw-r--r--loader2/hdinstall.c10
-rw-r--r--loader2/loader.c63
-rw-r--r--loader2/loader.h2
-rw-r--r--loader2/method.c11
-rw-r--r--loader2/nfsinstall.c16
-rw-r--r--loader2/urlinstall.c16
7 files changed, 88 insertions, 45 deletions
diff --git a/loader2/cdinstall.c b/loader2/cdinstall.c
index 5344ffe69..3e2231029 100644
--- a/loader2/cdinstall.c
+++ b/loader2/cdinstall.c
@@ -147,6 +147,7 @@ static void wrongCDMessage(void) {
static void mountCdromStage2(char *cddev) {
int gotcd1=0;
int rc;
+ char path[1024];
devMakeInode(cddev, "/tmp/cdrom");
do {
@@ -160,7 +161,8 @@ static void mountCdromStage2(char *cddev) {
}
} while (1);
- rc = mountStage2("/mnt/source/RedHat/base/stage2.img");
+ snprintf(path, sizeof(path), "/mnt/source/%s/base/stage2.img", getProductPath());
+ rc = mountStage2(path);
/* if we failed, umount /mnt/source and keep going */
if (rc) {
@@ -318,7 +320,10 @@ char * setupCdrom(char * location,
devMakeInode(kd->known[i].name, "/tmp/cdrom");
if (!doPwMount("/tmp/cdrom", "/mnt/source", "iso9660", 1, 0,
NULL, NULL, 0, 0)) {
- if (!access("/mnt/source/RedHat/base/stage2.img", R_OK) &&
+ char path[1024];
+
+ snprintf(path, sizeof(path), "/mnt/source/%s/base/stage2.img", getProductPath());
+ if (!access(path, R_OK) &&
(!requirepkgs || !access("/mnt/source/.discinfo", R_OK))) {
@@ -326,11 +331,13 @@ char * setupCdrom(char * location,
/* free up the CD drive and user can have it avaiable to */
/* aid system recovery. */
if (FL_RESCUE(flags) && totalMemory() > 128000) {
- rc = copyFile("/mnt/source/RedHat/base/stage2.img", "/tmp/ramfs/stage2.img");
+ snprintf(path, sizeof(path), "/mnt/source/%s/base/stage2.img", getProductPath());
+ rc = copyFile(path, "/tmp/ramfs/stage2.img");
stage2img = "/tmp/ramfs/stage2.img";
stage2inram = 1;
} else {
- stage2img = "/mnt/source/RedHat/base/stage2.img";
+ snprintf(path, sizeof(path), "/mnt/source/%s/base/stage2.img", getProductPath());
+ stage2img = strdup(path);
stage2inram = 0;
}
diff --git a/loader2/hdinstall.c b/loader2/hdinstall.c
index 08e399905..ad1d93a46 100644
--- a/loader2/hdinstall.c
+++ b/loader2/hdinstall.c
@@ -197,7 +197,7 @@ static int loadHDImages(char * prefix, char * dir, int flags,
target = NULL;
for (; stg2list[idx]; idx++) {
target = stg2list[idx];
- sprintf(path, "%s/%s/RedHat/base/%s", prefix, dir ? dir : "", target);
+ sprintf(path, "%s/%s/%s/base/%s", prefix, dir ? dir : "", getProductPath(), target);
logMessage("Looking for hd stage2 image %s", path);
if (!access(path, F_OK))
@@ -221,12 +221,12 @@ static int loadHDImages(char * prefix, char * dir, int flags,
/* handle updates.img now before we copy stage2 over... this allows
* us to keep our ramdisk size as small as possible */
- sprintf(path, "%s/%s/RedHat/base/updates.img", prefix, dir ? dir : "");
+ sprintf(path, "%s/%s/%s/base/updates.img", prefix, dir ? dir : "", getProductPath());
copyUpdatesImg(path);
/* handle product.img now before we copy stage2 over... this allows
* us to keep our ramdisk size as small as possible */
- sprintf(path, "%s/%s/RedHat/base/product.img", prefix, dir ? dir : "");
+ sprintf(path, "%s/%s/%s/base/product.img", prefix, dir ? dir : "", getProductPath());
copyProductImg(path);
dest = alloca(strlen(target) + 50);
@@ -262,7 +262,7 @@ static int mountHDImages(char * prefix, char * dir, int flags,
target = NULL;
for (idx=0; stg2list[idx]; idx++) {
target = stg2list[idx];
- sprintf(path, "%s/%s/RedHat/base/%s", prefix, dir ? dir : "", target);
+ sprintf(path, "%s/%s/%s/base/%s", prefix, dir ? dir : "", getProductPath(), target);
logMessage("Looking for hd stage2 image %s", path);
if (!access(path, F_OK))
@@ -302,7 +302,7 @@ static int mountHDImages(char * prefix, char * dir, int flags,
/* handle updates.img now before we copy stage2 over... this allows
* us to keep our ramdisk size as small as possible */
- sprintf(path, "%s/%s/RedHat/base/updates.img", prefix, dir ? dir : "");
+ sprintf(path, "%s/%s/%s/base/updates.img", prefix, dir ? dir : "", getProductPath());
copyUpdatesImg(path);
return rc;
diff --git a/loader2/loader.c b/loader2/loader.c
index b5aafa4e8..d3086a8ba 100644
--- a/loader2/loader.c
+++ b/loader2/loader.c
@@ -183,35 +183,56 @@ void stopNewt(void) {
newtRunning = 0;
}
-char * getProductName(void) {
- static char * productName = NULL;
+static char * productName = NULL;
+static char * productPath = NULL;
+
+static void initProductInfo(void) {
FILE *f;
int i;
- if (!productName) {
- f = fopen("/.buildstamp", "r");
- if (!f) {
- productName = strdup("anaconda");
- } else {
- productName = malloc(256);
- fgets(productName, 256, f); /* stamp time */
- fgets(productName, 256, f); /* product name */
-
- i = strlen(productName) - 1;
- while (isspace(*(productName + i))) {
- *(productName + i) = '\0';
- i--;
- }
-
- return productName;
- }
+ f = fopen("/.buildstamp", "r");
+ if (!f) {
+ productName = strdup("anaconda");
+ productPath = strdup("RedHat");
} else {
- return productName;
+ productName = malloc(256);
+ productPath = malloc(256);
+ fgets(productName, 256, f); /* stamp time */
+ fgets(productName, 256, f); /* product name */
+ fgets(productPath, 256, f); /* product version */
+ fgets(productPath, 256, f); /* product path */
+
+ i = strlen(productName) - 1;
+ while (isspace(*(productName + i))) {
+ *(productName + i) = '\0';
+ i--;
+ }
+ i = strlen(productPath) - 1;
+ while (isspace(*(productPath + i))) {
+ *(productPath + i) = '\0';
+ i--;
+ }
}
+}
- return NULL;
+char * getProductName(void) {
+ if (!productName) {
+ initProductInfo();
+ }
+ return productName;
+}
+
+char * getProductPath(void) {
+ if (!productPath) {
+ initProductInfo();
+ }
+ return productPath;
}
+
+
+
+
void initializeConsole(moduleList modLoaded, moduleDeps modDeps,
moduleInfoSet modInfo, int flags) {
if (!FL_NOFB(flags))
diff --git a/loader2/loader.h b/loader2/loader.h
index e0f524078..711a969a5 100644
--- a/loader2/loader.h
+++ b/loader2/loader.h
@@ -65,7 +65,7 @@
void startNewt(int flags);
void stopNewt();
char * getProductName(void);
-
+char * getProductPath(void);
#include "modules.h"
#include "moduledeps.h"
diff --git a/loader2/method.c b/loader2/method.c
index 0a9694462..faa85ae89 100644
--- a/loader2/method.c
+++ b/loader2/method.c
@@ -143,6 +143,7 @@ char * validIsoImages(char * dirName) {
DIR * dir;
struct dirent * ent;
char isoImage[1024];
+ char path[1024];
if (!(dir = opendir(dirName))) {
newtWinMessage(_("Error"), _("OK"),
@@ -167,7 +168,8 @@ char * validIsoImages(char * dirName) {
continue;
}
- if (!access("/tmp/loopimage/RedHat/base/hdstg2.img", F_OK)) {
+ snprintf(path, sizeof(path), "/tmp/loopimage/%s/base/hdstg2.img", getProductPath());
+ if (!access(path, F_OK)) {
umountLoopback("/tmp/loopimage", "loop7");
break;
}
@@ -570,6 +572,7 @@ void umountStage2(void) {
/* mount a second stage, verify the stamp file, copy updates
* Returns 0 on success, 1 on failure to mount, -1 on bad stamp */
int mountStage2(char * path) {
+ char imgPath[1024];
if (access(path, R_OK)) {
return 1;
}
@@ -584,10 +587,12 @@ int mountStage2(char * path) {
}
/* JKFIXME: this is kind of silly.. /mnt/source is hardcoded :/ */
- copyUpdatesImg("/mnt/source/RedHat/base/updates.img");
+ snprintf(imgPath, sizeof(imgPath), "/mnt/source/%s/base/updates.img", getProductPath());
+ copyUpdatesImg(imgPath);
/* more hard coding */
- copyProductImg("/mnt/source/RedHat/base/product.img");
+ snprintf(imgPath, sizeof(imgPath), "/mnt/source/%s/base/product.img", getProductPath());
+ copyProductImg(imgPath);
return 0;
}
diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c
index 4f8e9ff5c..80e8ea1e5 100644
--- a/loader2/nfsinstall.c
+++ b/loader2/nfsinstall.c
@@ -132,10 +132,13 @@ char * mountNfsImage(struct installMethod * method,
stage = NFS_STAGE_NFS;
if (!doPwMount(fullPath, "/mnt/source", "nfs", 1, 0, NULL, NULL, 0, 0)) {
+ char mntPath[1024];
+
logMessage("mounted %s on /mnt/source", fullPath);
- if (!access("/mnt/source/RedHat/base/stage2.img", R_OK)) {
+ snprintf(mntPath, sizeof(mntPath), "/mnt/source/%s/base/stage2.img", getProductPath());
+ if (!access(mntPath, R_OK)) {
logMessage("can access stage2.img");
- rc = mountStage2("/mnt/source/RedHat/base/stage2.img");
+ rc = mountStage2(mntPath);
logMessage("after mountStage2, rc is %d", rc);
if (rc) {
if (rc == -1) {
@@ -156,7 +159,8 @@ char * mountNfsImage(struct installMethod * method,
if (mountLoopback(path, "/mnt/source2", "loop1"))
logMessage("failed to mount iso %s loopback", path);
else {
- rc = mountStage2("/mnt/source2/RedHat/base/stage2.img");
+ snprintf(mntPath, sizeof(mntPath), "/mnt/source2/%s/base/stage2.img", getProductPath());
+ rc = mountStage2(mntPath);
if (rc) {
umountLoopback("/mnt/source2", "loop1");
if (rc == -1)
@@ -164,8 +168,10 @@ char * mountNfsImage(struct installMethod * method,
} else {
/* JKFIXME: hack because /mnt/source is hard-coded
* in mountStage2() */
- copyUpdatesImg("/mnt/source2/RedHat/base/updates.img");
- copyProductImg("/mnt/source2/RedHat/base/product.img");
+ snprintf(mntPath, sizeof(mntPath), "/mnt/source2/%s/base/updates.img", getProductPath());
+ copyUpdatesImg(mntPath);
+ snprintf(mntPath, sizeof(mntPath), "/mnt/source2/%s/base/product.img", getProductPath());
+ copyProductImg(mntPath);
queryIsoMediaCheck(path, flags);
diff --git a/loader2/urlinstall.c b/loader2/urlinstall.c
index d19766dc5..480e32c74 100644
--- a/loader2/urlinstall.c
+++ b/loader2/urlinstall.c
@@ -43,8 +43,12 @@ static int loadSingleUrlImage(struct iurlinfo * ui, char * file, int flags,
int fd;
int rc;
char * newFile = NULL;
+ char filepath[1024];
+
+ /* BNFIXME: hack - all callers want RedHat/<foo>, so add prefix here */
+ snprintf(filepath, sizeof(filepath), "%s/%s", getProductPath(), file);
- fd = urlinstStartTransfer(ui, file, NULL, 1, flags);
+ fd = urlinstStartTransfer(ui, filepath, NULL, 1, flags);
if (fd == -2) return 2;
@@ -52,7 +56,7 @@ static int loadSingleUrlImage(struct iurlinfo * ui, char * file, int flags,
/* file not found */
newFile = alloca(strlen(device) + 20);
- sprintf(newFile, "disc1/%s", file);
+ sprintf(newFile, "disc1/%s", filepath);
fd = urlinstStartTransfer(ui, newFile, NULL, 1, flags);
@@ -63,7 +67,7 @@ static int loadSingleUrlImage(struct iurlinfo * ui, char * file, int flags,
_("Unable to retrieve %s://%s/%s/%s."),
(ui->protocol == URL_METHOD_FTP ? "ftp" :
"http"),
- ui->address, ui->prefix, file);
+ ui->address, ui->prefix, filepath);
return 2;
}
}
@@ -92,7 +96,7 @@ static int loadUrlImages(struct iurlinfo * ui, int flags) {
/* grab the updates.img before netstg1.img so that we minimize our
* ramdisk usage */
- if (!loadSingleUrlImage(ui, "RedHat/base/updates.img", flags,
+ if (!loadSingleUrlImage(ui, "base/updates.img", flags,
"/tmp/ramfs/updates-disk.img", "/tmp/update-disk",
"loop7", 1)) {
copyDirectory("/tmp/update-disk", "/tmp/updates");
@@ -103,7 +107,7 @@ static int loadUrlImages(struct iurlinfo * ui, int flags) {
/* grab the product.img before netstg1.img so that we minimize our
* ramdisk usage */
- if (!loadSingleUrlImage(ui, "RedHat/base/product.img", flags,
+ if (!loadSingleUrlImage(ui, "base/product.img", flags,
"/tmp/ramfs/product-disk.img", "/tmp/product-disk",
"loop7", 1)) {
copyDirectory("/tmp/product-disk", "/tmp/product");
@@ -122,7 +126,7 @@ static int loadUrlImages(struct iurlinfo * ui, int flags) {
stage2img = "stage2.img";
}
- snprintf(tmpstr1, sizeof(tmpstr1), "RedHat/base/%s", stage2img);
+ snprintf(tmpstr1, sizeof(tmpstr1), "base/%s", stage2img);
snprintf(tmpstr2, sizeof(tmpstr2), "/tmp/ramfs/%s", stage2img);
rc = loadSingleUrlImage(ui, tmpstr1, flags, tmpstr2,