diff mbox

[Branch,~linaro-image-tools/linaro-image-tools/trunk] Rev 568: Fixed regression on missing default bootloader.

Message ID 20121001134910.5827.76362.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Milo Casagrande Oct. 1, 2012, 1:49 p.m. UTC
Merge authors:
  Milo Casagrande (milo)
Related merge proposals:
  https://code.launchpad.net/~milo/linaro-image-tools/bug1057639/+merge/127270
  proposed by: Milo Casagrande (milo)
  review: Approve - Paul Sokolovsky (pfalcon)
------------------------------------------------------------
revno: 568 [merge]
committer: Milo Casagrande <milo@ubuntu.com>
branch nick: trunk
timestamp: Mon 2012-10-01 15:45:53 +0200
message:
  Fixed regression on missing default bootloader.
modified:
  linaro-media-create
  linaro_image_tools/hwpack/hwpack_fields.py
  linaro_image_tools/media_create/__init__.py
  linaro_image_tools/media_create/boards.py


--
lp:linaro-image-tools
https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk

You are subscribed to branch lp:linaro-image-tools.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'linaro-media-create'
--- linaro-media-create	2012-08-09 23:00:50 +0000
+++ linaro-media-create	2012-10-01 12:50:55 +0000
@@ -106,6 +106,14 @@ 
     parser = get_args_parser()
     args = parser.parse_args()
 
+    ch = logging.StreamHandler()
+    ch.setLevel(logging.INFO)
+    formatter = logging.Formatter("%(message)s")
+    ch.setFormatter(formatter)
+    logger = logging.getLogger("linaro_image_tools")
+    logger.setLevel(logging.INFO)
+    logger.addHandler(ch)
+
     try:
         additional_option_checks(args)
     except IncompatibleOptions as e:
@@ -154,14 +162,6 @@ 
         # All good, move on.
         pass
 
-    ch = logging.StreamHandler()
-    ch.setLevel(logging.INFO)
-    formatter = logging.Formatter("%(message)s")
-    ch.setFormatter(formatter)
-    logger = logging.getLogger("linaro_image_tools")
-    logger.setLevel(logging.INFO)
-    logger.addHandler(ch)
-
     # If --help was specified this won't execute.
     # Create temp dir and initialize rest of path vars.
     TMP_DIR = tempfile.mkdtemp()

=== modified file 'linaro_image_tools/hwpack/hwpack_fields.py'
--- linaro_image_tools/hwpack/hwpack_fields.py	2012-09-24 09:07:37 +0000
+++ linaro_image_tools/hwpack/hwpack_fields.py	2012-10-01 12:49:58 +0000
@@ -91,6 +91,11 @@ 
     'bootfs_rootfs',
     'reserved_bootfs_rootfs', ]
 
+# Supported bootloaders
+U_BOOT = 'u_boot'
+UEFI = 'uefi'
+DEFAULT_BOOTLOADER = U_BOOT
+
 # Define where fields are valid, so we can test them.
 # If a key has a value None, this indicates there is either a value or
 #  list of values that can be associated with it.

=== modified file 'linaro_image_tools/media_create/__init__.py'
--- linaro_image_tools/media_create/__init__.py	2012-07-26 08:48:15 +0000
+++ linaro_image_tools/media_create/__init__.py	2012-10-01 13:44:05 +0000
@@ -26,6 +26,9 @@ 
 from linaro_image_tools.media_create.android_boards import (
     android_board_configs)
 from linaro_image_tools.__version__ import __version__
+from linaro_image_tools.hwpack.hwpack_fields import (
+    DEFAULT_BOOTLOADER
+)
 
 
 KNOWN_BOARDS = board_configs.keys()
@@ -167,8 +170,9 @@ 
               'on selecting [mmc]"'))
     parser.add_argument(
         '--bootloader',
-        help="Select a bootloader from a hardware pack that contains more than"
-             "one.")
+        help="Select a bootloader from a hardware pack that contains more "
+             "than one. If not specified, it will default to '%s'." %
+             DEFAULT_BOOTLOADER)
 
     add_common_options(parser)
     return parser

=== modified file 'linaro_image_tools/media_create/boards.py'
--- linaro_image_tools/media_create/boards.py	2012-09-12 10:51:00 +0000
+++ linaro_image_tools/media_create/boards.py	2012-10-01 12:58:41 +0000
@@ -47,6 +47,10 @@ 
     partition_mounted, SECTOR_SIZE, register_loopback)
 from StringIO import StringIO
 
+from linaro_image_tools.hwpack.hwpack_fields import (
+    DEFAULT_BOOTLOADER,
+)
+
 KERNEL_GLOB = 'vmlinuz-*-%(kernel_flavor)s'
 INITRD_GLOB = 'initrd.img-*-%(kernel_flavor)s'
 DTB_GLOB = 'dt-*-%(kernel_flavor)s/%(dtb_name)s'
@@ -438,6 +442,14 @@ 
 
     hardwarepack_handler = None
 
+    @staticmethod
+    def _get_logger():
+        """
+        Gets the logger instance.
+        :return: The logger instance
+        """
+        return logging.getLogger('linaro_image_tools')
+
     @classmethod
     def get_metadata_field(cls, field_name):
         """ Return the metadata value for field_name if it can be found.
@@ -451,6 +463,14 @@ 
 
     @classmethod
     def set_metadata(cls, hwpacks, bootloader=None, board=None):
+        # If not bootloader is specified, we use the default one.
+        logger = cls._get_logger()
+        if not bootloader:
+            logger.warning('WARNING: no bootloader specified on the command '
+                           'line. Defaulting to \'%s\'.' % DEFAULT_BOOTLOADER)
+            logger.warning('WARNING: specify another bootloader if this is '
+                           'not the correct one to use.')
+            bootloader = DEFAULT_BOOTLOADER
         cls.hardwarepack_handler = HardwarepackHandler(hwpacks, bootloader,
                                                        board)
         with cls.hardwarepack_handler: