fix(lib): fix macos package count
use libmacchina to count macos packages
This commit is contained in:
parent
e92fba8d8d
commit
7377504ed6
32
src/lib.rs
32
src/lib.rs
@ -100,33 +100,11 @@ pub fn total_packages(package_readout: &PackageReadout) -> usize {
|
|||||||
.map(|mngr| packages(mngr, &macchina_package_count))
|
.map(|mngr| packages(mngr, &macchina_package_count))
|
||||||
.sum()
|
.sum()
|
||||||
}
|
}
|
||||||
"macos" => {
|
"macos" => package_readout
|
||||||
// pkgin
|
.count_pkgs()
|
||||||
run_and_count_lines("pkgin", &["list"])
|
.iter()
|
||||||
// dpkg
|
.map(|elem| elem.1)
|
||||||
+ run_and_count_lines("dpkg-query", &["-f", "'.\n'", "-W"])
|
.sum(),
|
||||||
// brew
|
|
||||||
+ if check_if_command_exists("brew") {
|
|
||||||
match glob("/usr/local/Cellar/*") {
|
|
||||||
Ok(files) => files.count(),
|
|
||||||
Err(_) => 0,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
// port
|
|
||||||
+ match run_system_command("port", &["installed"]) {
|
|
||||||
Ok(output) => {
|
|
||||||
// port prints a single line to stdout when no packages are installed
|
|
||||||
if output == "No ports are installed." {
|
|
||||||
0
|
|
||||||
} else {
|
|
||||||
output.lines().count()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Err(_) => 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"freebsd" | "dragonfly" => run_and_count_lines("pkg", &["info"]),
|
"freebsd" | "dragonfly" => run_and_count_lines("pkg", &["info"]),
|
||||||
"openbsd" => match glob("/var/db/pkg/*/") {
|
"openbsd" => match glob("/var/db/pkg/*/") {
|
||||||
Ok(files) => files.count(),
|
Ok(files) => files.count(),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user