Skip to content

Commit 6ccea32

Browse files
xtexxeatradish
authored andcommitted
Revert "Merge pull request #44 from AOSC-Dev/cli-conflict"
This reverts commit 4ca26c6, reversing changes made to f8b45d6.
1 parent 4ca26c6 commit 6ccea32

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

src/main.rs

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/network.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub fn fetch_manifests(
7373
branch: &str,
7474
topics: &[String],
7575
arches: &[&str],
76-
comps: &Vec<String>,
76+
comps: Vec<String>,
7777
root: &Path,
7878
) -> Result<Vec<String>> {
7979
let manifests = Arc::new(Mutex::new(Vec::new()));

0 commit comments

Comments
 (0)