File tree Expand file tree Collapse file tree 3 files changed +46
-3
lines changed Expand file tree Collapse file tree 3 files changed +46
-3
lines changed Original file line number Diff line number Diff line change 7
7
// This sub-module is the "basic" installer that handles creating basic block device
8
8
// and filesystem setup.
9
9
pub ( crate ) mod baseline;
10
- mod osbuild;
11
10
pub ( crate ) mod config;
11
+ mod osbuild;
12
12
pub ( crate ) mod osconfig;
13
13
14
14
use std:: io:: Write ;
@@ -1185,7 +1185,7 @@ async fn prepare_install(
1185
1185
// creating multiple.
1186
1186
let tempdir = cap_std_ext:: cap_tempfile:: TempDir :: new ( cap_std:: ambient_authority ( ) ) ?;
1187
1187
// And continue to init global state
1188
- osbuild:: adjust_for_bootc_image_builder ( & tempdir) ?;
1188
+ osbuild:: adjust_for_bootc_image_builder ( & rootfs , & tempdir) ?;
1189
1189
1190
1190
if !target_opts. skip_fetch_check {
1191
1191
verify_target_fetch ( & tempdir, & target_imgref) . await ?;
Original file line number Diff line number Diff line change @@ -41,10 +41,33 @@ fn adjust_etc_containers(tempdir: &Dir) -> Result<()> {
41
41
Ok ( ( ) )
42
42
}
43
43
44
+ /// osbuild mounts the host's /var/lib/containers at /run/osbuild/containers; mount
45
+ /// it back to /var/lib/containers where the default container stack expects to find it.
46
+ fn propagate_run_osbuild_containers ( root : & Dir ) -> Result < ( ) > {
47
+ let osbuild_run_containers = Utf8Path :: new ( "run/osbuild/containers" ) ;
48
+ // If we're not apparently running under osbuild, then we no-op.
49
+ if !root. try_exists ( osbuild_run_containers) ? {
50
+ return Ok ( ( ) ) ;
51
+ }
52
+ // If we do seem to have a valid container store though, use that
53
+ if crate :: podman:: storage_exists_default ( root) ? {
54
+ return Ok ( ( ) ) ;
55
+ }
56
+ let relative_storage = Utf8Path :: new ( crate :: podman:: CONTAINER_STORAGE . trim_start_matches ( '/' ) ) ;
57
+ root. create_dir_all ( relative_storage) ?;
58
+ Task :: new ( "Creating bind mount for run/osbuild/containers" , "mount" )
59
+ . arg ( "--rbind" )
60
+ . args ( [ osbuild_run_containers, relative_storage] )
61
+ . cwd ( root) ?
62
+ . run ( ) ?;
63
+ Ok ( ( ) )
64
+ }
65
+
44
66
/// bootc-image-builder today does a few things that we need to
45
67
/// deal with.
46
68
#[ context( "bootc-image-builder adjustments" ) ]
47
- pub ( crate ) fn adjust_for_bootc_image_builder ( tempdir : & Dir ) -> Result < ( ) > {
69
+ pub ( crate ) fn adjust_for_bootc_image_builder ( root : & Dir , tempdir : & Dir ) -> Result < ( ) > {
48
70
adjust_etc_containers ( tempdir) ?;
71
+ propagate_run_osbuild_containers ( root) ?;
49
72
Ok ( ( ) )
50
73
}
Original file line number Diff line number Diff line change 1
1
use anyhow:: { anyhow, Result } ;
2
+ use camino:: Utf8Path ;
3
+ use cap_std_ext:: cap_std:: fs:: Dir ;
2
4
use serde:: Deserialize ;
3
5
4
6
use crate :: install:: run_in_host_mountns;
@@ -27,3 +29,21 @@ pub(crate) fn imageid_to_digest(imgid: &str) -> Result<String> {
27
29
. ok_or_else ( || anyhow ! ( "No images returned for inspect" ) ) ?;
28
30
Ok ( i. digest )
29
31
}
32
+
33
+ /// Return true if there is apparently an active container store at the target path.
34
+ pub ( crate ) fn storage_exists ( root : & Dir , path : impl AsRef < Utf8Path > ) -> Result < bool > {
35
+ fn impl_storage_exists ( root : & Dir , path : & Utf8Path ) -> Result < bool > {
36
+ let lock = "storage.lock" ;
37
+ root. try_exists ( path. join ( lock) ) . map_err ( Into :: into)
38
+ }
39
+ impl_storage_exists ( root, path. as_ref ( ) )
40
+ }
41
+
42
+ /// Return true if there is apparently an active container store in the default path
43
+ /// for the target root.
44
+ ///
45
+ /// Note this does not attempt to parse the root filesystem's container storage configuration,
46
+ /// this uses a hardcoded default path.
47
+ pub ( crate ) fn storage_exists_default ( root : & Dir ) -> Result < bool > {
48
+ storage_exists ( root, CONTAINER_STORAGE . trim_start_matches ( '/' ) )
49
+ }
You can’t perform that action at this time.
0 commit comments