Skip to content

Commit

Permalink
feat(aura): add -Oe to see top-level packages
Browse files Browse the repository at this point in the history
`-O` has always displayed "orphan packages", but there was no way to see
which packages were marked as "unrequired" yet installed explicitly.
Something of an opposite concept to orphans.

You'd assume that all such packages would be applications (given that
they aren't listed as being depended on), but sometimes installed
packages get forgotten or are somehow mislabelled. These are "elderly"
packages and should be uninstalled to avoid pointless updates.
  • Loading branch information
fosskers committed Oct 4, 2023
1 parent c89cca2 commit 5456c7a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions rust/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions rust/aura-pm/src/command/orphans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion rust/aura-pm/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions rust/aura-pm/src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 7 additions & 6 deletions rust/aura-pm/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! The Aura Package Manager.
//!
//! Copyright 2012 - 2022 Colin Woodbury <[email protected]>
//! Copyright 2012 - 2023 Colin Woodbury <[email protected]>
//!
//! This file is part of Aura.
//!
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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!(),
Expand Down

0 comments on commit 5456c7a

Please sign in to comment.