deb: allow adding multiple ppas for deps
This commit is contained in:
@@ -18,7 +18,7 @@ pub async fn build(
|
||||
series: &str,
|
||||
build_root: &str,
|
||||
cross: bool,
|
||||
ppa: Option<&str>,
|
||||
ppa: Option<&[&str]>,
|
||||
inject_packages: Option<&[&str]>,
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
// Environment
|
||||
@@ -58,47 +58,53 @@ pub async fn build(
|
||||
|
||||
let mut sources = apt::sources::load(None)?;
|
||||
let mut modified = false;
|
||||
let mut added_ppas: Vec<(&str, &str)> = Vec::new();
|
||||
|
||||
// Add PPA repository if specified
|
||||
if let Some(ppa_str) = ppa {
|
||||
// PPA format: user/ppa_name
|
||||
let parts: Vec<&str> = ppa_str.split('/').collect();
|
||||
if parts.len() == 2 {
|
||||
let base_url = crate::package_info::ppa_to_base_url(parts[0], parts[1]);
|
||||
// Add PPA repositories if specified
|
||||
if let Some(ppas) = ppa {
|
||||
for ppa_str in ppas {
|
||||
// PPA format: user/ppa_name
|
||||
let parts: Vec<&str> = ppa_str.split('/').collect();
|
||||
if parts.len() == 2 {
|
||||
let base_url = crate::package_info::ppa_to_base_url(parts[0], parts[1]);
|
||||
|
||||
// Add new PPA source if not found
|
||||
if !sources.iter().any(|s| s.uri.contains(&base_url)) {
|
||||
// Get host and target architectures
|
||||
let host_arch = crate::get_current_arch();
|
||||
let target_arch = arch;
|
||||
// Add new PPA source if not found
|
||||
if !sources.iter().any(|s| s.uri.contains(&base_url)) {
|
||||
// Get host and target architectures
|
||||
let host_arch = crate::get_current_arch();
|
||||
let target_arch = arch;
|
||||
|
||||
// Create architectures list with both host and target if different
|
||||
let mut architectures = vec![host_arch.clone()];
|
||||
if host_arch != *target_arch {
|
||||
architectures.push(target_arch.to_string());
|
||||
// Create architectures list with both host and target if different
|
||||
let mut architectures = vec![host_arch.clone()];
|
||||
if host_arch != *target_arch {
|
||||
architectures.push(target_arch.to_string());
|
||||
}
|
||||
|
||||
// Create suite list with all Ubuntu series
|
||||
let suites = vec![format!("{}", series)];
|
||||
|
||||
let new_source = crate::apt::sources::SourceEntry {
|
||||
enabled: true,
|
||||
components: vec!["main".to_string()],
|
||||
architectures: architectures.clone(),
|
||||
suite: suites,
|
||||
uri: base_url,
|
||||
};
|
||||
sources.push(new_source);
|
||||
modified = true;
|
||||
added_ppas.push((parts[0], parts[1]));
|
||||
log::info!(
|
||||
"Added PPA: {} for series {} with architectures {:?}",
|
||||
ppa_str,
|
||||
series,
|
||||
architectures
|
||||
);
|
||||
}
|
||||
|
||||
// Create suite list with all Ubuntu series
|
||||
let suites = vec![format!("{}", series)];
|
||||
|
||||
let new_source = crate::apt::sources::SourceEntry {
|
||||
enabled: true,
|
||||
components: vec!["main".to_string()],
|
||||
architectures: architectures.clone(),
|
||||
suite: suites,
|
||||
uri: base_url,
|
||||
};
|
||||
sources.push(new_source);
|
||||
modified = true;
|
||||
log::info!(
|
||||
"Added PPA: {} for series {} with architectures {:?}",
|
||||
ppa_str,
|
||||
series,
|
||||
architectures
|
||||
} else {
|
||||
return Err(
|
||||
format!("Invalid PPA format: '{}'. Expected: user/ppa_name", ppa_str).into(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Err("Invalid PPA format. Expected: user/ppa_name".into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,14 +119,14 @@ pub async fn build(
|
||||
if modified {
|
||||
apt::sources::save_legacy(None, sources, "/etc/apt/sources.list")?;
|
||||
|
||||
// Download and import PPA key if we added a PPA
|
||||
if let Some(ppa_str) = ppa {
|
||||
let parts: Vec<&str> = ppa_str.split('/').collect();
|
||||
if parts.len() == 2
|
||||
&& let Err(e) =
|
||||
crate::apt::keyring::download_trust_ppa_key(None, parts[0], parts[1]).await
|
||||
// Download and import PPA keys for all added PPAs
|
||||
for (user, ppa_name) in added_ppas {
|
||||
if let Err(e) = crate::apt::keyring::download_trust_ppa_key(None, user, ppa_name).await
|
||||
{
|
||||
warn!("Failed to download PPA key for {}: {}", ppa_str, e);
|
||||
warn!(
|
||||
"Failed to download PPA key for {}/{}: {}",
|
||||
user, ppa_name, e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user