This is the same as has been previously done for NFS and URL install methods.
While I'm at it, add a parseDeviceAndDir convenience function similar to what
we've got in nfsinstall.c.
---
loader/dirbrowser.c | 7 +-
loader/dirbrowser.h | 6 +-
loader/hdinstall.c | 258 +++++++++++++++++++++++----------------------------
loader/hdinstall.h | 4 +-
loader/loader.c | 2 +-
5 files changed, 128 insertions(+), 149 deletions(-)
-/* given a partition device and directory, tries to mount hd install image */
-static char * setupIsoImages(char * device, char * dirName, char * location) {
- int rc = 0;
- char *url = NULL, *dirspec, *updpath, *path;
+/* format is hd:device:/path */
+static void parseDeviceAndDir(char *url, char **device, char **dir) {
+ char *token, *src = NULL;
- logMessage(INFO, "mounting device %s for hard drive install", device);
+ if (!url)
+ return;
- if (doPwMount(device, "/mnt/isodir", "auto", "ro", NULL))
- return NULL;
+ /* Skip over the leading hd: if present. */
+ if (!strncmp(url, "hd:", 3))
+ url += 3;
- if (rc) {
- umount("/mnt/isodir");
- return NULL;
- }
+ logMessage(INFO, "Looking for updates for HD in %s", path);
+ copyUpdatesImg(path);
+ free(path);
+
+ if (dir[0] == '/') {
+ checked_asprintf(&path, "/mnt/isodir%s/product.img", dir);
+ } else {
+ checked_asprintf(&path, "/mnt/isodir/%s/product.img", dir);
}
-err:
- newtWinMessage(_("Error"), _("OK"),
- _("An error occured finding the installation image "
- "on your hard drive. Please check your images and "
- "try again."));
- return NULL;
+ logMessage(INFO, "Looking for product for HD in %s", path);
+ copyProductImg(path);
+
+ free(device);
+ free(dir);
+ free(path);
+ umount("/mnt/isodir");
+
+ return 1;
}
-/* setup hard drive based install from a partition with a filesystem and
- * ISO images on that filesystem
- */
-char * mountHardDrive(struct installMethod * method,
- char * location, struct loaderData_s * loaderData) {
+int promptForHardDrive(struct loaderData_s *loaderData) {
int rc;
int i;
- int done = 0;
char * dir = g_strdup("");
char * tmpDir;
- char * url = NULL;
char * buf;
int numPartitions;
+ char **files;
char **partition_list;
char *selpart;
char *kspartition = NULL, *ksdirectory = NULL;
- char *imgpath = "/images/install.img";
-
- /* handle kickstart/stage2= data first if available */
- if (loaderData->method == METHOD_HD && loaderData->stage2Data) {
- kspartition = ((struct hdInstallData *)loaderData->stage2Data)->partition;
- if (kspartition) {
- kspartition = g_strdup(kspartition);
- }
-
- ksdirectory = ((struct hdInstallData *)loaderData->stage2Data)->directory;
- if (ksdirectory) {
- if (g_str_has_suffix(ksdirectory, ".img")) {
- ksdirectory = g_strdup(ksdirectory);
- } else {
- ksdirectory = g_strconcat(ksdirectory, imgpath, NULL);
- }
- } else {
- ksdirectory = g_strdup(imgpath);
- }
-
- logMessage(INFO, "partition is %s, dir is %s", kspartition, ksdirectory);
-
- 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;
- if (!strncmp(kspart, "/dev/", 5))
- kspart = kspart + 5;
-
- url = setupIsoImages(kspart, ksdirectory, location);
- if (!url) {
- logMessage(ERROR, "unable to find %s installation images on hd",
- getProductName());
- loaderData->method = -1;
-
- if (loaderData->inferredStage2)
- loaderData->invalidRepoParam = 1;
- } else {
- g_free(kspartition);
- g_free(ksdirectory);
- return url;
- }
- }
- } else {
- kspartition = NULL;
- ksdirectory = NULL;
- }
-
- /* if we're here its either because this is interactive, or the */
- /* hd kickstart directive was faulty and we have to prompt for */
- /* location of harddrive image */
partition_list = NULL;
- while (!done) {
+ while (1) {
/* if we're doing another pass free this up first */
if (partition_list)
freePartitionsList(partition_list);
@@ -214,8 +168,8 @@ char * mountHardDrive(struct installMethod * method,
"your system! Would you like to configure "
"additional devices?"));
if (rc == 2) {
- loaderData->stage2Data = NULL;
- return NULL;
+ loaderData->instRepo = NULL;
+ return LOADER_BACK;
}