Photo by redcharlie on Unsplash

Photo by redcharlie on Unsplash

Supercharge your software upgrade routine

Top of the Line

Article from ADMIN 82/2024
By
Topgrade steps forward as the hero to help you keep an upper hand over updating and upgrading your stable of Linux applications.

Ever since the last millennium, the most common methods of deploying applications revolved around compiling from source or dealing with each respective distributions' package manager. Terminal front ends then helped with the wider adoption of Linux by making software manipulation much easier for a range of users. Next, AppImage, Flatpak, and Snap stepped in, with literally no pause between their appearance and endorsement by mainstream distributions.

Don't forget about self-updating third-party libraries from standalone processes or about all the various firmware incarnations that exist! Even though it's always possible to automate these processes (e.g., with anacron), in reality, ain't nobody got time for that.

Your security posture begins by religiously applying software patches; however, keeping an upper hand over the update and upgrade process on your stable of applications, not to mention the many attack vectors this portability brings, can be a hair-pulling task. Thankfully, Topgrade comes to the rescue when it comes to running the latest and greatest.

Topgrade

In 2018 the Topgrade project debuted on GitHub [1], and before long it formed a very vibrant and active community. The topgrade tool is the terminal front end of all terminal front ends, englobing all of the terminal installation wizards you can imagine. Sadly, development came to a screeching halt in 2022. With an astonishing 220+ contributors having already pitched in to make this tool great, it was clear that it would leave a gigantic void, so somebody had to take over its life cycle and ensure that it would carry on its legacy of greatness.

Shortly after the announcement of Topgrade's demise, the mini-juggernaut was forked, and its development indeed continued under a different leadership. Behold: topgrade-rs [2] was born. At the time of writing, the latest version was 14.0.1, and the number of contributors that rallied under this new fork exceeded 350. Those numbers should give you a strong opinion about such a new tool and how much it is really loved by its users.

Even with that kind of community behind it, you couldn't install either topgrade or topgrade-rs with Debian's Apt package manager or through official repositories. The most noble distribution that had picked up on this nifty tool was openSUSE [3]. Today, you can install it either with the usual git clone command or by going through a somewhat easier approach of a system-wide install with cargo, which is a part of the Rust crates.io package registry [4].

Topgrade Everything

For a system-level installation of topgrade-rs (the example in this article uses a freshly installed Ubuntu MATE 22.04.3 platform), first install all the requirements for compiling and deploying topgrade-rs (referred to as Topgrade moving forward): curl, git, pkg-config, and rust. Once in place, append the $HOME/.cargo/env absolute path to your already existing $PATH variable; then, install cargo. Listing 1 shows the download and installation of the official compiler for the Rust programming language and its package manager, Cargo.

Listing 1

Deploying Topgrade (Extract)

$ sudo apt install curl git pkg-config -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
  git-daemon-run | git-daemon-sysvinit git-doc git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
  curl git pkg-config
0 upgraded, 3 newly installed, 0 to remove and 1 not upgraded.
Need to get 3,409 kB of archives.
After this operation, 19.5 MB of additional disk space will be used.
Get:1 http://gb.archive.ubuntu.com/ubuntu jammy-updates/main amd64 curl amd64 7.81.0-1ubuntu1.15 [194 kB]
[...]
Setting up pkg-config (0.29.2-1ubuntu3) ...
Setting up git (1:2.34.1-1ubuntu1.10) ...
Setting up curl (7.81.0-1ubuntu1.15) ...
Processing triggers for man-db (2.10.2-1) ...
$
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
info: downloading installer
Welcome to Rust!
This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.
Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:
/home/Dan/.rustup
This can be modified with the RUSTUP_HOME environment variable.
The Cargo home directory is located at:
/home/Dan/.cargo
This can be modified with the CARGO_HOME environment variable.
The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:
/home/Dan/.cargo/bin
This path will then be added to your PATH environment variable by
modifying the profile file located at:
/home/Dan/.profile
You can uninstall at any time with rustup self uninstall and
these changes will be reverted.
Current installation options:
default host triple: x86_64-unknown-linux-gnu
default toolchain: stable (default)
profile: default
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1
info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
[...]
stable-x86_64-unknown-linux-gnu installed - rustc 1.76.0 (07dca489a 2024-02-04)
Rust is installed now. Great!
To get started, you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).
To configure your current shell, run:
source "$HOME/.cargo/env"
$
$ source "$HOME/.cargo/env"
$
$ cargo install cargo-update
Updating crates.io index
Installing cargo-update v14.0.1
Updating crates.io index
Compiling libc v0.2.153
Compiling cc v1.0.86
[...]
Finished release [optimized] target(s) in 10m 27s
Replacing /home/Dan/.cargo/bin/cargo-install-update
Replacing /home/Dan/.cargo/bin/cargo-install-update-config
Replaced package `cargo-update v14.0.1` with `cargo-update v14.0.1` (executables `cargo-install-update`, `cargo-install-update-config`)
$ cargo install topgrade
Updating crates.io index
Downloaded topgrade v14.0.1
Downloaded 1 crate (4.4 MB) in 1.52s
Installing topgrade v14.0.1
Updating crates.io index
Downloaded async-io v1.13.0
Downloaded async-fs v1.6.0
[...]
Compiling proc-macro2 v1.0.78
Compiling unicode-ident v1.0.12
[...]
Finished release [optimized] target(s) in 15m 31s
Installing /home/Dan/.cargo/bin/topgrade
Installed package `topgrade v14.0.1` (executable `topgrade`)
$

Once that step is complete, you can then begin getting acquainted with this tool. As mentioned earlier, you can also chose to install Topgrade by pulling its GitHub repository and launching the process with

build-all.sh

from the root of the repo.

Before moving in with all of the previous steps involving your system-wide installation method with cargo, allow me to share a bit of advice. From my personal experience on deploying Topgrade on several Debian systems and derivatives over the course of the past year, sometimes the Rust library is already installed yet can cause grief when proceeding with the regular installation of Topgrade. In that respect, I suggest purging everything related to Rust and reinstalling the latest from their official installation website [5] before attempting what follows.

Let the Upgrade Games Begin

All of the previous steps take about five minutes on a modern system. Once all the building and installing is done successfully, you can confirm that the binary was installed successfully by issuing the which topgrade command. This should then result in showing the path into which the binary was installed (e.g., ~/.cargo/bin/topgrade):

$ which topgrade
/home/Dan/.cargo/bin/topgrade
$

Another perk I deploy to keep on top of this never ending patching game is:

alias u="/home/Dan/.cargo/bin/topgrade -y"

in either my .bashrc or .zshrc file.

Thereafter, begin your exploration journey of this new tool by issuing topgrade -h (Figure 1).

Figure 1: Topgrade's initial offering.

The other switches you will mostly be using are -y (or --yes) to acknowledge automatically any questions that might arise (Figure 2), -c (or --cleanup) to purge any and all temporary and old files left by Topgrade, and perhaps --only, a still experimental switch as of the current version, that allows you to go through certain modules selectively (Figure 2 shows an upgrade of only the tldr portion) instead of going through the whole routine of upgrading everything (Figure 3). Do not forget the -t (or --tmux) switch, which facilitates tmux integration.

Figure 2: Output for the --only switch.
Figure 3: Failure to provide -y while executing topgrade will result in users having to accept or deny the forthcoming changes manually.
Figure 4: When not enforcing the --only switch, Topgrade covers any outdated software. © Courtesy r-darwish GitHub page

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus