deb: add quirks to allow packages to declare specific package directories
This commit is contained in:
@@ -12,3 +12,8 @@ quirks:
|
|||||||
# - another-dependency
|
# - another-dependency
|
||||||
# parameters:
|
# parameters:
|
||||||
# key: value
|
# key: value
|
||||||
|
|
||||||
|
linux-riscv:
|
||||||
|
deb:
|
||||||
|
package_directory:
|
||||||
|
- linux-main
|
||||||
|
|||||||
@@ -142,12 +142,26 @@ pub async fn build_binary_package(
|
|||||||
/// Find the current package directory by trying both patterns:
|
/// Find the current package directory by trying both patterns:
|
||||||
/// - package/package
|
/// - package/package
|
||||||
/// - package/package-origversion
|
/// - package/package-origversion
|
||||||
|
/// - custom directories from quirks configuration
|
||||||
pub(crate) fn find_package_directory(
|
pub(crate) fn find_package_directory(
|
||||||
parent_dir: &Path,
|
parent_dir: &Path,
|
||||||
package: &str,
|
package: &str,
|
||||||
version: &str,
|
version: &str,
|
||||||
ctx: &context::Context,
|
ctx: &context::Context,
|
||||||
) -> Result<PathBuf, Box<dyn Error>> {
|
) -> Result<PathBuf, Box<dyn Error>> {
|
||||||
|
// Check quirks first for custom package directories
|
||||||
|
let custom_dirs = crate::quirks::get_package_directories(package);
|
||||||
|
for custom_dir in custom_dirs {
|
||||||
|
let package_dir = parent_dir.join(&custom_dir);
|
||||||
|
if ctx.exists(&package_dir)? && ctx.exists(&package_dir.join("debian"))? {
|
||||||
|
log::debug!(
|
||||||
|
"Found package directory via quirks: {}",
|
||||||
|
package_dir.display()
|
||||||
|
);
|
||||||
|
return Ok(package_dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Try package/package pattern first
|
// Try package/package pattern first
|
||||||
let package_dir = parent_dir.join(package).join(package);
|
let package_dir = parent_dir.join(package).join(package);
|
||||||
if ctx.exists(&package_dir)? && ctx.exists(&package_dir.join("debian"))? {
|
if ctx.exists(&package_dir)? && ctx.exists(&package_dir.join("debian"))? {
|
||||||
|
|||||||
@@ -17,6 +17,12 @@ pub struct OperationQuirks {
|
|||||||
/// Additional parameters for the operation
|
/// Additional parameters for the operation
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub parameters: HashMap<String, serde_yaml::Value>,
|
pub parameters: HashMap<String, serde_yaml::Value>,
|
||||||
|
|
||||||
|
/// Custom package directories to try when looking for the package source
|
||||||
|
/// This is useful for packages that don't follow the standard naming conventions
|
||||||
|
/// like linux packages that use directories like "linux-main" or other custom names
|
||||||
|
#[serde(default)]
|
||||||
|
pub package_directory: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Quirks for a specific package
|
/// Quirks for a specific package
|
||||||
@@ -75,3 +81,31 @@ pub fn get_deb_extra_dependencies(package: &str) -> Vec<String> {
|
|||||||
|
|
||||||
Vec::new()
|
Vec::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get package directories from quirks configuration
|
||||||
|
///
|
||||||
|
/// This function returns the list of custom package directories to try
|
||||||
|
/// when looking for the package source directory.
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
/// * `package` - The package name
|
||||||
|
///
|
||||||
|
/// # Returns
|
||||||
|
/// * `Vec<String>` - List of package directories to try, or empty vector if none
|
||||||
|
pub fn get_package_directories(package: &str) -> Vec<String> {
|
||||||
|
if let Some(quirks) = get_package_quirks(&QUIRKS_DATA, package) {
|
||||||
|
// Check deb quirks first, then pull quirks
|
||||||
|
if let Some(deb_quirks) = &quirks.deb
|
||||||
|
&& !deb_quirks.package_directory.is_empty()
|
||||||
|
{
|
||||||
|
return deb_quirks.package_directory.clone();
|
||||||
|
}
|
||||||
|
if let Some(pull_quirks) = &quirks.pull
|
||||||
|
&& !pull_quirks.package_directory.is_empty()
|
||||||
|
{
|
||||||
|
return pull_quirks.package_directory.clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec::new()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user