Selasa, 17 September 2024

Apt, DNF, Zypper, Pip, Cargo, XYZ! App Rules Them All

Apt, DNF, Zypper, Pip, Cargo, XYZ! App Rules Them All

Managing packages in Linux distribution varies depending on the distribution. All the Debian-based distros use APT as the package management app. While Fedora uses DNF, openSUSE depends on Zypper package manager.

Recently, distro-agnostic package managers like Snap, Flatpak, AppImage, etc. made the scene even more fragmented.

More package managers mean more commands to get familiar with.

If that's what you feel as you distrohop around the Linux-verse, I have a new app for you. It's called app 😬

App, a cross-platform package management assistant written in Go, can help you in this scenario. Basically it is a wrapper for package managersand offers the same commands on all supported distributions. It means you don't need to memorize per-distro package management commands.

That's not it. The app keeps a record of installed applications in its config file. So, if you move distros, just use the previous config file to install the same packages in the new distro.

🚧
In my opinion, you should stick to the official package managers, specially if you are managing a critcal infrastructure. Don't experiment with such tools if you easily get overwhelmed and don't like to troubleshoot.

Install App Package Management Assistant

The App provides an installation script, which you can install on any Linux distribution. Open a terminal and run the command below:

bash <(curl -sL https://hkdb.github.io/app/getapp.sh)
Apt, DNF, Zypper, Pip, Cargo, XYZ! App Rules Them All
Install App Utility

To update the app to the latest version, use:

app -m app update
Apt, DNF, Zypper, Pip, Cargo, XYZ! App Rules Them All
Update App Utility

What happens behind the scene

App utility has its own simpler syntax. Since the utility uses the same syntax across distributions, you only need to remember the syntax of App utility.

When you install an app using the app command, it records the action. Be it an installation or removal of the package, the information is stored inside the ~/.config/app directory.

Now, when you want to migrate to another distribution, you can copy this directory and paste it inside the ~/.config folder of the new distribution to start installing packages. We will see the process in detail in the next section.

📋
For the App to work, you need to install the packages using the app command. Only then the package details are stored and restored on a new system.

Basic App utility commands

Let's see some of the important commands you need to remember while using this tool.

Enable/Disable necessary package managers

By default, package managers like Flatpak, Snap, AppImage, Yay, Pip, Go, and Cargo are disabled.

You can enable them using the general syntax:

app -m <package-manager> enable

For example, to enable Flatpak support,

app -m flatpak enable
Apt, DNF, Zypper, Pip, Cargo, XYZ! App Rules Them All
Enable Flatpak Support

To disable an enabled package manager, use the command:

app -m <package-manager> disable
Apt, DNF, Zypper, Pip, Cargo, XYZ! App Rules Them All
Disable a Package Manager

Search for packages

In order to search for packages using the App utility, do the following:

app search <package-name>
Apt, DNF, Zypper, Pip, Cargo, XYZ! App Rules Them All
Search for packages in official repos

To search for a package on another package manager like Flathub, specify the package manager.

app -m <package-manager> search <package-name>

For example, if I am searching for Blackbox terminal emulator in Flatpak, I will run:

app -m flatpak search blackbox
Apt, DNF, Zypper, Pip, Cargo, XYZ! App Rules Them All
Search packages in Flatpak Flathub

Install a package

To install a package on your system, run the command:

app install <package-name>

Let's say I want to install fortune. So I will run:

app install fortune
Apt, DNF, Zypper, Pip, Cargo, XYZ! App Rules Them All
Install a package

Install apps from other package manager

To install an app as a Flatpak, use the command:

app -m flatpak install <package-name>
Apt, DNF, Zypper, Pip, Cargo, XYZ! App Rules Them All
Install a Flatpak package

This is a general formula, so, we can install packages from other package managers using:

app -m <package-manager> install <package-name>

Install an AppImage

First go to the directory where the AppImage file is downloaded. Now, to install the AppImage file:

app -m appimage install <appimage-file-name>

I have an AppImage of Standard Notes app. So, I will open my Downloads directory in a terminal and run:

app -m appimage install standard-notes-3.195.1-linux-x86_64.AppImage
Apt, DNF, Zypper, Pip, Cargo, XYZ! App Rules Them All
Install an AppImage File

On the official page, you have a detailed description of all package managers that are supported and respective installation methods.

💡
The project has a neat documentation on installing apps like Brave browser, that needs its own repo configuration.

List installed packages

You can list the packages that were installed using App from official repos by using the command:

app history

Similarly, to list all the installed packages from a particular repository, run:

app -m <package-manager> history
Apt, DNF, Zypper, Pip, Cargo, XYZ! App Rules Them All
App install history

Remove a package

To remove a package, you can use:

app remove <package-name>
Apt, DNF, Zypper, Pip, Cargo, XYZ! App Rules Them All
Remove a Package

For other package managers, use:

app -m <package-manager> remove <package-name>
Apt, DNF, Zypper, Pip, Cargo, XYZ! App Rules Them All
Remove a Flatpak Package

If you are on a Debian-based distribution, you can use purge as well.

app purge <package-name>

Similarly, App supports autoremove for native package managers.

app autoremove

Upgrade packages

To upgrade all the packages installed on the system, use the command:

app update
app upgrade all

At the same time, the App allows individual package manager upgrades as well. For this, use the syntax:

app -m <package-manager> upgrade

Add PPA in Ubuntu

In an Ubuntu-based system, you can use PPA to install additional packages that are not available in the native Ubuntu repositories or there are old versions available in the repos.

So, if you are using the App for installing packages, you need to use the syntax:

app add-repo ppa:graphics-drivers/ppa

Restoring the packages in another distro

🚧
While restoring packages in cross-platform, not all platforms have the same package names.

Now, when you want to hop to a new distro, or want to replicate the current distribution, all you need to do is described below.

📋
You need to set up the extra package managers like Flatpak, Snap, etc. before starts restoring.

First, install the App utility on the new system, as mentioned in the first section.

Now, copy the ~/.config/app directory to the new system. Then open a terminal and run:

app -r all

That's it. Your packages will be installed on the new system.

🚧
Restoring Flatpak apps on a new system asked me to select an app from a huge list. So, when I inspected its ~/.config/app/packages/flatpak.json file, there was an additional space present on the beginning of the line.
I removed that space and rerun the command to restore Flatpak apps successfully.

You can restore individual package managers separately by using the command:

app -r <package-manager>

Conclusion

This seems like a useful tool if you distrohop quite often. You can get the list of the packages you install regularly and you can install them with less effort on a new system.

There are a few tools like Nala that try to provide similar features.

By the way, we are also offering Linux courses through our other portal. Something you might be interested in.

Linux For DevOps - Courses by Linux Handbook
Welcome to the “Linux for DevOps” course! In the fast-paced world of DevOps, proficiency in Linux is not just a skill but a necessity. Whether you are new to Linux or looking to deepen your skills, this course will guide you through essential concepts, command-line operations, and system administration tasks…
Apt, DNF, Zypper, Pip, Cargo, XYZ! App Rules Them All


from It's FOSS https://ift.tt/lidFGL3
via IFTTT

Tidak ada komentar:

Posting Komentar