Name update
This commit is contained in:
@@ -78,7 +78,9 @@ pub fn introspect(path: &Path) -> IntrospectionReport {
|
||||
let mut haystack = Vec::with_capacity(scan_bytes.min(32 * 1024 * 1024));
|
||||
while read_total < scan_bytes {
|
||||
let n = f.read(&mut buf).unwrap_or(0);
|
||||
if n == 0 { break; }
|
||||
if n == 0 {
|
||||
break;
|
||||
}
|
||||
haystack.extend_from_slice(&buf[..n]);
|
||||
read_total += n;
|
||||
}
|
||||
@@ -107,8 +109,11 @@ fn family_from_label(label: &str) -> DistroFamily {
|
||||
let l = label.to_ascii_lowercase();
|
||||
if l.contains("ubuntu") || l.contains("debian") || l.contains("mint") {
|
||||
DistroFamily::DebianUbuntu
|
||||
} else if l.contains("rhel") || l.contains("centos") || l.contains("fedora")
|
||||
|| l.contains("rocky") || l.contains("alma")
|
||||
} else if l.contains("rhel")
|
||||
|| l.contains("centos")
|
||||
|| l.contains("fedora")
|
||||
|| l.contains("rocky")
|
||||
|| l.contains("alma")
|
||||
{
|
||||
DistroFamily::RhelFedora
|
||||
} else if l.contains("suse") || l.contains("opensuse") {
|
||||
@@ -127,17 +132,30 @@ fn family_from_label(label: &str) -> DistroFamily {
|
||||
fn guess_kernel_initrd(family: DistroFamily) -> (Option<&'static str>, Vec<&'static str>) {
|
||||
match family {
|
||||
DistroFamily::DebianUbuntu => (Some("/casper/vmlinuz"), vec!["/casper/initrd"]),
|
||||
DistroFamily::RhelFedora => (Some("/images/pxeboot/vmlinuz"), vec!["/images/pxeboot/initrd.img"]),
|
||||
DistroFamily::OpenSuse => (Some("/boot/x86_64/loader/linux"), vec!["/boot/x86_64/loader/initrd"]),
|
||||
DistroFamily::Arch => (Some("/arch/boot/x86_64/vmlinuz-linux"), vec!["/arch/boot/x86_64/initramfs-linux.img"]),
|
||||
DistroFamily::RhelFedora => (
|
||||
Some("/images/pxeboot/vmlinuz"),
|
||||
vec!["/images/pxeboot/initrd.img"],
|
||||
),
|
||||
DistroFamily::OpenSuse => (
|
||||
Some("/boot/x86_64/loader/linux"),
|
||||
vec!["/boot/x86_64/loader/initrd"],
|
||||
),
|
||||
DistroFamily::Arch => (
|
||||
Some("/arch/boot/x86_64/vmlinuz-linux"),
|
||||
vec!["/arch/boot/x86_64/initramfs-linux.img"],
|
||||
),
|
||||
DistroFamily::Alpine => (Some("/boot/vmlinuz-lts"), vec!["/boot/initramfs-lts"]),
|
||||
DistroFamily::WindowsPe | DistroFamily::Unknown => (None, Vec::new()),
|
||||
}
|
||||
}
|
||||
|
||||
fn contains_ascii(haystack: &[u8], needle: &[u8]) -> bool {
|
||||
if needle.is_empty() || haystack.len() < needle.len() { return false; }
|
||||
haystack.windows(needle.len()).any(|w| w.eq_ignore_ascii_case(needle))
|
||||
if needle.is_empty() || haystack.len() < needle.len() {
|
||||
return false;
|
||||
}
|
||||
haystack
|
||||
.windows(needle.len())
|
||||
.any(|w| w.eq_ignore_ascii_case(needle))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -146,9 +164,18 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn label_matching() {
|
||||
assert_eq!(family_from_label("Ubuntu 24.04"), DistroFamily::DebianUbuntu);
|
||||
assert_eq!(family_from_label("Rocky-9-x86_64-dvd"), DistroFamily::RhelFedora);
|
||||
assert_eq!(family_from_label("openSUSE-Leap-15.6"), DistroFamily::OpenSuse);
|
||||
assert_eq!(
|
||||
family_from_label("Ubuntu 24.04"),
|
||||
DistroFamily::DebianUbuntu
|
||||
);
|
||||
assert_eq!(
|
||||
family_from_label("Rocky-9-x86_64-dvd"),
|
||||
DistroFamily::RhelFedora
|
||||
);
|
||||
assert_eq!(
|
||||
family_from_label("openSUSE-Leap-15.6"),
|
||||
DistroFamily::OpenSuse
|
||||
);
|
||||
assert_eq!(family_from_label("ARCH_202604"), DistroFamily::Arch);
|
||||
assert_eq!(family_from_label("weird-custom"), DistroFamily::Unknown);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user