Re: PATCH fix 510970, 529551, 530541

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> diff -up ./yuminstall.py.orig ./yuminstall.py
> --- ./yuminstall.py.orig	2009-11-21 20:24:29.000000000 -0600
> +++ ./yuminstall.py	2009-11-21 20:24:32.000000000 -0600
> @@ -725,6 +725,13 @@ class AnacondaYum(YumSorter):
>  
>          self.repos.setCacheDir(self.conf.cachedir)
>  
> +        if os.path.exists("/mnt/sysimage/boot/upgrade/install.img"):
> +            log.info("REMOVING stage2 image from /mnt/sysimage/boot/upgrade")
> +            try:
> +                os.unlink ("/mnt/sysimage/boot/upgrade/install.img")
> +            except:
> +                log.warning("failed to clean /boot/upgrade")
> +
>      def downloadHeader(self, po):
>          while True:
>              # retrying version of download header

You need to use self.anaconda.rootPath instead of "/mnt/sysimage".

> diff -up ./yuminstall.py.orig ./yuminstall.py
> --- ./yuminstall.py.orig	2009-11-21 05:16:04.000000000 -0600
> +++ ./yuminstall.py	2009-11-21 16:36:47.000000000 -0600
> @@ -625,6 +625,25 @@ class AnacondaYum(YumSorter):
>  
>  
>      def doConfigSetup(self, fn='/tmp/anaconda-yum.conf', root='/'):
> +        # installs that don't use /mnt/stage2 hold the install.img on 
> +        # a tmpfs, free this ram if things are tight.
> +        stage2img = "/tmp/install.img"
> +
> +        if os.path.exists(stage2img) and iutil.memInstalled() < isys.MIN_GUI_RAM: 
> +            log.info("%s exists and low memory" % stage2img )
> +
> +        # free up /tmp for more memory before yum is called, 
> +            try: 
> +                self.anaconda.backend.mountInstallImage(self.anaconda, stage2img)
> +            except: 
> +                log.info("mountInstallImage failed")
> +                   
> +            try:
> +                os.unlink(stage2img)
> +            except:
> +                log.info("clearing /tmp failed")
> +                pass
> +
>          if hasattr(self, "preconf"):
>              self.preconf.fn = fn
>              self.preconf.root = root

Agreed with Hans - this is not a good place for this code.  First, we
need to do it in all backends so you don't want to put it in AnacondaYum
(or really, anywhere in yuminstall.py).  Second even if you were to put
it in AnacondaYum, you wouldn't want it to go in doConfigSetup.
Basically any time you find yourself wanting to put code in AnacondaYum,
ask yourself whether that code would go in yum.  If not, AnacondaYum is
probably the wrong place for it.  This seems like something that should
go in image.py.

Also, if mountInstallImage raises an exception, that is pretty much
fatal.  See this existing code in yuminstall.py:

            if self.anaconda.backend.mountInstallImage(self.anaconda, stage2img):
                self.anaconda.id.storage.umountFilesystems()
                return DISPATCH_BACK

> @@ -199,7 +207,12 @@
>              return 1
>  
>          isys.lochangefd("/dev/loop0", self._loopbackFile)
> -        isys.umount("/mnt/stage2")
> +
> +        # http, ftp, hd installs don't mount /mnt/stage2
> +        try:
> +            isys.umount("/mnt/stage2")
> +        except:
> +            pass
>  
>      def removeInstallImage(self):
>          if self._loopbackFile:

The try...except where you don't catch a specific exception is pretty
bad, as you end up unintentionally hiding all sorts of issues.  Here, we
don't even need to handle an exception as we know whether or not
something's mounted:

    if os.path.ismount("/mnt/stage2"):
        isys.umount("/mnt/stage2")

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

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux