osupdater/README.md
2024-10-27 19:52:10 -05:00

7.3 KiB

osupdater

ABOUT

A terminal rust application for figuring out what package manager(s) are present on your system and use them to update your software packages.

This is for my educational purposes of learning rust to do tasks that I have done successfully in either bash or C/C++. Feel free to snatch this up or not.

Take note that currently, all the used update tools' parameters are hard coded. Down the line, I will incorporate a config file that will have these hardcoded settings as the defaults. Until then, to change said parameters, you will need to edit the source.

v1.0 REQUIREMENTS

Prior to releasing a v1.0, I will need the following features for the CLI version (GUI version will need not exist, but is on the roadmap)

  • The smarts to not run an old version of a tool if a newer is purposefully installed. This is specifically aimed at dnf/dnf5
  • CLI flags to pick and choose what to update and what to skip
  • Proper logging -- this means a datestamped file for each tool run plopped into /var/log/
  • Stock parameters to be pulled from /etc/osupdater.conf or ~/.config/osupdater/osupdater.conf

THE ROADMAP : v1.1 AND BEYOND

  • Central server for shared configs
  • GUI tool that is identical to the CLI version in functionality
  • Theming

FILES

File Function
./antiquated/ bash & python source
./osupdater/ rust source
./rust_build_osupdater.sh bash script to build the source

TESTED ENVIRONMENTS

Currently when I start work on distributions that I do not have a live environment to use or a VM available, I will use distrobox. Then, as time permits, I use VMs to test as a next best thing to a live environment.

Consider distrobox tests as the lowest grade pass, then VMs better and native tests best.

Trusted contributors will count as a passed/failed contributor test.

DISTRIBUTION PERSONALLY TESTED CONTRIBUTOR TESTED
Arch distrobox no
Debian distrobox yes - tswamp
OpenMandriva / Mageia no no
RHEL / Fedora yes yes
SuSE/ OpenSuSE yes no
Ubuntu distrobox no
CONTAINER TYPE PERSONALLY TESTED CONTRIBUTOR TESTED
Distrobox yes no
Flatpak yes no
Podman yes no
Snap yes no
OTHER TOOLS PERSONALLY TESTED CONTRIBUTOR TESTED
Python via pip-review yes no

COMPILATION

In the repo there is a build script that will build things for you. To do so follow the instructions below to setup your build environment. You can also use cargo to build and install as well, but again, the build environment will need to be setup.

BUILD ENVIRONMENT

To compile the application you will need to have rust and cargo installed.

ARCH & DERIVATIVES

sudo pacman -Sy rust
rustup default stable

DEBIAN & DERIVATIVES

The official documentation from Debian states one can either install the apt packages or use the official rustup installer.

Using apt packages for Debian 12+ (my used and tested method):

sudo apt update -y
sudo apt upgrade -y
sudo apt install rustc cargo rustfmt -y

Using rustup (required for Debian 11.x and older):

sudo apt update -y
sudo apt upgrade -y
sudo apt install curl build-essential gcc make -y
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

The final command above will pull in and run the installer. Follow the prompts on screen.

OPENMANDRIVA/MAGEIA (UNTESTED)

sudo urpmi update
sudo urpmi install gcc curl make
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

RHEL/FEDORA

sudo dnf install rust cargo -y

SUSE/OPENSUSE

The official documentation from OpenSuSE.org states to use rustup, so here it is:

sudo zypper install rustup -y && rustup toolchain install stable

INSTALLATION VIA CARGO

As of right now I have not published anything to crates.io or anything similar. So as of right now you can do a:

    cargo install --git https://git.schotty.com/andrew/osupdater.git

This will download the repo, compile, and install the binary in ~/.cargo/bin/, so ensure if you use this method you have that path in your $PATH environment variable.

GETTING SOURCE AND COMPILATION

To downloaded and then compile the program is done as follows:

git clone https://git.schotty.com/andrew/osupdater
cd osupdater
./rust_build_osupdater.sh

This should just build the application for you, providing you setup rust correctly. If you have issues compiling, double check that the toolchain is installed correctly for your platform. If the above instructions are insufficient, file a bug report and I can update them to include any missing instructions and/or caveats.

SCOPE & USAGE

CURRENT SCOPE AND LIMITATIONS

The current scope and intended use of the tool is:

  • Not to be run as root -- be a regular user with sudo rights to run the package manager tools.
  • Currently custom parameters, logging, and other useful fancy stuff is not implemented. It will be, but not now.
  • The testing has been done in a limited fashion. I have several Workstations, Laptops, VMs, VPS's, and contributors that are able to validate things. The testing matrix above has the details, play in a VM if your platform is untested (notably arch). I test first in distrobox, then if things work a VM or a contributor report.
  • If you have any doubts as to what the hell is going on under the hood, look at the source. If the parameters are too conservative/aggressive -- edit the source or wait until I get custom parameters implemented.

RUNNING OSUPDATE

Running the application is as simple as executing the ouput binary located at osupdater/target/release/osupdater

Depending on tastes, you can copy said binary to ~/.local/bin or any other location that is in your PATH.

The application will output whatever it does, and ignore any package managers that are not present on your system.

  • To run all the tools:

    osupdater

or

osupdater all
  • To select one tool:

    osupdater dnf

  • To run several tools:

    osupdater dnf flatpak distrobox

AVAILABLE UPDATER TOOLS SUPPORTED

  • Detect and run everything found

    • all
  • Package managers

    • apt
    • dnf
    • pacman
    • urpmi
    • zypper
  • Application sandboxes

    • flatpak
    • python
    • snap
  • Containers

    • distrobox
    • podman

NOTES

During testing via distrobox, pip-review will fail if the host python version is not the same as the container. The tool will find the pip-review package, but be unable to execute due to a version mismatch.

DISTROBOX CONTAINERS USED FOR TESTING

USING DISTROBOX

Starting container:

distrobox-create --name CONTAINER_NAME --image CONTAINER_URI
distrobox-enter CONTAINER_NAME

Entering container:

distrobox enter CONTAINER_NAME

Stopping container:

podman stop CONTAINER_NAME
podman rm CONTAINERF_NAME

CONTAINER URI'S

Arch:

  • quay.io/toolbx/arch-toolbox:latest

Debian:

  • quay.io/toolbx-images/debian-toolbox:latest
  • quay.io/toolbx/ubuntu-toolbox:latest

RHEL/Fedora:

  • quay.io/toolbx-images/almalinux-toolbox:latest
  • registry.fedoraproject.org/fedora-toolbox:40
  • quay.io/toolbx-images/rhel-toolbox:latest

SuSE/OpenSuSE:

  • registry.opensuse.org/opensuse/distrobox:latest