[elbe-devel] [PATCH 1/1] cdroms: do not fail without /var/cache/elbe/initvm-bin-repo

Torben Hohn torben.hohn at linutronix.de
Wed Nov 28 13:38:08 CET 2018


when /var/cache/elbe/initvm-bin-repo has not been generated
by "elbe fetch_initvm_pkgs" during initvm installation,
the copying would fail.

----------------------------------------------------------------------------------------------------------------------------
running cmd +cp -av /var/cache/elbe/initvm-bin-repo "/var/cache/elbe/ae76f5ae-a300-43a9-bed6-a76387b5d255/binrepo"+
------------------------------------------------------------------------------
cp: cannot stat '/var/cache/elbe/initvm-bin-repo': No such file or directory
------------------------------------------------------------------------------

Command failed with errorcode 1
Build failed
Traceback (most recent call last):
  File "/var/cache/elbe/devel/elbepack/asyncworker.py", line 158, in execute
    skip_pbuild=self.skip_pbuilder)
  File "/var/cache/elbe/devel/elbepack/elbeproject.py", line 572, in build
    self.build_cdroms(build_bin, build_sources, cdrom_size)
  File "/var/cache/elbe/devel/elbepack/elbeproject.py", line 395, in build_cdroms
    cdrom_size=cdrom_size)
  File "/var/cache/elbe/devel/elbepack/cdroms.py", line 134, in mk_binary_cdrom
    log.do('cp -av /var/cache/elbe/initvm-bin-repo "%s"' % repo_path)
  File "/var/cache/elbe/devel/elbepack/asciidoclog.py", line 62, in do
    raise CommandError(cmd, ret)
CommandError


Exception:
----------------------------------------------------------------------------------------------------------------------------

This error is not fatal. This only means, that the generated bin-cdrom.iso
does not allow building an initvm from it.

Log an Error and continue with an empty directory, when that happens.
---
 elbepack/cdroms.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/elbepack/cdroms.py b/elbepack/cdroms.py
index 3c1bd6dc..aa67bdaf 100644
--- a/elbepack/cdroms.py
+++ b/elbepack/cdroms.py
@@ -16,6 +16,7 @@ from elbepack.repomanager import CdromBinRepo
 from elbepack.repomanager import CdromInitRepo
 from elbepack.aptpkgutils import XMLPackage
 from elbepack.filesystem import Filesystem, hostfs
+from elbepack.shellhelper import CommandError
 
 CDROM_SIZE = 640 * 1000 * 1000
 
@@ -131,7 +132,16 @@ def mk_binary_cdrom(
     # initvm repo has been built upon initvm creation
     # just copy it. the repo __init__() afterwards will
     # not touch the repo config, nor generate a new key.
-    log.do('cp -av /var/cache/elbe/initvm-bin-repo "%s"' % repo_path)
+    try:
+        log.do('cp -av /var/cache/elbe/initvm-bin-repo "%s"' % repo_path)
+    except CommandError:
+        # When /var/cache/elbe/initvm-bin-repo has not been created
+        # (because the initvm install was an old version or somthing,
+        #  log an error, and continue with an empty directory.
+        log.printo('ERROR: /var/cache/elbe/initvm-bin-repo does not exist')
+        log.printo('       The generated CDROM will not contain initvm pkgs')
+        log.do('mkdir -p "%s"' % repo_path)
+
     repo = CdromInitRepo(init_codename, repo_path, log, cdrom_size, mirror)
 
     target_repo = CdromBinRepo(arch, codename, None,
-- 
2.11.0




More information about the elbe-devel mailing list