Universal Package-management Tool
Tags: linux, packagemanager
Published: 2024-03-26 17:50:15

[another article]: https://dev.to/cacilhas/yet-another-way-to-install-aur-packages-4j24
[UPT: Universal Package Management Tool for Linux]: https://itsfoss.com/upt/
[Advanced Package Tool]: https://wiki.debian.org/Apt
[Alpine Package Keeper]: https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html
[Aptitude]: https://tracker.debian.org/pkg/aptitude
[Emerge]: https://wiki.gentoo.org/wiki/Emerge
[Guix]: https://guix.gnu.org/
[Homebrew]: https://brew.sh/
[It’s FOSS]: https://itsfoss.com/upt/
[NixOS]: https://nixos.org/
[Pacman]: https://wiki.archlinux.org/title/Pacman
[`pkg`]: https://man.freebsd.org/cgi/man.cgi?query=pkg
[Rodrigo Montegasppα Cacilhας]: https://github.com/cacilhas
[`rustup`]: https://rustup.rs/
[Scoop]: https://scoop.sh/
[`sigoden`]: https://github.com/sigoden
[Slackpkg]: https://slackpkg.org/
[Snapcraft]: https://snapcraft.io/
[Universal Package-management Tool]: https://crates.io/crates/upt
[Yellowdog Updater Modified]: http://yum.baseurl.org/




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:

```sh
# 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 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`:

```bash
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
#!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:

```sh
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:

```sh
sudo upt update
```

Installing `clang`:

```sh
sudo upt install clang
```

Upgrading GCC:

```sh
sudo upt upgrade gcc
```

Upgrading all installed packages:

```sh
sudo upt upgrade
```

Removing a package (e.g. `emacs`):

```sh
sudo upt remove emacs
```

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

```sh
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:

```sh
# 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. 😉