Parse PKGBUILD output archives to fix -git packages

i18n
Michal S 2 years ago committed by Michal
parent 2e5c4075e7
commit 5bad161ef7

@ -1,4 +1,7 @@
use std::path::Path;
use std::{
fmt::{Display, Formatter},
path::Path,
};
use alpm::Alpm;
use alpm_utils::alpm_with_conf;
@ -10,6 +13,15 @@ pub enum Error {
Pacmanconf(pacmanconf::Error),
}
impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::Alpm(e) => Display::fmt(e, f),
Self::Pacmanconf(e) => Display::fmt(e, f),
}
}
}
impl From<alpm::Error> for Error {
fn from(err: alpm::Error) -> Self {
Error::Alpm(err)

@ -21,6 +21,7 @@ pub enum AppError {
MakePkg(String),
MinusError(minus::MinusError),
FmtError(std::fmt::Error),
AlpmError(crate::internal::alpm::Error),
}
impl Display for AppError {
@ -36,9 +37,10 @@ impl Display for AppError {
AppError::MissingDependencies(deps) => {
write!(f, "Missing dependencies {}", deps.join(", "))
}
AppError::MakePkg(msg) => write!(f, "Failed to ru makepkg {msg}"),
AppError::MakePkg(msg) => write!(f, "Failed to run makepkg {msg}"),
AppError::MinusError(e) => Display::fmt(e, f),
AppError::FmtError(e) => Display::fmt(e, f),
AppError::AlpmError(e) => Display::fmt(e, f),
}
}
}
@ -81,6 +83,12 @@ impl From<std::fmt::Error> for AppError {
}
}
impl From<crate::internal::alpm::Error> for AppError {
fn from(e: crate::internal::alpm::Error) -> Self {
Self::AlpmError(e)
}
}
pub trait SilentUnwrap<T> {
fn silent_unwrap(self, error_code: AppExitCode) -> T;
}

@ -1,5 +1,10 @@
use std::{collections::HashMap, path::Path, sync::Arc};
use std::{
collections::HashMap,
path::{Path, PathBuf},
sync::Arc,
};
use alpm::SigLevel;
use aur_rpc::PackageInfo;
use crossterm::style::Stylize;
use futures::future;
@ -196,11 +201,31 @@ async fn build_package(
});
}
let packages = MakePkgBuilder::package_list(build_path).await?;
tracing::debug!("Archives: {packages:?}");
let archives = MakePkgBuilder::package_list(build_path).await?;
tracing::debug!("Archives: {archives:?}");
let mut pkgs_produced: HashMap<String, PathBuf> = HashMap::new();
let alpm = crate::internal::alpm::get_handler()?;
for ar in archives {
let pkg = alpm
.pkg_load(ar.to_str().unwrap(), true, SigLevel::NONE)
.map_err(|e| AppError::Other(e.to_string()))?;
let name = pkg.name().to_owned();
pkgs_produced.insert(name, ar.clone());
}
tracing::debug!("Produced packages: {pkgs_produced:#?}");
let pkg_to_install = pkgs_produced
.get(&ctx.package.metadata.name)
.ok_or_else(|| {
AppError::Other(format!(
"Could not find package {} in produced packages",
ctx.package.metadata.name
))
})?;
pb.finish_with_message(format!("{}: {}", pkg_name.clone().bold(), "Built!".green()));
ctx.step = BuildStep::Install(PackageArchives(packages));
ctx.step = BuildStep::Install(PackageArchives(vec![pkg_to_install.to_path_buf()]));
Ok(ctx)
}

Loading…
Cancel
Save