@@ -12,6 +12,7 @@ mod bench;
12
12
mod build_backend;
13
13
mod build_sysroot;
14
14
mod config;
15
+ mod landlock;
15
16
mod path;
16
17
mod prepare;
17
18
mod rustc_info;
@@ -54,36 +55,6 @@ enum CodegenBackend {
54
55
}
55
56
56
57
fn main ( ) {
57
- use landlock:: { Access , Compatible , RulesetAttr , RulesetCreatedAttr } ;
58
- let abi = landlock:: ABI :: V2 ;
59
- let access_all = landlock:: AccessFs :: from_all ( abi) ;
60
- let access_read = landlock:: AccessFs :: from_read ( abi) ;
61
- landlock:: Ruleset :: default ( )
62
- . set_compatibility ( landlock:: CompatLevel :: BestEffort )
63
- . handle_access ( access_all)
64
- . unwrap ( )
65
- . create ( )
66
- . unwrap ( )
67
- . add_rules ( landlock:: path_beneath_rules ( & [ "/" ] , access_read) )
68
- . unwrap ( )
69
- . add_rules ( landlock:: path_beneath_rules ( & [ "/tmp" , "/dev/null" ] , access_all) )
70
- . unwrap ( )
71
- . add_rules ( landlock:: path_beneath_rules (
72
- & [
73
- std:: env:: current_dir ( ) . unwrap ( ) . join ( "build" ) ,
74
- std:: env:: current_dir ( ) . unwrap ( ) . join ( "dist" ) ,
75
- ] ,
76
- access_all,
77
- ) )
78
- . unwrap ( )
79
- . add_rules ( landlock:: path_beneath_rules (
80
- & [ std:: env:: home_dir ( ) . unwrap ( ) . join ( ".cargo/registry" ) ] ,
81
- access_all,
82
- ) )
83
- . unwrap ( )
84
- . restrict_self ( )
85
- . unwrap ( ) ;
86
-
87
58
if env:: var_os ( "RUST_BACKTRACE" ) . is_none ( ) {
88
59
env:: set_var ( "RUST_BACKTRACE" , "1" ) ;
89
60
}
@@ -160,15 +131,21 @@ fn main() {
160
131
out_dir = current_dir. join ( out_dir) ;
161
132
162
133
if command == Command :: Prepare {
163
- prepare :: prepare ( & path:: Dirs {
134
+ let dirs = path:: Dirs {
164
135
source_dir : current_dir. clone ( ) ,
165
136
download_dir : download_dir
166
137
. map ( |dir| current_dir. join ( dir) )
167
138
. unwrap_or_else ( || out_dir. join ( "download" ) ) ,
168
139
build_dir : PathBuf :: from ( "dummy_do_not_use" ) ,
169
140
dist_dir : PathBuf :: from ( "dummy_do_not_use" ) ,
170
141
frozen,
171
- } ) ;
142
+ } ;
143
+
144
+ path:: RelPath :: DOWNLOAD . ensure_exists ( & dirs) ;
145
+
146
+ landlock:: lock_fetch ( ) ;
147
+
148
+ prepare:: prepare ( & dirs) ;
172
149
process:: exit ( 0 ) ;
173
150
}
174
151
@@ -216,6 +193,7 @@ fn main() {
216
193
} ;
217
194
218
195
path:: RelPath :: BUILD . ensure_exists ( & dirs) ;
196
+ path:: RelPath :: DIST . ensure_exists ( & dirs) ;
219
197
220
198
{
221
199
// Make sure we always explicitly specify the target dir
@@ -226,6 +204,8 @@ fn main() {
226
204
std:: fs:: File :: create ( target) . unwrap ( ) ;
227
205
}
228
206
207
+ landlock:: lock_build ( ) ;
208
+
229
209
env:: set_var ( "RUSTC" , "rustc_should_be_set_explicitly" ) ;
230
210
env:: set_var ( "RUSTDOC" , "rustdoc_should_be_set_explicitly" ) ;
231
211
0 commit comments