@@ -208,6 +208,7 @@ fn do_stage1(
208208 st : solv:: Transaction ,
209209 target_path : & Path ,
210210 args : & Args ,
211+ m : & Manifests ,
211212 archive_path : std:: path:: PathBuf ,
212213 all_packages : Vec < PackageMeta > ,
213214 topics : Vec < Topic > ,
@@ -216,19 +217,24 @@ fn do_stage1(
216217 let stub_install = st. create_metadata ( ) ?;
217218 eprintln ! ( "Stage 1: Creating filesystem skeleton ..." ) ;
218219 std:: fs:: create_dir_all ( target_path. join ( "dev" ) ) ?;
219- if let Some ( ( mirror, branch) ) = args. mirror . as_ref ( ) . zip ( args. branch . as_ref ( ) ) {
220- fs:: bootstrap_apt (
221- target_path,
222- fs:: MirrorOrSourceList :: Mirror { mirror, branch } ,
223- )
224- . context ( "when preparing apt files" ) ?;
225- } else {
226- fs:: bootstrap_apt (
227- target_path,
228- fs:: MirrorOrSourceList :: SourceList ( args. sources_list . as_ref ( ) . unwrap ( ) ) ,
229- )
230- . context ( "when preparing apt files" ) ?;
220+
221+ match m {
222+ Manifests :: Single { mirror, branch, .. } => {
223+ fs:: bootstrap_apt (
224+ target_path,
225+ fs:: MirrorOrSourceList :: Mirror { mirror, branch } ,
226+ )
227+ . context ( "when preparing apt files" ) ?;
228+ }
229+ Manifests :: List ( _) => {
230+ fs:: bootstrap_apt (
231+ target_path,
232+ fs:: MirrorOrSourceList :: SourceList ( args. sources_list . as_ref ( ) . unwrap ( ) ) ,
233+ )
234+ . context ( "when preparing apt files" ) ?;
235+ }
231236 }
237+
232238 topics:: save_topics ( target_path, topics) ?;
233239 install:: extract_bootstrap_pack ( target_path) . context ( "when extracting base files" ) ?;
234240 eprintln ! ( "Stage 1: Extracting packages ..." ) ;
@@ -291,19 +297,26 @@ fn do_stage2(
291297 Ok ( ( ) )
292298}
293299
294- enum Manifests {
295- Single ( Vec < String > ) ,
300+ enum Manifests < ' a > {
301+ Single {
302+ mirror : & ' a str ,
303+ list : Vec < String > ,
304+ branch : & ' a str ,
305+ _comps : & ' a [ & ' a str ] ,
306+ } ,
296307 List ( HashMap < String , String > ) ,
297308}
298309
299- impl Manifests {
310+ impl < ' a > Manifests < ' a > {
300311 fn paths ( & self , target_path : & Path ) -> Vec < PathBuf > {
301312 match self {
302- Manifests :: Single ( items ) => items
313+ Manifests :: Single { list , .. } => list
303314 . iter ( )
304315 . map ( |p| target_path. join ( "var/lib/apt/lists" ) . join ( p) )
305316 . collect ( ) ,
306- Manifests :: List ( hash_map) => hash_map. values ( ) . map ( |p| target_path. join ( "var/lib/apt/lists" ) . join ( p) )
317+ Manifests :: List ( hash_map) => hash_map
318+ . values ( )
319+ . map ( |p| target_path. join ( "var/lib/apt/lists" ) . join ( p) )
307320 . collect ( ) ,
308321 }
309322 }
@@ -367,13 +380,13 @@ fn main() {
367380 arches. push ( "all" . to_string ( ) ) ;
368381 }
369382
370- let comps = if let Some ( comps) = & args . comps {
371- let mut comps = comps . to_owned ( ) ;
372- comps . push ( "main" . to_string ( ) ) ;
373- Some ( comps)
374- } else {
375- None
376- } ;
383+ let mut comps = vec ! [ ] ;
384+
385+ if let Some ( c ) = & args . comps {
386+ comps. extend ( c . iter ( ) . map ( |x| x . as_str ( ) ) ) ;
387+ }
388+
389+ comps . push ( "main" ) ;
377390
378391 std:: fs:: create_dir_all ( target_path. join ( "var/lib/apt/lists" ) ) . unwrap ( ) ;
379392 std:: fs:: create_dir_all ( & archive_path) . unwrap ( ) ;
@@ -398,18 +411,25 @@ fn main() {
398411 & arches,
399412 vec ! [ path. to_path_buf( ) ] ,
400413 ) ) ,
401- None => Manifests :: Single (
402- network:: fetch_manifests (
403- & client,
404- mirror. as_deref ( ) . unwrap_or ( DEFAULT_MIRROR ) ,
405- args. branch . as_deref ( ) . unwrap_or ( "stable" ) ,
406- & topics,
407- & arches,
408- comps. unwrap_or_else ( || vec ! [ "main" . to_string( ) ] ) ,
409- target_path,
410- )
411- . unwrap ( ) ,
412- ) ,
414+ None => {
415+ let mirror = mirror. as_deref ( ) . unwrap_or ( DEFAULT_MIRROR ) ;
416+ let branch = args. branch . as_deref ( ) . unwrap_or ( "stable" ) ;
417+ Manifests :: Single {
418+ mirror,
419+ branch,
420+ _comps : & comps,
421+ list : network:: fetch_manifests (
422+ & client,
423+ mirror,
424+ branch,
425+ & topics,
426+ & arches,
427+ & comps,
428+ target_path,
429+ )
430+ . unwrap ( ) ,
431+ }
432+ }
413433 } ;
414434
415435 let paths = manifests. paths ( target_path) ;
@@ -435,16 +455,17 @@ fn main() {
435455 network:: batch_download (
436456 & all_packages,
437457 & archive_path,
438- match manifests {
439- Manifests :: Single ( _) => {
440- Mirror :: Single ( args. mirror . as_deref ( ) . unwrap_or ( DEFAULT_MIRROR ) )
441- }
458+ match & manifests {
459+ Manifests :: Single { mirror, .. } => Mirror :: Single ( mirror) ,
442460 Manifests :: List ( hash_map) => Mirror :: List (
443461 SelectMirror :: new (
444462 hash_map
445463 . into_iter ( )
446464 . map ( |( url, file_name) | {
447- ( url, target_path. join ( "var/lib/apt/lists" ) . join ( file_name) )
465+ (
466+ url. to_string ( ) ,
467+ target_path. join ( "var/lib/apt/lists" ) . join ( file_name) ,
468+ )
448469 } )
449470 . collect ( ) ,
450471 )
@@ -467,11 +488,20 @@ fn main() {
467488 . expect ( "Did not find the main architecture" ) ;
468489 install:: generate_apt_extended_state ( target_path, & all_stages, & all_packages, main_arch)
469490 . expect ( "Unable to generate APT extended state" ) ;
470- let script =
471- match do_stage1 ( st, target_path, & args, archive_path, all_packages, filtered) . unwrap ( ) {
472- Some ( value) => value,
473- None => return ,
474- } ;
491+ let script = match do_stage1 (
492+ st,
493+ target_path,
494+ & args,
495+ & manifests,
496+ archive_path,
497+ all_packages,
498+ filtered,
499+ )
500+ . unwrap ( )
501+ {
502+ Some ( value) => value,
503+ None => return ,
504+ } ;
475505
476506 do_stage2 ( t, target_path, script, target, & args, threads) . unwrap ( ) ;
477507}
0 commit comments