Pacman, Pamac, Octopi, and package management

Pacman, Pamac, Octopi, and package management

December 12, 2023

Pacman, Pamac, Octopi, and package management – Chapter 8.2

This is the ninth of the free articles directly taken from the Manjaro Linux User Guide book, available at https://www.amazon.com/dp/B0C4PSWRQS/. The full list of freely available articles is here: Manjaro Linux User Guide – For newbies, fans, and mid users. More information at the end of the article.

Read time: 9 minutes. Previous article: 8.1 Dependencies In Linux. Next article: 9.3 The Linux Directory Structure.

Manjaro Linux User Guide book cover

Available on Amazon

We will start with pacman and then switch to the improvements in pamac. It is important to note that Flatpaks and Snaps cannot be installed with any of these tools in the terminal.

Pacman

At https://wiki.archlinux.org/, you can track the history of pacman back to October 2005, though it was created before this. It is stable, with great functionality, follows the Arch paradigm of providing only a CLI interface, and is based on the libalpm library. Pacman holds a local database of all the available packages in /var/lib/pacman/ and downloads the packages in /var/cache/pacman/pkg/. It requires root privileges for commands changing local installations and settings but not for query and information commands. Keep in mind that some applications, libraries, or packages belong to groups, and when we use a group name for installation, all the group’s packages will be installed.

Let’s examine the short help with $ pacman -h. It will list only its general options. Having angle brackets <…> means the parameter or argument is required. Having square brackets around a  parameter or argument […] means it is optional:

pacman {-h --help}
pacman {-V --version}
pacman {-D --database} <options> <package(s)>
pacman {-F --files} [options] [file(s)]
pacman {-Q --query} [options] [package(s)]
pacman {-R --remove} [options] <package(s)>
pacman {-S --sync} [options] [package(s)]
pacman {-T --deptest} [options] [package(s)]
pacman {-U --upgrade} [options] <file(s)>

—– —– —– —– —–

To perform common actions with pacman, you will often need more single-letter options. Here are the most ways it is used:

  • pacman -S [package] – install a package, e.g., $ pacman -S duf.
  • pacman -Rs [package] – uninstall a package, e.g., $ pacman -Rs duf. The small s is optional and triggers the removal of all dependencies if other packages don’t require them or if not explicitly installed by the user.
  • pacman -Sy – refresh the local database with the latest from the servers. Using -Syy will force an explicit refresh of all DBs, even if they are marked as up to date.
  • pacman -Su – upgrade all out-of-date packages.
  • pacman -Syu – refresh the local DB and then upgrade the system. You can also combine -Syyu to force the DB refresh, which is strongly recommended if you have any updates issues.
  • pacman -Suu – upgrade with downgrade ability. Usually, uu is used with yy in the form -Syyuu to switch from/to the Unstable, Testing, or Stable branch. Many packages will have lower versions when switching to Stable from the others. -Syyuu tells pacman to replace your local DB with the one from the server and then change all SW to the version from the changed DB, even if this means downgrading.
  • pacman -Ss <regexp>search for a package (case insensitive) with a regular expression, both in the name and description. An example is $ pacman -Ss ‘python.api’ (the dot represents any symbol; for more information, see Chapter 7, in the part on advanced commands, the section on regex and regexp). Filtering the results with grep can help, as it can highlight and has additional search options.
  • pacman -Qs [package] – search locally installed packages (case insensitive) for names or descriptions matching a regular expression pattern. Try it with $ pacman -Qs bash. The results will include a few other tools mentioning bash in their description.
  • pacman -Qi [package] – provides detailed information about a package, including the architecture, website (URL), dependencies, other packages requiring it, when it was built, and so on.
  • pacman -Si [package] – provides detailed information about a package from the repositories, including for packages not installed on our system.
  • pacman -Q – list all installed packages with their versions.
  • pacman -Q [package] – gives the version of an installed package.
  • pacman -Ql [package] – lists all paths of files owned by a package. The output is not optimized as it duplicates each sub-path, but the information is valuable.
  • pacman -Sg – list all the groups that can be installed. Some popular ones are base-devel, linux-tools, kde-utilities, and qt. List the group packages using the command with a group name, e.g., $ pacman -Sg qt5.
  • pacman -U local.file.pkg.tar.gz – install a package from a local archive, e.g., downloaded from a custom location. This command can also be used with a URL of a package on a specific server like this: $ pacman -U https://mirror.alpix.eu/manjaro/stable/community/x86_64/glances-3.3.0-1-any.pkg.tar.zst.

Here are a few more helpful package tools installed by default in Manjaro:

  • pactree [package] – gives the complete dependency tree for a given package. Try it with duf, exa, or vlc.
  • pacsearch [package] – searches for a package locally and remotely, printing in the result the repository, package name and version, and its short description.
  • pacman-conf –l – lists all the configured repositories.
  • paclist [repository] – lists all packages installed from a given repository. For example, try $ paclist core.

For pacman (apart from man and info), you can also check this Manjaro wiki: https://wiki.manjaro.org/index.php/Pacman_Overview.

—– —– —– —– —–

Pamac

We covered pamac’s GUI basics in Chapter 5. In it, you can click for detailed information on any package (both installed and uninstalled). It contains a short human-language description, the dependencies (including the optional ones), and the list of installation files.

In this section, we will dive into its CLI options. Compared to pacman, pamac more or less duplicates its options but in a human-readable format and with improvements. Its man page describes it as “a libalpm(3) frontend with AUR support”.

Before going further, from the additional tools mentioned at the end of the previous section, pactree remains unique. I strongly recommend using it to untangle dependencies.

The general form of pamac is pamac <action> [options] [targets]. Again, the angle brackets are a required argument (action), while the square brackets are optional. Here is its short help:

$ pamac -h
Available actions:
pamac --version
pamac --help, -h [action]
pamac search [options] <package(s)>
pamac list [options] <package(s)>
pamac info [options] <package(s)>
pamac install [options] <package(s)>
pamac reinstall [options] <package(s)>
pamac remove [options] [package(s)]
pamac checkupdates [options]
pamac update,upgrade [options]
pamac clone [options] <package(s)>
pamac build [options] [package(s)]
pamac clean [options]

While pacman requires sudo for executing system-critical tasks, pamac doesn’t. It will instead prompt you for a password only if you perform an action requiring sudo privileges. There is only one exception, which we will mention later. This way, pamac improves security, especially for unchecked AUR packages, as it will build them as a regular user and then ask for the password only for the installation. You can run it with sudo in front, but it is discouraged for AUR packages. Another nice pamac feature is that its first argument (the primary command) is available with the Tab key autocomplete on KDE’s Konsole and GNOME terminals. Now, let’s proceed with options, examples, and detailed explanations.

—– —– —– —– —–

pamac search, list, and info

Here’s a list of the various options:

  • pamac search [options] <package> – search case insensitive (both for name and description text), for example, $ pamac search exa. Sometimes, you might need to filter with grep, as it provides a maximum number of results. The -i option searches only in the installed packages, -r searches only in repositories, and -a is for adding AUR results.
  • pamac search -f filenamePart – search for packages that own a file with the given string in its name; for example, $ pamac search –f Breath.prof will return results from Konsole (the KDE terminal package), as it contains files named Breath.profile. Keep in mind that this search is case sensitive.
  • pamac list -i – list all installed packages, with versions, repository, source, and size, in a better format than pacman’s. As this is the default option, omitting the -i suffix does the same.
  • pamac list -e – list explicitly installed packages with versions, repository source, and size. Explicitly installed packages are those not installed as dependencies of other packages.
  • pamac list -g – list all available groups from the currently set repositories.
  • pamac list -g [group-name] – list all packages belonging to a given group.
  • pamac list -o – list installed orphaned dependencies packages, which are no longer required as dependencies, with versions, repository source, and size.
  • pamac list -r [repository] – list all packages from a given repository, with installation status. The current default repositories are community, core, extra, and multilib. Skipping the repository name will list the available repositories set on your system.
  • pamac list -f <package> – list all files installed for the package in a better format than pacman.
  • pamac info <package> – list the detailed info for the package; adding -a before the package name is necessary for AUR packages. This command will provide the installation status of the dependencies. It provides information even if the package is not installed.

    —– —– —– —– —–

pamac install and remove

The install function installs packages from repositories, paths, or URLs and has the following format:

pamac install [options] <package(s),group(s)>

As mentioned, if you install a package from official repositories, you don’t need to add sudo in front; you will be prompted for the password. Here comes the exception – installing a manually downloaded .pkg.tar.zst format package requires sudo:

$ sudo pamac install /path_to_file/XXXXX.pkg.tar.zst

This form also works with a URL. However, keep in mind that if the package requires dependencies, pamac will download them. Also, when the file is downloaded locally, double-clicking it in your GUI file manager (e.g., Thunar or Dolphin) will open the pamac GUI automatically.

The important options of the install command are listed in Table 8.1:

Table 8.1 – pamac install command options

Table 8.1 – pamac install command options

pamac also provides reinstall and checkupdates commands. reinstall is rarely necessary, but if an application or package has issues or you need it in its initial state, you can easily do it. With checkupdates, you can check for updates without modifying your local copy of the databases. Both provide additional options – check $ man pamac for this.

A note about optional dependencies: often, packages will ask you to provide your choice of optional dependencies in numerical form. We will try this with glances – a nice system monitor for the Terminal (and with an optional web interface). Run $ pamac install glances; after the authentication step, you will be asked for them. You can use commas to list some and specify a range with a dash, as shown in Figure 9.1:

Figure 9.1 – Choosing optional dependencies from the Terminal

Figure 9.1 – Choosing optional dependencies from the Terminal

—– —– —– —– —–

The remove command provides a few interesting options:

  • pamac remove -u <package(s)> – remove package(s) only if any other packages do not require them. A space-separated list is accepted for more than one package.
  • pamac remove -c <package(s)> – remove all target packages and packages that depend on one or more target packages. Be extremely careful with this option! Again, a space-separated list is accepted for more than one.
  • pamac remove -o [package(s)] – Remove orphaned dependencies not required by other packages. If this option is used without a package name, it will remove all orphans. It is excellent for freeing space.
  • pamac remove -n <package(s)> – uninstall package(s), but don’t remove orphaned dependencies.
  • pamac remove -d [options] [package(s)] – a dry run that will only show what will be done.
  • pamac remove –no-confirm <package(s)> – skip all confirmation messages.

I would always first use -c, -o, and -n with -d to see in a dry run what would be done.

—– —– —– —– —–

pamac upgrade/update

These two commands are the same. Using either of them without options will check for available updates. The most important additional options are listed in Table 8.2:

Table 8.2 - pamac update/upgrade command options

Table 8.2 – pamac update/upgrade command options

Of all the options, the most important is the first one. If you have any update issues, usually when you haven’t updated for months, executing this solves them all:

$ sudo pamac update --force-update

Regarding –overwrite and the downgrade options, I would use them after checking in advance with -d what will be done. If you need to downgrade some packages, check this Manjaro wiki: https://wiki.manjaro.org/index.php/Downgrading_packages. It will require setting an additional environmental variable, which we will look into later in the chapter.

We will look at the last five AUR-related options in the last part of this section.

—– —– —– —– —–

Number of locally kept package versions

When downloaded, packages are kept after a successful installation. This allows fast reinstallation or downgrade in case of failure. For the last few years, up to July 2023, the default number of previous versions kept is three. Thus, if I download a new version of the Brave browser every two months in the next year, I will always have the latest three.

The number of package versions to be kept is saved in the /etc/pamac.conf file, which you can edit with any text editor. Look for the KeepNumPackages = 3 configuration. You can also open the pamac GUI and change the number in Preferences | General | Cache. The pamac GUI also has a Clean button there.

If you have less space or test many or bigger applications, they may consume a considerable amount of space in pacman’s cache. A great tool to check this (or visually inspect your partitions’ HDD space consumption) is the official repositories’ Filelight GUI application. Check with it the /var/cache/pacman/pkg/ path. You can also check your root partition’s available and used space with the duf command.

There are two situations when keeping more than one package version is worthwhile. The first is if a current version has bugs, and the second is if you want to compare functionality between versions or test newer ones. As Manjaro is a rolling release distribution when you make periodic updates, a new application version may have bugs or problematic changes. In this case, if the older versions are already downloaded, it will be easy for you to switch back to an older version. Of course, such problems are rare, and from my experience, after a few years of extensive Manjaro usage, this never happened to me. This feature is thus primarily valuable to developers and people testing new versions before releasing applications to the Stable branch.

—– —– —– —– —–

Downgrading

Any branch (Stable, Testing, and Unstable) always keeps only one application version. If you don’t have the old versions downloaded on your PC, you cannot get them from the official repositories. Keeping many old versions of all packages would increase the workload of the servers immensely, which would result in the deterioration of the provided service. After four years of extensive usage of Manjaro, I can say that the Manjaro servers’ response and speed are great, and I would not be happy if the next update download was several times slower.

There is, of course, a way to downgrade packages described on this Manjaro page: https://wiki.manjaro.org/index.php/Downgrading_packages. It also contains information on where to get old packages. Check it if you need to downgrade.

—– —– —– —– —–

Pamac clean

Let’s now discuss the clean command, which can help us free up HDD space:

  • pamac clean -ddry run a generic clean to understand whether something should be cleaned and report the number of kept versions.
  • pamac clean -u – remove all not installed (i.e., only downloaded) packages.
  • pamac clean -k [number]change the number of kept versions and apply directly. It will also clean the uninstalled packages if you run it with -k 0, but it will not change the value of KeepNumPackages; it is only temporary. This command is good if you want an explicit space cleanup at the current moment; with the subsequent updates in the following months, KeepNumPackages versions of each updated package will be accumulated.
  • pamac clean -v – when cleaning, print all the names of cleaned files (verbose).
  • pamac clean –no-confirm – this will skip any confirmation messages.

    —– —– —– —– —–

The AUR options clone, build, and clean

Before continuing, we need a short introduction to the Arch User Repository (AUR) packages. They don’t contain actual application source code but instead contain configurations with server locations of packages’ source code (the input for building an application). They also contain some build instructions. These configurations are written in two files named PKGBUILD and .SRCINFO, put together in a .tar.gz archive.

On Linux distributions, tools such as yay, paru, and aurutils are used for AUR packages. All of them can download an AUR package, its sources (clone them), and its dependencies from servers worldwide. Then, they build them based on the configuration, clean the temporary build and source files, and install it on your system. Pamac is excellent, providing both GUI and CLI interfaces for this task.

Cloning means downloading the sources from a server (usually a Git repository). Building is the process of compiling them from source code to executable form. Cloning AUR files just downloads the configuration files.

In software development, cleaning is the process of the removal of all intermediate files. Thus, this clean command for AUR builds differs from the previous section’s clean command.

The AUR packages’ dependencies can be standard ones (often pre-installed by default in Manjaro and other distributions) such as glibc, zlib, and libpng, but also other AUR packages. In the second case, pamac will download and build them to complete the initial AUR package build process. AUR packages are cloned and built by default in /var/tmp (defined in /etc/pamac.conf). This directory is also used for any additional downloads.

To build AUR packages with pamac, you will need the core repository base-devel package. Whether you need it depends on your Manjaro flavor, configuration, and whether it was installed as a dependency from another package. To avoid any potential issues, execute:

$ pamac install base-devel

If it is installed/up to date, you will get a warning message, and nothing will be done.

Important note: Sometimes, the current state of an AUR package may generate build errors and fail. In this case, you can’t do anything but wait for fixes for the package or its Git repository. This task may be challenging even for developers and requires advanced knowledge. Searching for an alternative AUR package is an option. And also checking forums, groups, and the package website.

—– —– —– —– —–

A simple examples for AUR package build

Let’s take Clementine as an example, a famous audio player application supporting multiple formats and streaming services. Such software is complex and has several dependencies. It is available in the official repositories but also exists in AUR.

We first search for it with the AUR -a parameter, as shown in Figure 8.2:

Figure 8.2 – Searching for an AUR package via the terminal

Figure 8.2 – Searching for an AUR package via the terminal

Performing all actions (clone, build, and clean) at once is done by running:

$ pamac build clementine

You can add the -d option, short for –dry-run. The next command only downloads the AUR configurations file package. The -r option adds the necessary dependencies:

$ pamac clone –r clementine

Digging into /var/ directories is unpleasant, so to download and then build in a directory of our choice, we use the following two variations (considering, that luke is my username):

$ pamac clone -r --builddir ~/luke/build clementine

$ pamac build -k --builddir ~/luke/build clementine

The -k (or –keep) flag keeps the built packages in the cache after installation; otherwise, they are deleted. As in this case, we also specify a directory, they will be kept in it.

The last two separate options are helpful to SW developers. The rest of the users don’t need them. Unfortunately, the sources’ full copy is deleted after the build, but we have the Git repositories’ URLs in the downloaded PKGBUILD and .SRCINFO files.

You can also use the regular install command; however, if the package is in the official repositories – it will be downloaded from there! If not, then pamac typically warns you it will download and build an AUR package.

AUR contains a lot of packages. Many times, some of them are in a current development phase, while others are stable versions. From the previous screenshot, in July 2023, the clementine package was built successfully, but the clementine-git one with a different version failed to compile.

—– —– —– —– —–

Octopi

Octopi is an alternative to the pamac GUI. It offers a not-so-modern but excellent systematic interface. With one click, the user can go to package groups, a file, or information for a package. The search is helpful, as the results are presented in a table. However, the file lists don’t work for many of the packages. You can install it from the Official Repositories. I will not provide more information here, as I don’t see it offering any other significant advantages over pamac or pacman, and its development goes slowly. Still, it may be suitable for more systematic package searches.

We continue in the book with two sections on Environment Variables and Licenses.

—– —– —– —– —–

Next article: 9.3 The Linux Directory Structure.

* * * * *

You can subscribe for news, discounts, and giveaways HERE. Triple Helix Guarantees 100% privacy and will never provide your data to third parties. We keep the right to inform you on some of the news for our open-source projects, which will be rare. You can unsubscribe at any moment.

You can also follow me for such news on LinkedIn, where the giveaways will take place. I share development news, guides, and helpful content.

All rights reserved. Parts of this free content are allowed to be cited only when the official link to this article is provided as a source of the information, the author’s name is mentioned, as well as the publisher and the book name. Example: “Cited from the article <insert_link> by Atanas Georgiev Rusev, as part of the Manjaro Linux User Guide book, by PACKT publishing. All rights reserved”.

Share:

Leave A Comment