@@ -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' )
@@ -361,6 +363,10 @@ def import_ostree_commit(workdir, buildpath, buildmeta, extract_json=True, parti
361363
362364
363365def import_oci_archive (parent_tmpd , ociarchive , ref ):
366+ '''
367+ Imports layered/non-encapsulated OCI archive into the tmp/repo. Returns
368+ the OSTree commit that was imported.
369+ '''
364370 with tempfile .TemporaryDirectory (dir = parent_tmpd ) as tmpd :
365371 subprocess .check_call (['ostree' , 'init' , '--repo' , tmpd , '--mode=bare-user' ])
366372
@@ -379,6 +385,8 @@ def import_oci_archive(parent_tmpd, ociarchive, ref):
379385 f'ostree-unverified-image:oci-archive:{ ociarchive } ' ])
380386
381387 # awkwardly work around the fact that there is no --write-ref equivalent
388+ # XXX: we can make this better once we can rely on --ostree-digestfile
389+ # https://github.com/bootc-dev/bootc/pull/1421
382390 refs = subprocess .check_output (['ostree' , 'refs' , '--repo' , tmpd ,
383391 '--list' , 'ostree/container/image' ],
384392 encoding = 'utf-8' ).splitlines ()
@@ -393,7 +401,8 @@ def import_oci_archive(parent_tmpd, ociarchive, ref):
393401 encoding = 'utf-8' ).splitlines ()
394402 subprocess .check_call (['ostree' , 'pull-local' , '--repo' , 'tmp/repo' , tmpd ] + blob_refs )
395403
396- return subprocess .check_output (['ostree' , 'rev-parse' , '--repo' , 'tmp/repo' , ref ], encoding = 'utf-8' ).strip ()
404+ ostree_commit = subprocess .check_output (['ostree' , 'rev-parse' , '--repo' , 'tmp/repo' , ref ], encoding = 'utf-8' ).strip ()
405+ return ostree_commit
397406
398407
399408def get_basearch ():
0 commit comments