diff --git a/rust/CHANGELOG.md b/rust/CHANGELOG.md index 79372968b..efb9be758 100644 --- a/rust/CHANGELOG.md +++ b/rust/CHANGELOG.md @@ -24,6 +24,8 @@ Tarball Size : 72.09MiB Available Versions : 5.8.13.arch1-1, 5.8.10.arch1-1 ``` +- `-Oe` to display explicitly installed, top-level (i.e. unrequired) packages. + Useful for detecting packages that you no longer need installed. - `deps` command for analyzing dependency connections. Generates output in [Graphviz DOT format](https://en.wikipedia.org/wiki/DOT_%28graph_description_language%29), and can be used like so: diff --git a/rust/aura-pm/src/command/orphans.rs b/rust/aura-pm/src/command/orphans.rs index ef2d68a19..b1a5f9476 100644 --- a/rust/aura-pm/src/command/orphans.rs +++ b/rust/aura-pm/src/command/orphans.rs @@ -55,6 +55,13 @@ pub(crate) fn list(alpm: &Alpm) { aura_core::orphans(alpm).for_each(|o| println!("{} {}", o.name(), o.version())) } +/// Print the name of each "elderly" package. In theory these are all explicitly +/// installed applications, but occasionally packages are installed by mistake +/// or forgotten. We want to identify such packages for removal. +pub(crate) fn elderly(alpm: &Alpm) { + aura_core::elderly(alpm).for_each(|o| println!("{} {}", o.name(), o.version())) +} + /// Sets a package's install reason to "as explicit". An alias for `-D --asexplicit`. pub(crate) fn adopt( alpm: &Alpm, diff --git a/rust/aura-pm/src/error.rs b/rust/aura-pm/src/error.rs index c7abf1122..675aaf4b9 100644 --- a/rust/aura-pm/src/error.rs +++ b/rust/aura-pm/src/error.rs @@ -12,7 +12,7 @@ pub(crate) enum Error { A(crate::command::aur::Error), B(crate::command::snapshot::Error), C(crate::command::cache::Error), - L(crate::log::Error), + L(crate::command::log::Error), O(crate::command::orphans::Error), Dirs(crate::dirs::Error), /// A non-zero exit code was returned from a call to Pacman. diff --git a/rust/aura-pm/src/flags.rs b/rust/aura-pm/src/flags.rs index 3cbf5df2c..0f54f1166 100644 --- a/rust/aura-pm/src/flags.rs +++ b/rust/aura-pm/src/flags.rs @@ -790,6 +790,9 @@ pub struct Orphans { /// Uninstall all orphan packages. #[clap(group = "orphans", long, short = 'j')] pub abandon: bool, + /// Display all explicitly installed, top-level packages. + #[clap(group = "orphans", long, short = 'e')] + pub elderly: bool, } /// View various configuration settings and files. diff --git a/rust/aura-pm/src/main.rs b/rust/aura-pm/src/main.rs index 6e11a9209..55ccf7b23 100644 --- a/rust/aura-pm/src/main.rs +++ b/rust/aura-pm/src/main.rs @@ -1,6 +1,6 @@ //! The Aura Package Manager. //! -//! Copyright 2012 - 2022 Colin Woodbury +//! Copyright 2012 - 2023 Colin Woodbury //! //! This file is part of Aura. //! @@ -40,14 +40,14 @@ mod macros; pub(crate) mod pacman; pub(crate) mod utils; -use crate::command::{aur, cache, check, conf, deps, log, open, orphans, snapshot, stats}; +use crate::command::{aur, cache, check, conf, deps, log as llog, open, orphans, snapshot, stats}; use crate::error::{Error, Nested}; use crate::localization::Localised; -use ::log::debug; use aura_pm::flags::{Args, Cache, SubCmd, AURA_GLOBALS}; use clap::Parser; use colored::Colorize; use i18n_embed::fluent::FluentLanguageLoader; +use log::debug; use simplelog::{ColorChoice, Config, TermLogger, TerminalMode}; use std::ops::Not; use std::process::ExitCode; @@ -137,12 +137,13 @@ fn work(args: Args, fll: &FluentLanguageLoader) -> Result<(), Error> { SubCmd::Cache(c) if c.missing => cache::missing(&env.alpm()?, &env.caches()), SubCmd::Cache(c) => cache::downgrade(fll, &env.caches(), c.packages)?, // --- Logs --- // - SubCmd::Log(l) if l.search.is_some() => log::search(env.alpm_log(), l.search.unwrap())?, - SubCmd::Log(l) if !l.info.is_empty() => log::info(fll, env.alpm_log(), l.info)?, - SubCmd::Log(l) => log::view(env.alpm_log(), l.before, l.after)?, + SubCmd::Log(l) if l.search.is_some() => llog::search(env.alpm_log(), l.search.unwrap())?, + SubCmd::Log(l) if !l.info.is_empty() => llog::info(fll, env.alpm_log(), l.info)?, + SubCmd::Log(l) => llog::view(env.alpm_log(), l.before, l.after)?, // --- Orphan Packages --- // SubCmd::Orphans(o) if o.abandon => orphans::remove(&mut env.alpm()?, fll)?, SubCmd::Orphans(o) if !o.adopt.is_empty() => orphans::adopt(&env.alpm()?, fll, o.adopt)?, + SubCmd::Orphans(o) if o.elderly => orphans::elderly(&env.alpm()?), SubCmd::Orphans(_) => orphans::list(&env.alpm()?), // --- PKGBUILD Analysis --- // // SubCmd::Analysis(_) => unimplemented!(),