FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 09-29-2011, 08:15 AM
Ales Kozumplik
 
Default dracut args: "rhgb quiet" should come last.

The patch introduces a simple mechanism to order the (otherwise unsorted)
dracut arguments.

With a UT.

Resolves: rhbz#740949
---
pyanaconda/bootloader.py | 12 +++++++++++-
tests/pyanaconda_test/bootloader_test.py | 8 ++++++++
2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index 45950d7..210ea15 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -79,6 +79,11 @@ class BootLoaderError(Exception):
pass

class Arguments(set):
+ ordering_dict = {
+ "rhgb" : 99,
+ "quiet" : 100
+ }
+
def _merge_ip(self):
"""
Find ip= arguments targetting the same interface and merge them.
@@ -111,7 +116,12 @@ class Arguments(set):

def __str__(self):
self._merge_ip()
- return " ".join(self)
+ # sort the elements according to their values in ordering_dict. The
+ # higher the number the closer to the final string the argument
+ # gets. The default is 50.
+ lst = sorted(self, key=lambda s: self.ordering_dict.get(s, 50))
+
+ return " ".join(lst)

class BootLoaderImage(object):
""" Base class for bootloader images. Suitable for non-linux OS images. """
diff --git a/tests/pyanaconda_test/bootloader_test.py b/tests/pyanaconda_test/bootloader_test.py
index 59b6ea2..6aa93bb 100644
--- a/tests/pyanaconda_test/bootloader_test.py
+++ b/tests/pyanaconda_test/bootloader_test.py
@@ -49,3 +49,11 @@ class ArgumentsTest(mock.TestCase):
self.assertEqual(str(a), "ip=eth0:dhcp")
a = Arguments(["ip=eth0:dhcp", "ip=eth0:auto6"])
assert(str(a) in ["ip=eth0:auto6,dhcp", "ip=eth0:dhcp,auto6"])
+
+ def test_sorting(self):
+ from pyanaconda.bootloader import Arguments
+ a = Arguments(["ip=eth0:dhcp", "rhgb", "quiet",
+ "root=/dev/mapper/destroyers-rubies", "rd.md=0",
+ "rd.luks=0"])
+ # 'rhgb quiet' should be the final entries:
+ assert(str(a).endswith("rhgb quiet"))
--
1.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 09-29-2011, 08:28 AM
Martin Gracik
 
Default dracut args: "rhgb quiet" should come last.

looks good

----- Original Message -----
> The patch introduces a simple mechanism to order the (otherwise
> unsorted)
> dracut arguments.
>
> With a UT.
>
> Resolves: rhbz#740949
> ---
> pyanaconda/bootloader.py | 12 +++++++++++-
> tests/pyanaconda_test/bootloader_test.py | 8 ++++++++
> 2 files changed, 19 insertions(+), 1 deletions(-)
>
> diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
> index 45950d7..210ea15 100644
> --- a/pyanaconda/bootloader.py
> +++ b/pyanaconda/bootloader.py
> @@ -79,6 +79,11 @@ class BootLoaderError(Exception):
> pass
>
> class Arguments(set):
> + ordering_dict = {
> + "rhgb" : 99,
> + "quiet" : 100
> + }
> +
> def _merge_ip(self):
> """
> Find ip= arguments targetting the same interface and merge
> them.
> @@ -111,7 +116,12 @@ class Arguments(set):
>
> def __str__(self):
> self._merge_ip()
> - return " ".join(self)
> + # sort the elements according to their values in
> ordering_dict. The
> + # higher the number the closer to the final string the
> argument
> + # gets. The default is 50.
> + lst = sorted(self, key=lambda s: self.ordering_dict.get(s,
> 50))
> +
> + return " ".join(lst)
>
> class BootLoaderImage(object):
> """ Base class for bootloader images. Suitable for non-linux OS
> images. """
> diff --git a/tests/pyanaconda_test/bootloader_test.py
> b/tests/pyanaconda_test/bootloader_test.py
> index 59b6ea2..6aa93bb 100644
> --- a/tests/pyanaconda_test/bootloader_test.py
> +++ b/tests/pyanaconda_test/bootloader_test.py
> @@ -49,3 +49,11 @@ class ArgumentsTest(mock.TestCase):
> self.assertEqual(str(a), "ip=eth0:dhcp")
> a = Arguments(["ip=eth0:dhcp", "ip=eth0:auto6"])
> assert(str(a) in ["ip=eth0:auto6,dhcp",
> "ip=eth0:dhcp,auto6"])
> +
> + def test_sorting(self):
> + from pyanaconda.bootloader import Arguments
> + a = Arguments(["ip=eth0:dhcp", "rhgb", "quiet",
> + "root=/dev/mapper/destroyers-rubies",
> "rd.md=0",
> + "rd.luks=0"])
> + # 'rhgb quiet' should be the final entries:
> + assert(str(a).endswith("rhgb quiet"))
> --
> 1.7.6
>
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@redhat.com
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list
>

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

Thread Tools




All times are GMT. The time now is 01:22 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org