@@ -35,17 +35,17 @@ struct Args {
3535 /// Path to the destination
3636 #[ clap( long) ]
3737 target : String ,
38- /// Mirror to be used
39- #[ clap( long, default_value = DEFAULT_MIRROR ) ]
40- mirror : String ,
41- /// Branch to use
42- #[ clap( long, default_value = "stable " ) ]
43- branch : String ,
44- /// Add additional components
45- #[ clap( long, num_args = 1 .., alias = "components" , default_value = "main ") ]
46- comps : Vec < String > ,
38+ /// Mirror to be used (default as https://repo.aosc.io)
39+ #[ clap( short , long, conflicts_with = "sources_list" ) ]
40+ mirror : Option < String > ,
41+ /// Branch to use (default as stable)
42+ #[ clap( long, conflicts_with = "sources_list " ) ]
43+ branch : Option < String > ,
44+ /// Add additional components (default as main)
45+ #[ clap( long, num_args = 1 .., conflicts_with = "sources_list " ) ]
46+ comps : Option < Vec < String > > ,
4747 /// Use sources.list to fetch packages
48- #[ clap( long, conflicts_with_all = [ "mirror" , "branch" , "comps" ] ) ]
48+ #[ clap( long) ]
4949 sources_list : Option < PathBuf > ,
5050 /// Sets a custom config file
5151 #[ clap( short, long) ]
@@ -216,19 +216,16 @@ fn do_stage1(
216216 let stub_install = st. create_metadata ( ) ?;
217217 eprintln ! ( "Stage 1: Creating filesystem skeleton ..." ) ;
218218 std:: fs:: create_dir_all ( target_path. join ( "dev" ) ) ?;
219- if let Some ( sources_list ) = & args. sources_list {
219+ if let Some ( ( mirror , branch ) ) = args. mirror . as_ref ( ) . zip ( args . branch . as_ref ( ) ) {
220220 fs:: bootstrap_apt (
221221 target_path,
222- fs:: MirrorOrSourceList :: SourceList ( & sources_list ) ,
222+ fs:: MirrorOrSourceList :: Mirror { mirror , branch } ,
223223 )
224224 . context ( "when preparing apt files" ) ?;
225225 } else {
226226 fs:: bootstrap_apt (
227227 target_path,
228- fs:: MirrorOrSourceList :: Mirror {
229- mirror : & args. mirror ,
230- branch : & args. branch ,
231- } ,
228+ fs:: MirrorOrSourceList :: SourceList ( args. sources_list . as_ref ( ) . unwrap ( ) ) ,
232229 )
233230 . context ( "when preparing apt files" ) ?;
234231 }
@@ -306,9 +303,7 @@ impl Manifests {
306303 . iter ( )
307304 . map ( |p| target_path. join ( "var/lib/apt/lists" ) . join ( p) )
308305 . collect ( ) ,
309- Manifests :: List ( hash_map) => hash_map
310- . values ( )
311- . map ( |p| target_path. join ( "var/lib/apt/lists" ) . join ( p) )
306+ Manifests :: List ( hash_map) => hash_map. values ( ) . map ( |p| target_path. join ( "var/lib/apt/lists" ) . join ( p) )
312307 . collect ( ) ,
313308 }
314309 }
@@ -372,6 +367,14 @@ fn main() {
372367 arches. push ( "all" . to_string ( ) ) ;
373368 }
374369
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+ } ;
377+
375378 std:: fs:: create_dir_all ( target_path. join ( "var/lib/apt/lists" ) ) . unwrap ( ) ;
376379 std:: fs:: create_dir_all ( & archive_path) . unwrap ( ) ;
377380 eprintln ! ( "Downloading manifests ..." ) ;
@@ -398,11 +401,11 @@ fn main() {
398401 None => Manifests :: Single (
399402 network:: fetch_manifests (
400403 & client,
401- mirror,
402- & args. branch ,
404+ mirror. as_deref ( ) . unwrap_or ( DEFAULT_MIRROR ) ,
405+ args. branch . as_deref ( ) . unwrap_or ( "stable" ) ,
403406 & topics,
404407 & arches,
405- & args . comps ,
408+ comps. unwrap_or_else ( || vec ! [ "main" . to_string ( ) ] ) ,
406409 target_path,
407410 )
408411 . unwrap ( ) ,
@@ -433,7 +436,9 @@ fn main() {
433436 & all_packages,
434437 & archive_path,
435438 match manifests {
436- Manifests :: Single ( _) => Mirror :: Single ( & args. mirror ) ,
439+ Manifests :: Single ( _) => {
440+ Mirror :: Single ( args. mirror . as_deref ( ) . unwrap_or ( DEFAULT_MIRROR ) )
441+ }
437442 Manifests :: List ( hash_map) => Mirror :: List (
438443 SelectMirror :: new (
439444 hash_map
0 commit comments