← Back to davo.co
summaryrefslogtreecommitdiffstats
path: root/README.md
blob: 22edd5340005a744fcb08ee425eda670770c9b45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# ud

A clean, minimalist, robust C utility designed to automate Debian-based Linux system maintenance tasks. It manages `apt` package list updates, performs conditional upgrades, purges orphaned dependencies, clears package caches, and cleans local user thumbnail and screenshot directories while logging execution metrics.

## Features

- **Automated APT Maintenance:** Updates repository indices, checks for upgradeable packages, and runs `apt full-upgrade` only when updates exist.
- **Dependency & Cache Cleanup:** Automatically purges unused dependencies and lingering configuration files (`apt autoremove --purge`) and empties cached installer packages (`apt clean`).
- **User Cache Housekeeping:** Safely cleans desktop thumbnail caches and user screenshot directories without failing if the directories are empty.
- **Persistent Summary Logging:** Automatically writes session timestamps and task completion metrics (item counts purged/deleted) to `~/.local/state/ud/ud.log` following XDG Base Directory standards.
- **CLI Management Flags:** Built-in option parsing (`getopt_long`) to view logs with your system `$PAGER`, clear log files, or inspect utility version information.
- **Robust POSIX C Implementation:** Built using standard C (`-std=c11`, POSIX 2008) with explicit bounds checking on formatted buffers and POSIX exit status inspection (`WIFEXITED`, `WEXITSTATUS`).
- **Hardened & Optimized Build:** Compiled with `-O3`, `-flto`, `-march=native`, stack protection (`-fstack-protector-strong`), runtime buffer fortification (`-D_FORTIFY_SOURCE=2`), and strict warning checks (`-Wall -Wextra -Wpedantic -Werror`).
- **Clean Terminal Output:** Indents subprocess output using `sed` for a clear, readable terminal log.

---

## Prerequisites & Dependencies

This utility requires a **Debian-based distribution** (Debian, Ubuntu, Linux Mint, Pop!_OS, etc.) with the following installed:

- `gcc` or `clang`
- `make`
- `apt`
- `sed`
- `sudo` privileges for package management operations

---

## Repository Access & Cloning

Clone the repository directly from the cgit web frontend:

```bash
git clone https://git.davo.co/ud.git
```

---

## Build Instructions

To compile the executable using `make`:

```bash
# Build the utility with maximum optimization and hardening flags
make

# Install the binary to ~/.local/bin
make install

# Clean build artifacts
make clean

# Uninstall the binary from ~/.local/bin
make uninstall
```

---

## Execution Instructions

Run the utility directly from your terminal:

```bash
# Execute standard maintenance routine
ud

# View persistent maintenance log using $PAGER (defaults to less)
ud -v
ud --view-log

# Clear log history (~/.local/state/ud/ud.log)
ud -c
ud --clear-log

# Display utility version
ud -V
ud --version

# Display help message
ud -h
ud --help
```