From 5c344950969f3b19f42396bd1684fcd08e3f6b23 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Mon, 21 Nov 2016 21:21:41 +0000 Subject: [PATCH] [SWL-3475] Fix Firmware upgrade after initial ONIE upgrade. The ONIE firware upgrade staging area is not initialized properly if we don't first boot into ONIE after the initial upgrade. This causes our workflow of ONIE then CPLD upgrade to fail the first time. The onie-fwpkg script does not report an error about the staging area which is why our code is not detecting the failure to install the firmware package. --- .../all/vendor-config-onl/src/python/onl/grub/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/grub/__init__.py b/packages/base/all/vendor-config-onl/src/python/onl/grub/__init__.py index 2ef7373c..8b2501ea 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/grub/__init__.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/grub/__init__.py @@ -1,5 +1,6 @@ from onl.mounts import OnlOnieBootContext, OnlMountContextReadWrite import subprocess +import os ONIE_BOOT_MODES = [ 'install', 'rescue', @@ -17,8 +18,15 @@ def onie_boot_mode_set(mode): with OnlOnieBootContext() as ob: subprocess.check_call("%s/onie/tools/bin/onie-boot-mode -o %s" % (ob.directory, mode), shell=True) +def _makedirs(d): + if not os.path.exists(d): + os.makedirs(d) + def onie_fwpkg(arguments): with OnlOnieBootContext() as ob: + # This is necessary if we've upgraded ONIE but haven't booted into it yet... + _makedirs("%s/onie/update/pending" % ob.directory) + _makedirs("%s/onie/update/attempts" % ob.directory) subprocess.check_call("%s/onie/tools/bin/onie-fwpkg %s" % (ob.directory, arguments), shell=True) def boot_entry_set(index):