@@ -295,7 +295,7 @@ def import_ostree_commit(workdir, buildpath, buildmeta, extract_json=True, parti
295295 lifetime = LOCK_DEFAULT_LIFETIME ):
296296 repo = os .path .join (tmpdir , 'repo' )
297297 commit = buildmeta ['ostree-commit' ]
298- is_oci_imported = buildmeta .get ('coreos-assembler.oci-imported' , False )
298+ was_oci_imported = buildmeta .get ('coreos-assembler.oci-imported' , False )
299299 tarfile = os .path .join (buildpath , buildmeta ['images' ]['ostree' ]['path' ])
300300 # create repo in case e.g. tmp/ was cleared out; idempotent
301301 subprocess .check_call (['ostree' , 'init' , '--repo' , repo , '--mode=archive' ])
@@ -334,7 +334,9 @@ def import_ostree_commit(workdir, buildpath, buildmeta, extract_json=True, parti
334334 # We do this in two stages, because right now ex-container only writes to
335335 # non-archive repos. Also, in the privileged case we need sudo to write
336336 # to `repo-build`, though it might be good to change this by default.
337- if is_oci_imported :
337+ if was_oci_imported :
338+ # This was initially imported using `cosa import`. Go through that
339+ # path again because it's not an encapsulated commit.
338340 import_oci_archive (tmpdir , tarfile , buildmeta ['buildid' ])
339341 elif os .environ .get ('COSA_PRIVILEGED' , '' ) == '1' :
340342 build_repo = os .path .join (repo , '../../cache/repo-build' )
@@ -360,6 +362,8 @@ def import_ostree_commit(workdir, buildpath, buildmeta, extract_json=True, parti
360362 extract_image_json (workdir , commit )
361363
362364
365+ # Imports layered/non-encapsulated OCI archive into the tmp/repo. Returns the
366+ # OSTree commit that was imported.
363367def import_oci_archive (parent_tmpd , ociarchive , ref ):
364368 with tempfile .TemporaryDirectory (dir = parent_tmpd ) as tmpd :
365369 subprocess .check_call (['ostree' , 'init' , '--repo' , tmpd , '--mode=bare-user' ])
@@ -379,6 +383,8 @@ def import_oci_archive(parent_tmpd, ociarchive, ref):
379383 f'ostree-unverified-image:oci-archive:{ ociarchive } ' ])
380384
381385 # awkwardly work around the fact that there is no --write-ref equivalent
386+ # XXX: we can make this better once we can rely on --ostree-digestfile
387+ # https://github.com/bootc-dev/bootc/pull/1421
382388 refs = subprocess .check_output (['ostree' , 'refs' , '--repo' , tmpd ,
383389 '--list' , 'ostree/container/image' ],
384390 encoding = 'utf-8' ).splitlines ()
@@ -393,7 +399,8 @@ def import_oci_archive(parent_tmpd, ociarchive, ref):
393399 encoding = 'utf-8' ).splitlines ()
394400 subprocess .check_call (['ostree' , 'pull-local' , '--repo' , 'tmp/repo' , tmpd ] + blob_refs )
395401
396- return subprocess .check_output (['ostree' , 'rev-parse' , '--repo' , 'tmp/repo' , ref ], encoding = 'utf-8' ).strip ()
402+ ostree_commit = subprocess .check_output (['ostree' , 'rev-parse' , '--repo' , 'tmp/repo' , ref ], encoding = 'utf-8' ).strip ()
403+ return ostree_commit
397404
398405
399406def get_basearch ():
0 commit comments