pacsea/install/
mod.rs

1//! Modular install subsystem.
2//!
3//! This module splits the previous monolithic `install.rs` into focused
4//! submodules. Public API is preserved via re-exports.
5
6/// Batch installation operations.
7mod batch;
8pub mod command;
9/// Direct installation operations.
10mod direct;
11/// Executor for package operations.
12mod executor;
13/// Logging utilities for install operations.
14mod logging;
15/// Package removal operations.
16mod remove;
17/// Security scanning operations.
18mod scan;
19/// Shell command execution.
20mod shell;
21/// Single package installation.
22mod single;
23/// Utility functions for install operations.
24mod utils;
25
26pub use batch::spawn_install_all;
27pub use logging::log_removed;
28mod patterns;
29pub use remove::{check_config_directories, spawn_remove_all};
30
31#[cfg(not(target_os = "windows"))]
32pub use scan::spawn::build_sleuth_command_for_terminal;
33
34#[cfg(not(target_os = "windows"))]
35#[allow(clippy::too_many_arguments)]
36/// What: Load user-configured suspicious patterns and launch the AUR scan pipeline.
37///
38/// Input:
39/// - `pkg`: Package name passed to the scanner.
40/// - `do_clamav`/`do_trivy`/`do_semgrep`/`do_shellcheck`/`do_virustotal`/`do_custom`/`do_sleuth`: Toggles for optional scan stages.
41///
42/// Output:
43/// - Spawns a terminal executing the scan workflow defined in `scan::spawn_aur_scan_for_with_config`.
44///
45/// Details:
46/// - Loads `pattern.conf`, publishes severity regexes via environment variables, and lets the scan module honour them.
47/// - Environment overrides take precedence so UI toggles and config-driven patterns cooperate.
48#[allow(clippy::fn_params_excessive_bools)]
49pub fn spawn_aur_scan_for_with_config(
50    pkg: &str,
51    do_clamav: bool,
52    do_trivy: bool,
53    do_semgrep: bool,
54    do_shellcheck: bool,
55    do_virustotal: bool,
56    do_custom: bool,
57    do_sleuth: bool,
58) {
59    // Load configurable suspicious patterns (pattern.conf), override defaults via env vars
60    let sets = crate::install::patterns::load();
61    unsafe {
62        std::env::set_var("PACSEA_PATTERNS_CRIT", &sets.critical);
63    }
64    unsafe {
65        std::env::set_var("PACSEA_PATTERNS_HIGH", &sets.high);
66    }
67    unsafe {
68        std::env::set_var("PACSEA_PATTERNS_MEDIUM", &sets.medium);
69    }
70    unsafe {
71        std::env::set_var("PACSEA_PATTERNS_LOW", &sets.low);
72    }
73
74    // Forward to scanner; scan.rs will export defaults, but our env vars take precedence in crit/high/med/low expansions
75    scan::spawn_aur_scan_for_with_config(
76        pkg,
77        do_clamav,
78        do_trivy,
79        do_semgrep,
80        do_shellcheck,
81        do_virustotal,
82        do_custom,
83        do_sleuth,
84    );
85}
86pub use direct::{
87    start_integrated_install, start_integrated_install_all, start_integrated_remove_all,
88};
89#[cfg(not(target_os = "windows"))]
90pub use executor::build_scan_command_for_executor;
91pub use executor::{
92    ExecutorOutput, ExecutorRequest, build_downgrade_command_for_executor,
93    build_install_command_for_executor, build_remove_command_for_executor,
94    build_update_command_for_executor,
95};
96pub use shell::spawn_shell_commands_in_terminal;
97pub use single::spawn_install;
98pub use utils::command_on_path;
99#[cfg(not(target_os = "windows"))]
100pub use utils::editor_open_config_command;
101pub use utils::shell_single_quote;