diff options
author | Chris Lumens <clumens@redhat.com> | 2008-04-02 11:48:22 -0400 |
---|---|---|
committer | Chris Lumens <clumens@redhat.com> | 2008-04-02 11:48:36 -0400 |
commit | 2a568931477bef8811af6afe5c5392bf4dcc01a2 (patch) | |
tree | 9c23ea0268a53122c9dd4e91438911de091ee832 | |
parent | 75e4010a2d257848e9fc6eb64d02ea1742ba6573 (diff) | |
download | anaconda-2a568931477bef8811af6afe5c5392bf4dcc01a2.tar.gz anaconda-2a568931477bef8811af6afe5c5392bf4dcc01a2.tar.xz anaconda-2a568931477bef8811af6afe5c5392bf4dcc01a2.zip |
Use a better test to see if a package group doesn't exist (#439922).
-rw-r--r-- | backend.py | 6 | ||||
-rw-r--r-- | kickstart.py | 41 | ||||
-rw-r--r-- | yuminstall.py | 25 |
3 files changed, 37 insertions, 35 deletions
diff --git a/backend.py b/backend.py index 4c047a20e..c59ac4cb5 100644 --- a/backend.py +++ b/backend.py @@ -35,6 +35,12 @@ from rhpl.translate import _ from flags import flags log = logging.getLogger("anaconda") +class NoSuchGroup(Exception): + def __init__ (self, value): + self.value = value + + def __str__ (self): + return self.value class AnacondaBackend: def __init__(self, anaconda): diff --git a/kickstart.py b/kickstart.py index d990e9714..7f1b38470 100644 --- a/kickstart.py +++ b/kickstart.py @@ -18,6 +18,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from backend import NoSuchGroup import iutil import isys import os @@ -1005,26 +1006,26 @@ def selectPackages(anaconda): default = True optional = True - num = anaconda.backend.selectGroup(grp.name, (default, optional)) - - if ksdata.packages.handleMissing == KS_MISSING_IGNORE: - continue - if num > 0: - continue - rc = anaconda.intf.messageWindow(_("Missing Group"), - _("You have specified that the " - "group '%s' should be installed. " - "This group does not exist. " - "Would you like to continue or " - "abort your installation?") - %(grp.name,), - type="custom", - custom_buttons=[_("_Abort"), - _("_Continue")]) - if rc == 0: - sys.exit(1) - else: - pass + try: + anaconda.backend.selectGroup(grp.name, (default, optional)) + except NoSuchGroup, e: + if ksdata.packages.handleMissing == KS_MISSING_IGNORE: + pass + else: + rc = anaconda.intf.messageWindow(_("Missing Group"), + _("You have specified that the " + "group '%s' should be installed. " + "This group does not exist. " + "Would you like to continue or " + "abort your installation?") + %(grp.name,), + type="custom", + custom_buttons=[_("_Abort"), + _("_Continue")]) + if rc == 0: + sys.exit(1) + else: + pass map(anaconda.backend.deselectPackage, ksdata.packages.excludedList) diff --git a/yuminstall.py b/yuminstall.py index 808a6c2b6..78f01b774 100644 --- a/yuminstall.py +++ b/yuminstall.py @@ -40,7 +40,7 @@ import rhpl from yum.constants import * from yum.Errors import RepoError, YumBaseError, PackageSackError from yum.yumRepo import YumRepository -from backend import AnacondaBackend +from backend import AnacondaBackend, NoSuchGroup from product import productName, productStamp from sortedtransaction import SplitMediaTransactionData from constants import * @@ -1581,22 +1581,21 @@ class YumBackend(AnacondaBackend): return False def _selectDefaultOptGroup(self, grpid, default, optional): - retval = 0 grp = self.ayum.comps.return_group(grpid) if not default: for pkg in grp.default_packages.keys(): self.deselectPackage(pkg) - retval -= 1 if optional: for pkg in grp.optional_packages.keys(): self.selectPackage(pkg) - retval += 1 - - return retval def selectGroup(self, group, *args): + if not self.ayum.comps.has_group(group): + log.debug("no such group %s" % group) + raise NoSuchGroup + if args: default = args[0][0] optional = args[0][1] @@ -1607,25 +1606,21 @@ class YumBackend(AnacondaBackend): try: mbrs = self.ayum.selectGroup(group) if len(mbrs) == 0 and self.isGroupSelected(group): - return 1 - - extras = self._selectDefaultOptGroup(group, default, optional) + return - return len(mbrs) + extras + self._selectDefaultOptGroup(group, default, optional) except yum.Errors.GroupsError, e: # try to find out if it's the name or translated name gid = self.__getGroupId(group) if gid is not None: mbrs = self.ayum.selectGroup(gid) if len(mbrs) == 0 and self.isGroupSelected(gid): - return 1 - - extras = self._selectDefaultOptGroup(group, default, optional) + return - return len(mbrs) + extras + self._selectDefaultOptGroup(group, default, optional) else: log.debug("no such group %s" %(group,)) - return 0 + raise NoSuchGroup def deselectGroup(self, group, *args): try: |