Fix OVMF 4m variant detection and Gentoo dep atom parsing
1. host.ovmf: Arch edk2-ovmf 202508+ uses OVMF_CODE.4m.fd (4MB variant) instead of OVMF_CODE.fd. Added .4m.fd paths to the search list and updated the find fallback to match OVMF_CODE*.fd glob. 2. test_parse_dep_atoms: The single-regex approach with lazy quantifiers failed on atoms like "sys-libs/zlib" at end-of-string. Rewrote parse_dep_atoms to split on whitespace first, strip [:slot] and [USE] suffixes, then match category/name with a simple anchored regex. This is more robust and easier to reason about. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -321,27 +321,56 @@ fn parse_use_flags(iuse: &str) -> HashMap<String, OptionalDep> {
|
|||||||
/// Strips category prefixes and version constraints for dpack format.
|
/// Strips category prefixes and version constraints for dpack format.
|
||||||
fn parse_dep_atoms(deps: &str, warnings: &mut ConversionWarnings) -> Vec<String> {
|
fn parse_dep_atoms(deps: &str, warnings: &mut ConversionWarnings) -> Vec<String> {
|
||||||
let mut result = Vec::new();
|
let mut result = Vec::new();
|
||||||
|
// Regex to extract category/name from a single Gentoo atom token
|
||||||
|
// Strips: leading operator (>=, <=, ~, =), trailing version (-1.2.3),
|
||||||
|
// slot (:0=), and USE flags ([foo,bar])
|
||||||
let atom_re = Regex::new(
|
let atom_re = Regex::new(
|
||||||
r"(?:>=|<=|~|=)?([a-zA-Z0-9_-]+/[a-zA-Z0-9_.+-]+?)(?:-\d[^\s\[\]:]*)?(?:\[.*?\])?(?::[\w/=*]*)?(?:\s|$)"
|
r"^(?:>=|<=|~|=)?([a-zA-Z0-9_-]+/[a-zA-Z0-9_+-]+[a-zA-Z])"
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
for caps in atom_re.captures_iter(deps) {
|
// Process each whitespace-separated token, skipping non-atoms
|
||||||
if let Some(m) = caps.get(1) {
|
for token in deps.split_whitespace() {
|
||||||
let full_atom = m.as_str();
|
let clean = token.trim();
|
||||||
// Strip category prefix (e.g., "dev-libs/" -> "")
|
|
||||||
let pkg_name = full_atom
|
|
||||||
.rsplit('/')
|
|
||||||
.next()
|
|
||||||
.unwrap_or(full_atom)
|
|
||||||
.to_string();
|
|
||||||
|
|
||||||
// Skip virtual packages and test-only deps
|
// Skip conditional operators and parens
|
||||||
if full_atom.starts_with("virtual/") {
|
if clean.is_empty()
|
||||||
continue;
|
|| clean.ends_with('?')
|
||||||
}
|
|| clean == "("
|
||||||
|
|| clean == ")"
|
||||||
|
|| clean == "||"
|
||||||
|
|| clean == "^^"
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if !result.contains(&pkg_name) {
|
// Strip trailing [:slot] and [USE] before regex matching
|
||||||
result.push(pkg_name);
|
let without_use = if let Some(bracket_pos) = clean.find('[') {
|
||||||
|
&clean[..bracket_pos]
|
||||||
|
} else {
|
||||||
|
clean
|
||||||
|
};
|
||||||
|
let without_slot = if let Some(colon_pos) = without_use.find(':') {
|
||||||
|
&without_use[..colon_pos]
|
||||||
|
} else {
|
||||||
|
without_use
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(caps) = atom_re.captures(without_slot) {
|
||||||
|
if let Some(m) = caps.get(1) {
|
||||||
|
let full_atom = m.as_str();
|
||||||
|
let pkg_name = full_atom
|
||||||
|
.rsplit('/')
|
||||||
|
.next()
|
||||||
|
.unwrap_or(full_atom)
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
if full_atom.starts_with("virtual/") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if !result.contains(&pkg_name) {
|
||||||
|
result.push(pkg_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,11 +133,14 @@ else
|
|||||||
record "host.nested_virt" "skip" "No VMX/SVM — QEMU boot tests will be slower"
|
record "host.nested_virt" "skip" "No VMX/SVM — QEMU boot tests will be slower"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check OVMF — Arch uses split CODE/VARS files, others use a single OVMF.fd
|
# Check OVMF — search all known paths including 4m variant (newer Arch)
|
||||||
OVMF=""
|
OVMF=""
|
||||||
for p in \
|
for p in \
|
||||||
|
/usr/share/edk2/x64/OVMF_CODE.4m.fd \
|
||||||
/usr/share/edk2/x64/OVMF_CODE.fd \
|
/usr/share/edk2/x64/OVMF_CODE.fd \
|
||||||
|
/usr/share/edk2-ovmf/x64/OVMF_CODE.4m.fd \
|
||||||
/usr/share/edk2-ovmf/x64/OVMF_CODE.fd \
|
/usr/share/edk2-ovmf/x64/OVMF_CODE.fd \
|
||||||
|
/usr/share/OVMF/OVMF_CODE.4m.fd \
|
||||||
/usr/share/OVMF/OVMF_CODE.fd \
|
/usr/share/OVMF/OVMF_CODE.fd \
|
||||||
/usr/share/edk2/x64/OVMF.fd \
|
/usr/share/edk2/x64/OVMF.fd \
|
||||||
/usr/share/edk2-ovmf/x64/OVMF.fd \
|
/usr/share/edk2-ovmf/x64/OVMF.fd \
|
||||||
@@ -148,7 +151,7 @@ for p in \
|
|||||||
done
|
done
|
||||||
# Last resort: find it
|
# Last resort: find it
|
||||||
if [ -z "$OVMF" ]; then
|
if [ -z "$OVMF" ]; then
|
||||||
OVMF=$(find /usr/share -name "OVMF_CODE.fd" -o -name "OVMF.fd" 2>/dev/null | head -1)
|
OVMF=$(find /usr/share -name "OVMF_CODE*.fd" -o -name "OVMF.fd" 2>/dev/null | head -1)
|
||||||
fi
|
fi
|
||||||
[ -n "$OVMF" ] && record "host.ovmf" "pass" "$OVMF" || record "host.ovmf" "fail" "Not found — install edk2-ovmf"
|
[ -n "$OVMF" ] && record "host.ovmf" "pass" "$OVMF" || record "host.ovmf" "fail" "Not found — install edk2-ovmf"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user