Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Ubuntu Studio User (http://www.linux-archive.org/ubuntu-studio-user/)
-   -   methodstr cleanups. (http://www.linux-archive.org/ubuntu-studio-user/12638-methodstr-cleanups.html)

Chris Lumens 12-05-2007 02:49 AM

methodstr cleanups.
 
Don't use /mnt/source2 anymore. /mnt/isodir is for image installs to mount
whatever contains the images, and /mnt/source is always the source mount
point. Also don't use methodstr where we don't have to.
---
anaconda | 4 ++--
image.py | 30 ++++++++++++++++--------------
installclass.py | 2 +-
installmethod.py | 2 +-
loader2/nfsinstall.c | 42 +++++++++++++++++++++++++++++-------------
yuminstall.py | 35 +++++++++++++++++++----------------
6 files changed, 68 insertions(+), 47 deletions(-)

diff --git a/anaconda b/anaconda
index 0e8f7b3..539bffc 100755
--- a/anaconda
+++ b/anaconda
@@ -507,7 +507,7 @@ class Anaconda:
self.intf = InstallInterface()

def setBackend(self, instClass):
- b = instClass.getBackend(self.methodstr)
+ b = instClass.getBackend()
self.backend = apply(b, (self.rootPath,))

def setMethodstr(self, methodstr):
@@ -519,7 +519,7 @@ class Anaconda:
if methodstr.startswith("nfs://"):
self.methodstr = "file:///" + methodstr[6:]
elif methodstr.startswith("nfsiso:/"):
- self.methodstr = "file:///mnt/source2"
+ self.methodstr = "file://" + methodstr[8:]
elif methodstr.startswith("cdrom://"):
(device, tree) = string.split(methodstr[8:], ":", 1)

diff --git a/image.py b/image.py
index ebdbd53..a5d934c 100644
--- a/image.py
+++ b/image.py
@@ -11,7 +11,7 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
import isys
-import os, stat, string, sys
+import os, os.path, stat, string, sys
from constants import *

import rhpl
@@ -120,8 +120,8 @@ def getMediaId(path):
return None

# This mounts the directory containing the iso images, and places the
-# mount point in /tmp/isodir.
-def mountDirectory(methodstr, messageWindow):
+# mount point in isodir.
+def mountDirectory(isodir, methodstr, messageWindow):
if methodstr.startswith("hd://"):
method = methodstr[5:]
(device, fstype, path) = method.split(":", 3)
@@ -129,7 +129,7 @@ def mountDirectory(methodstr, messageWindow):
else:
return

- # First check to see if /tmp/isodir is mounted.
+ # First check to see if isodir is mounted.
f = open("/proc/mounts", "r")
lines = f.readlines()
f.close()
@@ -141,7 +141,7 @@ def mountDirectory(methodstr, messageWindow):
return

try:
- isys.mount(device, "/tmp/isodir", fstype = fstype)
+ isys.mount(device, isodir, fstype = fstype)
except SystemError, msg:
log.error("couldn't mount ISO source directory: %s" % msg)
messageWindow(_("Couldn't Mount ISO Source"),
@@ -155,16 +155,16 @@ def mountDirectory(methodstr, messageWindow):
custom_buttons=[_("_Exit")])
sys.exit(0)

-def mountImage(tree, discnum, currentMedia, messageWindow, discImages={}):
- if currentMedia:
+def mountImage(isodir, tree, discnum, messageWindow, discImages={}):
+ if os.path.ismount(tree):
raise SystemError, "trying to mount already-mounted iso image!"

if discImages == {}:
- discImages = findIsoImages("/mnt/source", messageWindow)
+ discImages = findIsoImages(isodir, messageWindow)

while True:
try:
- isoImage = "/mnt/source/%s" % (discImages[discnum])
+ isoImage = "%s/%s" % (isodir, discImages[discnum])
isys.losetup("/dev/loop1", isoImage, readOnly = 1)
isys.mount("/dev/loop1", tree, fstype = 'iso9660', readOnly = 1);
break
@@ -182,7 +182,9 @@ def mountImage(tree, discnum, currentMedia, messageWindow, discImages={}):
if ans == 0:
sys.exit(0)
elif ans == 1:
- discImages = findIsoImages("/mnt/source", messageWindow)
+ discImages = findIsoImages(isodir, messageWindow)
+
+ return discImages

# given groupset containing information about selected packages, use
# the disc number info in the headers to come up with message describing
@@ -248,13 +250,13 @@ def umountImage(tree, currentMedia):
isys.umount(tree, removeDir=0)
isys.unlosetup("/dev/loop1")

-def unmountCD(tree, messageWindow):
- if not tree:
+def unmountCD(path, messageWindow):
+ if not path:
return

while True:
try:
- isys.umount(tree, removeDir=0)
+ isys.umount(path, removeDir=0)
break
except Exception, e:
log.error("exception in _unmountCD: %s" %(e,))
@@ -263,7 +265,7 @@ def unmountCD(tree, messageWindow):
"Please make sure you're not accessing "
"%s from the shell on tty2 "
"and then click OK to retry.")
- % (tree,))
+ % (path,))

def verifyMedia(tree, discnum, timestamp):
if os.access("%s/.discinfo" % tree, os.R_OK):
diff --git a/installclass.py b/installclass.py
index 74036c5..7efd6b9 100644
--- a/installclass.py
+++ b/installclass.py
@@ -412,7 +412,7 @@ class BaseInstallClass(object):
mouse.set(mouseName, emulThree, device)
id.setMouse(mouse)

- def getBackend(self, methodstr):
+ def getBackend(self):
# this should be overriden in distro install classes
from backend import AnacondaBackend
return AnacondaBackend
diff --git a/installmethod.py b/installmethod.py
index c5ea871..f47e6fa 100644
--- a/installmethod.py
+++ b/installmethod.py
@@ -25,7 +25,7 @@ def doMethodComplete(anaconda):
except Exception:
pass

- if anaconda.methodstr.startswith("cdrom://"):
+ if anaconda.mediaDevice:
try:
shutil.copyfile("%s/media.repo" % anaconda.backend.ayum.tree,
"%s/etc/yum.repos.d/%s-install-media.repo" %(anaconda.rootPath, productName))
diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c
index a3cce72..829e824 100644
--- a/loader2/nfsinstall.c
+++ b/loader2/nfsinstall.c
@@ -6,7 +6,7 @@
* Michael Fulbright <msf@redhat.com>
* Jeremy Katz <katzj@redhat.com>
*
- * Copyright 1997 - 2002 Red Hat, Inc.
+ * Copyright 1997 - 2007 Red Hat, Inc.
*
* This software may be freely redistributed under the terms of the GNU
* General Public License.
@@ -115,7 +115,7 @@ char * mountNfsImage(struct installMethod * method,
} else if (nfsGetSetup(&host, &directory) == LOADER_BACK) {
return NULL;
}
-
+
stage = NFS_STAGE_MOUNT;
dir = 1;
break;
@@ -148,7 +148,7 @@ char * mountNfsImage(struct installMethod * method,

stage = NFS_STAGE_NFS;

- if (!doPwMount(fullPath, "/mnt/source", "nfs",
+ if (!doPwMount(fullPath, "/mnt/source", "nfs",
IMOUNT_RDONLY, mountOpts)) {
if (!access("/mnt/source/images/stage2.img", R_OK)) {
logMessage(INFO, "can access /mnt/source/images/stage2.img");
@@ -172,19 +172,36 @@ char * mountNfsImage(struct installMethod * method,
}
} else {
stage = NFS_STAGE_DONE;
- url = "nfs://mnt/source/.";
+ url = "nfs://mnt/source";
break;
}
} else {
logMessage(WARNING, "unable to access /mnt/source/images/stage2.img");
}

- if ((path = validIsoImages("/mnt/source", &foundinvalid))) {
+ /* 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.
+ */
+ umount("/mnt/source");
+ if (!doPwMount(fullPath, "/mnt/isodir", "nfs", IMOUNT_RDONLY,
+ mountOpts)) {
+ } else {
+ newtWinMessage(_("Error"), _("OK"),
+ _("That directory could not be mounted from "
+ "the server."));
+ if (loaderData->method >= 0) {
+ loaderData->method = -1;
+ }
+ break;
+ }
+
+ if ((path = validIsoImages("/mnt/isodir", &foundinvalid))) {
foundinvalid = 0;
logMessage(INFO, "Path to valid iso is %s", path);
- copyUpdatesImg("/mnt/source/updates.img");
+ copyUpdatesImg("/mnt/isodir/updates.img");

- if (mountLoopback(path, "/mnt/source2", "loop1"))
+ if (mountLoopback(path, "/mnt/source", "loop1"))
logMessage(WARNING, "failed to mount iso %s loopback", path);
else {
/* try to see if we're booted off of a CD with stage2 */
@@ -197,17 +214,17 @@ char * mountNfsImage(struct installMethod * method,
newtPopWindow();
rc = 0;
} else {
- rc = mountStage2("/mnt/source2/images/stage2.img");
+ rc = mountStage2("/mnt/source/images/stage2.img");
}
if (rc) {
- umountLoopback("/mnt/source2", "loop1");
+ umountLoopback("/mnt/source", "loop1");
if (rc == -1)
foundinvalid = 1;
} else {
/* JKFIXME: hack because /mnt/source is hard-coded
* in mountStage2() */
- copyUpdatesImg("/mnt/source2/images/updates.img");
- copyProductImg("/mnt/source2/images/product.img");
+ copyUpdatesImg("/mnt/source/images/updates.img");
+ copyProductImg("/mnt/source/images/product.img");

queryIsoMediaCheck(path);

@@ -220,7 +237,7 @@ char * mountNfsImage(struct installMethod * method,

/* if we fell through to here we did not find a valid NFS */
/* source for installation. */
- umount("/mnt/source");
+ umount("/mnt/isodir");
if (foundinvalid)
rc = asprintf(&buf, _("The %s installation tree in that "
"directory does not seem to match "
@@ -235,7 +252,6 @@ char * mountNfsImage(struct installMethod * method,
loaderData->method = -1;
}

-
break;
} else {
newtWinMessage(_("Error"), _("OK"),
diff --git a/yuminstall.py b/yuminstall.py
index 5b2375f..75dc76a 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -259,7 +259,6 @@ class AnacondaYum(YumSorter):
def __init__(self, anaconda):
YumSorter.__init__(self)
self.anaconda = anaconda
- self.methodstr = anaconda.methodstr
self._loopbackFile = None

# The loader mounts the first disc for us, so don't remount it.
@@ -269,11 +268,16 @@ class AnacondaYum(YumSorter):
# Only needed for hard drive and nfsiso installs.
self._discImages = {}

- # Where is the source media mounted?
- if self.methodstr.find("source2") != -1:
- self.tree = "/mnt/source2"
+ # 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.
+ self.tree = "/mnt/source"
+
+ if os.path.ismount("/mnt/isodir"):
+ self.isodir = "/mnt/isodir"
else:
- self.tree = "/mnt/source"
+ self.isodir = None

self.doConfigSetup(root=anaconda.rootPath)
self.conf.installonlypkgs = []
@@ -351,20 +355,19 @@ class AnacondaYum(YumSorter):
(self.currentMedia, discnum, relative))

# Unmount any currently mounted ISO images and mount the one
- # containing the requested packages. If this is the first time
- # through, /mnt/source is not going to be mounted yet so we first
- # need to do that.
- if self.tree.find("source2") != -1:
+ # containing the requested packages.
+ if self.isodir:
umountImage(self.tree, self.currentMedia)
self.currentMedia = None

# mountDirectory checks before doing anything, so it's safe to
# call this repeatedly.
- mountDirectory(self.methodstr, self.anaconda.intf.messageWindow)
+ mountDirectory(self.isodir, self.anaconda.methodstr,
+ self.anaconda.intf.messageWindow)

- mountImage(self.tree, discnum, self.currentMedia,
- self.anaconda.intf.messageWindow,
- discImages=self._discImages)
+ discImages = mountImage(self.isodir, self.tree, discnum,
+ self.anaconda.intf.messageWindow,
+ discImages=self._discImages)
self.currentMedia = discnum
else:
if os.access("%s/.discinfo" % self.tree, os.R_OK):
@@ -377,9 +380,9 @@ class AnacondaYum(YumSorter):
if self.timestamp is None:
self.timestamp = timestamp

- # if self.currentMedia is None, then we shouldn't have anything
+ # If self.currentMedia is None, then we shouldn't have anything
# mounted. double-check by trying to unmount, but we don't want
- # to get into a loop of trying to unmount forever. if
+ # to get into a loop of trying to unmount forever. If
# self.currentMedia is set, then it should still be mounted and
# we want to loop until it unmounts successfully
if self.currentMedia is None:
@@ -451,7 +454,7 @@ class AnacondaYum(YumSorter):
root = root)
repo.cost = 100

- if self.anaconda.mediaDevice or self.anaconda.methodstr.find("source2") != -1:
+ if self.anaconda.mediaDevice or self.isodir != -1:
repo.mediaid = getMediaId(self.tree)
log.info("set mediaid of repo to: %s" % repo.mediaid)

--
1.5.3.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


All times are GMT. The time now is 04:02 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.