Multiple changes
Some checks failed
CI / build (push) Failing after 18m0s
CI / snap (push) Has been skipped

- quirks: added quirks, that does nothing for now
- deb: install arch-independant dependencies (too much is better)
- deb: added linux-riscv crossbuild test
This commit is contained in:
2026-02-10 11:07:05 +01:00
parent 8345f51d2f
commit 97725efb34
5 changed files with 120 additions and 15 deletions

14
quirks.yml Normal file
View File

@@ -0,0 +1,14 @@
# Quirks configuration for package-specific workarounds
# This file defines package-specific quirks that are applied during pull and deb operations
quirks:
# Add more packages and their quirks as needed
# example-package:
# pull:
# method: archive
# deb:
# extra_dependencies:
# - another-dependency
# parameters:
# key: value

View File

@@ -185,22 +185,22 @@ pub async fn build(
return Err("Could not install build-dependencies for the build".into());
}
// // Install arch-independant build dependencies
// log::debug!("Installing arch-independant build dependencies...");
// let status = ctx.command("apt-get")
// .current_dir(package_dir_str)
// .envs(env.clone())
// .arg("-y")
// .arg("build-dep")
// .arg("--indep-only")
// .arg("./")
// .status()?;
// Install arch-independant build dependencies
log::debug!("Installing arch-independant build dependencies...");
let status = ctx
.command("apt-get")
.current_dir(package_dir_str)
.envs(env.clone())
.arg("-y")
.arg("build-dep")
.arg("./")
.status()?;
// // If build-dep fails, we try to explain the failure using dose-debcheck
// if !status.success() {
// dose3_explain_dependencies(package, version, arch, build_root, cross)?;
// return Err("Could not install build-dependencies for the build".into());
// }
// If build-dep fails, we try to explain the failure using dose-debcheck
if !status.success() {
dose3_explain_dependencies(package, version, arch, build_root, cross)?;
return Err("Could not install build-dependencies for the build".into());
}
// Run the build step
log::debug!("Building (debian/rules build) package...");
@@ -260,6 +260,7 @@ fn dose3_explain_dependencies(
}
// Transform the dsc file into a 'Source' stanza (replacing 'Source' with 'Package')
// TODO: Remove potential GPG headers/signature
let dsc_path = find_dsc_file(build_root, package, version)?;
let mut dsc_content = ctx.read_file(&dsc_path)?;
dsc_content = dsc_content.replace("Source", "Package");

View File

@@ -288,6 +288,17 @@ mod tests {
test_build_end_to_end("hello", "sid", None, None, false).await;
}
/// This is a specific test case for the linux-riscv package on Ubuntu
/// It is important to ensure that pkh can cross-compile linux-riscv, as
/// for risc-v hardware is still rare and cross-compilation is necessary
/// to debug and test
#[tokio::test]
#[test_log::test]
#[cfg(target_arch = "x86_64")]
async fn test_deb_linux_riscv_ubuntu_cross_end_to_end() {
test_build_end_to_end("linux-riscv", "questing", None, Some("riscv64"), true).await;
}
/// This is a specific test case for the latest gcc package on Debian
/// The GCC package is complex and hard to build, with specific stages
/// and system-bound scripts. Building it requires specific things that

View File

@@ -17,6 +17,8 @@ pub mod distro_info;
pub mod package_info;
/// Download a source package locally
pub mod pull;
/// Handle package-specific quirks and workarounds
pub mod quirks;
/// Handle context for .deb building: locally, over ssh, in a chroot...
pub mod context;

77
src/quirks.rs Normal file
View File

@@ -0,0 +1,77 @@
//! Quirks module for handling package-specific workarounds
//!
//! This module provides functionality to read quirks from a YAML file
//! and apply them during pull and deb operations.
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
/// Quirks configuration for a specific operation (pull or deb)
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct OperationQuirks {
/// Extra dependencies to install before the operation
#[serde(default)]
pub extra_dependencies: Vec<String>,
/// Additional parameters for the operation
#[serde(default)]
pub parameters: HashMap<String, serde_yaml::Value>,
}
/// Quirks for a specific package
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct PackageQuirks {
/// Quirks to apply during pull operation
#[serde(default)]
pub pull: Option<OperationQuirks>,
/// Quirks to apply during deb operation
#[serde(default)]
pub deb: Option<OperationQuirks>,
}
/// Top-level quirks configuration
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct QuirksConfig {
/// Map of package names to their quirks
pub quirks: HashMap<String, PackageQuirks>,
}
const QUIRKS_YAML: &str = include_str!("../quirks.yml");
lazy_static! {
static ref QUIRKS_DATA: QuirksConfig = serde_yaml::from_str(QUIRKS_YAML).unwrap();
}
/// Get quirks for a specific package
///
/// # Arguments
/// * `config` - The quirks configuration
/// * `package` - The package name
///
/// # Returns
/// * `Option<PackageQuirks>` - The quirks for the package, or None if not found
pub fn get_package_quirks<'a>(
config: &'a QuirksConfig,
package: &str,
) -> Option<&'a PackageQuirks> {
config.quirks.get(package)
}
/// Get deb-time extra dependencies for a package
///
/// This function returns the list of extra dependencies that should be installed
/// before building a package, as defined in the quirks configuration.
///
/// # Arguments
/// * `package` - The package name
///
/// # Returns
/// * `Vec<String>` - List of extra dependencies, or empty vector if none
pub fn get_deb_extra_dependencies(package: &str) -> Vec<String> {
if let Some(quirks) = &get_package_quirks(&QUIRKS_DATA, package).unwrap().deb {
return quirks.extra_dependencies.clone();
}
Vec::new()
}