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 a 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
Note: I use
clang
instead ofgcc
, and it works as well for me, you’re just gonna need to set yourCC
andCPP
environment variables, if you wish, toclang
andclang++ -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
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
Don’t forget to reload the shell.
Now you can install the upt
command tool:
rustup default stable
cargo install upt
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
Installing clang
:
sudo upt install clang
Upgrading GCC:
sudo upt upgrade gcc
Upgrading all installed packages:
sudo upt upgrade
Removing a package (e.g. emacs
):
sudo upt remove emacs
Searching for a package (e.g. vtk
):
upt search vtk
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
You’ll have to figure out the name of the package you want for each system – upt search
is your friend. 😉
Top comments (4)
Hey, why not. Aptitude being a wrapper around apt. Why not upt around them all.
This is probably a good thing, but first you need to install rust and upt on each distro
That’s a fact.