@@ -15,7 +15,7 @@ use fn_error_context::context;
15
15
/// if it does not exist error.
16
16
#[ context( "Linting" ) ]
17
17
pub ( crate ) fn lint ( root : & Dir ) -> Result < ( ) > {
18
- let lints = [ check_var_run, check_kernel, check_parse_kargs] ;
18
+ let lints = [ check_var_run, check_kernel, check_parse_kargs, check_usretc ] ;
19
19
for lint in lints {
20
20
lint ( & root) ?;
21
21
}
@@ -32,6 +32,21 @@ fn check_var_run(root: &Dir) -> Result<()> {
32
32
Ok ( ( ) )
33
33
}
34
34
35
+ fn check_usretc ( root : & Dir ) -> Result < ( ) > {
36
+ let etc_exists = root. symlink_metadata_optional ( "etc" ) ?. is_some ( ) ;
37
+ // For compatibility/conservatism don't bomb out if there's no /etc.
38
+ if !etc_exists {
39
+ return Ok ( ( ) ) ;
40
+ }
41
+ // But having both /etc and /usr/etc is not something we want to support.
42
+ if root. symlink_metadata_optional ( "usr/etc" ) ?. is_some ( ) {
43
+ anyhow:: bail!(
44
+ "Found /usr/etc - this is a bootc implementation detail and not supported to use in containers"
45
+ ) ;
46
+ }
47
+ Ok ( ( ) )
48
+ }
49
+
35
50
/// Validate that we can parse the /usr/lib/bootc/kargs.d files.
36
51
fn check_parse_kargs ( root : & Dir ) -> Result < ( ) > {
37
52
let _args = crate :: kargs:: get_kargs_in_root ( root, ARCH ) ?;
@@ -88,3 +103,17 @@ fn test_kargs() -> Result<()> {
88
103
assert ! ( check_parse_kargs( root) . is_err( ) ) ;
89
104
Ok ( ( ) )
90
105
}
106
+
107
+ #[ test]
108
+ fn test_usr_etc ( ) -> Result < ( ) > {
109
+ let root = & fixture ( ) ?;
110
+ // This one should pass
111
+ check_usretc ( root) . unwrap ( ) ;
112
+ root. create_dir_all ( "etc" ) ?;
113
+ root. create_dir_all ( "usr/etc" ) ?;
114
+ assert ! ( check_usretc( root) . is_err( ) ) ;
115
+ root. remove_dir_all ( "etc" ) ?;
116
+ // Now we should pass again
117
+ check_usretc ( root) . unwrap ( ) ;
118
+ Ok ( ( ) )
119
+ }
0 commit comments