Well here it is, a giant pile of patches that completely reworks all the installation repo selection and stage2 finding. Some of these patches are probably a little too small, and some are probably a little too large. But this is a huge body of work, so that's just how it goes.
Current status:
- The entire purpose of method selection in loader now is trying to find the stage2 image. If the stage2 image can be found on an attached CD, that's what will get used. - You can specify where the installation repo is located with repo= or method=. The intention is that method= is deprecated and will go away in the future, but we need to preserve it at least for now. - stage2= still exists and will continue to exist. preupgrade probably doesn't work, though. If you give a stage2=, that takes priority over any image that might be found on the CD. - If you don't give a method= or repo=, we first look for any CD/DVDs. If one is found, we look for packages. If those are found, we use them. If not, we default to using the mirrorlist provided by the /etc/yum.repos.d files. This means that for the most common installation method, you'll just toss your boot.iso in the drive, run straight into stage2, and be up using the mirrorlist. Hooray! - Since very few people will be getting the method selection screen in loader, most people won't have networking up when we get to stage2. That means in order to use the mirrorlist, we have to use the NetworkConfigurator. This isn't quite ideal, but David's going to have a giant networking patch one of these days so I'm not really going to bother.
Current problems:
- Media check is commented out. My intention here is to move this to stage2 if possible. - yum logs to tty1. - HDISO and NFSISO are completely untested and probably don't work, but I'll make them work later. - We don't write out a method to /root/anaconda-ks.cfg. - Error handling in AnacondaYum.__init__ is rather poor, but I need a better repo editor to fix that, and that's on a whole different branch I need to return to.
Anyway this isn't 100% working but it seems good enough for me to consider committing. I've tested boot.iso and pxebooting with HTTP, NFS, and a DVD and those all worked decently. The big problem for me right now is the error handling. But that can be beefed up once this stuff goes in and I have an easier time testing.
Questions?
- Chris
--- anaconda | 18 ++---------------- dmraid.py | 2 +- docs/anaconda-release-notes.txt | 6 ++---- docs/install-methods.txt | 2 -- fsset.py | 3 +-- gui.py | 7 ++----- installclass.py | 2 -- language.py | 3 +-- loader2/loader.c | 20 +------------------- scripts/pyrc.py | 10 ---------- yuminstall.py | 8 ++++---- 11 files changed, 14 insertions(+), 67 deletions(-)
diff --git a/anaconda b/anaconda index 6873f4c..06921e2 100755 --- a/anaconda +++ b/anaconda @@ -169,17 +169,6 @@ def setupPythonUpdates():
for pypkg in ("rhpl", "yum", "rpmUtils", "urlgrabber", "rhpxl", "pirut", "pykickstart"): - if os.access("/mnt/source/RHupdates/%s" %(pypkg,), os.X_OK): - try: - os.mkdir("/tmp/updates/%s" %(pypkg,)) - except: - pass - - # symlink the existing ones - for f in os.listdir("/mnt/source/RHupdates/%s" %(pypkg,)): - os.symlink("/mnt/source/RHupdates/%s/%s" %(pypkg, f), - "/tmp/updates/%s/%s" %(pypkg, f)) - # get the libdir. *sigh* if os.access("/usr/lib64/python%s/site-packages/%s" %(pyver, pypkg), os.X_OK): @@ -375,8 +364,6 @@ def addPoPath(dir): gettext.bindtextdomain(basename[:-3], dir)
def setupTranslations(): - if os.path.isdir("/mnt/source/RHupdates/po"): - addPoPath("/mnt/source/RHupdates/po") if os.path.isdir("/tmp/updates/po"): addPoPath("/tmp/updates/po") gettext.textdomain("anaconda") @@ -433,8 +420,7 @@ def runVNC():
child = os.fork() if child == 0: - for p in ('/mnt/source/RHupdates/pyrc.py', \ - '/tmp/updates/pyrc.py', \ + for p in ('/tmp/updates/pyrc.py', \ '/usr/lib/anaconda-runtime/pyrc.py'): if os.access(p, os.R_OK|os.X_OK): os.environ['PYTHONSTARTUP'] = p @@ -604,7 +590,7 @@ if __name__ == "__main__": # pull this in to get product name and versioning import product
- # this handles setting up RHupdates for pypackages to minimize the set needed + # this handles setting up updates for pypackages to minimize the set needed setupPythonUpdates()
import signal, traceback, string, isys, iutil, time diff --git a/dmraid.py b/dmraid.py index 8a90c03..90b5ad7 100644 --- a/dmraid.py +++ b/dmraid.py @@ -27,7 +27,7 @@ import sys import string
-_bdModulePath = "/tmp/updates/bdevid/:/mnt/source/RHupdates/bdevid/:" +_bdModulePath = "/tmp/updates/bdevid/:" import block oldPath = block.getBdevidPath() if not _bdModulePath in oldPath: diff --git a/docs/anaconda-release-notes.txt b/docs/anaconda-release-notes.txt index 5ace02b..167411c 100644 --- a/docs/anaconda-release-notes.txt +++ b/docs/anaconda-release-notes.txt @@ -121,10 +121,8 @@ the main directory of the floppy. The installer is invoked with an 'updates' option from the boot command line, and the user is prompted to insert the update disk. The files are copied off into a ramdisk location which Python has been instructed to look at first of modules. -For NFS installes, any files in the directory 'RHupdates' under the -directory mounted in the loader will also be used before the source -files shipped in the release. If one is customizing the distribution -and the installer then installing over NFS is the fastest way to work. +If one is customizing the distribution and the installer then installing +over NFS is the fastest way to work.
The installer will also use an 'updates.img' file to get patched source files. This is particularly useful for FTP and HTTP based installs. diff --git a/docs/install-methods.txt b/docs/install-methods.txt index 07abd25..b630946 100644 --- a/docs/install-methods.txt +++ b/docs/install-methods.txt @@ -57,8 +57,6 @@ Current Installation Methods: Update Options: - floppy or USB key drive. - 'updates.img' file in 'images/' directory. - - updated python sources or modules in 'RHupdates/' directory are - used in preference to those in original. - remote updates.img downloaded via FTP or HTTP.
- NFS (from a directory of ISOs) diff --git a/fsset.py b/fsset.py index 1788361..2e75f7f 100644 --- a/fsset.py +++ b/fsset.py @@ -2919,8 +2919,7 @@ def ext2FormatFilesystem(argList, messageFile, windowCreator, mntpoint): os.close(fd)
env = os.environ - configs = [ "/mnt/source/RHupdates/mke2fs.conf", - "/tmp/updates/mke2fs.conf", + configs = [ "/tmp/updates/mke2fs.conf", "/etc/mke2fs.conf", ] for config in configs: diff --git a/gui.py b/gui.py index 6f95ba2..4657e05 100755 --- a/gui.py +++ b/gui.py @@ -403,8 +403,7 @@ def addFrame(dialog, title=None, showtitle = 1): dialog.connect ("key-release-event", handleShiftPrintScrnRelease)
def findGladeFile(file): - for dir in ("/mnt/source/RHupdates/", "/tmp/updates/", - "ui/", "/usr/share/anaconda/ui/", + for dir in ("/tmp/updates/", "ui/", "/usr/share/anaconda/ui/", "/usr/share/pirut/ui/"): fn = dir + file if os.access(fn, os.R_OK): @@ -421,9 +420,7 @@ def getGladeWidget(file, rootwidget, i18ndomain="anaconda"): return (xml, w)
def findPixmap(file): - for dir in ("/mnt/source/RHupdates/pixmaps/", - "/mnt/source/RHupdates/", - "/tmp/updates/pixmaps/", "/tmp/updates/", + for dir in ( "/tmp/updates/pixmaps/", "/tmp/updates/", "/tmp/product/pixmaps/", "/tmp/product/", "pixmaps/", "/usr/share/anaconda/pixmaps/", "/usr/share/pixmaps/", diff --git a/installclass.py b/installclass.py index 8fda4b9..414b5cf 100644 --- a/installclass.py +++ b/installclass.py @@ -245,8 +245,6 @@ def availableClasses(showHidden=0):
if os.access("installclasses", os.R_OK): path = "installclasses" - elif os.access("/mnt/source/RHupdates/installclasses", os.R_OK): - path = "/mnt/source/RHupdates/installclasses" elif os.access("/tmp/updates/installclasses", os.R_OK): path = "/tmp/updates/installclasses" elif os.access("/tmp/product/installclasses", os.R_OK): diff --git a/language.py b/language.py index 64ecca2..a853da2 100644 --- a/language.py +++ b/language.py @@ -77,8 +77,7 @@ class Language: break
# nick -> (name, short name, font, keyboard, timezone) mapping - search = ('lang-table', '/tmp/updates/lang-table', - '/mnt/source/RHupdates/lang-table', '/etc/lang-table', + search = ('lang-table', '/tmp/updates/lang-table', '/etc/lang-table', '/usr/lib/anaconda/lang-table') for path in search: if os.access(path, os.R_OK): diff --git a/loader2/loader.c b/loader2/loader.c index baafba8..650f2ae 100644 --- a/loader2/loader.c +++ b/loader2/loader.c @@ -358,9 +358,7 @@ static void spawnShell(void) { signal(SIGINT, SIG_DFL); signal(SIGTSTP, SIG_DFL);
- if (!access("/mnt/source/RHupdates/pyrc.py", R_OK|X_OK)) - setenv("PYTHONSTARTUP", "/mnt/source/RHupdates/pyrc.py", 1); - else if (!access("/tmp/updates/pyrc.py", R_OK|X_OK)) + if (!access("/tmp/updates/pyrc.py", R_OK|X_OK)) setenv("PYTHONSTARTUP", "/tmp/updates/pyrc.py", 1); else if (!access("/usr/lib/anaconda-runtime/pyrc.py", R_OK|X_OK)) setenv("PYTHONSTARTUP", "/usr/lib/anaconda-runtime/pyrc.py", 1); @@ -1609,7 +1607,6 @@ int main(int argc, char ** argv) {
char ** argptr, ** tmparg; char * anacondaArgs[50]; - int useRHupdates = 0;
struct loaderData_s loaderData;
@@ -1829,19 +1826,11 @@ int main(int argc, char ** argv) { manualDeviceCheck(&loaderData); }
- useRHupdates = 0; if (loaderData.updatessrc) loadUpdatesFromRemote(loaderData.updatessrc, &loaderData); else if (FL_UPDATES(flags)) loadUpdates(&loaderData);
- /* we only want to use RHupdates on nfs installs. otherwise, we'll - * use files on the first iso image and not be able to umount it */ - if (!strncmp(url, "nfs:", 4) && !FL_STAGE2(flags)) { - logMessage(INFO, "NFS install method detected, will use RHupdates/"); - useRHupdates = 1; - } - /* make sure /tmp/updates exists so that magic in anaconda to */ /* symlink rhpl/ will work */ if (access("/tmp/updates", F_OK)) @@ -1857,13 +1846,6 @@ int main(int argc, char ** argv) { add_to_path_env("PATH", "/tmp/updates"); add_to_path_env("PATH", "/tmp/product");
- if (useRHupdates) { - add_to_path_env("PYTHONPATH", "/mnt/source/RHupdates"); - add_to_path_env("LD_LIBRARY_PATH", "/mnt/source/RHupdates"); - add_to_path_env("PATH", "/mnt/source/RHupdates"); - add_fw_search_dir(&loaderData, "/mnt/source/RHupdates/firmware"); - } - stop_fw_loader(&loaderData); start_fw_loader(&loaderData);
diff --git a/scripts/pyrc.py b/scripts/pyrc.py index 47b0f02..6acee5b 100755 --- a/scripts/pyrc.py +++ b/scripts/pyrc.py @@ -23,15 +23,5 @@ try: readline.parse_and_bind("tab: complete") del rlcompleter del readline - - import os - import sys - try: - os.stat('/mnt/source/RHupdates') - sys.path.insert(0, '/mnt/source/RHupdates') - except: - pass - del sys - del os except: pass diff --git a/yuminstall.py b/yuminstall.py index 6a2ec7c..3b6525b 100644 --- a/yuminstall.py +++ b/yuminstall.py @@ -371,7 +371,7 @@ class AnacondaYum(YumSorter): self.macros = {}
if flags.selinux: - for directory in ("/tmp/updates", "/mnt/source/RHupdates", + for directory in ("/tmp/updates", "/etc/selinux/targeted/contexts/files", "/etc/security/selinux/src/policy/file_contexts", "/etc/security/selinux"): @@ -977,9 +977,9 @@ keepcache=0 logfile=/tmp/yum.log metadata_expire=0 obsoletes=True -pluginpath=/usr/lib/yum-plugins,/tmp/updates/yum-plugins,/mnt/source/RHupdates/yum-plugins -pluginconfpath=/etc/yum/pluginconf.d,/tmp/updates/pluginconf.d,/mnt/source/RHupdates/pluginconf.d -reposdir=/etc/yum.repos.d,/tmp/updates/yum.repos.d,/mnt/source/RHupdates/yum.repos.d,/tmp/product/yum.repos.d +pluginpath=/usr/lib/yum-plugins,/tmp/updates/yum-plugins +pluginconfpath=/etc/yum/pluginconf.d,/tmp/updates/pluginconf.d +reposdir=/etc/yum.repos.d,/tmp/updates/yum.repos.d,/tmp/product/yum.repos.d """ % (anaconda.rootPath, anaconda.rootPath)
fd = open("/etc/yum.conf", "w")
--- anaconda | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/anaconda b/anaconda index 06921e2..d8dc855 100755 --- a/anaconda +++ b/anaconda @@ -226,13 +226,16 @@ def parseOptions(): op.add_option("-d", "--debug", dest="debug", action="store_true", default=False) op.add_option("--expert", action="store_true", default=False) op.add_option("--kickstart", dest="ksfile") - op.add_option("-m", "--method", default=None) op.add_option("--rescue", dest="rescue", action="store_true", default=False) op.add_option("-r", "--rootpath", action="callback", callback=rootpath_cb, dest="rootPath", default="/mnt/sysimage", nargs=1, type="string") op.add_option("-t", "--test", action="store_true", default=False) op.add_option("--targetarch", dest="targetArch", nargs=1, type="string") - + + op.add_option("-m", "--method", dest="method", default=None) + op.add_option("--repo", dest="method", default=None) + op.add_option("--stage2", dest="stage2", default=None) + # Display op.add_option("--headless", dest="isHeadless", action="store_true", default=False) op.add_option("--lowres", dest="runres", action="store_const", const="640x480")
--- loader2/hdinstall.c | 12 ++++++------ loader2/loader.h | 3 ++- loader2/method.c | 22 +++++++++++----------- loader2/method.h | 2 +- loader2/nfsinstall.c | 24 ++++++++++++------------ loader2/urlinstall.c | 8 ++++---- 6 files changed, 36 insertions(+), 35 deletions(-)
diff --git a/loader2/hdinstall.c b/loader2/hdinstall.c index 14148eb..28fe801 100644 --- a/loader2/hdinstall.c +++ b/loader2/hdinstall.c @@ -285,9 +285,9 @@ char * mountHardDrive(struct installMethod * method, char *kspartition, *ksdirectory;
/* handle kickstart data first if available */ - if (loaderData->method == METHOD_HD && loaderData->methodData) { - kspartition = ((struct hdInstallData *)loaderData->methodData)->partition; - ksdirectory = ((struct hdInstallData *)loaderData->methodData)->directory; + if (loaderData->method == METHOD_HD && loaderData->stage2Data) { + kspartition = ((struct hdInstallData *)loaderData->stage2Data)->partition; + ksdirectory = ((struct hdInstallData *)loaderData->stage2Data)->directory; logMessage(INFO, "partition is %s, dir is %s", kspartition, ksdirectory);
/* if exist, duplicate */ @@ -499,11 +499,11 @@ void setKickstartHD(struct loaderData_s * loaderData, int argc, }
loaderData->method = METHOD_HD; - loaderData->methodData = calloc(sizeof(struct hdInstallData *), 1); + loaderData->stage2Data = calloc(sizeof(struct hdInstallData *), 1); if (partition) - ((struct hdInstallData *)loaderData->methodData)->partition = partition; + ((struct hdInstallData *)loaderData->stage2Data)->partition = partition; if (dir) - ((struct hdInstallData *)loaderData->methodData)->directory = dir; + ((struct hdInstallData *)loaderData->stage2Data)->directory = dir;
logMessage(INFO, "results of hd ks, partition is %s, dir is %s", partition, dir); diff --git a/loader2/loader.h b/loader2/loader.h index 1c6d273..5c038fb 100644 --- a/loader2/loader.h +++ b/loader2/loader.h @@ -130,11 +130,12 @@ struct loaderData_s { char * ksFile; int method; char * ddsrc; - void * methodData; + void * stage2Data; char * logLevel; char * updatessrc; char * dogtailurl; char * gdbServer; + char * instRepo;
pid_t fw_loader_pid; char *fw_search_pathz; diff --git a/loader2/method.c b/loader2/method.c index bd5426f..9d34991 100644 --- a/loader2/method.c +++ b/loader2/method.c @@ -624,7 +624,7 @@ int getFileFromBlockDevice(char *device, char *path, char * dest) { return rc; }
-void setMethodFromCmdline(char * arg, struct loaderData_s * ld) { +void setStage2LocFromCmdline(char * arg, struct loaderData_s * ld) { char * c, * dup;
dup = strdup(arg); @@ -632,21 +632,21 @@ void setMethodFromCmdline(char * arg, struct loaderData_s * ld) { /* : will let us delimit real information on the method */ if ((c = strtok(c, ":"))) { c = strtok(NULL, ":"); - + if (!strncmp(arg, "nfs:", 4)) { ld->method = METHOD_NFS; - ld->methodData = calloc(sizeof(struct nfsInstallData *), 1); + ld->stage2Data = calloc(sizeof(struct nfsInstallData *), 1);
- ((struct nfsInstallData *)ld->methodData)->mountOpts = NULL; - ((struct nfsInstallData *)ld->methodData)->host = strdup(c); + ((struct nfsInstallData *)ld->stage2Data)->mountOpts = NULL; + ((struct nfsInstallData *)ld->stage2Data)->host = strdup(c); if ((c = strtok(NULL, ":"))) { - ((struct nfsInstallData *)ld->methodData)->directory = strdup(c); + ((struct nfsInstallData *)ld->stage2Data)->directory = strdup(c); } } else if (!strncmp(arg, "ftp:", 4) || !strncmp(arg, "http:", 5)) { ld->method = METHOD_URL; - ld->methodData = calloc(sizeof(struct urlInstallData *), 1); - ((struct urlInstallData *)ld->methodData)->url = strdup(arg); + ld->stage2Data = calloc(sizeof(struct urlInstallData *), 1); + ((struct urlInstallData *)ld->stage2Data)->url = strdup(arg); #if !defined(__s390__) && !defined(__s390x__) } else if (!strncmp(arg, "cdrom:", 6)) { ld->method = METHOD_CDROM; @@ -654,10 +654,10 @@ void setMethodFromCmdline(char * arg, struct loaderData_s * ld) { } else if (!strncmp(arg, "harddrive:", 10) || !strncmp(arg, "hd:", 3)) { ld->method = METHOD_HD; - ld->methodData = calloc(sizeof(struct hdInstallData *), 1); - ((struct hdInstallData *)ld->methodData)->partition = strdup(c); + ld->stage2Data = calloc(sizeof(struct hdInstallData *), 1); + ((struct hdInstallData *)ld->stage2Data)->partition = strdup(c); if ((c = strtok(NULL, ":"))) { - ((struct hdInstallData *)ld->methodData)->directory = strdup(c); + ((struct hdInstallData *)ld->stage2Data)->directory = strdup(c); } } } diff --git a/loader2/method.h b/loader2/method.h index 03fc529..dc5f61c 100644 --- a/loader2/method.h +++ b/loader2/method.h @@ -58,6 +58,6 @@ int unpackCpioBall(char * ballPath, char * rootDir); void copyUpdatesImg(char * path); void copyProductImg(char * path);
-void setMethodFromCmdline(char * arg, struct loaderData_s * ld); +void setStage2LocFromCmdline(char * arg, struct loaderData_s * ld);
#endif diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c index 75d5548..ae309d2 100644 --- a/loader2/nfsinstall.c +++ b/loader2/nfsinstall.c @@ -118,14 +118,14 @@ char * mountNfsImage(struct installMethod * method, switch (stage) { case NFS_STAGE_NFS: logMessage(INFO, "going to do nfsGetSetup"); - if (loaderData->method == METHOD_NFS && loaderData->methodData) { - host = ((struct nfsInstallData *)loaderData->methodData)->host; - directory = ((struct nfsInstallData *)loaderData->methodData)->directory; + if (loaderData->method == METHOD_NFS && loaderData->stage2Data) { + host = ((struct nfsInstallData *)loaderData->stage2Data)->host; + directory = ((struct nfsInstallData *)loaderData->stage2Data)->directory;
- if (((struct nfsInstallData *) loaderData->methodData)->mountOpts == NULL) + if (((struct nfsInstallData *) loaderData->stage2Data)->mountOpts == NULL) mountOpts = strdup("ro"); else - rc = asprintf(&mountOpts, "ro,%s", ((struct nfsInstallData *) loaderData->methodData)->mountOpts); + rc = asprintf(&mountOpts, "ro,%s", ((struct nfsInstallData *) loaderData->stage2Data)->mountOpts);
logMessage(INFO, "host is %s, dir is %s, opts are '%s'", host, directory, mountOpts);
@@ -373,15 +373,15 @@ void setKickstartNfs(struct loaderData_s * loaderData, int argc, }
loaderData->method = METHOD_NFS; - loaderData->methodData = calloc(sizeof(struct nfsInstallData *), 1); - ((struct nfsInstallData *)loaderData->methodData)->host = host; - ((struct nfsInstallData *)loaderData->methodData)->directory = dir; - ((struct nfsInstallData *)loaderData->methodData)->mountOpts = mountOpts; + loaderData->stage2Data = calloc(sizeof(struct nfsInstallData *), 1); + ((struct nfsInstallData *)loaderData->stage2Data)->host = host; + ((struct nfsInstallData *)loaderData->stage2Data)->directory = dir; + ((struct nfsInstallData *)loaderData->stage2Data)->mountOpts = mountOpts;
logMessage(INFO, "results of nfs, host is %s, dir is %s, opts are '%s'", - ((struct nfsInstallData *) loaderData->methodData)->host, - ((struct nfsInstallData *) loaderData->methodData)->directory, - ((struct nfsInstallData *) loaderData->methodData)->mountOpts); + ((struct nfsInstallData *) loaderData->stage2Data)->host, + ((struct nfsInstallData *) loaderData->stage2Data)->directory, + ((struct nfsInstallData *) loaderData->stage2Data)->mountOpts); }
diff --git a/loader2/urlinstall.c b/loader2/urlinstall.c index 55b7c3d..9bb230b 100644 --- a/loader2/urlinstall.c +++ b/loader2/urlinstall.c @@ -221,8 +221,8 @@ char * mountUrlImage(struct installMethod * method, while (stage != URL_STAGE_DONE) { switch(stage) { case URL_STAGE_MAIN: - if (loaderData->method == METHOD_URL && loaderData->methodData) { - url = ((struct urlInstallData *)loaderData->methodData)->url; + if (loaderData->method == METHOD_URL && loaderData->stage2Data) { + url = ((struct urlInstallData *)loaderData->stage2Data)->url; logMessage(INFO, "URL_STAGE_MAIN - url is %s", url);
if (!url) { @@ -460,8 +460,8 @@ void setKickstartUrl(struct loaderData_s * loaderData, int argc, return; }
- loaderData->methodData = calloc(sizeof(struct urlInstallData *), 1); - ((struct urlInstallData *)loaderData->methodData)->url = url; + loaderData->stage2Data = calloc(sizeof(struct urlInstallData *), 1); + ((struct urlInstallData *)loaderData->stage2Data)->url = url;
logMessage(INFO, "results of url ks, url %s", url); }
--- loader2/loader.c | 583 ++++++++++++++++++++++++++---------------------------- 1 files changed, 279 insertions(+), 304 deletions(-)
diff --git a/loader2/loader.c b/loader2/loader.c index 650f2ae..6bf9e58 100644 --- a/loader2/loader.c +++ b/loader2/loader.c @@ -1058,32 +1058,21 @@ static int haveDeviceOfType(int type) { return 0; }
-/* fsm for the basics of the loader. */ -static char *doLoaderMain(char * location, - struct loaderData_s * loaderData, +static char *doLoaderMain(struct loaderData_s *loaderData, moduleInfoSet modInfo) { - enum { STEP_LANG, STEP_KBD, STEP_METHOD, STEP_DRIVER, + enum { STEP_LANG, STEP_KBD, STEP_METHOD, STEP_DRIVER, STEP_DRIVERDISK, STEP_NETWORK, STEP_IFACE, - STEP_IP, STEP_URL, STEP_DONE } step; - char * url = NULL; - char * ret = NULL; - int dir = 1; - int rc, i; - - char * installNames[10]; /* 10 install methods will be enough for anyone */ - int numValidMethods = 0; - int validMethods[10]; - int methodNum = -1; - - int needed = -1; - int needsNetwork = 0; + STEP_IP, STEP_STAGE2, STEP_DONE } step;
- int rhcdfnd = 0; - - char * devName = NULL; + char *url = NULL, *ret = NULL, *devName = NULL, *kbdtype = NULL; static struct networkDeviceConfig netDev; + int i, rc, dir = 1; + int needsNetwork = 0, class = -1; + int haveStage2 = 0;
- char * kbdtype = NULL; + char *installNames[10]; + int numValidMethods = 0; + int validMethods[10];
for (i = 0; i < numMethods; i++, numValidMethods++) { installNames[numValidMethods] = installMethods[i].name; @@ -1091,363 +1080,349 @@ static char *doLoaderMain(char * location, } installNames[numValidMethods] = NULL;
+ if (!FL_CMDLINE(flags)) + startNewt(); + /* have we preselected this to be our install method? */ if (loaderData->method >= 0) { - methodNum = loaderData->method; /* disable the fast path (#102652) */ flags |= LOADER_FLAGS_ASKMETHOD; }
- /* 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)); - /* 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; - else { - rhcdfnd = 1; - methodNum = 0; - } + /* If neither the askmethod parameter nor the stage2= parameter was passed, + * check for the presence of a CD/DVD. If there's a stage2 on that, we + * use it and bypass all other checks for a stage2 image later. + */ + if (!FL_ASKMETHOD(flags) && !loaderData->stage2Data) { + url = findAnacondaCD("/mnt/stage2", 0); + if (url) + haveStage2 = 1; }
- if (!FL_CMDLINE(flags)) - startNewt(); - step = STEP_LANG; - while (step != STEP_DONE) { switch(step) { - case STEP_LANG: - if (loaderData->lang && (loaderData->lang_set == 1)) { - setLanguage(loaderData->lang, 1); - } else { - chooseLanguage(&loaderData->lang); - } - step = STEP_KBD; - dir = 1; - break; - case STEP_KBD: - if (loaderData->kbd && (loaderData->kbd_set == 1)) { - /* JKFIXME: this is broken -- we should tell of the - * failure; best by pulling code out in kbd.c to use */ - if (isysLoadKeymap(loaderData->kbd)) { - logMessage(WARNING, "requested keymap %s is not valid, asking", loaderData->kbd); - loaderData->kbd = NULL; - loaderData->kbd_set = 0; - break; - } - rc = LOADER_NOOP; - } else { - /* JKFIXME: should handle kbdtype, too probably... but it - * just matters for sparc */ - if (!FL_CMDLINE(flags)) - rc = chooseKeyboard(loaderData, &kbdtype); - else - rc = LOADER_NOOP; - } - if (rc == LOADER_NOOP) { - if (dir == -1) - step = STEP_LANG; + case STEP_LANG: { + if (loaderData->lang && (loaderData->lang_set == 1)) + setLanguage(loaderData->lang, 1); else - step = STEP_METHOD; - break; - } + chooseLanguage(&loaderData->lang);
- if (rc == LOADER_BACK) { - step = STEP_LANG; - dir = -1; - } else { - step = STEP_METHOD; + step = STEP_KBD; dir = 1; + break; }
- break; - - case STEP_METHOD: - /* this is kind of crappy, but we want the first few questions - * to be asked when using rescue mode even if we're going - * to short-circuit to the CD. - * - * 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 (FL_RESCUE(flags)) { - return url; - } else if (rhcdfnd) { - step = STEP_NETWORK; - dir = 1; - break; + case STEP_KBD: { + if (loaderData->kbd && (loaderData->kbd_set == 1)) { + /* JKFIXME: this is broken -- we should tell of the + * failure; best by pulling code out in kbd.c to use */ + if (isysLoadKeymap(loaderData->kbd)) { + logMessage(WARNING, "requested keymap %s is not valid, asking", + loaderData->kbd); + loaderData->kbd = NULL; + loaderData->kbd_set = 0; + break; + } + rc = LOADER_NOOP; + } else { + /* JKFIXME: should handle kbdtype, too probably... but it + * just matters for sparc */ + if (!FL_CMDLINE(flags)) + rc = chooseKeyboard(loaderData, &kbdtype); + else + rc = LOADER_NOOP; } - }
- needed = -1; + if (rc == LOADER_NOOP) { + if (dir == -1) + step = STEP_LANG; + else + step = STEP_METHOD;
- if (loaderData->method != -1 && methodNum != -1) { - /* dont forget the dir variable. */ - if ( dir == 1 ){ - rc = 1; - }else{ - rc = -1; + break; } - } else { - /* we need to set these each time through so that we get - * updated for language changes (#83672) */ - for (i = 0; i < numMethods; i++) { - installNames[i] = _(installMethods[i].name); + + if (rc == LOADER_BACK) { + step = STEP_LANG; + dir = -1; + } else { + step = STEP_METHOD; + dir = 1; } - installNames[i] = NULL; - - rc = newtWinMenu(FL_RESCUE(flags) ? _("Rescue Method") : - _("Installation Method"), - FL_RESCUE(flags) ? - _("What type of media contains the rescue " - "image?") : - _("What type of media contains the packages to " - "be installed?"), - 30, 10, 20, 6, installNames, &methodNum, - _("OK"), _("Back"), NULL); - } - - if (rc && rc != 1) { - step = STEP_KBD; - dir = -1; - } else { - needed = installMethods[validMethods[methodNum]].type; - step = STEP_DRIVER; - dir = 1; - } - break;
- case STEP_DRIVER: { - if (needed == -1 || haveDeviceOfType(needed)) { - step = STEP_NETWORK; - dir = 1; - needed = -1; break; }
- rc = newtWinTernary(_("No driver found"), _("Select driver"), - _("Use a driver disk"), _("Back"), - _("Unable to find any devices of the type " - "needed for this installation type. " - "Would you like to manually select your " - "driver or use a driver disk?")); - if (rc == 2) { - step = STEP_DRIVERDISK; - dir = 1; - break; - } else if (rc == 3) { - step = STEP_METHOD; - dir = -1; + case STEP_METHOD: { + /* If we already found a stage2 image, skip the prompt. */ + if (haveStage2 || loaderData->method) { + if (dir == 1) + rc = 1; + else + rc = -1; + } else { + /* we need to set these each time through so that we get + * updated for language changes (#83672) */ + for (i = 0; i < numMethods; i++) { + installNames[i] = _(installMethods[i].name); + } + installNames[i] = NULL; + + rc = newtWinMenu(FL_RESCUE(flags) ? _("Rescue Method") : + _("Installation Method"), + FL_RESCUE(flags) ? + _("What type of media contains the rescue " + "image?") : + _("What type of media contains the packages to " + "be installed?"), + 30, 10, 20, 6, installNames, &loaderData->method, + _("OK"), _("Back"), NULL); + } + + if (rc && rc != 1) { + step = STEP_KBD; + dir = -1; + } else { + class = installMethods[validMethods[loaderData->method]].type; + step = STEP_DRIVER; + dir = 1; + } break; }
- chooseManualDriver(installMethods[validMethods[methodNum]].type, - loaderData); - /* it doesn't really matter what we return here; we just want - * to reprobe and make sure we have the driver */ - step = STEP_DRIVER; - break; - } + case STEP_DRIVER: { + if (class == -1 || haveDeviceOfType(class)) { + step = STEP_NETWORK; + dir = 1; + class = -1; + break; + }
- case STEP_DRIVERDISK: + rc = newtWinTernary(_("No driver found"), _("Select driver"), + _("Use a driver disk"), _("Back"), + _("Unable to find any devices of the type " + "needed for this installation type. " + "Would you like to manually select your " + "driver or use a driver disk?")); + if (rc == 2) { + step = STEP_DRIVERDISK; + dir = 1; + break; + } else if (rc == 3) { + step = STEP_METHOD; + dir = -1; + break; + }
- rc = loadDriverFromMedia(needed, loaderData, 0, 0); - if (rc == LOADER_BACK) { + chooseManualDriver(installMethods[validMethods[loaderData->method]].type, + loaderData); + /* it doesn't really matter what we return here; we just want + * to reprobe and make sure we have the driver */ step = STEP_DRIVER; - dir = -1; break; }
- /* need to come back to driver so that we can ensure that we found - * the right kind of driver after loading the driver disk */ - step = STEP_DRIVER; - break; - - case STEP_NETWORK: - if ( (installMethods[validMethods[methodNum]].type != - DEVICE_NETWORK) && (!hasGraphicalOverride()) && - !FL_ASKNETWORK(flags)) { - needsNetwork = 0; - if (dir == 1) - step = STEP_URL; - else if (dir == -1) - step = STEP_METHOD; - break; - } + case STEP_DRIVERDISK: { + rc = loadDriverFromMedia(class, loaderData, 0, 0); + if (rc == LOADER_BACK) { + step = STEP_DRIVER; + dir = -1; + break; + }
- needsNetwork = 1; - if (!haveDeviceOfType(DEVICE_NETWORK)) { - needed = DEVICE_NETWORK; + /* need to come back to driver so that we can ensure that we found + * the right kind of driver after loading the driver disk */ step = STEP_DRIVER; break; } - logMessage(INFO, "need to set up networking");
- initLoopback(); - memset(&netDev, 0, sizeof(netDev)); - netDev.isDynamic = 1; + case STEP_NETWORK: { + if ((installMethods[validMethods[loaderData->method]].type != + DEVICE_NETWORK) && (!hasGraphicalOverride()) && + !FL_ASKNETWORK(flags)) { + needsNetwork = 0; + if (dir == 1) + step = STEP_STAGE2; + else if (dir == -1) + step = STEP_METHOD; + break; + }
- /* fall through to interface selection */ - case STEP_IFACE: - logMessage(INFO, "going to pick interface"); + needsNetwork = 1; + if (!haveDeviceOfType(DEVICE_NETWORK)) { + class = DEVICE_NETWORK; + step = STEP_DRIVER; + break; + } + logMessage(INFO, "need to set up networking");
- /* skip configureTCPIP() screen for kickstart (#260621) */ - if (loaderData->ksFile) - flags |= LOADER_FLAGS_IS_KICKSTART; + initLoopback(); + memset(&netDev, 0, sizeof(netDev)); + netDev.isDynamic = 1;
- if (FL_HAVE_CMSCONF(flags)) { - loaderData->ipinfo_set = 1; - loaderData->ipv6info_set = 1; - } else { - loaderData->ipinfo_set = 0; - loaderData->ipv6info_set = 0; + /* fall through to interface selection */ }
- rc = chooseNetworkInterface(loaderData); - if ((rc == LOADER_BACK) || (rc == LOADER_ERROR) || - ((dir == -1) && (rc == LOADER_NOOP))) { - step = STEP_METHOD; - dir = -1; - break; - } + case STEP_IFACE: { + logMessage(INFO, "going to pick interface");
- devName = loaderData->netDev; - strcpy(netDev.dev.device, devName); + /* skip configureTCPIP() screen for kickstart (#260621) */ + if (loaderData->ksFile) + flags |= LOADER_FLAGS_IS_KICKSTART;
- /* continue to ip config */ - step = STEP_IP; - dir = 1; - break; - case STEP_IP: - if (!needsNetwork || dir == -1) { - step = STEP_METHOD; /* only hit going back */ + if (FL_HAVE_CMSCONF(flags)) { + loaderData->ipinfo_set = 1; + loaderData->ipv6info_set = 1; + } else { + loaderData->ipinfo_set = 0; + loaderData->ipv6info_set = 0; + } + + rc = chooseNetworkInterface(loaderData); + if ((rc == LOADER_BACK) || (rc == LOADER_ERROR) || + ((dir == -1) && (rc == LOADER_NOOP))) { + step = STEP_METHOD; + dir = -1; + break; + } + + devName = loaderData->netDev; + strcpy(netDev.dev.device, devName); + + /* continue to ip config */ + step = STEP_IP; + dir = 1; break; }
- if ((ret = malloc(48)) == NULL) { - logMessage(ERROR, "malloc failure for ret in STEP_IP"); - exit(EXIT_FAILURE); - } + case STEP_IP: { + if (!needsNetwork || dir == -1) { + step = STEP_METHOD; /* only hit going back */ + break; + }
- logMessage(INFO, "going to do getNetConfig"); + if ((ret = malloc(48)) == NULL) { + logMessage(ERROR, "malloc failure for ret in STEP_IP"); + exit(EXIT_FAILURE); + }
- /* s390 provides all config info by way of the CMS conf file */ - if (FL_HAVE_CMSCONF(flags)) { - loaderData->ipinfo_set = 1; - loaderData->ipv6info_set = 1; - } + logMessage(INFO, "going to do getNetConfig");
- /* populate netDev based on any kickstart data */ - if (loaderData->ipinfo_set) { - netDev.preset = 1; - } - setupNetworkDeviceConfig(&netDev, loaderData); + /* s390 provides all config info by way of the CMS conf file */ + if (FL_HAVE_CMSCONF(flags)) { + loaderData->ipinfo_set = 1; + loaderData->ipv6info_set = 1; + }
- rc = readNetConfig(devName, &netDev, loaderData->netCls, methodNum); - if (FL_NOIPV4(flags)) { - loaderData->ipinfo_set = 0; - } else { - if (loaderData->ipv4 == NULL) { - if (strcmp((char *) &(netDev.dev.ip), "")) { - ret = (char *) inet_ntop(AF_INET, - IP_ADDR(&(netDev.dev.ip)), ret, - IP_STRLEN(&(netDev.dev.ip))); - } else { - ret = NULL; - netDev.isDynamic = 1; - } + /* populate netDev based on any kickstart data */ + if (loaderData->ipinfo_set) { + netDev.preset = 1; + } + setupNetworkDeviceConfig(&netDev, loaderData);
- if (netDev.isDynamic || ret == NULL) { - loaderData->ipv4 = strdup("dhcp"); - } else { - loaderData->ipv4 = strdup(ret); + rc = readNetConfig(devName, &netDev, loaderData->netCls, loaderData->method); + if (FL_NOIPV4(flags)) { + loaderData->ipinfo_set = 0; + } else { + if (loaderData->ipv4 == NULL) { + if (strcmp((char *) &(netDev.dev.ip), "")) { + ret = (char *) inet_ntop(AF_INET, + IP_ADDR(&(netDev.dev.ip)), ret, + IP_STRLEN(&(netDev.dev.ip))); + } else { + ret = NULL; + netDev.isDynamic = 1; + } + + if (netDev.isDynamic || ret == NULL) { + loaderData->ipv4 = strdup("dhcp"); + } else { + loaderData->ipv4 = strdup(ret); + } } - }
- loaderData->ipinfo_set = 1; - } + loaderData->ipinfo_set = 1; + }
- if (FL_NOIPV6(flags)) { - loaderData->ipv6info_set = 0; - } else { - if (loaderData->ipv6 == NULL) { - if (strcmp((char *) &(netDev.dev.ip), "")) { - ret = (char *) inet_ntop(AF_INET6, - IP_ADDR(&(netDev.dev.ip)), ret, - IP_STRLEN(&(netDev.dev.ip))); - } else { - ret = NULL; - netDev.isDynamic = 1; + if (FL_NOIPV6(flags)) { + loaderData->ipv6info_set = 0; + } else { + if (loaderData->ipv6 == NULL) { + if (strcmp((char *) &(netDev.dev.ip), "")) { + ret = (char *) inet_ntop(AF_INET6, + IP_ADDR(&(netDev.dev.ip)), ret, + IP_STRLEN(&(netDev.dev.ip))); + } else { + ret = NULL; + netDev.isDynamic = 1; + } + + if (netDev.isDynamic || ret == NULL) { + loaderData->ipv6 = strdup("dhcpv6"); + } else { + loaderData->ipv6 = strdup(ret); + } }
- if (netDev.isDynamic || ret == NULL) { - loaderData->ipv6 = strdup("dhcpv6"); - } else { - loaderData->ipv6 = strdup(ret); + loaderData->ipv6info_set = 1; + } + + /* set the hostname if we have that */ + if (loaderData->hostname) { + if (sethostname(loaderData->hostname, + strlen(loaderData->hostname))) { + logMessage(ERROR, "error setting hostname to %s", + loaderData->hostname); } }
- loaderData->ipv6info_set = 1; - } + free(ret); + ret = NULL;
- /* set the hostname if we have that */ - if (loaderData->hostname) { - if (sethostname(loaderData->hostname, - strlen(loaderData->hostname))) { - logMessage(ERROR, "error setting hostname to %s", - loaderData->hostname); + if ((rc == LOADER_BACK) || (rc == LOADER_ERROR) || + ((dir == -1) && (rc == LOADER_NOOP))) { + step = STEP_IFACE; + dir = -1; + break; } + + writeNetInfo("/tmp/netinfo", &netDev); + step = STEP_STAGE2; + dir = 1; + break; }
- free(ret); - ret = NULL; + case STEP_STAGE2: { + if (url) { + logMessage(INFO, "got stage2 at url %s", url); + return url; + }
- if ((rc == LOADER_BACK) || (rc == LOADER_ERROR) || - ((dir == -1) && (rc == LOADER_NOOP))) { - step = STEP_IFACE; - dir = -1; + logMessage(INFO, "starting STEP_STAGE2"); + url = installMethods[validMethods[loaderData->method]].mountImage( + installMethods + validMethods[loaderData->method], + "/mnt/stage2", loaderData); + if (!url) { + step = STEP_IP ; + loaderData->ipinfo_set = 0; + loaderData->ipv6info_set = 0; + dir = -1; + } else { + logMessage(INFO, "got stage2 at url %s", url); + step = STEP_DONE; + dir = 1; + } break; }
- writeNetInfo("/tmp/netinfo", &netDev); - step = STEP_URL; - dir = 1; - break; - case STEP_URL: - logMessage(INFO, "starting to STEP_URL"); - /* if we found a CD already short circuit out */ - /* 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; - - url = installMethods[validMethods[methodNum]].mountImage( - installMethods + validMethods[methodNum], - location, loaderData); - if (!url) { - step = STEP_IP ; - loaderData->ipinfo_set = 0; - loaderData->ipv6info_set = 0; - dir = -1; - } else { - logMessage(INFO, "got url %s", url); - step = STEP_DONE; - dir = 1; - } - break; - default: - break; + case STEP_DONE: + break; } }
return url; } - static int manualDeviceCheck(struct loaderData_s *loaderData) { char ** devices; int i, j, rc, num = 0; @@ -1787,7 +1762,7 @@ int main(int argc, char ** argv) { if (FL_TELNETD(flags)) startTelnetd(&loaderData);
- url = doLoaderMain("/mnt/source", &loaderData, modInfo); + url = doLoaderMain(&loaderData, modInfo);
if (!FL_TESTING(flags)) { int ret;
stage2= points directly at a stage2 image somewhere. repo= points at a source of packages for installation. method= is deprecated, but will have the effect of specifying a repo and assuming a location for the stage2 image. Make sure these options get passed to anaconda too. --- loader2/loader.c | 57 ++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 43 insertions(+), 14 deletions(-)
diff --git a/loader2/loader.c b/loader2/loader.c index 6bf9e58..c3460be 100644 --- a/loader2/loader.c +++ b/loader2/loader.c @@ -765,7 +765,7 @@ static void parseCmdLineFlags(struct loaderData_s * loaderData, int argc; int numExtraArgs = 0; int i; - char *front; + char *front, *stage2param = NULL;
/* we want to default to graphical and allow override with 'text' */ flags |= LOADER_FLAGS_GRAPHICAL; @@ -915,11 +915,15 @@ static void parseCmdLineFlags(struct loaderData_s * loaderData, loaderData->kbd = strdup(argv[i] + 7); loaderData->kbd_set = 1; } - else if (!strncasecmp(argv[i], "method=", 7) && !FL_STAGE2(flags)) - setMethodFromCmdline(argv[i] + 7, loaderData); + else if (!strncasecmp(argv[i], "method=", 7)) { + logMessage(WARNING, "method= is deprecated. Please use repo= instead."); + loaderData->instRepo = strdup(argv[i] + 7); + } + else if (!strncasecmp(argv[i], "repo=", 5)) + loaderData->instRepo = strdup(argv[i] + 5); else if (!strncasecmp(argv[i], "stage2=", 7)) { - flags |= LOADER_FLAGS_STAGE2; - setMethodFromCmdline(argv[i] + 7, loaderData); + stage2param = strdup(argv[i]+7); + setStage2LocFromCmdline(argv[i] + 7, loaderData); } else if (!strncasecmp(argv[i], "hostname=", 9)) loaderData->hostname = strdup(argv[i] + 9); @@ -1004,6 +1008,23 @@ static void parseCmdLineFlags(struct loaderData_s * loaderData, } }
+ /* Here's how it works: stage2= points to just the location of the + * stage2.img file. repo= points to the installation source. This is + * the same as the old method=, but makes the meaning more explicit. + * If stage2= is not given, we will try to piece together a valid + * setting based on the contents of repo=. If repo= is not given, we + * will try to figure it out once we're in stage2. + */ + if (loaderData->instRepo && !loaderData->stage2Data) { + char *tmp; + int rc; + + rc = asprintf(&tmp, "%s/images/stage2.img", loaderData->instRepo); + logMessage(INFO, "no stage2= given, assuming %s", tmp); + setStage2LocFromCmdline(tmp, loaderData); + free(tmp); + } + readNetInfo(&loaderData);
/* NULL terminates the array of extra args */ @@ -1089,14 +1110,16 @@ static char *doLoaderMain(struct loaderData_s *loaderData, flags |= LOADER_FLAGS_ASKMETHOD; }
- /* If neither the askmethod parameter nor the stage2= parameter was passed, - * check for the presence of a CD/DVD. If there's a stage2 on that, we - * use it and bypass all other checks for a stage2 image later. + /* Before anything else, see if there's a CD/DVD with a stage2 image on + * it. However if stage2= was given, use that value as an override here. + * That will also then bypass any method selection UI in loader. */ - if (!FL_ASKMETHOD(flags) && !loaderData->stage2Data) { - url = findAnacondaCD("/mnt/stage2", 0); - if (url) + if (!loaderData->stage2Data) { + url = findAnacondaCD("/mnt/stage2"); + if (url) { + setStage2LocFromCmdline(url, loaderData); haveStage2 = 1; + } }
step = STEP_LANG; @@ -1156,7 +1179,7 @@ static char *doLoaderMain(struct loaderData_s *loaderData,
case STEP_METHOD: { /* If we already found a stage2 image, skip the prompt. */ - if (haveStage2 || loaderData->method) { + if (haveStage2 && loaderData->method != -1) { if (dir == 1) rc = 1; else @@ -1404,12 +1427,13 @@ static char *doLoaderMain(struct loaderData_s *loaderData, installMethods + validMethods[loaderData->method], "/mnt/stage2", loaderData); if (!url) { - step = STEP_IP ; + step = STEP_IP; loaderData->ipinfo_set = 0; loaderData->ipv6info_set = 0; dir = -1; } else { logMessage(INFO, "got stage2 at url %s", url); + haveStage2 = 1; step = STEP_DONE; dir = 1; } @@ -1854,7 +1878,7 @@ int main(int argc, char ** argv) {
logMessage(INFO, "Running anaconda script %s", *(argptr-1));
- *argptr++ = "-m"; + *argptr++ = "--stage2"; if (strncmp(url, "ftp:", 4)) { *argptr++ = url; } else { @@ -1945,6 +1969,11 @@ int main(int argc, char ** argv) { *argptr++ = "--loglevel"; *argptr++ = loaderData.logLevel; } + + if (loaderData.instRepo) { + *argptr++ = "--repo"; + *argptr++ = loaderData.instRepo; + } }
*argptr = NULL;
This removes the capability to find implicit updates.img files, but that will be coming back in a later patch. This is just some cleanup for now. --- loader2/cdinstall.c | 14 ++++---------- loader2/hdinstall.c | 2 +- loader2/method.c | 15 +-------------- loader2/method.h | 2 +- loader2/nfsinstall.c | 23 +++++++---------------- 5 files changed, 14 insertions(+), 42 deletions(-)
diff --git a/loader2/cdinstall.c b/loader2/cdinstall.c index 7f3ef12..c6bc1db 100644 --- a/loader2/cdinstall.c +++ b/loader2/cdinstall.c @@ -154,10 +154,9 @@ static void wrongCDMessage(void) { static void mountCdromStage2(char *cddev, char *location) { int gotcd1=0; int rc; - char *stage2loc, *imageDir; + char *stage2loc;
rc = asprintf(&stage2loc, "%s/images/stage2.img", location); - rc = asprintf(&imageDir, "%s/images/", location);
do { do { @@ -169,7 +168,7 @@ static void mountCdromStage2(char *cddev, char *location) { } } while (1);
- rc = mountStage2(stage2loc, imageDir); + rc = mountStage2(stage2loc);
/* if we failed, umount location (usually) /mnt/source and keep going */ if (rc) { @@ -182,7 +181,6 @@ static void mountCdromStage2(char *cddev, char *location) { } while (!gotcd1);
free(stage2loc); - free(imageDir); }
/* ask about doing media check */ @@ -235,7 +233,7 @@ char * setupCdrom(char * location, struct loaderData_s * loaderData, int i, r, rc; int foundinvalid = 0; int stage2inram = 0; - char *buf, *stage2loc, *discinfoloc, *imageDir; + char *buf, *stage2loc, *discinfoloc; char *stage2img; struct device ** devices; char *cddev = NULL; @@ -248,11 +246,9 @@ char * setupCdrom(char * location, struct loaderData_s * loaderData,
if (loaderData && FL_STAGE2(flags)) { stage2loc = strdup(location); - r = asprintf(&imageDir, "%.*s", (int) (strrchr(location, '/') - location), location); r = asprintf(&discinfoloc, "%s/.discinfo", imageDir); } else { r = asprintf(&stage2loc, "%s/images/stage2.img", location); - r = asprintf(&imageDir, "%s/images", location); r = asprintf(&discinfoloc, "%s/.discinfo", location); }
@@ -289,7 +285,7 @@ char * setupCdrom(char * location, struct loaderData_s * loaderData, stage2img = strdup(stage2loc); stage2inram = 0; } - rc = mountStage2(stage2img, imageDir); + rc = mountStage2(stage2img);
if (rc) { logMessage(INFO, "mounting stage2 failed"); @@ -314,7 +310,6 @@ char * setupCdrom(char * location, struct loaderData_s * loaderData, devices[i]->device, location);
free(stage2loc); - free(imageDir); free(discinfoloc);
if (r == -1) @@ -358,7 +353,6 @@ char * setupCdrom(char * location, struct loaderData_s * loaderData,
err: free(stage2loc); - free(imageDir); free(discinfoloc); return NULL; } diff --git a/loader2/hdinstall.c b/loader2/hdinstall.c index 28fe801..3b99377 100644 --- a/loader2/hdinstall.c +++ b/loader2/hdinstall.c @@ -197,7 +197,7 @@ static char * setupIsoImages(char * device, char * dirName, char * location) {
if (FL_STAGE2(flags)) { if (!copyFile(path, "/tmp/stage2.img")) { - rc = mountStage2("/tmp/stage2.img", dirName); + rc = mountStage2("/tmp/stage2.img"); umount("/mnt/isodir"); free(path);
diff --git a/loader2/method.c b/loader2/method.c index 9d34991..f1eb55d 100644 --- a/loader2/method.c +++ b/loader2/method.c @@ -530,10 +530,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 *stage2path, char *imageDir) { - char *buf; - int rc; - +int mountStage2(char *stage2path) { if (access(stage2path, R_OK)) { return 1; } @@ -547,16 +544,6 @@ int mountStage2(char *stage2path, char *imageDir) { return -1; }
- /* JKFIXME: this is kind of silly.. /mnt/source is hardcoded :/ */ - rc = asprintf(&buf, "%s/updates.img", imageDir); - copyUpdatesImg(buf); - free(buf); - - /* more hard coding */ - rc = asprintf(&buf, "%s/product.img", imageDir); - copyProductImg(buf); - free(buf); - return 0; }
diff --git a/loader2/method.h b/loader2/method.h index dc5f61c..36f67f3 100644 --- a/loader2/method.h +++ b/loader2/method.h @@ -50,7 +50,7 @@ void queryIsoMediaCheck(char * isoDir); int verifyStamp(char * path);
void umountStage2(void); -int mountStage2(char *stage2path, char *imageDir); +int mountStage2(char *stage2path); int copyFileAndLoopbackMount(int fd, char *dest, char *device, char *mntpoint); int getFileFromBlockDevice(char *device, char *path, char * dest);
diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c index ae309d2..0be2aaa 100644 --- a/loader2/nfsinstall.c +++ b/loader2/nfsinstall.c @@ -147,7 +147,7 @@ char * mountNfsImage(struct installMethod * method, break;
case NFS_STAGE_MOUNT: { - char *buf, *stage2dir; + char *buf; struct in_addr ip;
if (loaderData->noDns && !(inet_pton(AF_INET, host, &ip))) { @@ -224,18 +224,14 @@ char * mountNfsImage(struct installMethod * method, stage = NFS_STAGE_NFS;
if (!doPwMount(fullPath, "/mnt/source", "nfs", mountOpts)) { - if (FL_STAGE2(flags)) { - stage2dir = strdup("/mnt/source"); + if (FL_STAGE2(flags)) tmp = asprintf(&buf, "/mnt/source/%s", strrchr(directory, '/')); - } else { - stage2dir = strdup("/mnt/source/images"); + else buf = strdup("/mnt/source/images/stage2.img"); - }
if (!access(buf, R_OK)) { logMessage(INFO, "can access %s", buf); - rc = mountStage2(buf, stage2dir); - free(stage2dir); + rc = mountStage2(buf);
if (rc == -1) { foundinvalid = 1; @@ -257,7 +253,6 @@ char * mountNfsImage(struct installMethod * method,
logMessage(WARNING, "unable to access %s", buf); free(buf); - free(stage2dir); umount("/mnt/source");
if ((path = isNfsIso(fullPath, mountOpts, &foundinvalid, 1)) != NULL) { @@ -272,20 +267,16 @@ char * mountNfsImage(struct installMethod * method, logMessage(WARNING, "failed to mount iso %s loopback", path); free(path); } else { - if (FL_STAGE2(flags)) { - stage2dir = strdup("/mnt/source"); + if (FL_STAGE2(flags)) tmp = asprintf(&buf, "/mnt/source/%s", strrchr(directory, '/')); - } else { - stage2dir = strdup("/mnt/source/images"); + else buf = strdup("/mnt/source/images/stage2.img"); - }
rc = copyFile(buf, "/tmp/stage2.img"); - rc = mountStage2("/tmp/stage2.img", stage2dir); + rc = mountStage2("/tmp/stage2.img"); umountLoopback("/mnt/source", "/dev/loop1");
free(buf); - free(stage2dir); free(path);
if (rc && rc == -1) {
This includes changing the API of setupCdrom to no longer take a requirepkgs parameter. Doing that also causes a cascade of having to change findAnacondaCD and all its callers for the same reason. --- loader2/cdinstall.c | 80 ++++++++++++++++--------------------------------- loader2/cdinstall.h | 3 +- loader2/hdinstall.c | 2 +- loader2/loader.c | 37 ++++++++++++----------- loader2/nfsinstall.c | 2 +- loader2/urlinstall.c | 2 +- 6 files changed, 49 insertions(+), 77 deletions(-)
diff --git a/loader2/cdinstall.c b/loader2/cdinstall.c index c6bc1db..a899a29 100644 --- a/loader2/cdinstall.c +++ b/loader2/cdinstall.c @@ -67,6 +67,9 @@ void ejectCdrom(char *device) { } }
+/* Commented out for now due to -Wall -Werror */ +#if 0 + /* * Given cd device cddriver, this function will attempt to check its internal * checksum. @@ -214,27 +217,20 @@ static void queryCDMediaCheck(char *dev, char *location) { } } } +#endif
-/* set up a cdrom, nominally for installation - * - * location: where to mount the cdrom at - * interactive: whether or not to prompt about questions/errors (1 is yes) - * - * loaderData is the kickstart info, can be NULL meaning no info - * - * requirepkgs=1 means CD should have packages, otherwise we just find stage2 +/* Set up a CD/DVD drive to mount the stage2 image from. If successful, the + * stage2 image will be left mounted on /mnt/runtime. * - * side effect: found cdrom is mounted on 'location' (usually /mnt/source, but - * could also be /mnt/stage2 if we're just looking for a stage2 image). stage2 - * mounted on /mnt/runtime. + * location: Where to mount the media at (usually /mnt/stage2) + * interactive: Whether or not to prompt about questions/errors + * loaderData: The usual, can be NULL if no info */ -char * setupCdrom(char * location, struct loaderData_s * loaderData, - int interactive, int requirepkgs) { +char *setupCdrom(char *location, struct loaderData_s *loaderData, + int interactive) { int i, r, rc; - int foundinvalid = 0; int stage2inram = 0; - char *buf, *stage2loc, *discinfoloc; - char *stage2img; + char *buf, *stage2loc, *stage2img; struct device ** devices; char *cddev = NULL;
@@ -244,13 +240,7 @@ char * setupCdrom(char * location, struct loaderData_s * loaderData, return NULL; }
- if (loaderData && FL_STAGE2(flags)) { - stage2loc = strdup(location); - r = asprintf(&discinfoloc, "%s/.discinfo", imageDir); - } else { - r = asprintf(&stage2loc, "%s/images/stage2.img", location); - r = asprintf(&discinfoloc, "%s/.discinfo", location); - } + r = asprintf(&stage2loc, "%s/images/stage2.img", location);
/* JKFIXME: ASSERT -- we have a cdrom device when we get here */ do { @@ -270,36 +260,30 @@ char * setupCdrom(char * location, struct loaderData_s * loaderData,
if (!(rc=doPwMount(devices[i]->device, location, "iso9660", "ro"))) { cddev = devices[i]->device; - if (!access(stage2loc, R_OK) && - (!requirepkgs || !access(discinfoloc, R_OK))) { - + if (!access(stage2loc, R_OK)) { /* if in rescue mode lets copy stage 2 into RAM so we can */ /* free up the CD drive and user can have it avaiable to */ /* aid system recovery. */ if (FL_RESCUE(flags) && !FL_TEXT(flags) && totalMemory() > 128000) { rc = copyFile(stage2loc, "/tmp/stage2.img"); - stage2img = "/tmp/stage2.img"; + stage2img = strdup("/tmp/stage2.img"); stage2inram = 1; } else { stage2img = strdup(stage2loc); stage2inram = 0; } + rc = mountStage2(stage2img); + free(stage2loc); + free(stage2img);
if (rc) { logMessage(INFO, "mounting stage2 failed"); - umount(location); - if (rc == -1) - foundinvalid = 1; continue; }
- /* do the media check */ - if (requirepkgs) - queryCDMediaCheck(devices[i]->device, location); - /* if in rescue mode and we copied stage2 to RAM */ /* we can now unmount the CD */ if (FL_RESCUE(flags) && stage2inram) { @@ -309,14 +293,10 @@ char * setupCdrom(char * location, struct loaderData_s * loaderData, r = asprintf(&buf, "cdrom://%s:%s", devices[i]->device, location);
- free(stage2loc); - free(discinfoloc); - if (r == -1) return NULL; else return buf; - }
/* this wasnt the CD we were looking for, clean up and */ @@ -328,16 +308,11 @@ char * setupCdrom(char * location, struct loaderData_s * loaderData, if (interactive) { char * buf; int i; - if (foundinvalid) - i = asprintf(&buf, _("No %s disc was found which matches your " - "boot media. Please insert the %s disc " - "and press %s to retry."), - getProductName(), getProductName(), _("OK")); - else - i = asprintf(&buf, _("The %s disc was not found in any of your " - "CDROM drives. Please insert the %s disc " - "and press %s to retry."), - getProductName(), getProductName(), _("OK")); + + i = asprintf(&buf, _("The %s disc was not found in any of your " + "CDROM drives. Please insert the %s disc " + "and press %s to retry."), + getProductName(), getProductName(), _("OK"));
ejectCdrom(cddev); rc = newtWinChoice(_("Disc Not Found"), @@ -353,21 +328,18 @@ char * setupCdrom(char * location, struct loaderData_s * loaderData,
err: free(stage2loc); - free(discinfoloc); return NULL; }
/* try to find a install CD non-interactively */ -char * findAnacondaCD(char * location, - int requirepkgs) { - return setupCdrom(location, NULL, 0, requirepkgs); +char * findAnacondaCD(char *location) { + return setupCdrom(location, NULL, 0); }
/* look for a CD and mount it. if we have problems, ask */ char * mountCdromImage(struct installMethod * method, char * location, struct loaderData_s * loaderData) { - - return setupCdrom(location, loaderData, 1, !FL_RESCUE(flags)); + return setupCdrom(location, loaderData, 1); }
void setKickstartCD(struct loaderData_s * loaderData, int argc, char ** argv) { diff --git a/loader2/cdinstall.h b/loader2/cdinstall.h index 5248d51..a0ecbc3 100644 --- a/loader2/cdinstall.h +++ b/loader2/cdinstall.h @@ -25,8 +25,7 @@ char * mountCdromImage(struct installMethod * method, char * location, struct loaderData_s * loaderData);
-char * findAnacondaCD(char * location, int requirepkgs); - +char * findAnacondaCD(char * location);
void setKickstartCD(struct loaderData_s * loaderData, int argc, char ** argv); diff --git a/loader2/hdinstall.c b/loader2/hdinstall.c index 3b99377..87b0713 100644 --- a/loader2/hdinstall.c +++ b/loader2/hdinstall.c @@ -73,7 +73,7 @@ static int loadHDImages(char * prefix, char * dir, * passing stage2= overrides this check. */ if (!FL_STAGE2(flags)) - cdurl = findAnacondaCD("/mnt/stage2", 0); + cdurl = findAnacondaCD("/mnt/stage2");
if (cdurl) { logMessage(INFO, "Detected stage 2 image on CD"); diff --git a/loader2/loader.c b/loader2/loader.c index c3460be..b0ded8e 100644 --- a/loader2/loader.c +++ b/loader2/loader.c @@ -1008,23 +1008,6 @@ static void parseCmdLineFlags(struct loaderData_s * loaderData, } }
- /* Here's how it works: stage2= points to just the location of the - * stage2.img file. repo= points to the installation source. This is - * the same as the old method=, but makes the meaning more explicit. - * If stage2= is not given, we will try to piece together a valid - * setting based on the contents of repo=. If repo= is not given, we - * will try to figure it out once we're in stage2. - */ - if (loaderData->instRepo && !loaderData->stage2Data) { - char *tmp; - int rc; - - rc = asprintf(&tmp, "%s/images/stage2.img", loaderData->instRepo); - logMessage(INFO, "no stage2= given, assuming %s", tmp); - setStage2LocFromCmdline(tmp, loaderData); - free(tmp); - } - readNetInfo(&loaderData);
/* NULL terminates the array of extra args */ @@ -1119,6 +1102,24 @@ static char *doLoaderMain(struct loaderData_s *loaderData, if (url) { setStage2LocFromCmdline(url, loaderData); haveStage2 = 1; + + logMessage(INFO, "Detected stage 2 image on CD"); + winStatus(50, 3, _("Media Detected"), + _("Local installation media detected..."), 0); + sleep(3); + newtPopWindow(); + } else if (loaderData->instRepo) { + /* If no CD/DVD with a stage2 image was found and we were given a + * repo=/method= parameter, try to piece together a valid setting + * for the stage2= parameter based on that. + */ + char *tmp; + int rc; + + rc = asprintf(&tmp, "%s/images/stage2.img", loaderData->instRepo); + logMessage(INFO, "no stage2= given, assuming %s", tmp); + setStage2LocFromCmdline(tmp, loaderData); + free(tmp); } }
@@ -1418,7 +1419,7 @@ static char *doLoaderMain(struct loaderData_s *loaderData,
case STEP_STAGE2: { if (url) { - logMessage(INFO, "got stage2 at url %s", url); + logMessage(INFO, "stage2 url is %s", url); return url; }
diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c index 0be2aaa..9024e3a 100644 --- a/loader2/nfsinstall.c +++ b/loader2/nfsinstall.c @@ -164,7 +164,7 @@ char * mountNfsImage(struct installMethod * method, /* Try to see if we're booted off of a CD with stage2. However, * passing stage2= overrides this check. */ - if (!FL_STAGE2(flags) && (stage2OnCD || findAnacondaCD("/mnt/stage2", 0))) { + if (!FL_STAGE2(flags) && (stage2OnCD || findAnacondaCD("/mnt/stage2"))) { stage2OnCD = 1; logMessage(INFO, "Detected stage 2 image on CD"); winStatus(50, 3, _("Media Detected"), diff --git a/loader2/urlinstall.c b/loader2/urlinstall.c index 9bb230b..7e34d48 100644 --- a/loader2/urlinstall.c +++ b/loader2/urlinstall.c @@ -270,7 +270,7 @@ char * mountUrlImage(struct installMethod * method, * this check. */ if (!FL_STAGE2(flags)) - cdurl = findAnacondaCD(location, 0); + cdurl = findAnacondaCD(location);
if (cdurl) { logMessage(INFO, "Detected stage 2 image on CD");
--- loader2/ftp.c | 9 +-- loader2/ftp.h | 2 +- loader2/urlinstall.c | 200 ++++++++++++++++++++------------------------------ loader2/urls.c | 98 +----------------------- loader2/urls.h | 2 +- 5 files changed, 89 insertions(+), 222 deletions(-)
diff --git a/loader2/ftp.c b/loader2/ftp.c index c636596..ce6deb5 100644 --- a/loader2/ftp.c +++ b/loader2/ftp.c @@ -253,14 +253,13 @@ static int getHostAddress(const char * host, void * address, int family) { }
int ftpOpen(char *host, int family, char *name, char *password, - char *proxy, int port) { + int port) { static int sock; struct in_addr addr; struct in6_addr addr6; struct sockaddr_in destPort; struct sockaddr_in6 destPort6; struct passwd * pw; - char * buf; int rc = 0;
if (port < 0) port = IPPORT_FTP; @@ -280,12 +279,6 @@ int ftpOpen(char *host, int family, char *name, char *password, } }
- if (proxy) { - if (asprintf(&buf, "%s@%s", name, host) != -1) - name = buf; - host = proxy; - } - if (family == AF_INET) rc = getHostAddress(host, &addr, AF_INET); else if (family == AF_INET6) diff --git a/loader2/ftp.h b/loader2/ftp.h index 8753e95..c1e7fcb 100644 --- a/loader2/ftp.h +++ b/loader2/ftp.h @@ -42,7 +42,7 @@ const char * ftpStrerror(int ftpErrno, urlprotocol protocol); #define FTPERR_UNKNOWN -100
int ftpOpen(char * host, int family, char * name, char * password, - char * proxy, int port); + int port); int ftpGetFile(int sock, char * remotename, int dest); int ftpGetFileDesc(int sock, struct in6_addr host, int family, char * remotename); diff --git a/loader2/urlinstall.c b/loader2/urlinstall.c index 7e34d48..dd2d89f 100644 --- a/loader2/urlinstall.c +++ b/loader2/urlinstall.c @@ -102,27 +102,16 @@ static void copyErrorFn (char *msg) { }
static int loadUrlImages(struct iurlinfo * ui) { - char *stage2img, *buf, *path, *tmp; + char *buf, *path, *dest; int rc;
- /* 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. + /* Figure out the path where updates.img and product.img files are + * kept. Since ui->prefix points to a stage2 image file, we just need + * to trim off the file name and look in the same directory. */ - 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) - return 1; - } - else - rc = asprintf(&path, "%s/images", ui->prefix); + path = strndup(ui->prefix, strrchr(ui->prefix, '/') - ui->prefix);
- /* grab the updates.img before netstg1.img so that we minimize our + /* grab the updates.img before stage2.img so that we minimize our * ramdisk usage */ rc = asprintf(&buf, "%s/%s", path, "updates.img"); if (!loadSingleUrlImage(ui, buf, @@ -140,7 +129,7 @@ static int loadUrlImages(struct iurlinfo * ui) {
free(buf);
- /* grab the product.img before netstg1.img so that we minimize our + /* grab the product.img before stage2.img so that we minimize our * ramdisk usage */ rc = asprintf(&buf, "%s/%s", path, "product.img"); if (!loadSingleUrlImage(ui, buf, @@ -155,33 +144,9 @@ static int loadUrlImages(struct iurlinfo * ui) {
free(buf);
- if (!FL_STAGE2(flags)) { - /* require 128MB for use of graphical stage 2 due to size of image */ - if (totalMemory() < GUI_STAGE2_RAM) { - stage2img = "minstg2.img"; - logMessage(WARNING, "URLINSTALL falling back to non-GUI stage2 " - "due to insufficient RAM"); - } 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 { - /* 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); - } - - free(tmp); - free(path); + rc = asprintf(&dest, "/tmp/stage2.img"); + rc = loadSingleUrlImage(ui, ui->prefix, dest, "/mnt/runtime", "/dev/loop0", 0); + free(dest);
if (rc) { if (rc != 2) @@ -205,98 +170,95 @@ static int loadUrlImages(struct iurlinfo * ui) { return 0; }
-char * mountUrlImage(struct installMethod * method, - char * location, struct loaderData_s * loaderData) { - int rc; - char *url; +char *mountUrlImage(struct installMethod *method, char *location, + struct loaderData_s *loaderData) { struct iurlinfo ui; - char needsSecondary = ' '; - char * cdurl = NULL; + char *url = NULL; + int rc;
- enum { URL_STAGE_MAIN, URL_STAGE_SECOND, URL_STAGE_FETCH, + enum { URL_STAGE_MAIN, URL_STAGE_FETCH, URL_STAGE_DONE } stage = URL_STAGE_MAIN;
memset(&ui, 0, sizeof(ui));
while (stage != URL_STAGE_DONE) { switch(stage) { - case URL_STAGE_MAIN: - if (loaderData->method == METHOD_URL && loaderData->stage2Data) { - url = ((struct urlInstallData *)loaderData->stage2Data)->url; - logMessage(INFO, "URL_STAGE_MAIN - url is %s", url); - - if (!url) { - logMessage(ERROR, "missing url specification"); - flags &= ~LOADER_FLAGS_STAGE2; - loaderData->method = -1; + case URL_STAGE_MAIN: { + /* If the stage2= parameter was given (or inferred from repo=) + * then use that configuration info to fetch the image. This + * could also have come from kickstart. Else, we need to show + * the UI. + */ + if (loaderData->method == METHOD_URL && loaderData->stage2Data) { + url = ((struct urlInstallData *) loaderData->stage2Data)->url; + logMessage(INFO, "URL_STAGE_MAIN: url is %s", url); + + if (!url) { + logMessage(ERROR, "missing URL specification"); + loaderData->method = -1; + free(loaderData->stage2Data); + loaderData->stage2Data = NULL; + break; + } + + /* explode url into ui struct */ + convertURLToUI(url, &ui); + + /* ks info was adequate, lets skip to fetching image */ + stage = URL_STAGE_FETCH; break; + } else { + char *substr; + + if (urlMainSetupPanel(&ui)) + return NULL; + + /* If the user-provided URL points at a repo instead of + * a stage2 image, fix it up now. + */ + substr = strstr(ui.prefix, ".img"); + if (!substr || (substr && *(substr+4) != '\0')) { + char *stage2img; + + /* Pick the right stage2 image depending on the + * amount of memory. + */ + if (totalMemory() < GUI_STAGE2_RAM) { + stage2img = "minstg2.img"; + logMessage(WARNING, "URLINSTALL falling back to non-GUI stage2 " + "due to insufficient RAM"); + } else { + stage2img = "stage2.img"; + } + + rc = asprintf(&ui.prefix, "%s/images/%s", ui.prefix, stage2img); + } }
- /* explode url into ui struct */ - convertURLToUI(url, &ui); - - /* ks info was adequate, lets skip to fetching image */ - stage = URL_STAGE_FETCH; - break; - } else { - flags &= ~LOADER_FLAGS_STAGE2; - - if (urlMainSetupPanel(&ui, &needsSecondary)) - return NULL; + stage = URL_STAGE_FETCH; + break; }
- /* got required information from user, proceed */ - stage = (needsSecondary != ' ') ? URL_STAGE_SECOND : - URL_STAGE_FETCH; - break; + case URL_STAGE_FETCH: { + if (FL_TESTING(flags)) { + stage = URL_STAGE_DONE; + break; + }
- case URL_STAGE_SECOND: - rc = urlSecondarySetupPanel(&ui); - if (rc) { - stage = URL_STAGE_MAIN; - } else { - stage = URL_STAGE_FETCH; - } - break; + if (loadUrlImages(&ui)) { + stage = URL_STAGE_MAIN; + + if (loaderData->method >= 0) + loaderData->method = -1; + } else { + stage = URL_STAGE_DONE; + }
- case URL_STAGE_FETCH: - if (FL_TESTING(flags)) { - stage = URL_STAGE_DONE; break; }
- /* See if we have a stage2 on a local CD before trying to pull - * one over the network. However, passing stage2= overrides - * this check. - */ - if (!FL_STAGE2(flags)) - cdurl = findAnacondaCD(location); - - if (cdurl) { - logMessage(INFO, "Detected stage 2 image on CD"); - winStatus(50, 3, _("Media Detected"), - _("Local installation media detected..."), 0); - sleep(3); - newtPopWindow(); - - stage = URL_STAGE_DONE; - } 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; - } - } - break; - - case URL_STAGE_DONE: - break; + case URL_STAGE_DONE: + break; } }
diff --git a/loader2/urls.c b/loader2/urls.c index 43006ac..fae48a3 100644 --- a/loader2/urls.c +++ b/loader2/urls.c @@ -199,7 +199,7 @@ int urlinstStartTransfer(struct iurlinfo * ui, char *path, ui->ftpPort = ftpOpen(hostname, family, ui->login ? ui->login : "anonymous", ui->password ? ui->password : "rhinstall@", - NULL, port); + port); if (ui->ftpPort < 0) { if (hostname) free(hostname); return -2; @@ -258,9 +258,9 @@ char * addrToIp(char * hostname) { return NULL; }
-int urlMainSetupPanel(struct iurlinfo * ui, char * doSecondarySetup) { +int urlMainSetupPanel(struct iurlinfo * ui) { newtComponent form, okay, cancel, urlEntry; - newtComponent answer, text, proxyCheckbox; + newtComponent answer, text; char *url = ""; char * reflowedText = NULL; int width, height; @@ -269,11 +269,6 @@ int urlMainSetupPanel(struct iurlinfo * ui, char * doSecondarySetup) { char * buf = NULL; int r;
- if (ui && (ui->login || ui->password || ui->proxy || ui->proxyPort)) - *doSecondarySetup = '*'; - else - *doSecondarySetup = ' '; - /* Populate the UI with whatever initial value we've got. */ if (ui && ui->prefix) url = convertUIToURL(ui); @@ -291,17 +286,13 @@ int urlMainSetupPanel(struct iurlinfo * ui, char * doSecondarySetup) {
urlEntry = newtEntry(22, 8, url, 60, (const char **) &url, NEWT_ENTRY_SCROLL); - proxyCheckbox = newtCheckbox(-1, -1, _("Configure proxy"), *doSecondarySetup, - NULL, doSecondarySetup);
- grid = newtCreateGrid(1, 4); + grid = newtCreateGrid(1, 3); newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, text, 0, 0, 0, 1, 0, 0); newtGridSetField(grid, 0, 1, NEWT_GRID_COMPONENT, urlEntry, 0, 0, 0, 1, 0, 0); - newtGridSetField(grid, 0, 2, NEWT_GRID_COMPONENT, proxyCheckbox, - 0, 0, 0, 1, 0, 0); - newtGridSetField(grid, 0, 3, NEWT_GRID_SUBGRID, buttons, + newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, buttons, 0, 0, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
form = newtForm(NULL, NULL, 0); @@ -353,87 +344,8 @@ int urlMainSetupPanel(struct iurlinfo * ui, char * doSecondarySetup) { chptr++; *chptr = '\0';
- if (*doSecondarySetup != '*') { - if (ui->proxy) - free(ui->proxy); - if (ui->proxyPort) - free(ui->proxyPort); - - ui->proxy = ui->proxyPort = NULL; - } - - newtFormDestroy(form); - newtPopWindow(); - - return 0; -} - -int urlSecondarySetupPanel(struct iurlinfo * ui) { - newtComponent form, okay, cancel, answer, text; - newtComponent proxyEntry = NULL; - newtComponent proxyPortEntry = NULL; - char * proxy, * proxyPort; - newtGrid buttons, entryGrid, grid; - char * reflowedText = NULL; - int width, height; - - reflowedText = newtReflowText( - _("If you are using a HTTP proxy server " - "enter the name of the HTTP proxy server to use."), - 47, 5, 5, &width, &height); - - text = newtTextbox(-1, -1, width, height, NEWT_TEXTBOX_WRAP); - newtTextboxSetText(text, reflowedText); - free(reflowedText); - - proxyEntry = newtEntry(-1, -1, ui->proxy, 24, (const char **) &proxy, - NEWT_ENTRY_SCROLL); - proxyPortEntry = newtEntry(-1, -1, ui->proxyPort, 6, - (const char **) &proxyPort, NEWT_FLAG_SCROLL); - - entryGrid = newtCreateGrid(2, 2); - newtGridSetField(entryGrid, 0, 0, NEWT_GRID_COMPONENT, - newtLabel(-1, -1, _("Proxy Name:")), - 0, 0, 2, 0, NEWT_ANCHOR_LEFT, 0); - newtGridSetField(entryGrid, 1, 0, NEWT_GRID_COMPONENT, proxyEntry, - 0, 0, 0, 0, 0, 0); - newtGridSetField(entryGrid, 0, 1, NEWT_GRID_COMPONENT, - newtLabel(-1, -1, _("Proxy Port:")), - 0, 0, 2, 0, NEWT_ANCHOR_LEFT, 0); - newtGridSetField(entryGrid, 1, 1, NEWT_GRID_COMPONENT, proxyPortEntry, - 0, 0, 0, 0, 0, 0); - - buttons = newtButtonBar(_("OK"), &okay, _("Back"), &cancel, NULL); - - grid = newtCreateGrid(1, 3); - newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, text, 0, 0, 0, 0, 0, 0); - newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, entryGrid, - 0, 1, 0, 0, 0, 0); - newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, buttons, - 0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX); - - form = newtForm(NULL, NULL, 0); - newtGridAddComponentsToForm(grid, form, 1); - newtGridWrappedWindow(grid, _("Further Setup")); - newtGridFree(grid, 1); - - answer = newtRunForm(form); - if (answer == cancel) { - newtFormDestroy(form); - newtPopWindow(); - - return LOADER_BACK; - } - - if (strlen(proxy)) - ui->proxy = strdup(proxy); - if (strlen(proxyPort)) - ui->proxyPort = strdup(proxyPort); - newtFormDestroy(form); newtPopWindow();
return 0; } - -/* vim:set shiftwidth=4 softtabstop=4: */ diff --git a/loader2/urls.h b/loader2/urls.h index 046ee72..75761ac 100644 --- a/loader2/urls.h +++ b/loader2/urls.h @@ -38,7 +38,7 @@ int convertURLToUI(char *url, struct iurlinfo *ui); char *convertUIToURL(struct iurlinfo *ui);
int setupRemote(struct iurlinfo * ui); -int urlMainSetupPanel(struct iurlinfo * ui, char * doSecondarySetup); +int urlMainSetupPanel(struct iurlinfo * ui); int urlSecondarySetupPanel(struct iurlinfo * ui); int urlinstStartTransfer(struct iurlinfo * ui, char *path, char *extraHeaders); int urlinstFinishTransfer(struct iurlinfo * ui, int fd);
--- loader2/hdinstall.c | 218 +++++++++++---------------------------------------- 1 files changed, 45 insertions(+), 173 deletions(-)
diff --git a/loader2/hdinstall.c b/loader2/hdinstall.c index 87b0713..1f0ea69 100644 --- a/loader2/hdinstall.c +++ b/loader2/hdinstall.c @@ -54,110 +54,10 @@ /* boot flags */ extern uint64_t flags;
-/* Pull in second stage image for hard drive install. This is only used - * if method= is passed, not if stage2= is pased. - */ -static int loadHDImages(char * prefix, char * dir, - char * device, char * mntpoint, - char * location) { - int fd = 0, rc, idx, tmp; - char *path = NULL, *target = NULL, *dest, *cdurl = NULL; - char *stg2list[] = {"stage2.img", "minstg2.img", NULL}; - - if (totalMemory() < 128000) - idx = 1; - else - idx = 0; - - /* Try to see if we're booted off of a CD with stage2. However, - * passing stage2= overrides this check. - */ - if (!FL_STAGE2(flags)) - cdurl = findAnacondaCD("/mnt/stage2"); - - if (cdurl) { - logMessage(INFO, "Detected stage 2 image on CD"); - winStatus(50, 3, _("Media Detected"), - _("Local installation media detected..."), 0); - sleep(3); - newtPopWindow(); - rc = 0; - } else { - target = NULL; - for (; stg2list[idx]; idx++) { - target = stg2list[idx]; - - if (path) - free(path); - - if (!dir || (dir && (!strcmp(dir, "/") || strcmp(dir, "")))) - tmp = asprintf(&path, "%s/images/%s", prefix, target); - else - tmp = asprintf(&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)); - free(path); - 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)); - free(path); - return 1; - } - - free(path); - } - - /* handle updates.img now before we copy stage2 over... this allows - * us to keep our ramdisk size as small as possible */ - tmp = asprintf(&path, "%s/%s/images/updates.img", prefix, dir ? dir : ""); - copyUpdatesImg(path); - free(path); - - /* handle product.img now before we copy stage2 over... this allows - * us to keep our ramdisk size as small as possible */ - tmp = asprintf(&path, "%s/%s/images/product.img", prefix, dir ? dir : ""); - copyProductImg(path); - free(path); - - if (!cdurl) { - dest = alloca(strlen(target) + 50); - sprintf(dest,"/tmp/%s", target); - rc = copyFileAndLoopbackMount(fd, dest, device, mntpoint); - close(fd); - - if (!verifyStamp(mntpoint)) { - char * buf; - fd = asprintf(&buf, - _("The %s installation tree in that directory does " - "not seem to match your boot media."), - getProductName()); - - newtWinMessage(_("Error"), _("OK"), buf); - free(buf); - umountLoopback(mntpoint, device); - return 1; - } - } - - return rc; -} - /* given a partition device and directory, tries to mount hd install image */ static char * setupIsoImages(char * device, char * dirName, char * location) { int rc; - char *url = NULL, *dirspec, *updpath; - char *path; + char *url = NULL, *dirspec, *updpath, *path; char *typetry[] = {"ext3", "ext2", "vfat", NULL}; char **type;
@@ -173,75 +73,37 @@ static char * setupIsoImages(char * device, char * dirName, char * location) { if (!type) return NULL;
- if (FL_STAGE2(flags)) { - rc = asprintf(&dirspec, "/mnt/isodir%.*s", (int) (strrchr(dirName, '/') - dirName), dirName); - rc = asprintf(&path, "/mnt/isodir%s", dirName); - } else { - if (*dirName == '/') - rc = asprintf(&dirspec, "/mnt/isodir%s", dirName); - else - rc = asprintf(&dirspec, "/mnt/isodir/%s", dirName); - - path = validIsoImages(dirspec, 0, 1); - } + rc = asprintf(&dirspec, "/mnt/isodir%.*s", (int) (strrchr(dirName, '/') - dirName), dirName); + rc = asprintf(&path, "/mnt/isodir%s", dirName);
if (path) { - logMessage(INFO, "Path to valid iso is %s", path); + logMessage(INFO, "Path to stage2 image is %s", path);
rc = asprintf(&updpath, "%s/updates.img", dirspec); logMessage(INFO, "Looking for updates for HD in %s", updpath); copyUpdatesImg(updpath);
+ rc = asprintf(&updpath, "%s/product.img", dirspec); + logMessage(INFO, "Looking for product for HD in %s", updpath); + copyProductImg(updpath); + + rc = mountStage2(path); + free(updpath); free(dirspec); + free(path);
- if (FL_STAGE2(flags)) { - if (!copyFile(path, "/tmp/stage2.img")) { - rc = mountStage2("/tmp/stage2.img"); - 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); - umount("/mnt/isodir"); - flags &= ~LOADER_FLAGS_STAGE2; - goto err; - } - } - - rc = mountLoopback(path, "/mnt/source", "/dev/loop1"); - if (!rc) { - /* This code is for copying small stage2 into ram */ - /* and mounting */ - rc = loadHDImages("/mnt/source", "/", "/dev/loop0", - "/mnt/runtime", location); - umountLoopback("/mnt/source", "/dev/loop1"); - - if (rc) { - umount("/mnt/isodir"); - free(path); - goto err; - } else { - queryIsoMediaCheck(path); - free(path); - rc = asprintf(&url, "hd:%s:%s:/%s", device, - *type, dirName ? dirName : "."); - return url; - } + if (rc) { + umountLoopback("/mnt/runtime", "/dev/loop0"); + goto err; + } else { + rc = asprintf(&url, "hd:%s:%s:/%s", device, *type, + dirName ? dirName : "."); + return url; } } else { free(dirspec); + free(path);
if (rc) { umount("/mnt/isodir"); @@ -277,18 +139,18 @@ char * mountHardDrive(struct installMethod * method, char * dir = strdup(""); char * tmpDir; char * url = NULL; - char * buf; + char * buf, *stage2img; int numPartitions;
char **partition_list; char *selpart; char *kspartition, *ksdirectory;
- /* handle kickstart data first if available */ + /* handle kickstart/stage2= data first if available */ if (loaderData->method == METHOD_HD && loaderData->stage2Data) { kspartition = ((struct hdInstallData *)loaderData->stage2Data)->partition; ksdirectory = ((struct hdInstallData *)loaderData->stage2Data)->directory; - logMessage(INFO, "partition is %s, dir is %s", kspartition, ksdirectory); + logMessage(INFO, "partition is %s, dir is %s", kspartition, ksdirectory);
/* if exist, duplicate */ if (kspartition) @@ -350,20 +212,20 @@ char * mountHardDrive(struct installMethod * method, continue; }
- /* now find out which partition has the hard drive install images */ + /* now find out which partition has the stage2 image*/ rc = asprintf(&buf, _("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."), + "partition hold the installation 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)); - + for (i = 0; i < numPartitions; i++) newtListboxAppendEntry(listbox,partition_list[i],partition_list[i]);
@@ -391,7 +253,7 @@ char * mountHardDrive(struct installMethod * method, NEWT_GRID_EMPTY);
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); @@ -401,9 +263,9 @@ char * mountHardDrive(struct installMethod * method, 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")); - + form = newtForm(NULL, NULL, 0); newtFormAddHotKey(form, NEWT_KEY_F2); newtFormAddHotKey(form, NEWT_KEY_F12); @@ -414,7 +276,7 @@ char * mountHardDrive(struct installMethod * method, newtFormRun(form, &es);
selpart = newtListboxGetCurrent(listbox); - + free(dir); if (tmpDir && *tmpDir) { /* Protect from form free. */ @@ -422,7 +284,7 @@ char * mountHardDrive(struct installMethod * method, } else { dir = strdup(""); } - + newtFormDestroy(form); newtPopWindow();
@@ -437,7 +299,17 @@ char * mountHardDrive(struct installMethod * method, }
logMessage(INFO, "partition %s selected", selpart); - + + /* The user-provided dir points at a repo instead of a stage2 + * image, so we have to fix that up now. + */ + if (totalMemory() < GUI_STAGE2_RAM) + stage2img = "minstg2.img"; + else + stage2img = "stage2.img"; + + rc = asprintf(&dir, "%s/%s", dir, stage2img); + url = setupIsoImages(selpart, dir, location); if (!url) { newtWinMessage(_("Error"), _("OK"),
--- loader2/nfsinstall.c | 155 +++++++++----------------------------------------- 1 files changed, 28 insertions(+), 127 deletions(-)
diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c index 9024e3a..fe1fae9 100644 --- a/loader2/nfsinstall.c +++ b/loader2/nfsinstall.c @@ -83,22 +83,6 @@ int nfsGetSetup(char ** hostptr, char ** dirptr) { return 0; }
-/* Check if we are using an nfsiso installation method. Assumptions: nothing - * is mounted before this function is called, /mnt/isodir is mounted at the - * end if we are doing nfsiso. - */ -static char *isNfsIso(char *fullPath, char *mountOpts, int *foundinvalid, - int checkStage2) { - char *path = NULL; - - if (!doPwMount(fullPath, "/mnt/isodir", "nfs", mountOpts)) { - if ((path = validIsoImages("/mnt/isodir", foundinvalid, checkStage2)) == NULL) - umount("/mnt/isodir"); - } - - return path; -} - char * mountNfsImage(struct installMethod * method, char * location, struct loaderData_s * loaderData) { char * host = NULL; @@ -110,8 +94,7 @@ char * mountNfsImage(struct installMethod * method, enum { NFS_STAGE_NFS, NFS_STAGE_MOUNT, NFS_STAGE_DONE } stage = NFS_STAGE_NFS;
- int rc, tmp, foundinvalid = 0; - int stage2OnCD = 0; + int rc, foundinvalid = 0;
/* JKFIXME: ASSERT -- we have a network device setup when we get here */ while (stage != NFS_STAGE_DONE) { @@ -131,16 +114,29 @@ char * mountNfsImage(struct installMethod * method,
if (!host || !directory) { logMessage(ERROR, "missing host or directory specification"); - flags &= ~LOADER_FLAGS_STAGE2; loaderData->method = -1; break; } else { host = strdup(host); directory = strdup(directory); } - } else if (nfsGetSetup(&host, &directory) == LOADER_BACK) { - flags &= ~LOADER_FLAGS_STAGE2; - return NULL; + } else { + char *stage2img, *substr; + + if (nfsGetSetup(&host, &directory) == LOADER_BACK) + return NULL; + + if (totalMemory() < GUI_STAGE2_RAM) + stage2img = "minstg2.img"; + else + stage2img = "stage2.img"; + + /* If the user-provided URL points at a repo instead of a + * stage2 image, fix that up now. + */ + substr = strstr(directory, ".img"); + if (!substr || (substr && *(substr+4) != '\0')) + rc = asprintf(&directory, "%s/images/%s", directory, stage2img); }
stage = NFS_STAGE_MOUNT; @@ -153,67 +149,14 @@ 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 >= 0) { + if (loaderData->method >= 0) loaderData->method = -1; - } - - flags &= ~LOADER_FLAGS_STAGE2; - break; - } - - /* Try to see if we're booted off of a CD with stage2. However, - * passing stage2= overrides this check. - */ - if (!FL_STAGE2(flags) && (stage2OnCD || findAnacondaCD("/mnt/stage2"))) { - stage2OnCD = 1; - logMessage(INFO, "Detected stage 2 image on CD"); - winStatus(50, 3, _("Media Detected"), - _("Local installation media detected..."), 0); - sleep(3); - newtPopWindow(); - - tmp = asprintf(&fullPath, "%s:%s", host, directory); - - if ((buf = isNfsIso(fullPath, mountOpts, &foundinvalid, 0)) != NULL) - rc = asprintf(&url, "nfsiso:%s:%s", host, directory); - else { - /* FIXME: Mount the NFS source here to make sure we - * were given a valid source. We'll leave it mounted - * going into stage2 just so we're not mounting and - * unmounting repeatedly. This can go once the repo - * editor supports NFS. - */ - if (!doPwMount(fullPath, "/mnt/source", "nfs", mountOpts)) { - rc = asprintf(&url, "nfs:%s:%s", host, directory); - } else { - newtWinMessage(_("Error"), _("OK"), - _("That directory could not be mounted from " - "the server.")); - stage = NFS_STAGE_NFS; - if (loaderData->method >= 0) { - loaderData->method = -1; - } - break; - } - }
- stage = NFS_STAGE_DONE; - free(buf); break; }
- if (FL_STAGE2(flags)) { - if (!strrchr(directory, '/')) { - flags &= ~LOADER_FLAGS_STAGE2; - return NULL; - } else { - tmp = asprintf(&fullPath, "%s:%.*s/", host, - (int) (strrchr(directory, '/') - directory), directory); - } - } - else - tmp = asprintf(&fullPath, "%s:%s", host, directory); - + rc = asprintf(&fullPath, "%s:%.*s", host, (int) (strrchr(directory, '/')-directory), + directory); logMessage(INFO, "mounting nfs path %s", fullPath);
if (FL_TESTING(flags)) { @@ -223,11 +166,8 @@ char * mountNfsImage(struct installMethod * method,
stage = NFS_STAGE_NFS;
- if (!doPwMount(fullPath, "/mnt/source", "nfs", mountOpts)) { - if (FL_STAGE2(flags)) - tmp = asprintf(&buf, "/mnt/source/%s", strrchr(directory, '/')); - else - buf = strdup("/mnt/source/images/stage2.img"); + if (!doPwMount(fullPath, "/mnt/stage2", "nfs", mountOpts)) { + rc = asprintf(&buf, "/mnt/stage2/%s", strrchr(directory, '/'));
if (!access(buf, R_OK)) { logMessage(INFO, "can access %s", buf); @@ -236,7 +176,7 @@ char * mountNfsImage(struct installMethod * method, if (rc == -1) { foundinvalid = 1; logMessage(WARNING, "not the right stage2 image"); - umount("/mnt/source"); + umount("/mnt/stage2"); free(buf); } else if (rc == 0) { stage = NFS_STAGE_DONE; @@ -249,54 +189,17 @@ char * mountNfsImage(struct installMethod * method, break; } } else { - char *path; - logMessage(WARNING, "unable to access %s", buf); free(buf); - umount("/mnt/source"); - - if ((path = isNfsIso(fullPath, mountOpts, &foundinvalid, 1)) != NULL) { - /* If we get here, it wasn't a regular NFS method but it may - * still be NFSISO. Remount on the isodir mountpoint and try - * again. - */ - logMessage(INFO, "Path to valid iso is %s", path); - copyUpdatesImg("/mnt/isodir/updates.img"); - - if (mountLoopback(path, "/mnt/source", "/dev/loop1")) { - logMessage(WARNING, "failed to mount iso %s loopback", path); - free(path); - } else { - if (FL_STAGE2(flags)) - tmp = asprintf(&buf, "/mnt/source/%s", strrchr(directory, '/')); - else - buf = strdup("/mnt/source/images/stage2.img"); - - rc = copyFile(buf, "/tmp/stage2.img"); - rc = mountStage2("/tmp/stage2.img"); - umountLoopback("/mnt/source", "/dev/loop1"); - - free(buf); - free(path); - - if (rc && rc == -1) { - foundinvalid = 1; - umount("/mnt/isodir"); - } else { - stage = NFS_STAGE_DONE; - rc = asprintf(&url, "nfsiso:%s:%s", host, directory); - break; - } - } - } + umount("/mnt/stage2"); } } else { newtWinMessage(_("Error"), _("OK"), _("That directory could not be mounted from " "the server.")); - if (loaderData->method >= 0) { + if (loaderData->method >= 0) loaderData->method = -1; - } + break; }
@@ -312,11 +215,9 @@ char * mountNfsImage(struct installMethod * method, newtWinMessage(_("Error"), _("OK"), buf); free(buf);
- if (loaderData->method >= 0) { + if (loaderData->method >= 0) loaderData->method = -1; - }
- flags &= ~LOADER_FLAGS_STAGE2; break; }
--- loader2/loader.h | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/loader2/loader.h b/loader2/loader.h index 5c038fb..10c81ed 100644 --- a/loader2/loader.h +++ b/loader2/loader.h @@ -45,7 +45,7 @@ #define LOADER_FLAGS_HALT (((uint64_t) 1) << 13) #define LOADER_FLAGS_SELINUX (((uint64_t) 1) << 14) #define LOADER_FLAGS_VIRTPCONSOLE (((uint64_t) 1) << 15) -#define LOADER_FLAGS_STAGE2 (((uint64_t) 1) << 16) +/* #16 unused */ #define LOADER_FLAGS_NOSHELL (((uint64_t) 1) << 17) #define LOADER_FLAGS_NOPCMCIA (((uint64_t) 1) << 18) #define LOADER_FLAGS_TELNETD (((uint64_t) 1) << 19) @@ -79,7 +79,6 @@ #define FL_SERIAL(a) ((a) & LOADER_FLAGS_SERIAL) #define FL_UPDATES(a) ((a) & LOADER_FLAGS_UPDATES) #define FL_KSFILE(a) ((a) & LOADER_FLAGS_KSFILE) -#define FL_STAGE2(a) ((a) & LOADER_FLAGS_STAGE2) #define FL_NOSHELL(a) ((a) & LOADER_FLAGS_NOSHELL) #define FL_TELNETD(a) ((a) & LOADER_FLAGS_TELNETD) #define FL_NOPASS(a) ((a) & LOADER_FLAGS_NOPASS)
--- loader2/nfsinstall.c | 28 +++++++++++++++++++++++++--- 1 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c index fe1fae9..4ba3d29 100644 --- a/loader2/nfsinstall.c +++ b/loader2/nfsinstall.c @@ -30,6 +30,7 @@ #include <string.h> #include <unistd.h>
+#include "copy.h" #include "loader.h" #include "lang.h" #include "loadermisc.h" @@ -91,8 +92,8 @@ char * mountNfsImage(struct installMethod * method, char * fullPath = NULL; char * url = NULL;
- enum { NFS_STAGE_NFS, NFS_STAGE_MOUNT, - NFS_STAGE_DONE } stage = NFS_STAGE_NFS; + enum { NFS_STAGE_NFS, NFS_STAGE_MOUNT, NFS_STAGE_DONE, + NFS_STAGE_UPDATES } stage = NFS_STAGE_NFS;
int rc, foundinvalid = 0;
@@ -179,7 +180,7 @@ char * mountNfsImage(struct installMethod * method, umount("/mnt/stage2"); free(buf); } else if (rc == 0) { - stage = NFS_STAGE_DONE; + stage = NFS_STAGE_UPDATES; rc = asprintf(&url, "nfs:%s:%s", host, directory); free(buf); break; @@ -221,6 +222,27 @@ char * mountNfsImage(struct installMethod * method, break; }
+ case NFS_STAGE_UPDATES: { + char *buf; + int rc; + + rc = asprintf(&buf, "%.*s/RHupdates", (int) (strrchr(fullPath, '/')-fullPath), + fullPath); + logMessage(INFO, "mounting nfs path %s for updates", buf); + + if (!doPwMount(buf, "/tmp/update-disk", "nfs", mountOpts)) { + logMessage(INFO, "Using RHupdates/ for NFS install"); + copyDirectory("/tmp/update-disk", "/tmp/updates", NULL, NULL); + umount("/tmp/update-disk"); + unlink("/tmp/update-disk"); + } else { + logMessage(INFO, "No RHupdates/ directory found, skipping"); + } + + stage = NFS_STAGE_DONE; + break; + } + case NFS_STAGE_DONE: break; }
--- loader2/loader.c | 12 ++---------- loader2/loader.h | 3 +-- 2 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/loader2/loader.c b/loader2/loader.c index b0ded8e..d3b75e6 100644 --- a/loader2/loader.c +++ b/loader2/loader.c @@ -794,10 +794,8 @@ static void parseCmdLineFlags(struct loaderData_s * loaderData, if (!strcasecmp(argv[i], "expert")) { flags |= LOADER_FLAGS_EXPERT; logMessage(INFO, "expert got used, ignoring"); - /* flags |= (LOADER_FLAGS_EXPERT | LOADER_FLAGS_MODDISK | - LOADER_FLAGS_ASKMETHOD);*/ - } else if (!strcasecmp(argv[i], "askmethod")) - flags |= LOADER_FLAGS_ASKMETHOD; + /* flags |= (LOADER_FLAGS_EXPERT | LOADER_FLAGS_MODDISK);*/ + } else if (!strcasecmp(argv[i], "asknetwork")) flags |= LOADER_FLAGS_ASKNETWORK; else if (!strcasecmp(argv[i], "noshell")) @@ -1087,12 +1085,6 @@ static char *doLoaderMain(struct loaderData_s *loaderData, if (!FL_CMDLINE(flags)) startNewt();
- /* have we preselected this to be our install method? */ - if (loaderData->method >= 0) { - /* disable the fast path (#102652) */ - flags |= LOADER_FLAGS_ASKMETHOD; - } - /* Before anything else, see if there's a CD/DVD with a stage2 image on * it. However if stage2= was given, use that value as an override here. * That will also then bypass any method selection UI in loader. diff --git a/loader2/loader.h b/loader2/loader.h index 10c81ed..0fe7037 100644 --- a/loader2/loader.h +++ b/loader2/loader.h @@ -53,7 +53,7 @@ /* #21 unused */ #define LOADER_FLAGS_MEDIACHECK (((uint64_t) 1) << 22) /* #23 unused */ -#define LOADER_FLAGS_ASKMETHOD (((uint64_t) 1) << 24) +/* #24 unused */ #define LOADER_FLAGS_ASKNETWORK (((uint64_t) 1) << 25) /* #26 unused */ /* #27 unused */ @@ -83,7 +83,6 @@ #define FL_TELNETD(a) ((a) & LOADER_FLAGS_TELNETD) #define FL_NOPASS(a) ((a) & LOADER_FLAGS_NOPASS) #define FL_MEDIACHECK(a) ((a) & LOADER_FLAGS_MEDIACHECK) -#define FL_ASKMETHOD(a) ((a) & LOADER_FLAGS_ASKMETHOD) #define FL_GRAPHICAL(a) ((a) & LOADER_FLAGS_GRAPHICAL) #define FL_CMDLINE(a) ((a) & LOADER_FLAGS_CMDLINE) #define FL_HALT(a) ((a) & LOADER_FLAGS_HALT)
--- loader2/method.c | 110 -------------------------------------------------- loader2/method.h | 3 - loader2/nfsinstall.c | 20 ++------- loader2/urlinstall.c | 12 ----- 4 files changed, 5 insertions(+), 140 deletions(-)
diff --git a/loader2/method.c b/loader2/method.c index f1eb55d..66dff42 100644 --- a/loader2/method.c +++ b/loader2/method.c @@ -111,67 +111,6 @@ int mountLoopback(char *fsystem, char *mntpoint, char *device) { }
/* returns the *absolute* path (malloced) to the #1 iso image */ -char * validIsoImages(char * dirName, int *foundinvalid, int checkStage2) { - DIR * dir; - struct dirent * ent; - char isoImage[1024]; - - if (!(dir = opendir(dirName))) { - newtWinMessage(_("Error"), _("OK"), - _("Failed to read directory %s: %s"), - dirName, strerror(errno)); - return 0; - } - - /* Walk through the directories looking for a CD image. */ - errno = 0; - while ((ent = readdir(dir))) { - if (*ent->d_name == '/') - snprintf(isoImage, sizeof(isoImage), "%s%s", dirName, ent->d_name); - else - snprintf(isoImage, sizeof(isoImage), "%s/%s", dirName, ent->d_name); - - if (!fileIsIso(isoImage)) { - errno = 0; - continue; - } - - if (mountLoopback(isoImage, "/tmp/loopimage", "/dev/loop7")) { - logMessage(WARNING, "failed to mount %s", isoImage); - errno = 0; - continue; - } - - if (!checkStage2) { - umountLoopback("/tmp/loopimage", "/dev/loop7"); - break; - } - - if (mountLoopback("/tmp/loopimage/images/stage2.img", "/mnt/runtime", "/dev/loop0")) { - umountLoopback("/mnt/runtime", "/dev/loop0"); - } else { - if (verifyStamp("/mnt/runtime")) { - umountLoopback("/mnt/runtime", "/dev/loop0"); - umountLoopback("/tmp/loopimage", "/dev/loop7"); - break; - } - logMessage(ERROR, "disc %s is not the right image", isoImage); - umountLoopback("/mnt/runtime", "/dev/loop0"); - if (foundinvalid) *foundinvalid = 1; - } - - umountLoopback("/tmp/loopimage", "/dev/loop7"); - - errno = 0; - } - - closedir(dir); - - if (!ent) return NULL; - - return strdup(isoImage); -} - /* get timestamp and description of ISO image from stamp file */ /* returns 0 on success, -1 otherwise */ int readStampFileFromIso(char *file, char **timestamp, char **releasedescr) { @@ -478,50 +417,6 @@ void copyProductImg(char * path) { } }
- -/* verify that the stamp files in / of the initrd and the stage2 match */ -int verifyStamp(char * path) { - char *stamp1; - char *stamp2; - FILE *f; - int fail = 0; - int i; - char * p, *q; - - stamp1 = alloca(80); - stamp2 = alloca(80); - - /* grab the one from the initrd */ - f = fopen("/.buildstamp", "r"); - if (!f) { - fail = 1; - } else { - q = fgets(stamp1, 80, f); - fclose(f); - - /* and the runtime */ - i = asprintf(&p, "%s/.buildstamp", path); - f = fopen(p, "r"); - free(p); - if (!f) { - fail = 1; - } else { - q = fgets(stamp2, 80, f); - fclose(f); - - if (strcmp(stamp1, stamp2) != 0) { - fail = 1; - } - } - } - - if (fail == 1) { - return 0; - } else { - return 1; - } -} - /* unmount a second stage, if mounted. Used for CDs and mediacheck mostly, so we can eject CDs. */ void umountStage2(void) { @@ -539,11 +434,6 @@ int mountStage2(char *stage2path) { return 1; }
- if (!verifyStamp("/mnt/runtime")) { - umountLoopback("/mnt/runtime", "/dev/loop0"); - return -1; - } - return 0; }
diff --git a/loader2/method.h b/loader2/method.h index 36f67f3..e1918ae 100644 --- a/loader2/method.h +++ b/loader2/method.h @@ -43,12 +43,9 @@ struct installMethod { int umountLoopback(char * mntpoint, char * device); int mountLoopback(char * fsystem, char * mntpoint, char * device);
-char * validIsoImages(char * dirName, int *foundinvalid, int checkStage2); int readStampFileFromIso(char *file, char **descr, char **timestamp); void queryIsoMediaCheck(char * isoDir);
-int verifyStamp(char * path); - void umountStage2(void); int mountStage2(char *stage2path); int copyFileAndLoopbackMount(int fd, char *dest, char *device, char *mntpoint); diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c index 4ba3d29..9ee5f09 100644 --- a/loader2/nfsinstall.c +++ b/loader2/nfsinstall.c @@ -95,7 +95,7 @@ char * mountNfsImage(struct installMethod * method, enum { NFS_STAGE_NFS, NFS_STAGE_MOUNT, NFS_STAGE_DONE, NFS_STAGE_UPDATES } stage = NFS_STAGE_NFS;
- int rc, foundinvalid = 0; + int rc;
/* JKFIXME: ASSERT -- we have a network device setup when we get here */ while (stage != NFS_STAGE_DONE) { @@ -174,12 +174,7 @@ char * mountNfsImage(struct installMethod * method, logMessage(INFO, "can access %s", buf); rc = mountStage2(buf);
- if (rc == -1) { - foundinvalid = 1; - logMessage(WARNING, "not the right stage2 image"); - umount("/mnt/stage2"); - free(buf); - } else if (rc == 0) { + if (rc == 0) { stage = NFS_STAGE_UPDATES; rc = asprintf(&url, "nfs:%s:%s", host, directory); free(buf); @@ -204,14 +199,9 @@ char * mountNfsImage(struct installMethod * method, break; }
- if (foundinvalid) - rc = asprintf(&buf, _("The %s installation tree in that " - "directory does not seem to match " - "your boot media."), getProductName()); - else - rc = asprintf(&buf, _("That directory does not seem to " - "contain a %s installation tree."), - getProductName()); + rc = asprintf(&buf, _("That directory does not seem to " + "contain a %s installation tree."), + getProductName());
newtWinMessage(_("Error"), _("OK"), buf); free(buf); diff --git a/loader2/urlinstall.c b/loader2/urlinstall.c index dd2d89f..5da206d 100644 --- a/loader2/urlinstall.c +++ b/loader2/urlinstall.c @@ -155,18 +155,6 @@ static int loadUrlImages(struct iurlinfo * ui) { return 1; }
- /* now verify the stamp... */ - if (!verifyStamp("/mnt/runtime")) { - rc = asprintf(&buf, _("The %s installation tree in that directory does " - "not seem to match your boot media."), - getProductName()); - - newtWinMessage(_("Error"), _("OK"), buf); - - umountLoopback("/mnt/runtime", "/dev/loop0"); - return 1; - } - return 0; }
--- yuminstall.py | 26 +++++--------------------- 1 files changed, 5 insertions(+), 21 deletions(-)
diff --git a/yuminstall.py b/yuminstall.py index 3b6525b..7ab9bb4 100644 --- a/yuminstall.py +++ b/yuminstall.py @@ -394,20 +394,11 @@ class AnacondaYum(YumSorter): if self._loopbackFile and os.path.exists(self._loopbackFile): return
- # If they booted with a boot.iso, just continue using that stage2.img. - if os.path.exists("/mnt/stage2/images/stage2.img"): - log.info("Don't need to transfer stage2 image") - return - - stage2img = None - if os.path.exists("/tmp/stage2.img"): - log.info("Using /tmp/stage2.img as stage2 image") - stage2img = "/tmp/stage2.img" - elif os.path.exists("%s/images/stage2.img" % self.tree): - log.info("Using %s/images/stage2.img as stage2 image" % self.tree) - stage2img = "%s/images/stage2.img" % self.tree - else: - log.debug("Not copying stage2.img as we can't find it") + # If we've booted off the first CD/DVD (so, not the boot.iso) then + # copy the stage2.img to the filesystem and switch loopback devices + # to there. Otherwise we won't be able to unmount and swap media. + stage2img = "%s/images/stage2.img" % self.tree + if not self.anaconda.mediaDevice or not os.path.exists(stage2img): return
self._loopbackFile = "%s%s/rhinstall-stage2.img" % (chroot, @@ -443,13 +434,6 @@ class AnacondaYum(YumSorter):
isys.lochangefd("/dev/loop0", self._loopbackFile)
- # Try to remove the stage2 image from /tmp to decrease memory usage. - if stage2img == "/tmp/stage2.img": - try: - os.unlink(stage2img) - except: - pass - def _switchCD(self, discnum): if os.access("%s/.discinfo" % self.tree, os.R_OK): f = open("%s/.discinfo" % self.tree)
--- image.py | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/image.py b/image.py index 0b56c16..8b62877 100644 --- a/image.py +++ b/image.py @@ -268,7 +268,7 @@ def unmountCD(path, messageWindow): "and then click OK to retry.") % (path,))
-def verifyMedia(tree, discnum, timestamp): +def verifyMedia(tree, discnum, timestamp=None): if os.access("%s/.discinfo" % tree, os.R_OK): f = open("%s/.discinfo" % tree)
@@ -290,7 +290,12 @@ def verifyMedia(tree, discnum, timestamp): discs = [ 0 ]
f.close() - if (newStamp == timestamp and arch == _arch and discnum in discs): - return True + + if timestamp is not None: + if newStamp == timestamp and arch == _arch and discnum in discs: + return True + else: + if arch == _arch and discnum in discs: + return True
return False
--- anaconda | 62 ++++++--------------------------------------- installclass.py | 2 +- installclasses/fedora.py | 8 +++-- installclasses/rhel.py | 2 +- instdata.py | 10 ++----- 5 files changed, 19 insertions(+), 65 deletions(-)
diff --git a/anaconda b/anaconda index d8dc855..94be9ad 100755 --- a/anaconda +++ b/anaconda @@ -478,7 +478,6 @@ class Anaconda: self.intf = None self.dir = None self.id = None - self._loaderMethodstr = None self.methodstr = None self.backend = None self.rootPath = None @@ -524,29 +523,12 @@ class Anaconda: self.intf = InstallInterface()
def setBackend(self, instClass): - b = instClass.getBackend(self.methodstr) + b = instClass.getBackend() self.backend = apply(b, (self,))
def setMethodstr(self, methodstr): - # Save the method string we are given from the loader for printing out - # later. For dealing with the backends, we need to convert it into - # real URIs, though. - self._loaderMethodstr = methodstr - - # Make a best guess at where the repo is by trimming off the image file - # from the end. If this doesn't work, we've got repo reconfig screens - # to use later on. - if methodstr.endswith(".img"): - try: - m = methodstr[:methodstr.rindex("/")] - m = m[:m.rindex("/")] - except: - m = methodstr - else: - m = methodstr - - if m.startswith("cdrom://"): - (device, tree) = string.split(m[8:], ":", 1) + if methodstr.startswith("cdrom://"): + (device, tree) = string.split(methodstr[8:], ":", 1)
if not tree.startswith("/"): tree = "/%s" %(tree,) @@ -554,23 +536,7 @@ class Anaconda: self.mediaDevice = device self.methodstr = "cdrom://%s" % tree else: - self.methodstr = m - - def writeMethodstr(self, f): - import urllib - - if self._loaderMethodstr.startswith('ftp://') or self._loaderMethodstr.startswith('http://'): - f.write("url --url %s\n" % urllib.unquote(self._loaderMethodstr)) - elif self._loaderMethodstr.startswith('cdrom://'): - f.write("cdrom\n") - elif self._loaderMethodstr.startswith('hd:'): - (partition, filesystem, dir) = string.split(self._loaderMethodstr[3:], ':') - if partition.startswith("/dev/"): - partition = partition[5:] - f.write("harddrive --partition=%s --dir=%s\n" % (partition, dir)) - elif self._loaderMethodstr.startswith('nfs:') or self._loaderMethodstr.startswith('nfsiso:'): - (method, server, dir) = string.split(self._loaderMethodstr, ':') - f.write("nfs --server=%s --dir=%s\n" % (server, dir)) + self.methodstr = methodstr
if __name__ == "__main__": anaconda = Anaconda() @@ -655,12 +621,9 @@ if __name__ == "__main__": if opts.method[0] == '@': expandFTPMethod(opts)
- # FIXME: this is terrible, but it gets the desired behavior without - # requiring scary loader changes at this point - if flags.cmdline.has_key("stage2") and flags.cmdline.has_key("method"): - opts.method = flags.cmdline["method"] - anaconda.setMethodstr(opts.method) + else: + anaconda.methodstr = None
if opts.module: for mod in opts.module: @@ -764,15 +727,11 @@ if __name__ == "__main__":
import rescue, instdata
- anaconda.id = instdata.InstallData(anaconda, [], anaconda.methodstr, opts.display_mode) + anaconda.id = instdata.InstallData(anaconda, [], opts.display_mode) rescue.runRescue(anaconda, instClass)
# shouldn't get back here sys.exit(1) - else: - if not anaconda.methodstr: - sys.stderr.write('no install method specified\n') - sys.exit(1)
# # Here we have a hook to pull in second half of kickstart file via https @@ -794,9 +753,7 @@ if __name__ == "__main__": # if display_mode wasnt set by command line parameters then set default # if not opts.display_mode: - if (anaconda.methodstr and - anaconda.methodstr.startswith('ftp://') or - anaconda.methodstr.startswith('http://')): + if opts.stage2 and opts.stage2.find("minstg2.img") != -1: opts.display_mode = 't' else: opts.display_mode = 'g' @@ -812,7 +769,6 @@ if __name__ == "__main__":
log.info("anaconda called with cmdline = %s" %(sys.argv,)) log.info("Display mode = %s" %(opts.display_mode,)) - log.info("Method = %s" %(anaconda.methodstr,))
checkMemory(opts)
@@ -885,7 +841,7 @@ if __name__ == "__main__":
anaconda.setBackend(instClass)
- anaconda.id = instClass.installDataClass(anaconda, extraModules, anaconda.methodstr, opts.display_mode, anaconda.backend) + anaconda.id = instClass.installDataClass(anaconda, extraModules, opts.display_mode, anaconda.backend)
anaconda.id.x_already_set = x_already_set
diff --git a/installclass.py b/installclass.py index 414b5cf..ef1b262 100644 --- a/installclass.py +++ b/installclass.py @@ -181,7 +181,7 @@ class BaseInstallClass(object): grps = anaconda.backend.getDefaultGroups(anaconda) map(lambda x: anaconda.backend.selectGroup(x), grps)
- def getBackend(self, methodstr): + def getBackend(self): # this should be overriden in distro install classes from backend import AnacondaBackend return AnacondaBackend diff --git a/installclasses/fedora.py b/installclasses/fedora.py index f140139..8bb3be7 100644 --- a/installclasses/fedora.py +++ b/installclasses/fedora.py @@ -19,6 +19,7 @@
from installclass import BaseInstallClass from constants import * +from flags import flags import os, types import iutil
@@ -64,11 +65,12 @@ class InstallClass(BaseInstallClass): BaseInstallClass.setSteps(self, anaconda); anaconda.dispatch.skipStep("partition")
- def getBackend(self, methodstr): - if methodstr.startswith("livecd://"): + def getBackend(self): + if flags.livecd: import livecd return livecd.LiveCDCopyBackend - return yuminstall.YumBackend + else: + return yuminstall.YumBackend
def __init__(self, expert): BaseInstallClass.__init__(self, expert) diff --git a/installclasses/rhel.py b/installclasses/rhel.py index d1b00ee..98134bc 100644 --- a/installclasses/rhel.py +++ b/installclasses/rhel.py @@ -172,7 +172,7 @@ class InstallClass(BaseInstallClass):
log.info("repopaths is %s" %(self.repopaths,))
- def getBackend(self, methodstr): + def getBackend(self): return yuminstall.YumBackend
def __init__(self, expert): diff --git a/instdata.py b/instdata.py index 4b22e8a..227557a 100644 --- a/instdata.py +++ b/instdata.py @@ -98,8 +98,8 @@ class InstallData: stat.S_ISBLK(os.stat("/dev/live")[stat.ST_MODE]): target = os.readlink("/dev/live") self.partitions.protected = [target] - elif self.anaconda._loaderMethodstr.startswith("hd:"): - method = self.anaconda._loaderMethodstr[3:] + elif self.anaconda.methodstr and self.anaconda.methodstr.startswith("hd:"): + method = self.anaconda.methodstr[3:] device = method.split(":", 3)[0] if device.startswith("/dev/"): device = device[5:] @@ -222,9 +222,6 @@ class InstallData: else: f.write("install\n");
- # figure out the install method and write out a line - self.anaconda.writeMethodstr(f) - if self.instClass.skipkey: f.write("key --skip\n") elif self.instClass.installkey: @@ -275,7 +272,7 @@ class InstallData: os.chmod(filename, 0600)
- def __init__(self, anaconda, extraModules, methodstr, displayMode, backend = None): + def __init__(self, anaconda, extraModules, displayMode, backend = None): self.displayMode = displayMode
self.instLanguage = language.Language(self.displayMode) @@ -289,5 +286,4 @@ class InstallData: self.extraModules = extraModules self.fsset = fsset.FileSystemSet()
- self.methodstr = methodstr self.reset()
--- yuminstall.py | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/yuminstall.py b/yuminstall.py index 7ab9bb4..ee47253 100644 --- a/yuminstall.py +++ b/yuminstall.py @@ -41,7 +41,7 @@ from yum.constants import * from yum.Errors import RepoError, YumBaseError, PackageSackError from yum.yumRepo import YumRepository from backend import AnacondaBackend -from product import productName, productStamp +from product import * from sortedtransaction import SplitMediaTransactionData from constants import * from image import * @@ -553,12 +553,12 @@ class AnacondaYum(YumSorter): from ConfigParser import ConfigParser c = ConfigParser()
- if os.access("%s/.treeinfo" % self.methodstr, os.R_OK): - ConfigParser.read(c, "%s/.treeinfo" % self.methodstr) + if os.access("%s/.treeinfo" % self.anaconda.methodstr, os.R_OK): + ConfigParser.read(c, "%s/.treeinfo" % self.anaconda.methodstr) else: ug = URLGrabber() - ug.urlgrab("%s/.treeinfo" % self.methodstr, "/tmp/.treeinfo", - copy_local=1) + ug.urlgrab("%s/.treeinfo" % self.anaconda.methodstr, + "/tmp/.treeinfo", copy_local=1) ConfigParser.read(c, "/tmp/.treeinfo")
return c.get("general", "version") @@ -566,8 +566,7 @@ class AnacondaYum(YumSorter): try: self.yumvar["releasever"] = _getReleasever() except: - log.error("Unable to get .treeinfo file, $releasever substitution " - "will be unavailable.") + self.yumvar["releasever"] = productVersion
YumSorter.getReposFromConfig(self)
--- image.py | 22 +++++++++------------- 1 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/image.py b/image.py index 8b62877..45779ef 100644 --- a/image.py +++ b/image.py @@ -130,22 +130,18 @@ def mountDirectory(methodstr, messageWindow): method = methodstr[3:] (device, fstype, path) = method.split(":", 3) device = method[0:method.index(":")] + + if not device.startswith("/dev/"): + device = "/dev/%s" % device + elif methodstr.startswith("nfsiso:"): + device = methodstr[7:] + fstype = "nfs" else: return
- # First check to see if isodir is mounted. - f = open("/proc/mounts", "r") - lines = f.readlines() - f.close() - - if not device.startswith("/dev/"): - device = "/dev/%s" %(device,) - - for l in lines: - s = string.split(l) - if s[0] == device: - # It is, so there's no need to try again. - return + # No need to mount it again. + if os.path.ismount("/mnt/isodir"): + return
try: isys.mount(device, "/mnt/isodir", fstype = fstype)
--- yuminstall.py | 162 +++++++++++++++++++++++++++++++++----------------------- 1 files changed, 95 insertions(+), 67 deletions(-)
diff --git a/yuminstall.py b/yuminstall.py index ee47253..7bfea8d 100644 --- a/yuminstall.py +++ b/yuminstall.py @@ -333,38 +333,77 @@ class AnacondaYum(YumSorter): def __init__(self, anaconda): YumSorter.__init__(self) self.anaconda = anaconda - self.currentMedia = None self._loopbackFile = None self._timestamp = None
# Only needed for hard drive and nfsiso installs. self._discImages = {} + self.isodir = None + + # Only needed for media installs. + self.currentMedia = None + self.mediagrabber = None
- # Where is the source media mounted? isodir only matters if we are - # doing NFS or HD image installs, and points to the directory where - # the ISO images themselves may be found. tree always points to the - # directory where Packages/ is located. + # Where is the source media mounted? This is the directory + # where Packages/ is located. self.tree = "/mnt/source"
- if self.anaconda.methodstr.startswith("hd:"): - (device, fstype, path) = self.anaconda.methodstr[3:].split(":", 3) - self.isodir = "/mnt/isodir/%s" % path - elif self.anaconda.methodstr.startswith("nfsiso:"): - self.isodir = "/mnt/isodir" - else: - self.isodir = None + # yum doesn't understand all our method URLs, so use this for all + # except FTP and HTTP installs. + self._baseRepoURL = "file://%s" % self.tree
- # The loader may have mounted the first disc for us, but there's - # no guarantee what with the stage2= stuff. - if self.anaconda.mediaDevice or self.isodir: - if os.path.ismount(self.tree): - self.currentMedia = 1 - else: + # We only have a methodstr if method= or repo= was passed to + # anaconda. No source for this base repo (the CD media, NFS, + # whatever) is mounted yet since loader only mounts the source + # for the stage2 image. We need to set up the source mount + # now. + if self.anaconda.methodstr: + m = self.anaconda.methodstr + + if m.startswith("hd:"): + (device, fstype, path) = m[3:].split(":", 3) + self.isodir = "/mnt/isodir/%s" % path + + # This takes care of mounting /mnt/isodir first. self._switchImage(1) + self.mediagrabber = self.mediaHandler + elif m.startswith("nfsiso:"): + self.isodir = "/mnt/isodir"
- self.mediagrabber = self.mediaHandler + # This takes care of mounting /mnt/isodir first. + self._switchImage(1) + self.mediagrabber = self.mediaHandler + elif m.startswith("http:") or m.startswith("ftp:"): + self._baseRepoURL = m + elif m.startswith("nfs:"): + isys.mount(m[4:], self.tree, "nfs") + elif m.startswith("cdrom:"): + self._switchCD(1) else: - self.mediagrabber = None + # No methodstr was given. In order to find an installation source, + # we should first check to see if there's a CD/DVD with packages + # on it, and then default to the mirrorlist URL. The user can + # always change the repo with the repo editor later. + foundCD = False + + for cdr in map(lambda d: "/dev/%s" % d, isys.cdromList()): + if isys.mount(cdr, self.tree, fstype="iso9660", readOnly=1): + continue + + if not verifyMedia(self.tree, 1): + isys.umount(self.tree) + continue + + self.anaconda.mediaDevice = cdr + self.currentMedia = 1 + log.info("found installation media on %s" % cdr) + foundCD = True + break + + if not foundCD: + # No CD with media on it and no repo=/method= parameter, so + # default to using whatever's enabled in /etc/yum.repos.d/ + self._baseRepoURL = None
self.doConfigSetup(root=anaconda.rootPath) self.conf.installonlypkgs = [] @@ -575,59 +614,48 @@ class AnacondaYum(YumSorter): pass
def doConfigSetup(self, fn='/etc/yum.conf', root='/'): - if self.anaconda.methodstr.startswith("nfs:"): - if os.path.isdir(self.anaconda.methodstr[4:]): - self.tree = self.anaconda.methodstr[4:] - else: - if not os.path.ismount(self.tree): - isys.mount(self.anaconda.methodstr[4:], self.tree, "nfs") - self.methodstr = "file://%s" % self.tree - elif self.anaconda.methodstr.startswith("nfsiso:"): - self.methodstr = "file://%s" % self.tree - elif self.anaconda.methodstr.startswith("cdrom:"): - self.methodstr = "file://%s" % self.tree - elif self.anaconda.methodstr.startswith("hd:"): - self.methodstr = "file://%s" % self.tree - elif self.anaconda.methodstr.startswith("ftp:") or self.anaconda.methodstr.startswith("http:"): - self.methodstr = self.anaconda.methodstr - YumSorter.doConfigSetup(self, fn=fn, root=root)
# override default logging to use our logs ylog = logging.getLogger("yum") map(lambda x: ylog.addHandler(x), log.handlers)
- _preupgset = False - # add default repos - for (name, uri) in self.anaconda.id.instClass.getPackagePaths(self.methodstr).items(): - rid = name.replace(" ", "") - repo = AnacondaYumRepo(uri=uri, addon=False, - repoid="anaconda-%s-%s" %(rid, productStamp), - root = root) - repo.name = name - repo.cost = 100 - - # if we've been booted with 'preupgrade', then we want to - # use the cache on the hd for the upgrade info and thus avoid - # needing to use the network. - # FIXME: longer-term, I'd like to see - # the anaconda-upgrade dir just become a full-fledged repo - # (maybe combining input from multiple repos) that we add - # in addition to the base repos. then we catch a depcheck error - # and ask if you want to add more repos. - if flags.cmdline.has_key("preupgrade") and _preupgset == False: - _preupgset = True - if os.path.exists("%s/var/cache/yum/anaconda-upgrade" % self.anaconda.rootPath): - repo.cachedir = "%s/var/cache/yum/anaconda-upgrade" % self.anaconda.rootPath - repo.metadata_expire = -1 - log.info("setting cachedir for %s to %s based on preupgrade flag" %(rid, repo.cachedir)) - - if self.anaconda.mediaDevice or self.isodir: - repo.mediaid = getMediaId(self.tree) - log.info("set mediaid of repo to: %s" % repo.mediaid) - - repo.enable() - self.repos.add(repo) + # Create the "base" repo object, assuming there is one. Otherwise we + # just skip all this and use the defaults from /etc/yum.repos.d. + # preupgrade always sets a _baseRepoURL so it'll still get taken care + # of with this block. + if self._baseRepoURL: + _preupgset = False + # add default repos + for (name, uri) in self.anaconda.id.instClass.getPackagePaths(self._baseRepoURL).items(): + rid = name.replace(" ", "") + repo = AnacondaYumRepo(uri=uri, addon=False, + repoid="anaconda-%s-%s" %(rid, productStamp), + root = root) + repo.name = name + repo.cost = 100 + + # if we've been booted with 'preupgrade', then we want to + # use the cache on the hd for the upgrade info and thus avoid + # needing to use the network. + # FIXME: longer-term, I'd like to see + # the anaconda-upgrade dir just become a full-fledged repo + # (maybe combining input from multiple repos) that we add + # in addition to the base repos. then we catch a depcheck error + # and ask if you want to add more repos. + if flags.cmdline.has_key("preupgrade") and _preupgset == False: + _preupgset = True + if os.path.exists("%s/var/cache/yum/anaconda-upgrade" % self.anaconda.rootPath): + repo.cachedir = "%s/var/cache/yum/anaconda-upgrade" % self.anaconda.rootPath + repo.metadata_expire = -1 + log.info("setting cachedir for %s to %s based on preupgrade flag" %(rid, repo.cachedir)) + + if self.anaconda.mediaDevice or self.isodir: + repo.mediaid = getMediaId(self.tree) + log.info("set mediaid of repo to: %s" % repo.mediaid) + + repo.enable() + self.repos.add(repo)
extraRepos = []
A better fix for this would include an updated repo editor with support for all these various types of repositories. But that's not ready yet, so the error handling here will have to be a little sub-standard. --- iw/task_gui.py | 21 +----------------- yuminstall.py | 66 ++++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 46 insertions(+), 41 deletions(-)
diff --git a/iw/task_gui.py b/iw/task_gui.py index 243415e..1a73377 100644 --- a/iw/task_gui.py +++ b/iw/task_gui.py @@ -82,21 +82,7 @@ class RepoEditor: self.dialog.set_title(_("Edit Repository"))
def _enableRepo(self, repourl): - # Only do this for the real base repo, as that's what will get - # written out to anaconda-ks.cfg as the method. - if not self.repo.addon and not self.repo.name.startswith("Driver Disk"): - self.anaconda.setMethodstr(repourl) - - # Ideally we should be able to unmount here, but if not - # it's probably not a big deal. - try: - isys.umount(self.backend.ayum.tree) - - if self.backend.ayum.isodir: - isys.umount(self.backend.ayum.isodir) - except: - pass - + # FIXME: Don't do anything here for now. return True
def _proxyToggled(self, *args): @@ -325,11 +311,6 @@ class TaskWindow(InstallWindow): wasChecked = store.get_value(i, 0) repo = store.get_value(i, 2)
- # The base repositories can never be disabled, but they can be edited. - if wasChecked and not repo.addon: - button.set_active(True) - return - if not wasChecked: if not network.hasActiveNetDev(): net = NetworkConfigurator(self.anaconda.id.network) diff --git a/yuminstall.py b/yuminstall.py index 7bfea8d..ee4b93e 100644 --- a/yuminstall.py +++ b/yuminstall.py @@ -130,6 +130,15 @@ def ui_comps_sort(one, two): return -1 return 0
+def enableNetwork(anaconda): + from netconfig_dialog import NetworkConfigurator + import gtk + net = NetworkConfigurator(anaconda.id.network) + ret = net.run() + net.destroy() + + return ret != gtk.RESPONSE_CANCEL + class AnacondaCallback:
def __init__(self, ayum, anaconda, instLog, modeText): @@ -275,7 +284,7 @@ class AnacondaCallback: class AnacondaYumRepo(YumRepository): def __init__( self, repoid='anaconda%s' % productStamp, uri=None, mirrorlist=None, - root = "/mnt/sysimage/", addon=True): + root = "/mnt/sysimage/"): YumRepository.__init__(self, repoid) conf = yum.config.RepoConf() for k, v in conf.iteritems(): @@ -284,7 +293,6 @@ class AnacondaYumRepo(YumRepository): self.gpgcheck = False #self.gpgkey = "%s/RPM-GPG-KEY-fedora" % (method, ) self.keepalive = False - self.addon = addon
if type(uri) == types.ListType: self.baseurl = uri @@ -296,6 +304,17 @@ class AnacondaYumRepo(YumRepository):
self.setAttribute('cachedir', os.path.join(root, "var/cache/yum", self.id))
+ def needsNetwork(self): + def _isURL(s): + return s.startswith("http") or s.startswith("ftp") + + if len(self.baseurl) > 0: + return len(filter(lambda s: _isURL(s), self.baseurl)) > 0 + elif self.mirrorlist: + return _isURL(self.mirrorlist) + else: + return False + def dirSetup(self): # FIXME: this is terrible, awful and shouldn't be allowed to see # the light of day. but if we use YumRepository.dirSetup(), then @@ -376,7 +395,13 @@ class AnacondaYum(YumSorter): elif m.startswith("http:") or m.startswith("ftp:"): self._baseRepoURL = m elif m.startswith("nfs:"): - isys.mount(m[4:], self.tree, "nfs") + if not network.hasActiveNetDev(): + if not enableNetwork(self.anaconda): + self._baseRepoURL = None + else: + isys.mount(m[4:], self.tree, "nfs") + else: + isys.mount(m[4:], self.tree, "nfs") elif m.startswith("cdrom:"): self._switchCD(1) else: @@ -616,10 +641,6 @@ class AnacondaYum(YumSorter): def doConfigSetup(self, fn='/etc/yum.conf', root='/'): YumSorter.doConfigSetup(self, fn=fn, root=root)
- # override default logging to use our logs - ylog = logging.getLogger("yum") - map(lambda x: ylog.addHandler(x), log.handlers) - # Create the "base" repo object, assuming there is one. Otherwise we # just skip all this and use the defaults from /etc/yum.repos.d. # preupgrade always sets a _baseRepoURL so it'll still get taken care @@ -629,8 +650,7 @@ class AnacondaYum(YumSorter): # add default repos for (name, uri) in self.anaconda.id.instClass.getPackagePaths(self._baseRepoURL).items(): rid = name.replace(" ", "") - repo = AnacondaYumRepo(uri=uri, addon=False, - repoid="anaconda-%s-%s" %(rid, productStamp), + repo = AnacondaYumRepo(uri=uri, repoid="anaconda-%s-%s" %(rid, productStamp), root = root) repo.name = name repo.cost = 100 @@ -665,7 +685,7 @@ class AnacondaYum(YumSorter): rid = "anaconda-%s" % dirname
repo = AnacondaYumRepo(uri="file:///%s" % d, repoid=rid, - root=root, addon=False) + root=root) repo.name = "Driver Disk %s" % dirname.split("-")[1] repo.enable() extraRepos.append(repo) @@ -713,13 +733,7 @@ class AnacondaYum(YumSorter):
def _handleFailure(self, package): if flags.cmdline.has_key("preupgrade") and os.environ.has_key("DISPLAY") and not network.hasActiveNetDev(): - from netconfig_dialog import NetworkConfigurator - import gtk - net = NetworkConfigurator(self.anaconda.id.network) - ret = net.run() - net.destroy() - - if ret != gtk.RESPONSE_CANCEL: + if not enableNetwork(self.anaconda): return
if not self.isodir and self.currentMedia: @@ -1106,7 +1120,19 @@ reposdir=/etc/yum.repos.d,/tmp/updates/yum.repos.d,/tmp/product/yum.repos.d task(thisrepo = repo.id) waitwin.next_task() waitwin.pop() - except Exception, e: + except RepoError, e: + waitwin.pop() + if repo.needsNetwork() and not network.hasActiveNetDev(): + from netconfig_dialog import NetworkConfigurator + import gtk + net = NetworkConfigurator(anaconda.id.network) + ret = net.run() + net.destroy() + + if ret != gtk.RESPONSE_CANCEL: + repo.mirrorlistparsed = False + continue + buttons = [_("_Exit installer"), _("Edit"), _("_Retry")] else: break # success @@ -1844,9 +1870,7 @@ reposdir=/etc/yum.repos.d,/tmp/updates/yum.repos.d,/tmp/product/yum.repos.d self.selectPackage(new)
def writeKS(self, f): - # Only write out lines for repositories that weren't added - # automatically by anaconda. - for repo in filter(lambda r: r.addon, self.ayum.repos.listEnabled()): + for repo in self.ayum.repos.listEnabled(): line = "repo --name="%s" " % (repo.name or repo.repoid)
if repo.baseurl:
--- installclasses/fedora.py | 2 +- yuminstall.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/installclasses/fedora.py b/installclasses/fedora.py index 8bb3be7..828678a 100644 --- a/installclasses/fedora.py +++ b/installclasses/fedora.py @@ -52,7 +52,7 @@ class InstallClass(BaseInstallClass): if not type(uri) == types.ListType: uri = [uri,]
- return {'Fedora': uri} + return {'Installation Repo': uri}
def setInstallData(self, anaconda): BaseInstallClass.setInstallData(self, anaconda) diff --git a/yuminstall.py b/yuminstall.py index ee4b93e..24e1280 100644 --- a/yuminstall.py +++ b/yuminstall.py @@ -607,6 +607,11 @@ class AnacondaYum(YumSorter): repo.yumvar.update(self.conf.yumvar) repo.cfg = parser
+ # If repo=/method= was passed in, we want to default these extra + # repos to off. + if self._baseRepoURL: + repo.enabled = False + return repo
# We need to make sure $releasever gets set up before .repo files are
On Jun 17, 2008, at 5:45 AM, Chris Lumens wrote:
loader2/method.c | 110
loader2/method.h | 3 - loader2/nfsinstall.c | 20 ++------- loader2/urlinstall.c | 12 ----- 4 files changed, 5 insertions(+), 140 deletions(-)
diff --git a/loader2/method.c b/loader2/method.c index f1eb55d..66dff42 100644 --- a/loader2/method.c +++ b/loader2/method.c @@ -111,67 +111,6 @@ int mountLoopback(char *fsystem, char *mntpoint, char *device) { }
/* returns the *absolute* path (malloced) to the #1 iso image */ -char * validIsoImages(char * dirName, int *foundinvalid, int checkStage2) {
- DIR * dir;
- struct dirent * ent;
- char isoImage[1024];
- if (!(dir = opendir(dirName))) {
newtWinMessage(_("Error"), _("OK"),
_("Failed to read directory %s: %s"),
dirName, strerror(errno));
return 0;
- }
- /* Walk through the directories looking for a CD image. */
- errno = 0;
- while ((ent = readdir(dir))) {
if (*ent->d_name == '/')
snprintf(isoImage, sizeof(isoImage), "%s%s", dirName,
ent->d_name);
else
snprintf(isoImage, sizeof(isoImage), "%s/%s", dirName,
ent->d_name);
if (!fileIsIso(isoImage)) {
errno = 0;
continue;
}
if (mountLoopback(isoImage, "/tmp/loopimage", "/dev/
loop7")) {
logMessage(WARNING, "failed to mount %s", isoImage);
errno = 0;
continue;
}
if (!checkStage2) {
umountLoopback("/tmp/loopimage", "/dev/loop7");
break;
}
- if (mountLoopback("/tmp/loopimage/images/stage2.img", "/mnt/
runtime", "/dev/loop0")) {
umountLoopback("/mnt/runtime", "/dev/loop0");
- } else {
if (verifyStamp("/mnt/runtime")) {
umountLoopback("/mnt/runtime", "/dev/loop0");
umountLoopback("/tmp/loopimage", "/dev/loop7");
break;
}
logMessage(ERROR, "disc %s is not the right image", isoImage);
umountLoopback("/mnt/runtime", "/dev/loop0");
if (foundinvalid) *foundinvalid = 1;
- }
umountLoopback("/tmp/loopimage", "/dev/loop7");
errno = 0;
- }
- closedir(dir);
- if (!ent) return NULL;
- return strdup(isoImage);
-}
/* get timestamp and description of ISO image from stamp file */ /* returns 0 on success, -1 otherwise */ int readStampFileFromIso(char *file, char **timestamp, char **releasedescr) { @@ -478,50 +417,6 @@ void copyProductImg(char * path) { } }
-/* verify that the stamp files in / of the initrd and the stage2 match */ -int verifyStamp(char * path) {
- char *stamp1;
- char *stamp2;
- FILE *f;
- int fail = 0;
- int i;
- char * p, *q;
- stamp1 = alloca(80);
- stamp2 = alloca(80);
- /* grab the one from the initrd */
- f = fopen("/.buildstamp", "r");
- if (!f) {
fail = 1;
- } else {
q = fgets(stamp1, 80, f);
- fclose(f);
/* and the runtime */
i = asprintf(&p, "%s/.buildstamp", path);
f = fopen(p, "r");
free(p);
if (!f) {
fail = 1;
} else {
q = fgets(stamp2, 80, f);
fclose(f);
if (strcmp(stamp1, stamp2) != 0) {
fail = 1;
}
}
- }
- if (fail == 1) {
return 0;
- } else {
return 1;
- }
-}
/* unmount a second stage, if mounted. Used for CDs and mediacheck mostly, so we can eject CDs. */ void umountStage2(void) { @@ -539,11 +434,6 @@ int mountStage2(char *stage2path) { return 1; }
- if (!verifyStamp("/mnt/runtime")) {
umountLoopback("/mnt/runtime", "/dev/loop0");
return -1;
- }
- return 0;
}
diff --git a/loader2/method.h b/loader2/method.h index 36f67f3..e1918ae 100644 --- a/loader2/method.h +++ b/loader2/method.h @@ -43,12 +43,9 @@ struct installMethod { int umountLoopback(char * mntpoint, char * device); int mountLoopback(char * fsystem, char * mntpoint, char * device);
-char * validIsoImages(char * dirName, int *foundinvalid, int checkStage2); int readStampFileFromIso(char *file, char **descr, char **timestamp); void queryIsoMediaCheck(char * isoDir);
-int verifyStamp(char * path);
void umountStage2(void); int mountStage2(char *stage2path); int copyFileAndLoopbackMount(int fd, char *dest, char *device, char *mntpoint); diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c index 4ba3d29..9ee5f09 100644 --- a/loader2/nfsinstall.c +++ b/loader2/nfsinstall.c @@ -95,7 +95,7 @@ char * mountNfsImage(struct installMethod * method, enum { NFS_STAGE_NFS, NFS_STAGE_MOUNT, NFS_STAGE_DONE, NFS_STAGE_UPDATES } stage = NFS_STAGE_NFS;
- int rc, foundinvalid = 0;
int rc;
/* JKFIXME: ASSERT -- we have a network device setup when we get
here */ while (stage != NFS_STAGE_DONE) { @@ -174,12 +174,7 @@ char * mountNfsImage(struct installMethod * method, logMessage(INFO, "can access %s", buf); rc = mountStage2(buf);
if (rc == -1) {
foundinvalid = 1;
logMessage(WARNING, "not the right stage2
image");
umount("/mnt/stage2");
free(buf);
} else if (rc == 0) {
if (rc == 0) { stage = NFS_STAGE_UPDATES; rc = asprintf(&url, "nfs:%s:%s", host,
directory); free(buf); @@ -204,14 +199,9 @@ char * mountNfsImage(struct installMethod * method, break; }
if (foundinvalid)
rc = asprintf(&buf, _("The %s installation tree in
that "
"directory does not seem to match "
"your boot media."),
getProductName());
else
rc = asprintf(&buf, _("That directory does not seem
to "
"contain a %s installation tree."),
getProductName());
rc = asprintf(&buf, _("That directory does not seem to "
"contain a %s installation tree."),
getProductName());
Also abort here if we get -1 from asprintf().
newtWinMessage(_("Error"), _("OK"), buf); free(buf);
diff --git a/loader2/urlinstall.c b/loader2/urlinstall.c index dd2d89f..5da206d 100644 --- a/loader2/urlinstall.c +++ b/loader2/urlinstall.c @@ -155,18 +155,6 @@ static int loadUrlImages(struct iurlinfo * ui) { return 1; }
- /* now verify the stamp... */
- if (!verifyStamp("/mnt/runtime")) {
rc = asprintf(&buf, _("The %s installation tree in that
directory does "
"not seem to match your boot media."),
getProductName());
- newtWinMessage(_("Error"), _("OK"), buf);
- umountLoopback("/mnt/runtime", "/dev/loop0");
- return 1;
- }
- return 0;
}
-- 1.5.5.1
Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list
On Jun 17, 2008, at 5:45 AM, Chris Lumens wrote:
loader2/nfsinstall.c | 28 +++++++++++++++++++++++++--- 1 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c index fe1fae9..4ba3d29 100644 --- a/loader2/nfsinstall.c +++ b/loader2/nfsinstall.c @@ -30,6 +30,7 @@ #include <string.h> #include <unistd.h>
+#include "copy.h" #include "loader.h" #include "lang.h" #include "loadermisc.h" @@ -91,8 +92,8 @@ char * mountNfsImage(struct installMethod * method, char * fullPath = NULL; char * url = NULL;
- enum { NFS_STAGE_NFS, NFS_STAGE_MOUNT,
NFS_STAGE_DONE } stage = NFS_STAGE_NFS;
enum { NFS_STAGE_NFS, NFS_STAGE_MOUNT, NFS_STAGE_DONE,
NFS_STAGE_UPDATES } stage = NFS_STAGE_NFS;
int rc, foundinvalid = 0;
@@ -179,7 +180,7 @@ char * mountNfsImage(struct installMethod * method, umount("/mnt/stage2"); free(buf); } else if (rc == 0) {
stage = NFS_STAGE_DONE;
stage = NFS_STAGE_UPDATES; rc = asprintf(&url, "nfs:%s:%s", host,
directory); free(buf); break; @@ -221,6 +222,27 @@ char * mountNfsImage(struct installMethod * method, break; }
case NFS_STAGE_UPDATES: {
char *buf;
int rc;
rc = asprintf(&buf, "%.*s/RHupdates", (int)
(strrchr(fullPath, '/')-fullPath),
fullPath);
If asprintf() returns -1, we should abort with a log message pointing us back to this code rather than continuing.
logMessage(INFO, "mounting nfs path %s for updates",
buf);
if (!doPwMount(buf, "/tmp/update-disk", "nfs",
mountOpts)) {
logMessage(INFO, "Using RHupdates/ for NFS install");
copyDirectory("/tmp/update-disk", "/tmp/updates",
NULL, NULL);
umount("/tmp/update-disk");
unlink("/tmp/update-disk");
} else {
logMessage(INFO, "No RHupdates/ directory found,
skipping");
}
stage = NFS_STAGE_DONE;
break;
}
case NFS_STAGE_DONE: break; }
-- 1.5.5.1
Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list
On Tue, 2008-06-17 at 11:45 -0400, Chris Lumens wrote:
- Since very few people will be getting the method selection screen in loader, most people won't have networking up when we get to stage2. That means in order to use the mirrorlist, we have to use the NetworkConfigurator. This isn't quite ideal, but David's going to have a giant networking patch one of these days so I'm not really going to bother.
I don't know that this is worse than the current state, though. The NetworkConfigurator has the advantage of being accessible to people in more languages :)
Current problems:
- Media check is commented out. My intention here is to move this to stage2 if possible.
So the question I'd have about this is what do we do to ensure that reading the stage2 isn't bad. But maybe that's less of a problem these days.
Anyway this isn't 100% working but it seems good enough for me to consider committing. I've tested boot.iso and pxebooting with HTTP, NFS, and a DVD and those all worked decently. The big problem for me right now is the error handling. But that can be beefed up once this stuff goes in and I have an easier time testing.
It sounds good to me from the high-level. And the patches look pretty reasonable from a quick look through them
Jeremy
anaconda-devel@lists.fedoraproject.org