[PATCH] Fix Unhandled Exception Deleting All PPC Partitions (#1021445)
by Robert Marshall
Users reported that the installer would crash when deleting all
existing partitions on the PowerPC Platform. This crash occurred
because the installer preferentially looks for a PRePBoot on the
same partition as /boot which does not exist. Modified the call
to handle the exception and return the first PRePBoot device
found if an exception occurs.
Resolves rhbz#1021445
---
booty/ppc.py | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/booty/ppc.py b/booty/ppc.py
index 2cb2103..61a2dbb 100644
--- a/booty/ppc.py
+++ b/booty/ppc.py
@@ -27,16 +27,17 @@ class ppcBootloaderInfo(bootloaderInfo):
# we'd prefer a PReP partition that's on the same disk as /boot.
bootdev = self.storage.mountpoints.get("/boot",self.storage.rootDevice)
- if bootdev.type == "mdarray":
- bootdisks = set(p.disk for p in bootdev.parents)
- else:
- bootdisks = set([bootdev.disk])
- for dev in prepdevs:
- if dev.disk in bootdisks:
- return dev
-
- # failing that, return the first PReP partition we found
- return prepdevs[0]
+ try:
+ if hasattr(bootdev, 'type') and bootdev.type == "mdarray":
+ bootdisks = set(p.disk for p in bootdev.parents)
+ else:
+ bootdisks = set([bootdev.disk])
+ for dev in prepdevs:
+ if dev.disk in bootdisks:
+ return dev
+ except:
+ # failing that, return the first PReP partition we found
+ return prepdevs[0]
def getBootDevs(self, bl):
--
2.1.0
9 years, 2 months
[master] Clear TUI source spoke errors that may have been leftover from a prior attempt. (#1192259)
by Samantha N. Bueno
This does a few things:
-- self.errors -> self._error in the TUI source spoke; and it is now
just a boolean value instead of a list, same as in the GUI source
spoke; any error messages that were previously being stored here in a
list were never being shown anyway
-- gets rid of _update_summary() since that was never used
-- before attempting to apply a user's selection, clear any errors which
may have been incurred from a prior attempt
Resolves: rhbz#1192259
---
pyanaconda/ui/tui/spokes/source.py | 29 ++++++++++++-----------------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/pyanaconda/ui/tui/spokes/source.py b/pyanaconda/ui/tui/spokes/source.py
index 50c50b8..67043dd 100644
--- a/pyanaconda/ui/tui/spokes/source.py
+++ b/pyanaconda/ui/tui/spokes/source.py
@@ -63,7 +63,7 @@ class SourceSpoke(EditTUISpoke, SourceSwitchHandler):
EditTUISpoke.__init__(self, app, data, storage, payload, instclass)
SourceSwitchHandler.__init__(self)
self._ready = False
- self.errors = []
+ self._error = False
self._cdrom = None
def initialize(self):
@@ -88,7 +88,7 @@ class SourceSpoke(EditTUISpoke, SourceSwitchHandler):
self._ready = True
def _payload_error(self):
- self.errors.append(payloadMgr.error)
+ self._error = True
def _repo_status(self):
""" Return a string describing repo url or lack of one. """
@@ -113,28 +113,19 @@ class SourceSpoke(EditTUISpoke, SourceSwitchHandler):
@property
def status(self):
- if self.errors:
+ if self._error:
return _("Error setting up software source")
elif not self.ready:
return _("Processing...")
else:
return self._repo_status()
- def _update_summary(self):
- """ Update screen with a summary. Show errors if there are any. """
- summary = (_("Repo URL set to: %s") % self._repo_status())
-
- if self.errors:
- summary = summary + "\n" + "\n".join(self.errors)
-
- return summary
-
@property
def completed(self):
if flags.automatedInstall and self.ready and not self.payload.baseRepo:
return False
else:
- return not self.errors and self.ready and (self.data.method.method or self.payload.baseRepo)
+ return not self._error and self.ready and (self.data.method.method or self.payload.baseRepo)
def refresh(self, args=None):
EditTUISpoke.refresh(self, args)
@@ -198,7 +189,7 @@ class SourceSpoke(EditTUISpoke, SourceSwitchHandler):
# preliminary NFS source switch
self.set_source_nfs()
newspoke = SpecifyNFSRepoSpoke(self.app, self.data, self.storage,
- self.payload, self.instclass, self._selection, self.errors)
+ self.payload, self.instclass, self._selection, self._error)
self.app.switch_screen_modal(newspoke)
self.apply()
self.close()
@@ -240,6 +231,10 @@ class SourceSpoke(EditTUISpoke, SourceSwitchHandler):
if flags.askmethod:
flags.askmethod = False
+ # if we had any errors, e.g. from a previous attempt to set the source,
+ # clear them at this point
+ self._error = False
+
payloadMgr.restartThread(self.storage, self.data, self.payload, self.instclass,
checkmount=False)
@@ -291,11 +286,11 @@ class SpecifyNFSRepoSpoke(EditTUISpoke, SourceSwitchHandler):
Entry(N_("NFS mount options"), "opts", re.compile(".*$"), True)
]
- def __init__(self, app, data, storage, payload, instclass, selection, errors):
+ def __init__(self, app, data, storage, payload, instclass, selection, error):
EditTUISpoke.__init__(self, app, data, storage, payload, instclass)
SourceSwitchHandler.__init__(self)
self.selection = selection
- self.errors = errors
+ self._error = error
nfs = self.data.method
self.args = DataHolder(server="", opts=nfs.opts or "")
@@ -322,7 +317,7 @@ class SpecifyNFSRepoSpoke(EditTUISpoke, SourceSwitchHandler):
(self.data.method.server, self.data.method.dir) = self.args.server.split(":", 2)
except ValueError as err:
LOG.error("ValueError: %s", err)
- self.errors.append(_("Failed to set up installation source. Check the source address."))
+ self._error = True
return
opts = self.args.opts or ""
--
1.9.3
9 years, 2 months
[rhel6-branch] Exclude prelink package in FIPS mode (#697938)
by Brian C. Lane
In fips mode prelinking needs to be disabled.
Resolves: rhbz#697938
---
platform.py | 15 ++++++++++++---
yuminstall.py | 1 +
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/platform.py b/platform.py
index 59a782c..53412c3 100644
--- a/platform.py
+++ b/platform.py
@@ -44,6 +44,7 @@ class Platform(object):
_isEfi = iutil.isEfi()
_minimumSector = 0
_packages = []
+ _excluded_packages = []
_supportsLvmBoot = False
_supportsMdRaidBoot = False
_minBootPartSize = 50
@@ -190,11 +191,19 @@ class Platform(object):
@property
def packages (self):
if self.anaconda.isKickstart and self.anaconda.id.ksdata.bootloader.disabled:
- return []
+ packages = []
+ else:
+ packages = self._packages
+
+ if flags.cmdline.get('fips', None) == '1':
+ packages += ['dracut-fips']
+ return packages
+ @property
+ def excluded_packages (self):
if flags.cmdline.get('fips', None) == '1':
- return self._packages + ['dracut-fips']
- return self._packages
+ return self._excluded_packages + ['prelink']
+ return self._excluded_packages
def setDefaultPartitioning(self):
"""Return the default platform-specific partitioning information."""
diff --git a/yuminstall.py b/yuminstall.py
index 2d72a6a..da35677 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -1614,6 +1614,7 @@ debuglevel=6
# New installs only - upgrades will already have all this stuff.
self.selectBestKernel(anaconda)
map(self.selectPackage, anaconda.platform.packages)
+ map(self.deselectPackage, anaconda.platform.excluded_packages)
self.selectFSPackages(anaconda.id.storage)
if anaconda.id.network.hasActiveIPoIBDevice():
self.selectPackage("rdma")
--
2.1.0
9 years, 2 months
[PATCH 1/2] Add test lib methods to check regexes
by David Shea
We currently test regular expressions in two ways: does the expression
match and not match lists of strings, and does the expression parse a
string into the expected groups. Share those two methods in a common
module.
---
tests/lib/regexcheck.py | 71 ++++++++++++++++++++++++++++++++++++
tests/regex_tests/groupparse_test.py | 11 +-----
tests/regex_tests/hostname_test.py | 29 ++++-----------
tests/regex_tests/repo_name_test.py | 23 ++----------
tests/regex_tests/url_test.py | 17 +--------
tests/regex_tests/username_test.py | 32 +++++-----------
6 files changed, 94 insertions(+), 89 deletions(-)
create mode 100644 tests/lib/regexcheck.py
diff --git a/tests/lib/regexcheck.py b/tests/lib/regexcheck.py
new file mode 100644
index 0000000..57307d9
--- /dev/null
+++ b/tests/lib/regexcheck.py
@@ -0,0 +1,71 @@
+#
+# regexcheck.py: check a regular expression against lists of matching and non-matching strings
+#
+# Copyright (C) 2015 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: David Shea <dshea(a)redhat.com>
+
+def regex_match(expression, goodlist, badlist):
+ """ Check that a regular expression matches and does not match lists of strings.
+
+ This method will print a message for any failure and return a a bool
+ to indicate whether the testcase passed.
+
+ :param expression: a compiled regular expression object
+ :param goodlist: a list of strings expected to be matched by expression
+ :param badlist: a list of strings expected not to be matched by expression
+ :returns: True if all strings in the lists matched or did not match as expected
+ :rtype: bool
+ """
+
+ success = True
+
+ for good in goodlist:
+ if expression.match(good) is None:
+ success = False
+ print("Good string %s did not match expression" % good)
+
+ for bad in badlist:
+ if expression.match(bad) is not None:
+ success = False
+ print("Bad string %s matched expression" % bad)
+
+ return success
+
+def regex_group(expression, test_cases):
+ """ Check that a regex parses strings into expected groups.
+
+ Test cases is a list of tuples of the form (test_string, expected_result)
+ where expected_result is the groups tuples that should be returned by
+ regex.match.
+
+ :param expression: a compiled expression object
+ :param test_cases: a list of test strings and expected results
+ :returns: True if all test cases return the expected groups
+ :rtype: bool
+ """
+
+ success = True
+ for test_str, result in test_cases:
+ match = expression.match(test_str)
+ if match is not None:
+ match = match.groups()
+
+ if match != result:
+ print("Test case `%s' did not parse as `%s': %s" % (test_str, result, match))
+ success = False
+
+ return success
diff --git a/tests/regex_tests/groupparse_test.py b/tests/regex_tests/groupparse_test.py
index 0d2e6ba..80e7187 100644
--- a/tests/regex_tests/groupparse_test.py
+++ b/tests/regex_tests/groupparse_test.py
@@ -20,6 +20,7 @@
#
import unittest
+from regexcheck import regex_group
from pyanaconda.regexes import GROUPLIST_FANCY_PARSE
class GroupParseTestCase(unittest.TestCase):
@@ -49,13 +50,5 @@ class GroupParseTestCase(unittest.TestCase):
("", ("", None)),
]
- got_error = False
- for group, result in tests:
- try:
- self.assertEqual(GROUPLIST_FANCY_PARSE.match(group).groups(), result)
- except AssertionError:
- got_error = True
- print("Group parse error: `%s' did not not parse as `%s'" % (group, result))
-
- if got_error:
+ if not regex_group(GROUPLIST_FANCY_PARSE, tests):
self.fail()
diff --git a/tests/regex_tests/hostname_test.py b/tests/regex_tests/hostname_test.py
index 529fbb7..df04327 100644
--- a/tests/regex_tests/hostname_test.py
+++ b/tests/regex_tests/hostname_test.py
@@ -22,28 +22,10 @@
import unittest
import re
+from regexcheck import regex_match
from pyanaconda.regexes import HOSTNAME_PATTERN_WITHOUT_ANCHORS, IPV4_PATTERN_WITHOUT_ANCHORS,\
IPV6_PATTERN_WITHOUT_ANCHORS
-def _run_tests(testcase, expression, goodlist, badlist):
- got_error = False
- for good in goodlist:
- try:
- testcase.assertIsNotNone(expression.match(good))
- except AssertionError:
- got_error = True
- print("Good string %s did not match expression" % good)
-
- for bad in badlist:
- try:
- testcase.assertIsNone(expression.match(bad))
- except AssertionError:
- got_error = True
- print("Bad string %s matched expression" % bad)
-
- if got_error:
- testcase.fail()
-
class HostnameRegexTestCase(unittest.TestCase):
def hostname_test(self):
good_tests = [
@@ -76,7 +58,8 @@ class HostnameRegexTestCase(unittest.TestCase):
]
hostname_re = re.compile('^' + HOSTNAME_PATTERN_WITHOUT_ANCHORS + '$')
- _run_tests(self, hostname_re, good_tests, bad_tests)
+ if not regex_match(hostname_re, good_tests, bad_tests):
+ self.fail()
class IPv4RegexTestCase(unittest.TestCase):
def ipv4_test(self):
@@ -99,7 +82,8 @@ class IPv4RegexTestCase(unittest.TestCase):
]
ipv4_re = re.compile('^(' + IPV4_PATTERN_WITHOUT_ANCHORS + ')$')
- _run_tests(self, ipv4_re, good_tests, bad_tests)
+ if not regex_match(ipv4_re, good_tests, bad_tests):
+ self.fail()
class IPv6RegexTestCase(unittest.TestCase):
def ipv6_test(self):
@@ -187,4 +171,5 @@ class IPv6RegexTestCase(unittest.TestCase):
]
ipv6_re = re.compile('^(' + IPV6_PATTERN_WITHOUT_ANCHORS + ')$')
- _run_tests(self, ipv6_re, good_tests, bad_tests)
+ if not regex_match(ipv6_re, good_tests, bad_tests):
+ self.fail()
diff --git a/tests/regex_tests/repo_name_test.py b/tests/regex_tests/repo_name_test.py
index 85d9376..76ac0f9 100644
--- a/tests/regex_tests/repo_name_test.py
+++ b/tests/regex_tests/repo_name_test.py
@@ -21,27 +21,9 @@
#
import unittest
+from regexcheck import regex_match
from pyanaconda.regexes import REPO_NAME_VALID
-def _run_tests(testcase, expression, goodlist, badlist):
- got_error = False
- for good in goodlist:
- try:
- testcase.assertIsNotNone(expression.match(good))
- except AssertionError:
- got_error = True
- print("Good string %s did not match expression" % good)
-
- for bad in badlist:
- try:
- testcase.assertIsNone(expression.match(bad))
- except AssertionError:
- got_error = True
- print("Bad string %s matched expression" % bad)
-
- if got_error:
- testcase.fail()
-
class RepoNameTestCase(unittest.TestCase):
def reponame_test(self):
good_tests = [
@@ -63,4 +45,5 @@ class RepoNameTestCase(unittest.TestCase):
'[reponame]'
]
- _run_tests(self, REPO_NAME_VALID, good_tests, bad_tests)
+ if not regex_match(REPO_NAME_VALID, good_tests, bad_tests):
+ self.fail()
diff --git a/tests/regex_tests/url_test.py b/tests/regex_tests/url_test.py
index 3c77f7d..0f40ea2 100644
--- a/tests/regex_tests/url_test.py
+++ b/tests/regex_tests/url_test.py
@@ -21,6 +21,7 @@
import unittest
+from regexcheck import regex_group
from pyanaconda.regexes import URL_PARSE
class URLRegexTestCase(unittest.TestCase):
@@ -165,19 +166,5 @@ class URLRegexTestCase(unittest.TestCase):
]
- got_error = False
- for proxy, result in tests:
- match = URL_PARSE.match(proxy)
- if match:
- match= match.groups()
- else:
- match = None
-
- try:
- self.assertEqual(match, result)
- except AssertionError:
- got_error = True
- print("Proxy parse error: `%s' did not parse as `%s': %s" % (proxy, result, match))
-
- if got_error:
+ if not regex_group(URL_PARSE, tests):
self.fail()
diff --git a/tests/regex_tests/username_test.py b/tests/regex_tests/username_test.py
index 3ac6bd7..b205945 100644
--- a/tests/regex_tests/username_test.py
+++ b/tests/regex_tests/username_test.py
@@ -21,28 +21,10 @@
#
import unittest
+from regexcheck import regex_match
from pyanaconda.regexes import GECOS_VALID, USERNAME_VALID, GROUPNAME_VALID, GROUPLIST_SIMPLE_VALID
class UsernameRegexTestCase(unittest.TestCase):
- def _run_tests(self, expression, goodlist, badlist):
- got_error = False
- for good in goodlist:
- try:
- self.assertIsNotNone(expression.match(good))
- except AssertionError:
- got_error = True
- print("Good string %s did not match expression" % good)
-
- for bad in badlist:
- try:
- self.assertIsNone(expression.match(bad))
- except AssertionError:
- got_error = True
- print("Bad string %s matched expression" % bad)
-
- if got_error:
- self.fail()
-
def gecos_test(self):
"""Test a list of possible Full Name values."""
# These are valid full names
@@ -59,7 +41,8 @@ class UsernameRegexTestCase(unittest.TestCase):
# These are invalid full names
bad_tests = ['George:Burdell']
- self._run_tests(GECOS_VALID, good_tests, bad_tests)
+ if not regex_match(GECOS_VALID, good_tests, bad_tests):
+ self.fail()
def username_test(self):
"""Test a list of possible username values."""
@@ -94,10 +77,12 @@ class UsernameRegexTestCase(unittest.TestCase):
'-'
]
- self._run_tests(USERNAME_VALID, good_tests, bad_tests)
+ if not regex_match(USERNAME_VALID, good_tests, bad_tests):
+ self.fail()
# The group name checks for the same thing as the user name
- self._run_tests(GROUPNAME_VALID, good_tests, bad_tests)
+ if not regex_match(GROUPNAME_VALID, good_tests, bad_tests):
+ self.fail()
def grouplist_simple_test(self):
good_tests = [
@@ -129,4 +114,5 @@ class UsernameRegexTestCase(unittest.TestCase):
'gburdell, wheel,'
]
- self._run_tests(GROUPLIST_SIMPLE_VALID, good_tests, bad_tests)
+ if not regex_match(GROUPLIST_SIMPLE_VALID, good_tests, bad_tests):
+ self.fail()
--
2.1.0
9 years, 2 months
[PATCH 1/4] Don't try to run new-kernel-pkg if it doesn't exist.
by Chris Lumens
---
pyanaconda/packaging/__init__.py | 4 ++++
pyanaconda/packaging/livepayload.py | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index a8388e7..7642d2f 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -523,6 +523,10 @@ class Payload(object):
:returns: None
"""
+ if not os.path.exists(iutil.getSysroot() + "/usr/sbin/new-kernel-pkg"):
+ log.error("new-kernel-pkg does not exist - grubby wasn't installed? skipping")
+ return
+
for kernel in self.kernelVersionList:
log.info("recreating initrd for %s", kernel)
if not flags.imageInstall:
diff --git a/pyanaconda/packaging/livepayload.py b/pyanaconda/packaging/livepayload.py
index f582219..ed3f073 100644
--- a/pyanaconda/packaging/livepayload.py
+++ b/pyanaconda/packaging/livepayload.py
@@ -164,6 +164,10 @@ class LiveImagePayload(ImagePayload):
threadMgr.wait(THREAD_LIVE_PROGRESS)
# Live needs to create the rescue image before bootloader is written
+ if not os.path.exists(iutil.getSysroot() + "/usr/sbin/new-kernel-pkg"):
+ log.error("new-kernel-pkg does not exist - grubby wasn't installed? skipping")
+ return
+
for kernel in self.kernelVersionList:
log.info("Generating rescue image for %s", kernel)
iutil.execInSysroot("new-kernel-pkg",
--
2.2.2
9 years, 2 months
[PATCH] Remove timestamp-based version support.
by David Shea
If you make a Fedora image with a timestamp-based version you are going
to get Fedora release twenty million some. If you are doing this please
stop doing this.
---
pyanaconda/packaging/__init__.py | 5 -----
1 file changed, 5 deletions(-)
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index e4a9a63..84a7066 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -395,11 +395,6 @@ class Payload(object):
except ConfigParser.Error:
pass
- # If the version looks like a timestamp, assume it's rawhide
- # plz change before Fedora version 9999999
- if version[:8].isdigit():
- version = "rawhide"
-
log.debug("got a release version of %s", version)
return version
--
2.1.0
9 years, 2 months
[PATCH] Fix list-harrdrive-stub
by Brian C. Lane
Change to py3 print resulted in the output looking like a tuple
---
data/command-stubs/list-harddrives-stub | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/data/command-stubs/list-harddrives-stub b/data/command-stubs/list-harddrives-stub
index 3c52d35..28274e4 100755
--- a/data/command-stubs/list-harddrives-stub
+++ b/data/command-stubs/list-harddrives-stub
@@ -35,7 +35,7 @@ def main(argv):
lst = list(lst)
lst.sort()
for dev, size in lst:
- print(dev, size)
+ print("%s %s" % (dev, size))
if __name__ == "__main__":
main(sys.argv)
--
2.1.0
9 years, 2 months