File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 1
1
//! Integration with Red Hat Subscription Manager
2
2
3
- use anyhow:: Result ;
4
- use cap_std:: fs:: { Dir , OpenOptions } ;
5
- use cap_std_ext:: cap_std;
3
+ use anyhow:: { Context , Result } ;
4
+ use cap_std:: fs:: Dir ;
5
+ use cap_std_ext:: { cap_std, dirext :: CapStdExtDirExt } ;
6
6
use fn_error_context:: context;
7
7
use serde:: Serialize ;
8
8
@@ -96,11 +96,11 @@ pub(crate) async fn publish_facts(root: &Dir) -> Result<()> {
96
96
let ( _deployments, host) = crate :: status:: get_status ( & sysroot, booted_deployment. as_ref ( ) ) ?;
97
97
98
98
let facts = RhsmFacts :: from ( host. status ) ;
99
- let mut bootc_facts_file = root. open_with (
100
- FACTS_PATH ,
101
- OpenOptions :: new ( ) . write ( true ) . create ( true ) . truncate ( true ) ,
102
- ) ? ;
103
- serde_json :: to_writer_pretty ( & mut bootc_facts_file , & facts ) ?;
99
+ root. atomic_replace_with ( FACTS_PATH , |w| {
100
+ serde_json :: to_writer_pretty ( w , & facts ) ? ;
101
+ anyhow :: Ok ( ( ) )
102
+ } )
103
+ . with_context ( || format ! ( "Writing {FACTS_PATH}" ) ) ?;
104
104
Ok ( ( ) )
105
105
}
106
106
Original file line number Diff line number Diff line change @@ -46,8 +46,16 @@ RUN echo test content > /usr/share/blah.txt
46
46
# Just sanity check it
47
47
let v = podman run -- rm localhost/bootc-derived cat /usr/share/blah.txt | str trim
48
48
assert equal $v " test content"
49
+
50
+ let orig_root_mtime = ls - Dl /ostree/bootc | get modified
51
+
49
52
# Now, fetch it back into the bootc storage!
50
53
bootc switch -- transport containers-storage localhost/bootc-derived
54
+
55
+ # Also test that the mtime changes on modification
56
+ let new_root_mtime = ls - Dl /ostree/bootc | get modified
57
+ assert ($new_root_mtime > $orig_root_mtime )
58
+
51
59
# And reboot into it
52
60
tmt-reboot
53
61
}
You can’t perform that action at this time.
0 commit comments