FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 05-15-2008, 02:09 AM
Jerry Vonau
 
Default loader/stage2 interaction

OK, should I be thinking that stage2= will be the replacement for
method= for stage1? I'm getting that feeling, just want to be sure.


Yes, though not really a complete replacement. The final goal is that
stage2= points to just the stage2.img file, while method= points to just
the package repository. Perhaps at that point we rename it to repo= to
avoid confusion? Don't know quite what to do here yet.



/wish list
Maybe stage2.img and related boot.iso could just be moved to the updates
repo all together. The boot.iso could then be updated, containing the
latest changes that lead to the need for a updates.img in the first
place, as required. Now you really have disconnected the location of
stage2 from the primary repo.

wish list/

Back to what is required now in loader, The boot.iso is mounted for
stage2, if present, else look for an iso-image to use for stage2 for
nfsiso, hd(iso), or tree-path for nfs. That just leaves net installs,
where what you're really being asked is for the location of stage2 and
not the location of a repo in stage1. Anaconda should then discard the
net install's method-path, but not method, that is passed from loader
when building its own repo list with data supplied from a kickstart file
and/or the repo editor.


Does that sum up what maybe required here? Think all the *install.c
files could become just one install.c file here. Is that what I should
work towards?



I was thinking of something like setmethodfromcmdline but for stage2.
attached is a rough patch as proof of concept. Mounts stage2 at the
given path, then returns the url for the method string.


03:37:07 INFO : mounted loopback device /mnt/runtime on /dev/loop0 as
/mnt/isodir//images/stage2.img
03:37:07 INFO : URL_STAGE_MAIN - url is
http://download.fedora.redhat.com/pub/fedora/linux/development/i386/os

03:37:07 DEBUG : url address download.fedora.redhat.com
03:37:07 DEBUG : url prefix /pub/fedora/linux/development/i386/os
03:37:07 INFO : URL URL_STAGE2 - stg2url hd:sdb1:/images/stage2.img
03:37:07 INFO : got url
http://download.fedora.redhat.com/pub/fedora/linux/development/i386/os

03:37:08 INFO : Loading SELinux policy

I have the whole log saved if your interested.
To do: port cdinstall to return stg2url for stage2.

I think is would help with preupgrade and rescue modes, being able to
point stage2 to any available hard drive partition.


Just an idea,

Jerry


diff -u anaconda-11.4.0.82.orig/loader2/hdinstall.c anaconda-11.4.0.82/loader2/hdinstall.c
--- anaconda-11.4.0.82.orig/loader2/hdinstall.c 2008-05-06 16:06:57.000000000 -0500
+++ anaconda-11.4.0.82/loader2/hdinstall.c 2008-05-11 20:19:57.000000000 -0500
@@ -154,9 +154,9 @@
}

/* given a partition device and directory, tries to mount hd install image */
-static char * setupIsoImages(char * device, char * dirName, char * location) {
+char * setupIsoImages(char * device, char * dirName, char * location) {
int rc;
- char *url = NULL, *dirspec, *updpath;
+ char *dirspec, *updpath, *url = NULL;
char *path;
char *typetry[] = {"ext3", "ext2", "vfat", NULL};
char **type;
@@ -186,39 +187,29 @@
}

if (path) {
- logMessage(INFO, "Path to valid iso is %s", path);
+ logMessage(INFO, "Path to stage2 is %s", path);

rc = asprintf(&updpath, "%s/updates.img", dirspec);
logMessage(INFO, "Looking for updates for HD in %s", updpath);
copyUpdatesImg(updpath);

free(updpath);
- free(dirspec);

if (FL_STAGE2(flags)) {
- if (!copyFile(path, "/tmp/stage2.img")) {
- rc = mountStage2("/tmp/stage2.img", dirName);
- umount("/mnt/isodir");
- free(path);
-
- if (rc) {
- umountLoopback("/mnt/runtime", "/dev/loop0");
- flags &= ~LOADER_FLAGS_STAGE2;
- goto err;
- } else {
- rc = asprintf(&url, "hd:%s:%s:/%s",
- device,
- *type, dirName ? dirName : ".");
- return url;
- }
- }
- else {
- free(path);
+ /* rc = asprintf(&stg2url, "hd:%s:%s:/%s",
+ * device,
+ * *type, dirName ? dirName : ".");
+ */
+ rc = mountStage2(path, dirspec);
+ free(path);
+ free(dirspec);
+ return NULL;
+ } else {
umount("/mnt/isodir");
flags &= ~LOADER_FLAGS_STAGE2;
- goto err;
+ /* goto err;
+ * free(path);*/
}
- }

rc = mountLoopback(path, "/mnt/source", "/dev/loop1");
if (!rc) {
@@ -284,6 +275,13 @@
char *selpart;
char *kspartition, *ksdirectory;

+ /* handle stage2 data first if available */
+ if (loaderData->stage2 == METHOD_HD && loaderData->stage2Data) {
+ kspartition = ((struct hdstage2Data *)loaderData->stage2Data)->partition;
+ ksdirectory = ((struct hdstage2Data *)loaderData->stage2Data)->directory;
+ logMessage(INFO, "HD Stage2 partition is %s, dir is %s", kspartition, ksdirectory);
+ }
+
/* handle kickstart data first if available */
if (loaderData->method == METHOD_HD && loaderData->methodData) {
kspartition = ((struct hdInstallData *)loaderData->methodData)->partition;

diff -u anaconda-11.4.0.82.orig/loader2/hdinstall.h anaconda-11.4.0.82/loader2/hdinstall.h
--- anaconda-11.4.0.82.orig/loader2/hdinstall.h 2008-05-06 16:06:57.000000000 -0500
+++ anaconda-11.4.0.82/loader2/hdinstall.h 2008-05-11 19:21:25.000000000 -0500
@@ -27,7 +27,7 @@
char * directory;
};

-
+char * setupIsoImages(char * device, char * dirName, char * location);
void setKickstartHD(struct loaderData_s * loaderData, int argc,
char ** argv);
char * mountHardDrive(struct installMethod * method,

--- anaconda-11.4.0.82.orig/loader2/loader.c 2008-05-06 16:06:57.000000000 -0500
+++ anaconda-11.4.0.82/loader2/loader.c 2008-05-14 19:10:40.000000000 -0500
@@ -872,7 +872,7 @@
setMethodFromCmdline(argv[i] + 7, loaderData);
else if (!strncasecmp(argv[i], "stage2=", 7)) {
flags |= LOADER_FLAGS_STAGE2;
- setMethodFromCmdline(argv[i] + 7, loaderData);
+ setStg2FromCmdline(argv[i] + 7, loaderData);
}
else if (!strncasecmp(argv[i], "hostname=", 9))
loaderData->hostname = strdup(argv[i] + 9);
@@ -1016,6 +1016,7 @@
enum { STEP_LANG, STEP_KBD, STEP_METHOD, STEP_DRIVER,
STEP_DRIVERDISK, STEP_NETWORK, STEP_IFACE,
STEP_IP, STEP_URL, STEP_DONE } step;
+ char * stg2url = NULL;
char * url = NULL;
char * ret = NULL;
int dir = 1;
@@ -1049,21 +1050,35 @@
flags |= LOADER_FLAGS_ASKMETHOD;
}

+ /* handle stage2 data first if available */
+ if (loaderData->stage2 == METHOD_HD && loaderData->stage2Data) {
+ char * stg2part;
+ char * stg2dir;
+ stg2url = ((struct hdstage2Data *)loaderData->stage2Data)->stg2loc;
+ stg2part = ((struct hdstage2Data *)loaderData->stage2Data)->partition;
+ stg2dir = ((struct hdstage2Data *)loaderData->stage2Data)->directory;
+ logMessage(INFO, "LOADER Stage2 partition is %s, dir is %s", stg2part, stg2dir);
+ if (stg2url)
+ logMessage(INFO, "LOADER URL_STAGE2 - stg2url is %s", stg2url);
+/* return stg2url;
+*/
/* check to see if we have a CD. If we have one, then
* we can fast-path the CD and not make people answer questions in
* text mode. */
if (!FL_ASKMETHOD(flags) && !FL_KICKSTART(flags)) {
- url = findAnacondaCD(location, !FL_RESCUE(flags));
+ stg2url = findAnacondaCD(location, !FL_RESCUE(flags));
/* if we found a CD and we're not in rescue or vnc mode return */
/* so we can short circuit straight to stage 2 from CD */
- if (url && (!FL_RESCUE(flags) && !hasGraphicalOverride()))
- return url;
+ if (stg2url && (!FL_RESCUE(flags) && !hasGraphicalOverride()))
+ return stg2url;
else {
rhcdfnd = 1;
methodNum = 0;
}
}

+ }
+
if (!FL_CMDLINE(flags))
startNewt();

@@ -1124,9 +1139,9 @@
*
* Alternately, if we're in a VNC install based from CD we
* can skip this step because we already found the CD */
- if (url) {
+ if (stg2url) {
if (FL_RESCUE(flags)) {
- return url;
+ return stg2url;
} else if (rhcdfnd) {
step = STEP_NETWORK;
dir = 1;
@@ -1374,8 +1389,8 @@
/* we get this case when we're doing a VNC install from CD */
/* and we didnt short circuit earlier because we had to */
/* prompt for network info for vnc to work */
- if (url && rhcdfnd)
- return url;
+ if (stg2url && rhcdfnd)
+ return stg2url;

url = installMethods[validMethods[methodNum]].mountImage(
installMethods + validMethods[methodNum],
@@ -1736,7 +1751,7 @@
if (FL_TELNETD(flags))
startTelnetd(&loaderData);

- url = doLoaderMain("/mnt/source", &loaderData, modInfo);
+ url = doLoaderMain("/mnt/stage2", &loaderData, modInfo);

if (!FL_TESTING(flags)) {
int ret;

diff -u anaconda-11.4.0.82.orig/loader2/loader.h anaconda-11.4.0.82/loader2/loader.h
--- anaconda-11.4.0.82.orig/loader2/loader.h 2008-05-06 16:06:57.000000000 -0500
+++ anaconda-11.4.0.82/loader2/loader.h 2008-05-13 18:20:26.000000000 -0500
@@ -129,10 +129,12 @@
int ipv6info_set;
char * ksFile;
int method;
+ int stage2;
char * ddsrc;
void * methodData;
char * logLevel;
char * updatessrc;
+ void * stage2Data;
char * dogtailurl;

pid_t fw_loader_pid;

diff -u anaconda-11.4.0.82.orig/loader2/method.c anaconda-11.4.0.82/loader2/method.c
--- anaconda-11.4.0.82.orig/loader2/method.c 2008-05-06 16:06:57.000000000 -0500
+++ anaconda-11.4.0.82/loader2/method.c 2008-05-11 17:51:32.000000000 -0500
@@ -625,6 +624,34 @@
return rc;
}

+void setStg2FromCmdline(char * arg, struct loaderData_s * ld) {
+ char * c, * dup;
+
+ dup = strdup(arg);
+ c = dup;
+ /* : will let us delimit real information on the method */
+ if ((c = strtok(c, ":"))) {
+ c = strtok(NULL, ":");
+
+#if !defined(__s390__) && !defined(__s390x__)
+ if (!strncmp(arg, "cdrom:", 6)) {
+ ld->stage2 = METHOD_CDROM;
+#endif
+ } else if (!strncmp(arg, "harddrive:", 10) ||
+ !strncmp(arg, "hd:", 3)) {
+ ld->stage2 = METHOD_HD;
+ ld->stage2Data = calloc(sizeof(struct hdstage2Data *), 1);
+ ((struct hdstage2Data *)ld->stage2Data)->stg2loc = strdup(arg);
+ ((struct hdstage2Data *)ld->stage2Data)->partition = strdup(c);
+ if ((c = strtok(NULL, ":"))) {
+ ((struct hdstage2Data *)ld->stage2Data)->directory = strdup(c);
+ }
+ }
+ }
+ free(dup);
+}
+
+

diff -u anaconda-11.4.0.82.orig/loader2/method.h anaconda-11.4.0.82/loader2/method.h
--- anaconda-11.4.0.82.orig/loader2/method.h 2008-05-06 16:06:57.000000000 -0500
+++ anaconda-11.4.0.82/loader2/method.h 2008-05-13 19:03:58.000000000 -0500
@@ -40,6 +40,14 @@
char * location, struct loaderData_s * loaderData);
};

+struct hdstage2Data {
+ char * partition;
+ char * directory;
+ char * stg2loc;
+};
+
+
+
int umountLoopback(char * mntpoint, char * device);
int mountLoopback(char * fsystem, char * mntpoint, char * device);

@@ -58,5 +66,6 @@
void copyProductImg(char * path);

void setMethodFromCmdline(char * arg, struct loaderData_s * ld);
+void setStg2FromCmdline(char * arg, struct loaderData_s * ld);

#endif

diff -u anaconda-11.4.0.82.orig/loader2/urlinstall.c anaconda-11.4.0.82/loader2/urlinstall.c
--- anaconda-11.4.0.82.orig/loader2/urlinstall.c 2008-05-06 16:06:57.000000000 -0500
+++ anaconda-11.4.0.82/loader2/urlinstall.c 2008-05-11 20:29:00.000000000 -0500
@@ -31,7 +31,6 @@
#include <unistd.h>

#include "../isys/iface.h"
-
#include "copy.h"
#include "kickstart.h"
#include "loader.h"
@@ -45,6 +44,7 @@
#include "cdinstall.h"
#include "urls.h"
#include "windows.h"
+#include "hdinstall.h"

/* boot flags */
extern uint64_t flags;
@@ -107,16 +107,19 @@

/* 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.
+ * updates.img and friends must live.JV BUT hacks off /os in url path
*/
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)
+ if (path)
+ logMessage(INFO, "stage2 path is %s", path);
+ else
return 1;
}
else
@@ -161,27 +164,30 @@
} 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 {
+ } 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);
- }
+/* rc = asprintf(&tmp, "/tmp/%s", strrchr(ui->prefix, '/'));
+ * rc = loadSingleUrlImage(ui, ui->prefix, tmp, "/mnt/runtime",
+ * "/dev/loop0", 0);
+*/
+ stage2img = "stage2.img";
+ rc = asprintf(&buf, "%s/%s", path, stage2img);
+ rc = mountStage2(buf, path);
+ free(buf);
+ }

free(tmp);
free(path);

if (rc) {
- if (rc != 2)
+ if (rc != 0)
newtWinMessage(_("Error"), _("OK"),
_("Unable to retrieve the install image."));
return 1;
@@ -209,6 +215,7 @@
struct iurlinfo ui;
char needsSecondary = ' ';
char * cdurl = NULL;
+ char * stg2url = NULL;

enum { URL_STAGE_MAIN, URL_STAGE_SECOND, URL_STAGE_FETCH,
URL_STAGE_DONE } stage = URL_STAGE_MAIN;
@@ -218,6 +225,24 @@
while (stage != URL_STAGE_DONE) {
switch(stage) {
case URL_STAGE_MAIN:
+
+ /* handle stage2 data first if available */
+ if (loaderData->stage2 == METHOD_HD && loaderData->stage2Data) {
+ char * stg2part;
+ char * stg2dir;
+ stg2part = ((struct hdstage2Data*)loaderData->stage2Data)->partition;
+ stg2dir = ((struct hdstage2Data *)loaderData->stage2Data)->directory;
+ logMessage(INFO, "URL Stage2 partition is %s, dir is %s", stg2part, stg2dir);
+
+ /*if exist, duplicate */
+ if (stg2part)
+ stg2part = strdup(stg2part);
+ if (stg2dir)
+ stg2dir = strdup(stg2dir);
+ logMessage(INFO, "URL setupIso for Stage2");
+ setupIsoImages(stg2part, stg2dir, location);
+ }
+
if (loaderData->method == METHOD_URL && loaderData->methodData) {
url = ((struct urlInstallData *)loaderData->methodData)->url;
logMessage(INFO, "URL_STAGE_MAIN - url is %s", url);
@@ -266,10 +292,10 @@
* one over the network. However, passing stage2= overrides
* this check.
*/
- if (!FL_STAGE2(flags))
+ if (!FL_STAGE2(flags)){
cdurl = findAnacondaCD(location, 0);

- if (cdurl) {
+ if (cdurl) {
logMessage(INFO, "Detected stage 2 image on CD");
winStatus(50, 3, _("Media Detected"),
_("Local installation media detected..."), 0);
@@ -277,21 +303,22 @@
newtPopWindow();

stage = URL_STAGE_DONE;
- } else {
+ } 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;
- }
- }
+ }
+ }
+ } else {
+ /* JV */
+ stg2url = ((struct hdstage2Data*)loaderData->stage2Data)->stg2loc;
+ logMessage(INFO, "URL URL_STAGE2 - stg2url is %s", stg2url);
+ stage = URL_STAGE_DONE;
+ }
break;
-
case URL_STAGE_DONE:
break;
}
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 12:13 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org