DEV Community

Cover image for Universal Package-management Tool
Montegasppα Cacilhας
Montegasppα Cacilhας

Posted on

Universal Package-management Tool

As I told in another article, I decided not to keep writing for It’s FOSS, due to a bunch of unpleasant events I’m not discussing here (out of scope).

Therefore I decided to re-release those articles here in DEV.to. 🥰

This article was originally published as UPT: Universal Package Management Tool for Linux, but with a lotta changes I hadn’t authorised. Here’s the original version, with only ONE change I had agreed to.


Universal Package-management Tool

Introduction

The world of software packages on Linux and other Unix-based systems is quite a savannah: each system has its own singular package management approach, making life hell for those who have to deal with multiple platforms.

There are Pacman for Arch Linux and derivatives, Alpine Package Keeper (a.k.a. APK), Advanced Package Tool (a.k.a. APT) for Debian GNU/Linux and derivatives, Aptitude, a front-end for APT, Snapcraft for Ubuntu and derivatives, Yellowdog Updater Modified (a.k.a. Yum) for RPM-based systems, Slackpkg for Slackware, Emerge for Gentoo, the guix command on Guix, and nix-env on NixOS, among others, notta mention pkg on FreeBSD, Homebrew for macOS, and Scoop for Windows. Every one of those has its own way of management, forcing you to learn different ways to do the same thing.

In brief, it’s really a mess… or is it?

Enter UPT

A developer called sigoden has created a universal tool called Universal Package-management Tool, or UPT for short, able to put things together in this jungle. Once you have it installed, you won’t need to learn another package management’s lifestyle again.

In order to install UPT, I recommend to install the rustup package for your system – GNU/Linux systems usually have a rustup package available from their default package manager:

# On Debian GNU/Linux and derivatives:
sudo apt install gcc make rustup

# On Arch Linux and derivatives:
sudo packman -S gcc make rustup

# On Alpine:
apk add gcc make rustup
rustup-init
source ~/.cargo/env

# On RPM-based systems:
sudo yum install gcc make rustup

# On macOS with Homebrew (not Linux, obviously)
brew install clang make rustup
Enter fullscreen mode Exit fullscreen mode

Note: I use clang instead of gcc, and it works as well for me, you’re just gonna need to set your CC and CPP environment variables, if you wish, to clang and clang++ -E respectively.

After installing rustup, don’t forget to add $HOME/.cargo/bin to your PATH. If you’re using Bash as shell (usually the default shell), you have to add the following line to ~/.bash_profile:

export PATH $HOME/.cargo/bin:$PATH
Enter fullscreen mode Exit fullscreen mode

If your shell is Zsh, you can add the very same line above to ~/.zshrc instead. Another famous shell is FishShell, if you’re using it, create a file called ~/.config/fish/conf.d/rust.fish with the following contents:

#!fish

begin
    set -l cargo_home $HOME/.cargo
    path is $cargo_home/bin
    and set -p PATH $cargo_home/bin
end
Enter fullscreen mode Exit fullscreen mode

Don’t forget to reload the shell.

Now you can install the upt command tool:

rustup default stable
cargo install upt
Enter fullscreen mode Exit fullscreen mode

All set! Now you have a single package management interface you can use across your systems.

Using UPT

Updating the package manager:

sudo upt update
Enter fullscreen mode Exit fullscreen mode

Installing clang:

sudo upt install clang
Enter fullscreen mode Exit fullscreen mode

Upgrading GCC:

sudo upt upgrade gcc
Enter fullscreen mode Exit fullscreen mode

Upgrading all installed packages:

sudo upt upgrade
Enter fullscreen mode Exit fullscreen mode

Removing a package (e.g. emacs):

sudo upt remove emacs
Enter fullscreen mode Exit fullscreen mode

Searching for a package (e.g. vtk):

upt search vtk
Enter fullscreen mode Exit fullscreen mode

Caveats

Unfortunately, although the package manager is the same across different systems, it’s still just a front-end for each system default package manager, which means package names are still the same used by each distro, you can’t use a single package name for different systems.

For instance, if you want to install the Python development package, you’ll need different packages for different systems:

# On Alpine, Debian GNU/Linux, and derivatives
sudo upt install python3-dev

# On RPM-based systems:
sudo upt install python3-devel

# On Arch Linux
sudo upt install python
Enter fullscreen mode Exit fullscreen mode

You’ll have to figure out the name of the package you want for each system – upt search is your friend. 😉

Top comments (4)

Collapse
 
mengzyou profile image
Mengz

This is probably a good thing, but first you need to install rust and upt on each distro

Collapse
 
cacilhas profile image
Montegasppα Cacilhας

That’s a fact.

Collapse
 
code-hunter profile image
Code Hunter

Hey, why not. Aptitude being a wrapper around apt. Why not upt around them all.

Collapse
 
cacilhas profile image
Montegasppα Cacilhας

Sorry, I didn’t get the “why not.” 😬

But yes, the idea is wrapping any package manager with UPT in order to get a consistent interface.