diff options
-rw-r--r-- | ChangeLog | 35 | ||||
-rw-r--r-- | loader2/cdinstall.c | 266 | ||||
-rw-r--r-- | loader2/hdinstall.c | 502 | ||||
-rw-r--r-- | loader2/loader.c | 5 | ||||
-rw-r--r-- | loader2/loader.h | 3 | ||||
-rw-r--r-- | loader2/method.c | 8 | ||||
-rw-r--r-- | loader2/method.h | 12 | ||||
-rw-r--r-- | loader2/net.c | 23 | ||||
-rw-r--r-- | loader2/net.h | 4 | ||||
-rw-r--r-- | loader2/nfsinstall.c | 28 | ||||
-rw-r--r-- | loader2/urlinstall.c | 18 |
11 files changed, 444 insertions, 460 deletions
@@ -1,3 +1,38 @@ +2006-07-27 David Cantrell <dcantrell@redhat.com> + + * loader2/cdinstall.c: loaderData->method is now an int. + + * loader2/hdinstall.c: Whitespace consistency, loaderData->method + is now an int. + + * loader2/loader.c (doLoaderMain): loaderData->method is now an + int, pass methodNum to readNetConfig(). + + * loader2/loader.h: char * method -> int method. + + * loader2/method.c: Set loaderData->method to appropriate METHOD_ + value since it's now an int. + + * loader2/method.h: Add METHOD_* macros. + + * loader2/net.c (cidrCallback): Dialog wording change. + + * loader2/net.c (readNetConfig): Take methodNum as a param, pass + methodNum to configureTCPIP(). + + * loader2/net.c (configureTCPIP): Take methodNum as a param, if + user selects METHOD_NFS and unchecks IPv4, display error dialog + and ask user to try again. + + * loader2/net.c (kickstartNetworkUp): Pass methodNum to + readNetConfig(). + + * loader2/net.h: Prototype updates. + + * loader2/nfsinstall.c: loaderData->method is now an int. + + * loader2/urlinstall.c: loaderData->method is now an int. + 2006-07-27 Jeremy Katz <katzj@redhat.com> * installclasses/rhel.py (InstallClass.__init__): base repopath diff --git a/loader2/cdinstall.c b/loader2/cdinstall.c index 79e256796..56f621336 100644 --- a/loader2/cdinstall.c +++ b/loader2/cdinstall.c @@ -49,20 +49,21 @@ static int getISOStatusFromFD(int isofd, char *mediasum); /* ejects the CD device the device node /tmp/cdrom points at */ void ejectCdrom(void) { - int ejectfd; - - logMessage(INFO, "ejecting /tmp/cdrom..."); - if ((ejectfd = open("/tmp/cdrom", O_RDONLY | O_NONBLOCK, 0)) >= 0) { - if (ioctl(ejectfd, CDROMEJECT, 0)) - logMessage(ERROR, "eject failed %d ", errno); - close(ejectfd); - } else { - logMessage(ERROR, "eject failed %d ", errno); - } + int ejectfd; + + logMessage(INFO, "ejecting /tmp/cdrom..."); + if ((ejectfd = open("/tmp/cdrom", O_RDONLY | O_NONBLOCK, 0)) >= 0) { + if (ioctl(ejectfd, CDROMEJECT, 0)) + logMessage(ERROR, "eject failed %d ", errno); + close(ejectfd); + } else { + ogMessage(ERROR, "eject failed %d ", errno); + } } /* - * Given cd device cddriver, this function will attempt to check its internal checksum. + * Given cd device cddriver, this function will attempt to check its internal + * checksum. * * JKFIXME: this ignores "location", which should be fixed */ static char * mediaCheckCdrom(char *cddriver) { @@ -73,58 +74,58 @@ static char * mediaCheckCdrom(char *cddriver) { first = 1; do { - char *descr; - char *tstamp; - int ejectcd; - - /* init every pass */ - ejectcd = 0; - descr = NULL; - - /* if first time through, see if they want to eject the CD */ - /* currently in the drive (most likely the CD they booted from) */ - /* and test a different disk. Otherwise just test the disk in */ - /* the drive since it was inserted in the previous pass through */ - /* this loop, so they want it tested. */ - if (first) { - first = 0; - rc = newtWinChoice(_("Media Check"), _("Test"), _("Eject CD"), - _("Choose \"%s\" to test the CD currently in " - "the drive, or \"%s\" to eject the CD and " - "insert another for testing."), _("Test"), - _("Eject CD")); - - if (rc == 2) - ejectcd = 1; - } - - if (!ejectcd) { - /* XXX MSFFIXME: should check return code for error */ - readStampFileFromIso("/tmp/cdrom", &tstamp, &descr); - mediaCheckFile("/tmp/cdrom", descr); - - if (descr) - free(descr); - } - - ejectCdrom(); + char *descr; + char *tstamp; + int ejectcd; + + /* init every pass */ + ejectcd = 0; + descr = NULL; + + /* if first time through, see if they want to eject the CD */ + /* currently in the drive (most likely the CD they booted from) */ + /* and test a different disk. Otherwise just test the disk in */ + /* the drive since it was inserted in the previous pass through */ + /* this loop, so they want it tested. */ + if (first) { + first = 0; + rc = newtWinChoice(_("Media Check"), _("Test"), _("Eject CD"), + _("Choose \"%s\" to test the CD currently in " + "the drive, or \"%s\" to eject the CD and " + "insert another for testing."), _("Test"), + _("Eject CD")); + + if (rc == 2) + ejectcd = 1; + } + + if (!ejectcd) { + /* XXX MSFFIXME: should check return code for error */ + readStampFileFromIso("/tmp/cdrom", &tstamp, &descr); + mediaCheckFile("/tmp/cdrom", descr); + + if (descr) + free(descr); + } + + ejectCdrom(); - rc = newtWinChoice(_("Media Check"), _("Test"), _("Continue"), - _("If you would like to test additional media, " - "insert the next CD and press \"%s\". " - "Testing each CD is not strictly required, however " - "it is highly recommended. Minimally, the CDs should " - "be tested prior to using them for the first time. " - "After they have been successfully tested, it is not " - "required to retest each CD prior to using it again."), - _("Test"), _("Continue")); - - if (rc == 2) { - unlink("/tmp/cdrom"); - return NULL; - } else { - continue; - } + rc = newtWinChoice(_("Media Check"), _("Test"), _("Continue"), + _("If you would like to test additional media, " + "insert the next CD and press \"%s\". " + "Testing each CD is not strictly required, however " + "it is highly recommended. Minimally, the CDs should " + "be tested prior to using them for the first time. " + "After they have been successfully tested, it is not " + "required to retest each CD prior to using it again."), + _("Test"), _("Continue")); + + if (rc == 2) { + unlink("/tmp/cdrom"); + return NULL; + } else { + continue; + } } while (1); return NULL; @@ -134,9 +135,9 @@ static char * mediaCheckCdrom(char *cddriver) { /* Used by mountCdromStage2() */ static void wrongCDMessage(void) { char *buf = sdupprintf(_("The %s CD was not found " - "in any of your CDROM drives. Please insert " - "the %s CD and press %s to retry."), getProductName(), - getProductName(), _("OK")); + "in any of your CDROM drives. Please insert " + "the %s CD and press %s to retry."), + getProductName(), getProductName(), _("OK")); newtWinMessage(_("Error"), _("OK"), buf, _("OK")); free(buf); } @@ -152,26 +153,26 @@ static void mountCdromStage2(char *cddev) { devMakeInode(cddev, "/tmp/cdrom"); do { - do { - if (doPwMount("/tmp/cdrom", "/mnt/source", - "iso9660", IMOUNT_RDONLY, NULL)) { - ejectCdrom(); - wrongCDMessage(); - } else { - break; - } - } while (1); - - rc = mountStage2("/mnt/source/images/stage2.img"); - - /* if we failed, umount /mnt/source and keep going */ - if (rc) { - umount("/mnt/source"); - ejectCdrom(); - wrongCDMessage(); - } else { - gotcd1 = 1; - } + do { + if (doPwMount("/tmp/cdrom", "/mnt/source", + "iso9660", IMOUNT_RDONLY, NULL)) { + ejectCdrom(); + wrongCDMessage(); + } else { + break; + } + } while (1); + + rc = mountStage2("/mnt/source/images/stage2.img"); + + /* if we failed, umount /mnt/source and keep going */ + if (rc) { + umount("/mnt/source"); + ejectCdrom(); + wrongCDMessage(); + } else { + gotcd1 = 1; + } } while (!gotcd1); } @@ -183,9 +184,9 @@ static int getISOStatusFromCDROM(char *cddriver, char *mediasum) { devMakeInode(cddriver, "/tmp/cdrom"); isofd = open("/tmp/cdrom", O_RDONLY); if (isofd < 0) { - logMessage(WARNING, "Could not check iso status: %s", strerror(errno)); - unlink("/tmp/cdrom"); - return 0; + logMessage(WARNING, "Could not check iso status: %s", strerror(errno)); + unlink("/tmp/cdrom"); + return 0; } isostatus = getISOStatusFromFD(isofd, mediasum); @@ -205,17 +206,19 @@ static int getISOStatusFromFD(int isofd, char *mediasum) { long long isosize, pvd_offset, fragmentcount = 0; if (mediasum) - mediasum[0] = '\0'; + mediasum[0] = '\0'; fragmentsums[0] = '\0'; - if ((pvd_offset = parsepvd(isofd, tmpsum, &skipsectors, &isosize, &isostatus, fragmentsums, &fragmentcount)) < 0) { - logMessage(ERROR, "Could not parse pvd"); - return 0; + pvd_offset = parsepvd(isofd, tmpsum, &skipsectors, &isosize, &isostatus, + fragmentsums, &fragmentcount); + if (pvd_offset < 0) { + logMessage(ERROR, "Could not parse pvd"); + return 0; } if (mediasum) - strcpy(mediasum, tmpsum); + strcpy(mediasum, tmpsum); return isostatus; } @@ -225,54 +228,51 @@ static void writeISOStatus(int status, char *mediasum) { FILE *f; if (!(f = fopen("/tmp/isoinfo", "w"))) - return; + return; fprintf(f, "ISOSTATUS=%d\n", status); fprintf(f, "MEDIASUM=%s\n", mediasum); fclose(f); - } /* ask about doing media check */ /* JKFIXME: Assumes CD is mounted as /mnt/source */ static void queryCDMediaCheck(char *dev) { - int rc; - char mediasum[33]; - int isostatus; - - /* dont bother to test in automated installs */ - if (FL_KICKSTART(flags) && !FL_MEDIACHECK(flags)) - return; - - /* see what status is */ - isostatus = getISOStatusFromCDROM(dev, mediasum); - writeISOStatus(isostatus, mediasum); - - /* see if we should check image(s) */ - /* in rescue mode only test if they explicitly asked to */ - if ((!isostatus && !FL_RESCUE(flags)) || FL_MEDIACHECK(flags)) { - - startNewt(); - rc = newtWinChoice(_("CD Found"), _("OK"), - _("Skip"), - _("To begin testing the CD media before installation press %s.\n\n" - "Choose %s to skip the media test and start the installation."), _("OK"), _("Skip")); + int rc; + char mediasum[33]; + int isostatus; - if (rc != 2) { - - /* unmount CD now we've identified */ - /* a valid disc #1 is present */ - umountStage2(); - umount("/mnt/source"); + /* dont bother to test in automated installs */ + if (FL_KICKSTART(flags) && !FL_MEDIACHECK(flags)) + return; + + /* see what status is */ + isostatus = getISOStatusFromCDROM(dev, mediasum); + writeISOStatus(isostatus, mediasum); + + /* see if we should check image(s) */ + /* in rescue mode only test if they explicitly asked to */ + if ((!isostatus && !FL_RESCUE(flags)) || FL_MEDIACHECK(flags)) { + startNewt(); + rc = newtWinChoice(_("CD Found"), _("OK"), _("Skip"), + _("To begin testing the CD media before installation press %s.\n\n" + "Choose %s to skip the media test and start the installation."), + _("OK"), _("Skip")); + + if (rc != 2) { + /* unmount CD now we've identified */ + /* a valid disc #1 is present */ + umountStage2(); + umount("/mnt/source"); - /* test CD(s) */ - mediaCheckCdrom(dev); + /* test CD(s) */ + mediaCheckCdrom(dev); - /* remount stage2 from CD #1 and proceed */ - mountCdromStage2(dev); + /* remount stage2 from CD #1 and proceed */ + mountCdromStage2(dev); + } } - } } /* set up a cdrom, nominally for installation @@ -416,7 +416,7 @@ char * mountCdromImage(struct installMethod * method, void setKickstartCD(struct loaderData_s * loaderData, int argc, char ** argv) { logMessage(INFO, "kickstartFromCD"); - loaderData->method = strdup("cdrom"); + loaderData->method = METHOD_CDROM; } int kickstartFromCD(char *kssrc) { @@ -428,18 +428,18 @@ int kickstartFromCD(char *kssrc) { devices = probeDevices(CLASS_CDROM, BUS_UNSPEC, 0); if (!devices) { - logMessage(ERROR, "No CDROM devices found!"); - return 1; + logMessage(ERROR, "No CDROM devices found!"); + return 1; } /* format is ks=cdrom:[/path/to/ks.cfg] */ kspath = ""; p = strchr(kssrc, ':'); if (p) - kspath = p + 1; + kspath = p + 1; if (!p || strlen(kspath) < 1) - kspath = "/ks.cfg"; + kspath = "/ks.cfg"; for (i=0; devices[i]; i++) { if (!devices[i]->device) @@ -452,7 +452,7 @@ int kickstartFromCD(char *kssrc) { startNewt(); newtWinMessage(_("Error"), _("OK"), - _("Cannot find kickstart file on CDROM.")); + _("Cannot find kickstart file on CDROM.")); return 1; } diff --git a/loader2/hdinstall.c b/loader2/hdinstall.c index fe3864cf1..2e11a37e6 100644 --- a/loader2/hdinstall.c +++ b/loader2/hdinstall.c @@ -55,31 +55,31 @@ static int loadHDImages(char * prefix, char * dir, path = alloca(50 + strlen(prefix) + (dir ? strlen(dir) : 2)); if (totalMemory() < 128000) - idx = 1; + idx = 1; else - idx = 0; + idx = 0; target = NULL; for (; stg2list[idx]; idx++) { - target = stg2list[idx]; - sprintf(path, "%s/%s/images/%s", prefix, dir ? dir : "", target); + target = stg2list[idx]; + sprintf(path, "%s/%s/images/%s", prefix, dir ? dir : "", target); - logMessage(INFO, "Looking for hd stage2 image %s", path); - if (!access(path, F_OK)) - break; - logMessage(INFO, "%s does not exist: %s, trying next target", path, strerror(errno)); + logMessage(INFO, "Looking for hd stage2 image %s", path); + if (!access(path, F_OK)) + break; + logMessage(INFO, "%s does not exist: %s, trying next target", path, strerror(errno)); } if (!(*target)) { - logMessage(ERROR, "failed to find hd stage 2 image%s: %s", path, strerror(errno)); - return 1; + logMessage(ERROR, "failed to find hd stage 2 image%s: %s", path, strerror(errno)); + return 1; } logMessage(INFO, "Found hd stage2, copying %s in RAM as stage2", path); if ((fd = open(path, O_RDONLY)) < 0) { - logMessage(ERROR, "failed to open %s: %s", path, strerror(errno)); - return 1; + logMessage(ERROR, "failed to open %s: %s", path, strerror(errno)); + return 1; } /* handle updates.img now before we copy stage2 over... this allows @@ -111,65 +111,6 @@ static int loadHDImages(char * prefix, char * dir, return rc; } -#if 0 /* Unused now */ -/* mount loopback second stage image for hard drive install */ -static int mountHDImages(char * prefix, char * dir, - char * device, char * mntpoint, - int checkstamp) { - int idx, rc; - char * path, *target; - char *stg2list[] = {"stage2.img", "minstg2.img", NULL}; - - path = alloca(50 + strlen(prefix) + (dir ? strlen(dir) : 2)); - - target = NULL; - for (idx=0; stg2list[idx]; idx++) { - target = stg2list[idx]; - sprintf(path, "%s/%s/images/%s", prefix, dir ? dir : "", target); - - logMessage(INFO, "Looking for hd stage2 image %s", path); - if (!access(path, F_OK)) - break; - logMessage(INFO, "%s does not exist: %s, trying next target", path, strerror(errno)); - } - - if (!(*target)) { - logMessage(ERROR, "failed to find hd stage 2 image%s: %s", path, strerror(errno)); - return 1; - } - - logMessage(INFO, "Found hd stage2, mounting %s on loop %s as mntpoint %s", path, device, mntpoint); - rc = mountLoopback(path, mntpoint, device); - - if (rc) { - logMessage(ERROR, "Unable to mount hdstage2 loopback"); - return rc; - } - - /* now verify the stamp... */ - if (checkstamp && !verifyStamp(mntpoint)) { - char * buf; - - buf = sdupprintf(_("The %s installation tree in that directory does " - "not seem to match your boot media."), - getProductName()); - - newtWinMessage(_("Error"), _("OK"), buf); - - umountLoopback(mntpoint, device); - return 1; - } - - - /* 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/images/updates.img", prefix, dir ? dir : ""); - copyUpdatesImg(path); - - return rc; -} -#endif - /* given a partition device and directory, tries to mount hd install image */ static char * setupIsoImages(char * device, char * dirName) { int rc; @@ -182,60 +123,60 @@ static char * setupIsoImages(char * device, char * dirName) { logMessage(INFO, "mounting device %s for hard drive install", device); if (!FL_TESTING(flags)) { - if (devMakeInode(device, "/tmp/hddev")) - logMessage(WARNING, "devMakeInode failed!"); - - /* XXX try to mount as ext2 and then vfat */ - for (type=typetry; *type; type++) { - if (!doPwMount("/tmp/hddev", "/tmp/hdimage", *type, - IMOUNT_RDONLY, NULL)) - break; - } + if (devMakeInode(device, "/tmp/hddev")) + logMessage(WARNING, "devMakeInode failed!"); + + /* XXX try to mount as ext2 and then vfat */ + for (type=typetry; *type; type++) { + if (!doPwMount("/tmp/hddev", "/tmp/hdimage", *type, + IMOUNT_RDONLY, NULL)) + break; + } - if (!type) - return NULL; + if (!type) + return NULL; - sprintf(filespec, "/tmp/hdimage/%s", dirName); + sprintf(filespec, "/tmp/hdimage/%s", dirName); - if ((path = validIsoImages(filespec, 0))) { - char updpath[4096]; + if ((path = validIsoImages(filespec, 0))) { + char updpath[4096]; - logMessage(INFO, "Path to valid iso is %s", path); + logMessage(INFO, "Path to valid iso is %s", path); - snprintf(updpath, sizeof(updpath), "%s/updates.img", filespec); - logMessage(INFO, "Looking for updates for HD in %s", updpath); - copyUpdatesImg(updpath); + snprintf(updpath, sizeof(updpath), "%s/updates.img", filespec); + logMessage(INFO, "Looking for updates for HD in %s", updpath); + copyUpdatesImg(updpath); - rc = mountLoopback(path, "/tmp/loopimage", "loop0"); - if (!rc) { - /* This code is for copying small stage2 into ram */ - /* and mounting */ - rc = loadHDImages("/tmp/loopimage", "/", "loop1", - "/mnt/runtime"); - if (rc) { - newtWinMessage(_("Error"), _("OK"), - _("An error occured reading the install " - "from the ISO images. Please check your ISO " - "images and try again.")); - } else { - queryIsoMediaCheck(path); - } - } - - /* we copied stage2 into RAM so we can now umount image */ - umountLoopback("/tmp/loopimage", "loop0"); - - } else { - rc = 1; - } - - /* we copied stage2 into RAM so now umount partition */ - umount("/tmp/hdimage"); - if (rc) - return NULL; + rc = mountLoopback(path, "/tmp/loopimage", "loop0"); + if (!rc) { + /* This code is for copying small stage2 into ram */ + /* and mounting */ + rc = loadHDImages("/tmp/loopimage", "/", "loop1", + "/mnt/runtime"); + if (rc) { + newtWinMessage(_("Error"), _("OK"), + _("An error occured reading the install " + "from the ISO images. Please check your ISO " + "images and try again.")); + } else { + queryIsoMediaCheck(path); + } + } + + /* we copied stage2 into RAM so we can now umount image */ + umountLoopback("/tmp/loopimage", "loop0"); + + } else { + rc = 1; + } + + /* we copied stage2 into RAM so now umount partition */ + umount("/tmp/hdimage"); + if (rc) + return NULL; } else { - /* in test mode I dont know what to do - just pretend I guess */ - type = typetry; + /* in test mode I dont know what to do - just pretend I guess */ + type = typetry; } url = malloc(50 + strlen(dirName ? dirName : "")); @@ -244,7 +185,6 @@ static char * setupIsoImages(char * device, char * dirName) { return url; } - /* setup hard drive based install from a partition with a filesystem and * ISO images on that filesystem */ @@ -271,44 +211,40 @@ char * mountHardDrive(struct installMethod * method, char *kspartition, *ksdirectory; /* handle kickstart data first if available */ - if (loaderData->method && - !strncmp(loaderData->method, "hd", 2) && - loaderData->methodData) { - - kspartition = ((struct hdInstallData *)loaderData->methodData)->partition; - ksdirectory = ((struct hdInstallData *)loaderData->methodData)->directory; - logMessage(INFO, "partition is %s, dir is %s", kspartition, ksdirectory); - - /* if exist, duplicate */ - if (kspartition) - kspartition = strdup(kspartition); - if (ksdirectory) - ksdirectory = strdup(ksdirectory); - - if (!kspartition || !ksdirectory) { - logMessage(ERROR, "missing partition or directory specification"); - free(loaderData->method); - loaderData->method = NULL; - } else { + if (loaderData->method == METHOD_HD && loaderData->methodData) { + kspartition = ((struct hdInstallData *)loaderData->methodData)->partition; + ksdirectory = ((struct hdInstallData *)loaderData->methodData)->directory; + logMessage(INFO, "partition is %s, dir is %s", kspartition, ksdirectory); + + /* if exist, duplicate */ + if (kspartition) + kspartition = strdup(kspartition); + if (ksdirectory) + ksdirectory = strdup(ksdirectory); + + if (!kspartition || !ksdirectory) { + logMessage(ERROR, "missing partition or directory specification"); + loaderData->method = -1; + } else { /* if we start with /dev, strip it (#121486) */ char *kspart = kspartition; if (!strncmp(kspart, "/dev/", 5)) kspart = kspart + 5; - url = setupIsoImages(kspart, ksdirectory); - if (!url) { - logMessage(ERROR, "unable to find %s installation images on hd",getProductName()); - free(loaderData->method); - loaderData->method = NULL; - } else { - free(kspartition); - free(ksdirectory); - return url; - } - } + url = setupIsoImages(kspart, ksdirectory); + if (!url) { + logMessage(ERROR, "unable to find %s installation images on hd", + getProductName()); + loaderData->method = -1; + } else { + free(kspartition); + free(ksdirectory); + return url; + } + } } else { - kspartition = NULL; - ksdirectory = NULL; + kspartition = NULL; + ksdirectory = NULL; } /* if we're here its either because this is interactive, or the */ @@ -317,130 +253,131 @@ char * mountHardDrive(struct installMethod * method, partition_list = NULL; while (!done) { - /* if we're doing another pass free this up first */ - if (partition_list) - freePartitionsList(partition_list); - - partition_list = getPartitionsList(NULL); - numPartitions = lenPartitionsList(partition_list); - - /* no partitions found, try to load a device driver disk for storage */ - if (!numPartitions) { - rc = newtWinChoice(_("Hard Drives"), _("Yes"), _("Back"), - _("You don't seem to have any hard drives on " - "your system! Would you like to configure " - "additional devices?")); - if (rc == 2) - return NULL; + /* if we're doing another pass free this up first */ + if (partition_list) + freePartitionsList(partition_list); + + partition_list = getPartitionsList(NULL); + numPartitions = lenPartitionsList(partition_list); + + /* no partitions found, try to load a device driver disk for storage */ + if (!numPartitions) { + rc = newtWinChoice(_("Hard Drives"), _("Yes"), _("Back"), + _("You don't seem to have any hard drives on " + "your system! Would you like to configure " + "additional devices?")); + if (rc == 2) + return NULL; rc = loadDriverFromMedia(CLASS_HD, modLoaded, modDepsPtr, - modInfo, 0, 0); + modInfo, 0, 0); if (rc == LOADER_BACK) - return NULL; - - continue; - } + return NULL; + continue; + } - /* now find out which partition has the hard drive install images */ - buf = sdupprintf(_("What partition and directory on that " - "partition hold the CD (iso9660) images " - "for %s? If you don't see the disk drive " - "you're using listed here, press F2 " - "to configure additional devices."), getProductName()); - text = newtTextboxReflowed(-1, -1, buf, 62, 5, 5, 0); - free(buf); + /* now find out which partition has the hard drive install images */ + buf = sdupprintf(_("What partition and directory on that " + "partition hold the CD (iso9660) images " + "for %s? If you don't see the disk drive " + "you're using listed here, press F2 " + "to configure additional devices."), + getProductName()); + text = newtTextboxReflowed(-1, -1, buf, 62, 5, 5, 0); + free(buf); - listbox = newtListbox(-1, -1, numPartitions > 5 ? 5 : numPartitions, - NEWT_FLAG_RETURNEXIT | - (numPartitions > 5 ? NEWT_FLAG_SCROLL : 0)); + listbox = newtListbox(-1, -1, numPartitions > 5 ? 5 : numPartitions, + NEWT_FLAG_RETURNEXIT | + (numPartitions > 5 ? NEWT_FLAG_SCROLL : 0)); - for (i = 0; i < numPartitions; i++) - newtListboxAppendEntry(listbox, partition_list[i], partition_list[i]); - - /* if we had ks data around use it to prime entry, then get rid of it*/ - if (kspartition) { - newtListboxSetCurrentByKey(listbox, kspartition); - free(kspartition); - kspartition = NULL; - } + for (i = 0; i < numPartitions; i++) + newtListboxAppendEntry(listbox,partition_list[i],partition_list[i]); + + /* if we had ks data around use it to prime entry, then get rid of it*/ + if (kspartition) { + newtListboxSetCurrentByKey(listbox, kspartition); + free(kspartition); + kspartition = NULL; + } - label = newtLabel(-1, -1, _("Directory holding images:")); + label = newtLabel(-1, -1, _("Directory holding images:")); - dirEntry = newtEntry(28, 11, dir, 28, (const char **) &tmpDir, NEWT_ENTRY_SCROLL); + dirEntry = newtEntry(28, 11, dir, 28, (const char **) &tmpDir, + NEWT_ENTRY_SCROLL); - /* if we had ks data around use it to prime entry, then get rid of it*/ - if (ksdirectory) { - newtEntrySet(dirEntry, ksdirectory, 1); - free(ksdirectory); - ksdirectory = NULL; - } + /* if we had ks data around use it to prime entry, then get rid of it*/ + if (ksdirectory) { + newtEntrySet(dirEntry, ksdirectory, 1); + free(ksdirectory); + ksdirectory = NULL; + } - entryGrid = newtGridHStacked(NEWT_GRID_COMPONENT, label, - NEWT_GRID_COMPONENT, dirEntry, - NEWT_GRID_EMPTY); + entryGrid = newtGridHStacked(NEWT_GRID_COMPONENT, label, + NEWT_GRID_COMPONENT, dirEntry, + NEWT_GRID_EMPTY); - buttons = newtButtonBar(_("OK"), &okay, _("Back"), &back, NULL); + buttons = newtButtonBar(_("OK"), &okay, _("Back"), &back, NULL); - grid = newtCreateGrid(1, 4); - newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, text, - 0, 0, 0, 1, 0, 0); - newtGridSetField(grid, 0, 1, NEWT_GRID_COMPONENT, listbox, - 0, 0, 0, 1, 0, 0); - newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, entryGrid, - 0, 0, 0, 1, 0, 0); - newtGridSetField(grid, 0, 3, NEWT_GRID_SUBGRID, buttons, - 0, 0, 0, 0, 0, NEWT_GRID_FLAG_GROWX); + grid = newtCreateGrid(1, 4); + newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, text, + 0, 0, 0, 1, 0, 0); + newtGridSetField(grid, 0, 1, NEWT_GRID_COMPONENT, listbox, + 0, 0, 0, 1, 0, 0); + newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, entryGrid, + 0, 0, 0, 1, 0, 0); + newtGridSetField(grid, 0, 3, NEWT_GRID_SUBGRID, buttons, + 0, 0, 0, 0, 0, NEWT_GRID_FLAG_GROWX); - newtGridWrappedWindow(grid, _("Select Partition")); + newtGridWrappedWindow(grid, _("Select Partition")); - form = newtForm(NULL, NULL, 0); - newtFormAddHotKey(form, NEWT_KEY_F2); - newtFormAddHotKey(form, NEWT_KEY_F12); + form = newtForm(NULL, NULL, 0); + newtFormAddHotKey(form, NEWT_KEY_F2); + newtFormAddHotKey(form, NEWT_KEY_F12); - newtGridAddComponentsToForm(grid, form, 1); - newtGridFree(grid, 1); + newtGridAddComponentsToForm(grid, form, 1); + newtGridFree(grid, 1); - newtFormRun(form, &es); + newtFormRun(form, &es); - selpart = newtListboxGetCurrent(listbox); + selpart = newtListboxGetCurrent(listbox); - free(dir); - if (tmpDir && *tmpDir) { - /* Protect from form free. */ - dir = strdup(tmpDir); - } else { - dir = strdup(""); - } + free(dir); + if (tmpDir && *tmpDir) { + /* Protect from form free. */ + dir = strdup(tmpDir); + } else { + dir = strdup(""); + } - newtFormDestroy(form); - newtPopWindow(); + newtFormDestroy(form); + newtPopWindow(); - if (es.reason == NEWT_EXIT_COMPONENT && es.u.co == back) { - return NULL; - } else if (es.reason == NEWT_EXIT_HOTKEY && es.u.key == NEWT_KEY_F2) { + if (es.reason == NEWT_EXIT_COMPONENT && es.u.co == back) { + return NULL; + } else if (es.reason == NEWT_EXIT_HOTKEY && es.u.key == NEWT_KEY_F2) { rc = loadDriverFromMedia(CLASS_HD, modLoaded, modDepsPtr, - modInfo, 0, 0); + modInfo, 0, 0); if (rc == LOADER_BACK) - return NULL; + return NULL; - continue; - } + continue; + } - logMessage(INFO, "partition %s selected", selpart); + logMessage(INFO, "partition %s selected", selpart); - url = setupIsoImages(selpart + 5, dir); - if (!url) { - newtWinMessage(_("Error"), _("OK"), - _("Device %s does not appear to contain " - "%s CDROM images."), selpart, getProductName()); - continue; - } - - done = 1; - - umount("/tmp/hdimage"); - rmdir("/tmp/hdimage"); + url = setupIsoImages(selpart + 5, dir); + if (!url) { + newtWinMessage(_("Error"), _("OK"), + _("Device %s does not appear to contain " + "%s CDROM images."), selpart, getProductName()); + continue; + } + + done = 1; + + umount("/tmp/hdimage"); + rmdir("/tmp/hdimage"); } free(dir); @@ -492,7 +429,7 @@ void setKickstartHD(struct loaderData_s * loaderData, int argc, sprintf(partition, "%s%s", dev, p + 1); } - loaderData->method = strdup("hd"); + loaderData->method = METHOD_HD; loaderData->methodData = calloc(sizeof(struct hdInstallData *), 1); if (partition) ((struct hdInstallData *)loaderData->methodData)->partition = partition; @@ -505,7 +442,7 @@ void setKickstartHD(struct loaderData_s * loaderData, int argc, int kickstartFromHD(char *kssrc) { int rc; - char *p, *q = NULL, *tmpstr, *ksdev, *kspath; + char *p, *np = NULL, *tmpstr, *ksdev, *kspath; logMessage(INFO, "getting kickstart file from harddrive"); @@ -514,31 +451,32 @@ int kickstartFromHD(char *kssrc) { tmpstr = strdup(kssrc); p = strchr(tmpstr, ':'); if (p) - q = strchr(p+1, ':'); + np = strchr(p+1, ':'); - /* no second colon, assume its the old format of ks=hd:[device]/path/to/ks.cfg */ + /* no second colon, assume its the old format of */ + /* ks=hd:[device]/path/to/ks.cfg */ /* this format is bad however because some devices have '/' in them! */ - if (!q) - q = strchr(p+1, '/'); + if (!np) + np = strchr(p+1, '/'); - if (!p || !q) { - logMessage(WARNING, "Format of command line is ks=hd:[device]:/path/to/ks.cfg"); - free(tmpstr); - return 1; + if (!p || !np) { + logMessage(WARNING, "Format of command line is ks=hd:[device]:/path/to/ks.cfg"); + free(tmpstr); + return 1; } - *q = '\0'; + *np = '\0'; ksdev = p+1; - kspath = q+1; + kspath = np+1; logMessage(INFO, "Loading ks from device %s on path %s", ksdev, kspath); if ((rc=getKickstartFromBlockDevice(ksdev, kspath))) { - if (rc == 3) { - startNewt(); - newtWinMessage(_("Error"), _("OK"), - _("Cannot find kickstart file on hard drive.")); - } - return 1; + if (rc == 3) { + startNewt(); + newtWinMessage(_("Error"), _("OK"), + _("Cannot find kickstart file on hard drive.")); + } + return 1; } return 0; @@ -547,7 +485,7 @@ int kickstartFromHD(char *kssrc) { int kickstartFromBD(char *kssrc) { int rc; - char *p, *q = NULL, *r = NULL, *tmpstr, *ksdev, *kspath, *biosksdev; + char *p, *np = NULL, *r = NULL, *tmpstr, *ksdev, *kspath, *biosksdev; logMessage(INFO, "getting kickstart file from biosdrive"); @@ -556,16 +494,16 @@ int kickstartFromBD(char *kssrc) { tmpstr = strdup(kssrc); p = strchr(tmpstr, ':'); if (p) - q = strchr(p+1, ':'); + np = strchr(p+1, ':'); - if (!p || !q) { - logMessage(WARNING, "Format of command line is ks=bd:device:/path/to/ks.cfg"); - free(tmpstr); - return 1; + if (!p || !np) { + logMessage(WARNING, "Format of command line is ks=bd:device:/path/to/ks.cfg"); + free(tmpstr); + return 1; } - *q = '\0'; - kspath = q+1; + *np = '\0'; + kspath = np+1; r = strchr(p+1,'p'); if(!r){ @@ -589,13 +527,15 @@ int kickstartFromBD(char *kssrc) { sprintf(ksdev, "%s%s", biosksdev, r + 1); logMessage(INFO, "Loading ks from device %s on path %s", ksdev, kspath); if ((rc=getKickstartFromBlockDevice(ksdev, kspath))) { - if (rc == 3) { - startNewt(); - newtWinMessage(_("Error"), _("OK"), - _("Cannot find kickstart file on hard drive.")); - } - return 1; + if (rc == 3) { + startNewt(); + newtWinMessage(_("Error"), _("OK"), + _("Cannot find kickstart file on hard drive.")); + } + return 1; } return 0; } + +/* vim:set shiftwidth=4 softtabstop=4: */ diff --git a/loader2/loader.c b/loader2/loader.c index 985b637bf..91f84e9df 100644 --- a/loader2/loader.c +++ b/loader2/loader.c @@ -825,8 +825,7 @@ static char *doLoaderMain(char * location, validMethods[numValidMethods] = i; /* have we preselected this to be our install method? */ - if (loaderData->method && *loaderData->method && - !strcmp(loaderData->method, installMethods[i].shortname)) { + if (loaderData->method >= 0) { methodNum = numValidMethods; /* disable the fast path (#102652) */ flags |= LOADER_FLAGS_ASKMETHOD; @@ -1049,7 +1048,7 @@ static char *doLoaderMain(char * location, /* populate netDev based on any kickstart data */ setupNetworkDeviceConfig(&netDev, loaderData); - rc = readNetConfig(devName, &netDev, loaderData->netCls); + rc = readNetConfig(devName, &netDev, loaderData->netCls, methodNum); if ((rc == LOADER_BACK) || (rc == LOADER_ERROR) || ((dir == -1) && (rc == LOADER_NOOP))) { step = STEP_IFACE; diff --git a/loader2/loader.h b/loader2/loader.h index 9dedb51bd..85e8ca37d 100644 --- a/loader2/loader.h +++ b/loader2/loader.h @@ -105,7 +105,7 @@ struct loaderData_s { int ipinfo_set; int noipv4, noipv6; char * ksFile; - char * method; + int method; char * ddsrc; void * methodData; char * logLevel; @@ -132,5 +132,4 @@ struct loaderData_s { #define LIBPATH "/lib:/usr/lib:/usr/X11R6/lib:/usr/kerberos/lib:/mnt/usr/lib:/mnt/sysimage/lib:/mnt/sysimage/usr/lib" #endif - #endif diff --git a/loader2/method.c b/loader2/method.c index 47e070485..1794559df 100644 --- a/loader2/method.c +++ b/loader2/method.c @@ -690,7 +690,7 @@ void setMethodFromCmdline(char * arg, struct loaderData_s * ld) { c = strtok(NULL, ":"); if (!strncmp(arg, "nfs:", 4)) { - ld->method = strdup("nfs"); + ld->method = METHOD_NFS; ld->methodData = calloc(sizeof(struct nfsInstallData *), 1); ((struct nfsInstallData *)ld->methodData)->host = strdup(c); if ((c = strtok(NULL, ":"))) { @@ -698,14 +698,14 @@ void setMethodFromCmdline(char * arg, struct loaderData_s * ld) { } } else if (!strncmp(arg, "ftp:", 4) || !strncmp(arg, "http:", 5)) { - ld->method = strcmp(arg, "ftp") ? strdup("ftp") : strdup("http"); + ld->method = strcmp(arg, "ftp") ? METHOD_FTP : METHOD_HTTP; ld->methodData = calloc(sizeof(struct urlInstallData *), 1); ((struct urlInstallData *)ld->methodData)->url = strdup(arg); } else if (!strncmp(arg, "cdrom:", 6)) { - ld->method = strdup("cdrom"); + ld->method = METHOD_CDROM; } else if (!strncmp(arg, "harddrive:", 10) || !strncmp(arg, "hd:", 3)) { - ld->method = strdup("hd"); + ld->method = METHOD_HD; ld->methodData = calloc(sizeof(struct hdInstallData *), 1); ((struct hdInstallData *)ld->methodData)->partition = strdup(c); if ((c = strtok(NULL, ":"))) { diff --git a/loader2/method.h b/loader2/method.h index e4862ae7b..5da5fbee3 100644 --- a/loader2/method.h +++ b/loader2/method.h @@ -6,6 +6,17 @@ #include "loader.h" #include <kudzu/kudzu.h> +/* method identifiers, needs to match struct installMethod order in loader.c */ +enum { +#if !defined(__s390__) && !defined(__s390x__) + METHOD_CDROM, +#endif + METHOD_HD, + METHOD_NFS, + METHOD_FTP, + METHOD_HTTP +}; + struct installMethod { char * name; char * shortname; @@ -17,7 +28,6 @@ struct installMethod { moduleDeps * modDepsPtr); }; - int umountLoopback(char * mntpoint, char * device); int mountLoopback(char * fsystem, char * mntpoint, char * device); diff --git a/loader2/net.c b/loader2/net.c index df0f39cee..ce92fe07f 100644 --- a/loader2/net.c +++ b/loader2/net.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 Red Hat, Inc. + * Copyright 1999-2006 Red Hat, Inc. * * David Cantrell <dcantrell@redhat.com> * @@ -52,6 +52,7 @@ #include "loader.h" #include "loadermisc.h" #include "log.h" +#include "method.h" #include "net.h" #include "windows.h" @@ -93,8 +94,8 @@ static void cidrCallback(newtComponent co, void * dptr) { if (upper != 0) { if (cidr < 1 || cidr > upper) { - newtWinMessage(_("Invalid CIDR Mask"), _("Retry"), - _("CIDR mask value must be between 1 and 32 " + newtWinMessage(_("Invalid Prefix"), _("Retry"), + _("Prefix must be between 1 and 32 " "for IPv4 networks or between 1 and 128 " "for IPv6 networks")); } @@ -504,7 +505,7 @@ void setupNetworkDeviceConfig(struct networkDeviceConfig * cfg, } int readNetConfig(char * device, struct networkDeviceConfig * cfg, - char * dhcpclass) { + char * dhcpclass, int methodNum) { struct networkDeviceConfig newCfg; int ret; int i = 0; @@ -562,7 +563,8 @@ int readNetConfig(char * device, struct networkDeviceConfig * cfg, /* dhcp/manual network configuration loop */ i = 1; while (i == 1) { - ret = configureTCPIP(device, cfg, &newCfg, &ipv4Choice, &ipv6Choice); + ret = configureTCPIP(device, cfg, &newCfg, &ipv4Choice, &ipv6Choice, + methodNum); if (ret == LOADER_NOOP) { /* dhcp selected, proceed */ @@ -651,7 +653,7 @@ int readNetConfig(char * device, struct networkDeviceConfig * cfg, int configureTCPIP(char * device, struct networkDeviceConfig * cfg, struct networkDeviceConfig * newCfg, - char * ipv4Choice, char * ipv6Choice) { + char * ipv4Choice, char * ipv6Choice, int methodNum) { int i = 0; char dhcpChoice; char *dret = NULL; @@ -748,6 +750,12 @@ int configureTCPIP(char * device, struct networkDeviceConfig * cfg, return LOADER_BACK; } + if (*ipv4Choice == ' ' && methodNum == METHOD_NFS) { + newtWinMessage(_("IPv4 Needed for NFS"), _("Retry"), + _("NFS installation method requires IPv4 support.")); + continue; + } + if (dhcpChoice == ' ') { if (*ipv4Choice == ' ' && *ipv6Choice == ' ') { newtWinMessage(_("Missing Protocol"), _("Retry"), @@ -1703,7 +1711,8 @@ int kickstartNetworkUp(struct loaderData_s * loaderData, setupNetworkDeviceConfig(netCfgPtr, loaderData); - rc = readNetConfig(loaderData->netDev, netCfgPtr, loaderData->netCls); + rc = readNetConfig(loaderData->netDev, netCfgPtr, loaderData->netCls, + loaderData->method); if ((rc == LOADER_BACK) || (rc == LOADER_ERROR)) { logMessage(ERROR, "unable to setup networking"); return -1; diff --git a/loader2/net.h b/loader2/net.h index 677f20479..a860cfa0c 100644 --- a/loader2/net.h +++ b/loader2/net.h @@ -38,10 +38,10 @@ struct intfconfig_s { typedef int int32; int readNetConfig(char * device, struct networkDeviceConfig * dev, - char * dhcpclass); + char * dhcpclass, int methodNum); int configureTCPIP(char * device, struct networkDeviceConfig * cfg, struct networkDeviceConfig * newCfg, - char * ipv4Choice, char * ipv6Choice); + char * ipv4Choice, char * ipv6Choice, int methodNum); int manualNetConfig(char * device, struct networkDeviceConfig * cfg, struct networkDeviceConfig * newCfg, struct intfconfig_s * ipcomps, diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c index a8a2bb785..d1ffbca1d 100644 --- a/loader2/nfsinstall.c +++ b/loader2/nfsinstall.c @@ -71,8 +71,6 @@ int nfsGetSetup(char ** hostptr, char ** dirptr) { return 0; } - - char * mountNfsImage(struct installMethod * method, char * location, struct loaderData_s * loaderData, moduleInfoSet modInfo, moduleList modLoaded, @@ -95,9 +93,7 @@ char * mountNfsImage(struct installMethod * method, switch (stage) { case NFS_STAGE_NFS: logMessage(INFO, "going to do nfsGetSetup"); - if (loaderData->method && *loaderData->method && - !strncmp(loaderData->method, "nfs", 3) && - loaderData->methodData) { + if (loaderData->method == METHOD_NFS && loaderData->methodData) { host = ((struct nfsInstallData *)loaderData->methodData)->host; directory = ((struct nfsInstallData *)loaderData->methodData)->directory; mountOpts = ((struct nfsInstallData *)loaderData->methodData)->mountOpts; @@ -106,8 +102,7 @@ char * mountNfsImage(struct installMethod * method, if (!host || !directory) { logMessage(ERROR, "missing host or directory specification"); - free(loaderData->method); - loaderData->method = NULL; + loaderData->method = -1; break; } else { host = strdup(host); @@ -129,9 +124,8 @@ char * mountNfsImage(struct installMethod * method, if (loaderData->noDns && !(inet_pton(AF_INET, host, &ip))) { newtWinMessage(_("Error"), _("OK"), _("Hostname specified with no DNS configured")); - if (loaderData->method) { - free(loaderData->method); - loaderData->method = NULL; + if (loaderData->method >= 0) { + loaderData->method = -1; } break; } @@ -209,9 +203,8 @@ char * mountNfsImage(struct installMethod * method, "contain a %s installation tree."), getProductName()); newtWinMessage(_("Error"), _("OK"), buf); - if (loaderData->method) { - free(loaderData->method); - loaderData->method = NULL; + if (loaderData->method >= 0) { + loaderData->method = -1; } @@ -220,9 +213,8 @@ char * mountNfsImage(struct installMethod * method, newtWinMessage(_("Error"), _("OK"), _("That directory could not be mounted from " "the server.")); - if (loaderData->method) { - free(loaderData->method); - loaderData->method = NULL; + if (loaderData->method >= 0) { + loaderData->method = -1; } break; } @@ -269,7 +261,7 @@ void setKickstartNfs(struct loaderData_s * loaderData, int argc, return; } - loaderData->method = strdup("nfs"); + loaderData->method = METHOD_NFS; loaderData->methodData = calloc(sizeof(struct nfsInstallData *), 1); if (host) ((struct nfsInstallData *)loaderData->methodData)->host = host; @@ -373,3 +365,5 @@ int getFileFromNfs(char * url, char * dest, struct loaderData_s * loaderData) { int kickstartFromNfs(char * url, struct loaderData_s * loaderData) { return getFileFromNfs(url, "/tmp/ks.cfg", loaderData); } + +/* vim:set shiftwidth=4 softtabstop=4: */ diff --git a/loader2/urlinstall.c b/loader2/urlinstall.c index 455a55ea5..661319467 100644 --- a/loader2/urlinstall.c +++ b/loader2/urlinstall.c @@ -227,9 +227,8 @@ char * mountUrlImage(struct installMethod * method, while (stage != URL_STAGE_DONE) { switch(stage) { case URL_STAGE_MAIN: - if (loaderData->method && *loaderData->method && - (!strncmp(loaderData->method, "ftp", 3) || - !strncmp(loaderData->method, "http", 3)) && + if ((loaderData->method == METHOD_FTP || + loaderData->method == METHOD_HTTP) && loaderData->methodData) { url = ((struct urlInstallData *)loaderData->methodData)->url; @@ -238,8 +237,7 @@ char * mountUrlImage(struct installMethod * method, if (!url) { logMessage(ERROR, "missing url specification"); - free(loaderData->method); - loaderData->method = NULL; + loaderData->method = -1; break; } @@ -306,9 +304,8 @@ char * mountUrlImage(struct installMethod * method, if (loadUrlImages(&ui)) { stage = URL_STAGE_MAIN; dir = -1; - if (loaderData->method) { - free(loaderData->method); - loaderData->method = NULL; + if (loaderData->method >= 0) { + loaderData->method = -1; } } else { stage = URL_STAGE_DONE; @@ -489,9 +486,9 @@ void setKickstartUrl(struct loaderData_s * loaderData, int argc, /* determine install type */ if (strstr(url, "http://")) - loaderData->method = strdup("http"); + loaderData->method = METHOD_HTTP; else if (strstr(url, "ftp://")) - loaderData->method = strdup("ftp"); + loaderData->method = METHOD_FTP; else { newtWinMessage(_("Kickstart Error"), _("OK"), _("Unknown Url method %s"), url); @@ -504,3 +501,4 @@ void setKickstartUrl(struct loaderData_s * loaderData, int argc, logMessage(INFO, "results of url ks, url %s", url); } +/* vim:set shiftwidth=4 softtabstop=4: */ |