ginger-dev-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ginger-dev-list] [PATCH 1/2] Add support to update Power FW using not o


From: pvital
Subject: [Ginger-dev-list] [PATCH 1/2] Add support to update Power FW using not only RPM files.
Date: Tue, 6 Oct 2015 17:01:00 -0300

From: Paulo Vital <address@hidden>

The newest version of Power machines are using HPM (Hardware Platform
Management) files to provide Firmware update. This patch splits how
we manage the image information to be update spliting between RPM and
other file systems.

Signed-off-by: Paulo Vital <address@hidden>
---
 models/firmware.py | 41 ++++++++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 17 deletions(-)

diff --git a/models/firmware.py b/models/firmware.py
index 1bfbdd4..fb35fef 100644
--- a/models/firmware.py
+++ b/models/firmware.py
@@ -20,6 +20,7 @@
 
 import os
 import platform
+import magic
 
 from wok.exception import OperationFailed
 from wok.utils import wok_log
@@ -60,23 +61,29 @@ class FirmwareModel(object):
         fw_path = params['path']
         pow_ok = params.get('overwrite-perm-ok', True)
 
-        # First unpack the rpm to get the fw img file
-        # FIXME: When there's a .deb package available, add support for that
-        command = ['rpm', '-U', '--force', '--ignoreos', fw_path]
-        output, error, rc = run_command(command)
-        if rc:
-            # rpm returns num failed pkgs on failure or neg for unknown
-            raise OperationFailed('GINFW0002E', {'rc': rc, 'err': error})
-
-        # The image file should now be in /tmp/fwupdate/
-        # and match the rpm name.
-        image_file, ext = os.path.splitext(os.path.basename(fw_path))
-        if image_file is None:
-            wok_log.error('FW update failed: '
-                          'No image file found in the package file.')
-            raise OperationFailed('GINFW0003E')
-        command = ['update_flash', '-f',
-                   os.path.join('/tmp/fwupdate', '%s.img' % image_file)]
+        ms = magic.open(magic.NONE)
+        ms.load()
+        if ms.file(fw_path).lower().startswith('rpm'):
+            # First unpack the rpm to get the fw img file
+            command = ['rpm', '-U', '--force', '--ignoreos', fw_path]
+            output, error, rc = run_command(command)
+            if rc:
+                # rpm returns num failed pkgs on failure or neg for unknown
+                raise OperationFailed('GINFW0002E', {'rc': rc, 'err': error})
+
+            # The image file should now be in /tmp/fwupdate/
+            # and match the rpm name.
+            image_file, ext = os.path.splitext(os.path.basename(fw_path))
+            if image_file is None:
+                wok_log.error('FW update failed: '
+                              'No image file found in the package file.')
+                raise OperationFailed('GINFW0003E')
+            image_file = os.path.join('/tmp/fwupdate', '%s.img' % image_file)
+        else:
+            image_file = fw_path
+        ms.close()
+
+        command = ['update_flash', '-f', image_file]
         if not pow_ok:
             command.insert(1, '-n')
         wok_log.info('FW update: System will reboot to flash the firmware.')
-- 
2.4.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]