Created the core functionality for Fedora. Need to update the logic to include filtering from input, not just dnf
This commit is contained in:
parent
8108221bd0
commit
d115716d45
23
readme.md
23
readme.md
|
@ -1,6 +1,6 @@
|
|||
# CARTO - Universal System File and Package Mapper
|
||||
|
||||
A command-line tool that provides comprehensive observability into your Linux system's package installations and file ownership. Built in Rust for performance and reliability.
|
||||
A command-line tool that provides comprehensive observability into your Linux system's package installations and file ownership. Providing a clear, tracable providence for every executable, and configuration file on your system.
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -13,22 +13,27 @@ just install
|
|||
## Usage
|
||||
|
||||
# Show package file tree
|
||||
carto tree --package bash
|
||||
carto tree --package "Signal Desktop (org.signal.Signal)"
|
||||
`carto tree --package bash`
|
||||
|
||||
`carto tree --package "Signal Desktop (org.signal.Signal)"`
|
||||
|
||||
# Package information
|
||||
carto package bash
|
||||
`carto package bash`
|
||||
|
||||
# File ownership
|
||||
carto file /usr/bin/bash
|
||||
|
||||
`carto file /usr/bin/bash`
|
||||
|
||||
# List packages
|
||||
carto packages
|
||||
carto packages --source dnf
|
||||
carto packages --source flatpak
|
||||
`carto packages`
|
||||
|
||||
`carto packages --source dnf`
|
||||
|
||||
`carto packages --source flatpak`
|
||||
|
||||
# Find files in package
|
||||
carto find --package bash
|
||||
|
||||
`carto find --package bash`
|
||||
|
||||
## Example Output
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ pub enum Commands {
|
|||
include_expected: bool,
|
||||
|
||||
/// Force full rescan
|
||||
#[arg(short, long)]
|
||||
#[arg(short = 'F', long)]
|
||||
force: bool,
|
||||
},
|
||||
|
||||
|
|
|
@ -48,15 +48,30 @@ pub struct Scanner<'a> {
|
|||
}
|
||||
impl<'a> Scanner<'a> {
|
||||
pub fn new(managers: &'a [Box<dyn PackageManager>]) -> Self {
|
||||
let exclude_paths = vec![
|
||||
PathBuf::from("/proc"),
|
||||
PathBuf::from("/sys"),
|
||||
PathBuf::from("/dev"),
|
||||
PathBuf::from("/run"),
|
||||
PathBuf::from("/var/run"),
|
||||
PathBuf::from("/tmp/.X11-unix"),
|
||||
PathBuf::from("/tmp/.ICE-unix"),
|
||||
];
|
||||
let exclude_paths = vec![
|
||||
// Existing exclusions
|
||||
PathBuf::from("/proc"),
|
||||
PathBuf::from("/sys"),
|
||||
PathBuf::from("/dev"),
|
||||
PathBuf::from("/run"),
|
||||
PathBuf::from("/var/run"),
|
||||
PathBuf::from("/tmp/.X11-unix"),
|
||||
PathBuf::from("/tmp/.ICE-unix"),
|
||||
|
||||
PathBuf::from("/var/lib/containers"),
|
||||
PathBuf::from("/var/lib/docker"),
|
||||
PathBuf::from("/home/.local/share/containers"), // Your specific issue
|
||||
PathBuf::from("/var/lib/flatpak"),
|
||||
PathBuf::from("/var/cache"),
|
||||
PathBuf::from("/var/tmp"),
|
||||
PathBuf::from("/tmp"),
|
||||
PathBuf::from("/var/log"),
|
||||
PathBuf::from("/var/spool"),
|
||||
PathBuf::from("/boot"),
|
||||
PathBuf::from("/usr/src"), // Kernel sources
|
||||
PathBuf::from("/home"), // User data isn't "orphaned"
|
||||
PathBuf::from("/root"),
|
||||
];
|
||||
|
||||
Self {
|
||||
managers,
|
||||
|
@ -71,11 +86,17 @@ impl<'a> Scanner<'a> {
|
|||
) -> Result<ScanResults, CartoError> {
|
||||
let start_time = std::time::Instant::now();
|
||||
let scan_paths = if paths.is_empty() {
|
||||
vec!["/".to_string()]
|
||||
vec![
|
||||
"/usr".to_string(),
|
||||
"/etc".to_string(),
|
||||
"/opt".to_string(),
|
||||
"/lib".to_string(),
|
||||
"/lib64".to_string(),
|
||||
]
|
||||
} else {
|
||||
paths.to_vec()
|
||||
};
|
||||
|
||||
|
||||
let mut results = ScanResults::new(scan_paths.clone());
|
||||
let mut orphans: Vec<OrphanFile> = Vec::new();
|
||||
|
||||
|
@ -168,13 +189,26 @@ impl<'a> Scanner<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
// Additional exclusions for common mount points and special directories
|
||||
let path_str = path.to_string_lossy();
|
||||
if path_str.contains("/.git/") ||
|
||||
path_str.contains("/.cache/") ||
|
||||
path_str.contains("/.local/share/Trash/") ||
|
||||
path_str.starts_with("/media/") ||
|
||||
path_str.starts_with("/mnt/") {
|
||||
|
||||
// Container storage patterns
|
||||
if path_str.contains("/containers/storage/") ||
|
||||
path_str.contains("/overlay/") ||
|
||||
path_str.contains("/docker/") ||
|
||||
|
||||
// Build and cache directories
|
||||
path_str.contains("/.git/") ||
|
||||
path_str.contains("/.cache/") ||
|
||||
path_str.contains("/cache/") ||
|
||||
path_str.contains("/.local/share/Trash/") ||
|
||||
|
||||
// Mount points and removable media
|
||||
path_str.starts_with("/media/") ||
|
||||
path_str.starts_with("/mnt/") ||
|
||||
|
||||
// Snap and flatpak user data
|
||||
path_str.contains("/snap/") ||
|
||||
path_str.contains("/.var/app/") {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue