1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! Parser for Autotools configure scripts.
//!
//! Extracts basic package metadata from Autotools configure files by using
//! the parent directory name as the package name.
//!
//! # Supported Formats
//! - configure (Autotools configure script)
//! - configure.ac (Autoconf input file)
//!
//! # Key Features
//! - Lightweight detection based on parent directory name
//! - No file content parsing required
//!
//! # Implementation Notes
//! - This parser does NOT read file contents, only extracts parent directory name
//! - configure.in is NOT supported (deprecated legacy format)
//! - Returns minimal PackageData with only package_type and name fields
use crate::models::PackageData;
use crate::models::{DatasourceId, PackageType};
use std::path::Path;
use super::PackageParser;
/// Parser for Autotools configure scripts.
///
/// Extracts the parent directory name as the package name without parsing file contents.
pub struct AutotoolsConfigureParser;
impl PackageParser for AutotoolsConfigureParser {
const PACKAGE_TYPE: PackageType = PackageType::Autotools;
fn is_match(path: &Path) -> bool {
path.file_name()
.and_then(|name| name.to_str())
.is_some_and(|name| name == "configure" || name == "configure.ac")
}
fn extract_packages(path: &Path) -> Vec<PackageData> {
let name = path
.parent()
.and_then(|p| p.file_name())
.and_then(|n| n.to_str())
.map(|s| s.to_string());
vec![PackageData {
package_type: Some(Self::PACKAGE_TYPE),
name,
datasource_id: Some(DatasourceId::AutotoolsConfigure),
..Default::default()
}]
}
}
crate::register_parser!(
"Autotools configure script",
&["**/configure", "**/configure.ac"],
"autotools",
"C",
Some("https://www.gnu.org/software/autoconf/"),
);