soda64 97c6ac2ab9
Build and Publish Release / Build Packages and Publish (push) Successful in 26s
docs: document Gitea package registry client config and CI/CD workflow
2026-10-03 08:34:44 +02:00

Linux System Updater (linux-updater)

Python 3.6+ License: MIT Platforms

linux-updater is an enterprise-grade, standalone, zero-dependency Python 3 CLI tool designed to safely inspect, auto-remediate, and update Linux systems. It supports Debian, Ubuntu, RHEL (8 & 9), Fedora, AlmaLinux, Rocky Linux, and Arch Linux.


Key Features

  • Zero External Dependencies: Built entirely with the Python standard library. Runs out of the box on Python >= 3.6 (including stock AlmaLinux 8 / RHEL 8 without pip or AppStream updates).
  • Pre-flight Health Diagnostics:
    • Disk Space: Enforces safety thresholds on /boot (>= 250 MB), /var (>= 1024 MB), and / (>= 1024 MB).
    • Process Locks: Detects active package manager locks (via PID checking and non-blocking fcntl.flock advisory locks).
    • Package Database Consistency: Verifies package manager integrity (dpkg --audit, dnf check, pacman lock integrity) and auto-remediates interrupted transactions (dpkg --configure -a, apt-get install -f, dnf clean all).
    • Memory & OOM Pressure: Inspects /proc/meminfo to warn or halt if available RAM is dangerously low (< 300 MB).
    • AC Power Protection: Inspects /sys/class/power_supply on laptops to prevent updates on battery power.
    • Reboot Detection: Detects pending reboots from previous kernel/library updates.
  • Safe Automated Remediation: Safely cleans package cache when /var is low, clears stale locks if the holder process is dead, and repairs interrupted package transactions.
  • Advanced Update Capabilities:
    • Security-only Updates: --security flag restricts updates strictly to CVE/security advisories on RHEL, Fedora, CentOS, Rocky, AlmaLinux, Debian, and Ubuntu.
    • Package Filtering: --exclude skips specified packages or glob patterns (e.g., --exclude "kernel*" "nginx").
    • Selective Packages: --packages selectively targets specific packages for updates.
    • Flatpak Integration: --flatpak triggers Flatpak application updates after OS packages.
  • Shell Tab Autocompletion: Native, zero-latency Bash and Zsh completions with instant flag/subcommand suggestions (linux-updater completion bash|zsh).
  • Two Update Tiers:
    • update: Routine updates with security filters, exclusions, and Flatpak support.
    • release-upgrade: Major distribution upgrades (e.g. Debian 12 \rightarrow 13, Ubuntu 22.04 \rightarrow 24.04, Fedora 40 \rightarrow 41, or RHEL/AlmaLinux leapp upgrades) with safety warnings.
  • Standard Linux FHS Logging & Logrotate:
    • Logs transactions to /var/log/linux-updater/linux-updater-<YYYYMMDD>-<HHMMSS>.log.
    • Atomically maintains /var/log/linux-updater/latest.log symlink.
    • Ships with /etc/logrotate.d/linux-updater (weekly rotation, 4 copies, compressed).
  • Automation Ready:
    • Structured --json output for Zabbix, Wazuh, Prometheus node exporters, or custom agents.
    • Non-interactive mode (-y / --non-interactive) for cron, Ansible, and central management.
    • Deterministic exit codes.

Distribution Support Matrix

Family Distributions Supported Package Manager Driver Major Upgrade Driver
Debian Debian 11/12/Testing, Ubuntu 20.04/22.04/24.04, Linux Mint apt / apt-get do-release-upgrade or apt-get dist-upgrade
RHEL RHEL 8 & 9, AlmaLinux 8 & 9, Rocky Linux 8 & 9, CentOS Stream, Fedora 39/40/41 dnf dnf system-upgrade (Fedora) or leapp (RHEL/AlmaLinux)
Arch Arch Linux, Manjaro, EndeavourOS pacman pacman -Syu (Rolling sync)

Installation

Option 1: Native .deb Package (Debian / Ubuntu)

# Build package using pure Python standard library:
python3 packaging/build_packages.py

# Install generated deb:
sudo dpkg -i dist/linux-updater_2.0.0_all.deb

Option 2: Native .rpm Package (RHEL / Fedora / AlmaLinux / Rocky)

# Build package (sets up RPM tree and calls rpmbuild):
python3 packaging/build_packages.py

# Install generated rpm:
sudo rpm -Uvh dist/rpm/RPMS/noarch/linux-updater-*.noarch.rpm

Option 3: Standalone Tarball (All Linux Distributions)

tar -xzf dist/linux-updater-2.0.0.tar.gz
cd linux-updater-2.0.0
sudo ./install.sh

Quickstart & Common Usage

# 1. Run pre-flight health checks and print diagnostics:
linux-updater health

# 2. Output health diagnostics as JSON (monitoring):
linux-updater health --json

# 3. Check for available updates non-destructively:
linux-updater check

# 4. Simulate a routine system update (dry run):
linux-updater update --dry-run

# 5. Apply routine updates interactively (prompts for reboot if required):
sudo linux-updater update

# 6. Apply updates non-interactively with automated reboot:
sudo linux-updater update -y --reboot

# 7. Apply security-only updates non-interactively:
sudo linux-updater update -y --security

# 8. Exclude specific packages or glob patterns:
sudo linux-updater update -y --exclude "kernel*" "nginx"

# 9. Update system packages and Flatpak apps:
sudo linux-updater update -y --flatpak

# 10. Selectively update specific packages:
sudo linux-updater update -y --packages openssl nginx

# 11. Major distribution release upgrade (interactive confirmation & prompt for reboot):
sudo linux-updater release-upgrade -t 44

# 12. Major release upgrade with alias syntax and automated reboot:
sudo linux-updater release-upgrade --releasever 44 --reboot

# 13. Clean package cache and remove orphaned packages:
sudo linux-updater clean --all

# 14. Enable Bash or Zsh tab autocompletion:
eval "$(linux-updater completion bash)"

Configuration Reference (/etc/linux-updater.json)

Default settings can be customized in /etc/linux-updater.json:

{
  "thresholds": {
    "min_boot_mb": 250,
    "min_var_mb": 1024,
    "min_root_mb": 1024,
    "min_ram_mb": 300
  },
  "behavior": {
    "auto_remediate": true,
    "non_interactive": false,
    "check_ac_power": true,
    "clean_after_update": false,
    "auto_reboot": false,
    "exclude_packages": [],
    "security_only": false,
    "update_flatpak": false
  },
  "logging": {
    "log_dir": "/var/log/linux-updater",
    "log_file": null,
    "verbose": false
  }
}

CLI flags always take precedence over configuration file values.


Exit Codes

Code Status Meaning
0 Success All operations completed cleanly (or automated reboot successfully initiated).
1 Error Pre-flight check failed and unrecovered, or package manager command returned non-zero.
2 Reboot Required Operation succeeded, but a system reboot is required (and --reboot was not supplied).
3 Aborted User cancelled operation at interactive confirmation prompt.

Containerized Testing Matrix

All packaging builds and integration tests run inside clean Podman containers:

# Run tests for all distros (Debian 12, Ubuntu 22.04, Fedora 40, AlmaLinux 8):
./tests/containers/run_tests.sh all

# Or run for a specific distro:
./tests/containers/run_tests.sh debian
./tests/containers/run_tests.sh ubuntu
./tests/containers/run_tests.sh fedora
./tests/containers/run_tests.sh almalinux8

Documentation

  • User Guide: Comprehensive instructions for operators and desktop users (selective updates, filtering, security-only, Flatpak, shell completion).
  • Administrator Guide: Automation, cron/systemd configuration, monitoring, logrotate setup, and Gitea Package Registry integration (RPM & Debian).
  • Developer Guide: Internal architecture, adding package managers, test development, packaging, and Gitea Actions CI/CD release workflow.
  • MAN Page (Section 8): System administration manual (man 8 linux-updater).

License

MIT License. See LICENSE for details.

S
Description
No description provided
Readme
321 KiB
0 Stars 1 Watchers 0 Forks
2026-10-03 08:34:50 +02:00
Languages
Python 92.7%
Shell 7.3%