Merge lp:~milo/linaro-image-tools/bug1057639 into lp:linaro-image-tools/11.11

Proposed by Milo Casagrande
Status: Merged
Merged at revision: 568
Proposed branch: lp:~milo/linaro-image-tools/bug1057639
Merge into: lp:linaro-image-tools/11.11
Diff against target: 120 lines (+39/-10)
4 files modified
linaro-media-create (+8/-8)
linaro_image_tools/hwpack/hwpack_fields.py (+5/-0)
linaro_image_tools/media_create/__init__.py (+6/-2)
linaro_image_tools/media_create/boards.py (+20/-0)
To merge this branch: bzr merge lp:~milo/linaro-image-tools/bug1057639
Reviewer Review Type Date Requested Status
Paul Sokolovsky Approve
Linaro Infrastructure Pending
Review via email: mp+127270@code.launchpad.net

Description of the change

Branch adds default value for bootloader option when none is passed on the command line.
Default bootloader is set to 'u_boot'. A warning will be printed on the command line when no bootloader is specified.

To post a comment you must log in.
Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

Good approach on issuing a warning in case explicit value is not provided (I assume we want user to know what bootloader they will use by specifying it themselves). Also assume that moving logging configuration section around was necessary.

review: Approve
571. By Milo Casagrande

Added default bootloader to option help.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'linaro-media-create'
2--- linaro-media-create 2012-08-09 23:00:50 +0000
3+++ linaro-media-create 2012-10-01 13:47:22 +0000
4@@ -106,6 +106,14 @@
5 parser = get_args_parser()
6 args = parser.parse_args()
7
8+ ch = logging.StreamHandler()
9+ ch.setLevel(logging.INFO)
10+ formatter = logging.Formatter("%(message)s")
11+ ch.setFormatter(formatter)
12+ logger = logging.getLogger("linaro_image_tools")
13+ logger.setLevel(logging.INFO)
14+ logger.addHandler(ch)
15+
16 try:
17 additional_option_checks(args)
18 except IncompatibleOptions as e:
19@@ -154,14 +162,6 @@
20 # All good, move on.
21 pass
22
23- ch = logging.StreamHandler()
24- ch.setLevel(logging.INFO)
25- formatter = logging.Formatter("%(message)s")
26- ch.setFormatter(formatter)
27- logger = logging.getLogger("linaro_image_tools")
28- logger.setLevel(logging.INFO)
29- logger.addHandler(ch)
30-
31 # If --help was specified this won't execute.
32 # Create temp dir and initialize rest of path vars.
33 TMP_DIR = tempfile.mkdtemp()
34
35=== modified file 'linaro_image_tools/hwpack/hwpack_fields.py'
36--- linaro_image_tools/hwpack/hwpack_fields.py 2012-09-24 09:07:37 +0000
37+++ linaro_image_tools/hwpack/hwpack_fields.py 2012-10-01 13:47:22 +0000
38@@ -91,6 +91,11 @@
39 'bootfs_rootfs',
40 'reserved_bootfs_rootfs', ]
41
42+# Supported bootloaders
43+U_BOOT = 'u_boot'
44+UEFI = 'uefi'
45+DEFAULT_BOOTLOADER = U_BOOT
46+
47 # Define where fields are valid, so we can test them.
48 # If a key has a value None, this indicates there is either a value or
49 # list of values that can be associated with it.
50
51=== modified file 'linaro_image_tools/media_create/__init__.py'
52--- linaro_image_tools/media_create/__init__.py 2012-07-26 08:48:15 +0000
53+++ linaro_image_tools/media_create/__init__.py 2012-10-01 13:47:22 +0000
54@@ -26,6 +26,9 @@
55 from linaro_image_tools.media_create.android_boards import (
56 android_board_configs)
57 from linaro_image_tools.__version__ import __version__
58+from linaro_image_tools.hwpack.hwpack_fields import (
59+ DEFAULT_BOOTLOADER
60+)
61
62
63 KNOWN_BOARDS = board_configs.keys()
64@@ -167,8 +170,9 @@
65 'on selecting [mmc]"'))
66 parser.add_argument(
67 '--bootloader',
68- help="Select a bootloader from a hardware pack that contains more than"
69- "one.")
70+ help="Select a bootloader from a hardware pack that contains more "
71+ "than one. If not specified, it will default to '%s'." %
72+ DEFAULT_BOOTLOADER)
73
74 add_common_options(parser)
75 return parser
76
77=== modified file 'linaro_image_tools/media_create/boards.py'
78--- linaro_image_tools/media_create/boards.py 2012-09-12 10:51:00 +0000
79+++ linaro_image_tools/media_create/boards.py 2012-10-01 13:47:22 +0000
80@@ -47,6 +47,10 @@
81 partition_mounted, SECTOR_SIZE, register_loopback)
82 from StringIO import StringIO
83
84+from linaro_image_tools.hwpack.hwpack_fields import (
85+ DEFAULT_BOOTLOADER,
86+)
87+
88 KERNEL_GLOB = 'vmlinuz-*-%(kernel_flavor)s'
89 INITRD_GLOB = 'initrd.img-*-%(kernel_flavor)s'
90 DTB_GLOB = 'dt-*-%(kernel_flavor)s/%(dtb_name)s'
91@@ -438,6 +442,14 @@
92
93 hardwarepack_handler = None
94
95+ @staticmethod
96+ def _get_logger():
97+ """
98+ Gets the logger instance.
99+ :return: The logger instance
100+ """
101+ return logging.getLogger('linaro_image_tools')
102+
103 @classmethod
104 def get_metadata_field(cls, field_name):
105 """ Return the metadata value for field_name if it can be found.
106@@ -451,6 +463,14 @@
107
108 @classmethod
109 def set_metadata(cls, hwpacks, bootloader=None, board=None):
110+ # If not bootloader is specified, we use the default one.
111+ logger = cls._get_logger()
112+ if not bootloader:
113+ logger.warning('WARNING: no bootloader specified on the command '
114+ 'line. Defaulting to \'%s\'.' % DEFAULT_BOOTLOADER)
115+ logger.warning('WARNING: specify another bootloader if this is '
116+ 'not the correct one to use.')
117+ bootloader = DEFAULT_BOOTLOADER
118 cls.hardwarepack_handler = HardwarepackHandler(hwpacks, bootloader,
119 board)
120 with cls.hardwarepack_handler:

Subscribers

People subscribed via source and target branches