@@ -295,7 +295,7 @@ def import_ostree_commit(workdir, buildpath, buildmeta, extract_json=True, parti
295
295
lifetime = LOCK_DEFAULT_LIFETIME ):
296
296
repo = os .path .join (tmpdir , 'repo' )
297
297
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 )
299
299
tarfile = os .path .join (buildpath , buildmeta ['images' ]['ostree' ]['path' ])
300
300
# create repo in case e.g. tmp/ was cleared out; idempotent
301
301
subprocess .check_call (['ostree' , 'init' , '--repo' , repo , '--mode=archive' ])
@@ -334,7 +334,9 @@ def import_ostree_commit(workdir, buildpath, buildmeta, extract_json=True, parti
334
334
# We do this in two stages, because right now ex-container only writes to
335
335
# non-archive repos. Also, in the privileged case we need sudo to write
336
336
# 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.
338
340
import_oci_archive (tmpdir , tarfile , buildmeta ['buildid' ])
339
341
elif os .environ .get ('COSA_PRIVILEGED' , '' ) == '1' :
340
342
build_repo = os .path .join (repo , '../../cache/repo-build' )
@@ -361,6 +363,10 @@ def import_ostree_commit(workdir, buildpath, buildmeta, extract_json=True, parti
361
363
362
364
363
365
def 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
+ '''
364
370
with tempfile .TemporaryDirectory (dir = parent_tmpd ) as tmpd :
365
371
subprocess .check_call (['ostree' , 'init' , '--repo' , tmpd , '--mode=bare-user' ])
366
372
@@ -379,6 +385,8 @@ def import_oci_archive(parent_tmpd, ociarchive, ref):
379
385
f'ostree-unverified-image:oci-archive:{ ociarchive } ' ])
380
386
381
387
# 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
382
390
refs = subprocess .check_output (['ostree' , 'refs' , '--repo' , tmpd ,
383
391
'--list' , 'ostree/container/image' ],
384
392
encoding = 'utf-8' ).splitlines ()
@@ -393,7 +401,8 @@ def import_oci_archive(parent_tmpd, ociarchive, ref):
393
401
encoding = 'utf-8' ).splitlines ()
394
402
subprocess .check_call (['ostree' , 'pull-local' , '--repo' , 'tmp/repo' , tmpd ] + blob_refs )
395
403
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
397
406
398
407
399
408
def get_basearch ():
0 commit comments