Skip to content

Commit 62fa3b5

Browse files
committed
split packages support for GETPKGBUILD
1 parent 5355012 commit 62fa3b5

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

Diff for: src/download.rs

+21-16
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::process::{Command, Stdio};
1010
use std::result::Result as StdResult;
1111

1212
use alpm::Version;
13-
use alpm_utils::{AsTarg, DbListExt, Targ};
13+
use alpm_utils::{AsTarg, DbListExt};
1414
use ansi_term::Style;
1515
use anyhow::{bail, ensure, Context, Result};
1616
use aur_depends::AurBase;
@@ -184,11 +184,10 @@ pub async fn getpkgbuilds(config: &mut Config) -> Result<i32> {
184184
let mut ret = 0;
185185

186186
if !repo.is_empty() {
187-
ret = repo_pkgbuilds(config, &repo)?;
187+
ret = repo_pkgbuilds(config, &repo[..])?;
188188
}
189189

190190
if !aur.is_empty() {
191-
let aur = aur.iter().map(|t| t.pkg).collect::<Vec<_>>();
192191
let action = config.color.action;
193192
let bold = config.color.bold;
194193
println!(
@@ -220,11 +219,11 @@ pub async fn getpkgbuilds(config: &mut Config) -> Result<i32> {
220219
Ok(ret)
221220
}
222221

223-
fn repo_pkgbuilds(config: &Config, pkgs: &[Targ<'_>]) -> Result<i32> {
222+
fn repo_pkgbuilds(config: &Config, pkgs: &[String]) -> Result<i32> {
224223
let pkgctl = &config.pkgctl_bin;
225224

226225
for (n, targ) in pkgs.iter().enumerate() {
227-
print_download(config, n + 1, pkgs.len(), targ.pkg);
226+
print_download(config, n + 1, pkgs.len(), targ);
228227

229228
let ret = Command::new(pkgctl)
230229
.arg("repo")
@@ -447,17 +446,17 @@ pub async fn show_comments(config: &mut Config) -> Result<i32> {
447446
fn split_repo_aur_pkgbuilds<'a, T: AsTarg>(
448447
config: &Config,
449448
targets: &'a [T],
450-
) -> (Vec<Targ<'a>>, Vec<Targ<'a>>) {
449+
) -> (Vec<String>, Vec<String>) {
451450
let mut local = Vec::new();
452451
let mut aur = Vec::new();
453452
let db = config.alpm.syncdbs();
454453

455454
for targ in targets {
456455
let targ = targ.as_targ();
457456
if !config.mode.repo() {
458-
aur.push(targ);
457+
aur.push(targ.pkg.to_string());
459458
} else if !config.mode.aur() && !config.mode.pkgbuild() {
460-
local.push(targ);
459+
local.push(targ.pkg.to_string());
461460
} else if let Some(repo) = targ.repo {
462461
if matches!(
463462
repo,
@@ -471,9 +470,9 @@ fn split_repo_aur_pkgbuilds<'a, T: AsTarg>(
471470
| "extra-testing"
472471
| "multilib-testing"
473472
) {
474-
local.push(targ);
473+
local.push(targ.pkg.to_string());
475474
} else {
476-
aur.push(targ);
475+
aur.push(targ.pkg.to_string());
477476
}
478477
} else if let Ok(pkg) = db.pkg(targ.pkg) {
479478
if matches!(
@@ -488,12 +487,20 @@ fn split_repo_aur_pkgbuilds<'a, T: AsTarg>(
488487
| "extra-testing"
489488
| "multilib-testing"
490489
) {
491-
local.push(targ);
490+
if let Some(base) = pkg.base() {
491+
if base != pkg.name() {
492+
local.push(base.to_string())
493+
} else {
494+
local.push(targ.pkg.to_string());
495+
}
496+
} else {
497+
local.push(targ.pkg.to_string());
498+
}
492499
} else {
493-
aur.push(targ);
500+
aur.push(targ.pkg.to_string());
494501
}
495502
} else {
496-
aur.push(targ);
503+
aur.push(targ.pkg.to_string());
497504
}
498505
}
499506

@@ -512,7 +519,7 @@ pub async fn show_pkgbuilds(config: &mut Config) -> Result<i32> {
512519
for pkg in &repo {
513520
let url = Url::parse(&format!(
514521
"https://gitlab.archlinux.org/archlinux/packaging/packages/{}/-/raw/HEAD/PKGBUILD",
515-
pkg.pkg
522+
pkg
516523
))?;
517524

518525
let response = client
@@ -535,8 +542,6 @@ pub async fn show_pkgbuilds(config: &mut Config) -> Result<i32> {
535542
}
536543

537544
if !aur.is_empty() {
538-
let aur = aur.iter().map(|t| t.pkg).collect::<Vec<_>>();
539-
540545
let warnings = cache_info_with_warnings(
541546
&config.raur,
542547
&mut config.cache,

0 commit comments

Comments
 (0)