From 48689e3d98ac758b100cac1d1c3782e1ac4ceba0 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 9 Nov 2016 21:18:17 +0000 Subject: [PATCH] Boot-config installation is optional. --- .../src/python/onl/install/BaseInstall.py | 11 ++++++--- .../src/python/onl/install/SystemInstall.py | 23 ++++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py b/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py index 36cab127..e7319b25 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py @@ -102,7 +102,7 @@ class Base: src = os.path.join(self.im.installerConf.installer_dir, basename) if os.path.exists(src): self.copy2(src, dst) - return + return True if basename in self.zf.namelist(): self.log.debug("+ unzip -p %s %s > %s", @@ -110,11 +110,13 @@ class Base: with self.zf.open(basename, "r") as rfd: with open(dst, "wb") as wfd: shutil.copyfileobj(rfd, wfd) - return + return True if not optional: raise ValueError("missing installer file %s" % basename) + return False + def installerDd(self, basename, device): p = os.path.join(self.im.installerConf.installer_dir, basename) @@ -354,7 +356,10 @@ class Base: basename = 'boot-config' with MountContext(dev.device, log=self.log) as ctx: dst = os.path.join(ctx.dir, basename) - self.installerCopy(basename, dst) + + if not self.installerCopy(basename, dst, True): + return + with open(dst) as fd: buf = fd.read() diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py b/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py index b3339550..e6e8662d 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py @@ -85,9 +85,13 @@ class App(SubprocessMixin): # constitute an /etc/onl/installer.conf in place installerConf = InstallerConf(path="/dev/null") - with open("/etc/onl/loader/versions.json") as fd: - data = json.load(fd) - installerConf.onl_version = data['VERSION_ID'] + vj = "/etc/onl/loader/versions.json" + if os.path.exists(vj): + with open(vj) as fd: + data = json.load(fd) + installerConf.onl_version = data['VERSION_ID'] + else: + installerConf.onl_version = "unknown" installerConf.installer_dir = chroot_idir @@ -146,11 +150,14 @@ class App(SubprocessMixin): self.log.debug("+ /bin/cp %s %s", src, dst) shutil.copy2(src, dst) - with OnlMountContextReadWrite('ONL-BOOT', logger=self.log) as octx: - src = os.path.join(octx.directory, "boot-config") - dst = os.path.join(abs_idir, "boot-config") - self.log.debug("+ /bin/cp %s %s", src, dst) - shutil.copy2(src, dst) + # + # Disable until a system for boot-config upgrade is implemented. + # with OnlMountContextReadWrite('ONL-BOOT', logger=self.log) as octx: + # src = os.path.join(octx.directory, "boot-config") + # dst = os.path.join(abs_idir, "boot-config") + # self.log.debug("+ /bin/cp %s %s", src, dst) + # shutil.copy2(src, dst) + # # chroot to the onl-install script ##cmd = ('chroot', ctx.dir,