Skip to main content

Report urgency of package upgrades

Project description

siun

PyPI - Version PyPI - Python Version codecov

siun Icon

Check how urgently packages have to be upgraded.

siun will check available updates for various criteria - like the number of updates, or important package names. Each criterion will count towards a total score which gives an indication of how urgently upgrades are required. You can also write your own criteria using Python.


Table of Contents

Usage

On Arch Linux, or any other system that uses pacman, the most basic way to use siun is to simply run the check command:

siun check

Any other OS/distribution will require some configuration first.

Check command

The check command runs a configurable console command to find which packages can be updated and checks them against various criteria to determine how urgent it is to apply those updates.

Options

The check command supports a few options:

  • --quiet: Suppress regular output; Useful if you only want to update the cache file
  • --no-update: Don't refresh available updates, only read from cache if available
  • --no-cache: Don't read or write cache file
  • --output-format: Pick output format for urgency report; Available formats are [plain|fancy|json|i3status|custom]

Installation

pip install siun

Optional features

Some features require additional dependencies to work which will not be installed by default.

Currently, this only applies to the notification feature. In order to use this feature, install siun with the notification classifier:

pip install siun[notification]

The notification feature shows a desktop notification the first time a configurable threshold is exceeded. All variables available for the custom output format can also be used to customize the notification body and title.

NOTE: Using the notification feature in conjunction with the --no-cache flag will cause the notification to show up on every check, provided the requirements are met.

Development

# Set up dev env
uv sync

Configuration

Configuration happens through a TOML file. By default, siun will try to read the following files in order:

  1. $XDG_CONFIG_HOME/siun/config.toml
  2. $HOME/.config/siun/config.toml

See examples/config.toml for an example config. This example config also contains the default values which will be used if siun can't find any usable configuration.

Automatically run siun check

It is recommended to set up some kind of automation for running siun. One possibility is to set up a systemd user unit & timer. Find siun.service and siun.timer in examples/systemd for examples of such.

Since siun is supposed be able to run on most Arch Linux installations, it only calls pacman to check for package updates by default. This has the obvious drawback that it will only show updates if the local pacman database has been synced recently. There are multiple options to solve this:

checkupdates

The first, and recommended, option is to use the checkupdates script. It is available in the pacman-contrib package. Once it's installed, simply update the configuration like so:

cmd_available = "checkupdates --nocolor | cut -d ' ' -f1"

NOTE: The pipe to cut can be removed to also get a diff of version numbers - but for basic operation this is not required

checkupdates can be combined with aur-check-updates in order to also take AUR packages into account:

cmd_available = "{ checkupdates --nocolor; aur-check-updates -n --raw; } | cut -d ' ' -f1"

systemd unit & timer

Since the default configuration gets the list of available package updates from pacman without syncing, it might be useful to define a system unit & timer which automatically updates the local pacman database. Find pacman-sync.service and pacman-sync.timer in examples/systemd for examples of such.

NOTE: When using the pacman-sync unit it might be tempting to not sync the pacman database on updating packages since the service will sync every day anyway. However, this is a bad idea. See the Arch Linux Wiki for more information on this. A safer way to make sure package update information is up to date is to use the checkupdates script

Automatically clear cache

In order to automatically clear siun's cache when packages get updated, it's possible to set up a pacman hook. Simply edit the siun-clear-cache.hook file in the examples/pacman folder to contain the correct $HOME path and copy it to /etc/pacman.d/hooks/. The example deletes the state cache after Install, Upgrade, and Remove operations.

Criteria

siun checks various criteria to determine how urgent updates are. Each criterion has a weight which contributes to a total score. This score is then compared to a list of thresholds to determine wheter updates are available, recommended or required.

Built-in criteria

The following criteria are built-in:

  • available: Any updates are available
  • count: Number of available updates exceeds threshold
  • critical: Any of the available updates is considered a critical package
  • lastupdate: Time since last update has exceeded threshold

Custom criteria

You can also define your own criteria as Python code. Any python file in $XDG_CONFIG_DIR/siun/criteria will be checked for a class called SiunCriterion and run its is_fulfilled method.

Example custom criterion checking if any available updates are reported by arch-audit:

import subprocess


class SiunCriterion:
    """Custom criterion."""

    def is_fulfilled(self, criteria_settings: dict, available_updates: list):
        """Check if any available updates are in arch-audit list."""
        audit_packages = []
        arch_audit_run = subprocess.run(
            ["/usr/bin/arch-audit", "-q", "-u"],
            check=True,
            capture_output=True,
            text=True,
        )
        audit_packages = arch_audit_run.stdout.splitlines()

        return bool(set(available_updates) & set(audit_packages))

Custom output format

It's possible to define your own output format by setting a custom_format in the configuration file, and passing --output-format=custom to the siun check call. See Configuration.

Available format variables:

  • $available_updates: Comma-separated list of available updates
  • $last_update: Date and time of last time siun checked for updates in ISO format
  • $matched_criteria: Comma-separated names of matched criteria
  • $matched_criteria_short: Comma-separated matched criteria, shortened to 2 characters
  • $score: Sum weight of matched criteria
  • $status_text: Text representation of update status, e.g. "Updates available"
  • $update_count: Number of available updates

License

siun is distributed under the terms of the MIT license.

Name

siun stands for, and tries to answer, the question "Should I upgrade now?".

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

siun-1.5.1.tar.gz (41.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

siun-1.5.1-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file siun-1.5.1.tar.gz.

File metadata

  • Download URL: siun-1.5.1.tar.gz
  • Upload date:
  • Size: 41.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.18

File hashes

Hashes for siun-1.5.1.tar.gz
Algorithm Hash digest
SHA256 cf20fbf4965d3c40eb50baed3de058ec2c2759aacb35d994dd25cfd36fa2abb7
MD5 a40b2d3e25f35c6ea064d008ccde4528
BLAKE2b-256 de96a295405d50209696b8985fb1e415edcc6dfff732304596789dc92da6f87b

See more details on using hashes here.

File details

Details for the file siun-1.5.1-py3-none-any.whl.

File metadata

  • Download URL: siun-1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.18

File hashes

Hashes for siun-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e5b9bc5ee0ed17578a708a1bbfe7ade730df04aadbdef23122976b4b810b128b
MD5 f63fe0f1ed60e65c161eebfd16905114
BLAKE2b-256 5517ad08c1d6c8fbb250dfcf2cb6beb224050797a500e5f20f3a5f1eb5990f3a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page