Table of Content

This is a four-parts article. There are few sections here.

Part One
  • Preface: Test Bed, Must Read
  • Getting Started With Docker
  • Package Management: ALPM Frontend, ASP and AUR Helper, Get Help
  • Updating System: OS Release, The Riddle, Refresh Update, List Upgradable, Download Upgrade, Upgrade, Common Form
  • Package IRSIF: Install, Removal, Query Search, Show Info, Change Log, List Files, Verify, Package as File
  • What's Next
Part Two
  • Dependency: Using pacman, Test, Using pactree
  • Repository: Configuration, Mirror
  • Group: Blackarch Example, List Group
  • Lock Package: IgnorePkg, HoldPkg
  • System Wide: List Packages, Search Files
  • History: The Log File
  • Clean Up: Cache, Autoremove
  • Case: When chroot fail
  • What's Next
Part Three
  • Automatic Build: User Privilege, PKGBUILD, makepkg, Example, Dependency, Download, Install, Namcap
  • ABS: Deprecation, ASP, SVN
  • What's Next
Part Four
  • Introducing AUR: Package Query, cower, Foreign Package
  • AUR Helper: yaourt, pacaur, packer, aura
  • Screenshot: Query AUR
  • Conclusion

Preface

Goal: Examine Package Manager, Focus on Command Line Interface

We have this ALPM, The Arch Linux Package Management, as a base for pacman binary package frontend, and source package tools such as the famous AUR, and ASP (formerly ABS), or even the lower level makepkg tool. They are all under ALPM umbrella.

Using Arch Linux minimal install in Docker, is a good way to learn ALPM. ALPM is considered a basic knowledge utilized by Arch’s based distribution such as Manjaro, Antergos, Artix, and some other cool Arch’s influenced distribution such as KaOS. In short, any distribution using pacman

Personally I have been an Arch user since 2014, I have used so many pacman command, but never really understand. Reading pacman manual again makes me realize that I know nothing. That is why I have a need to write down this blog article.

Test Bed

  1. Container: Docker

  2. Operating System: Artix (OpenRC )

  3. Window Manager: Herbstluftwm

Since we are going to use docker again, you can read a common overview here.

Of course you can use virtualization, the issue is distraction. We need to avoid tendency to focus on GUI tools. At the same time, limiting the scope to CLI tools. Most of the time, CLI tools is considered lower level than the GUI one.

Must Read

You are encouraged to read the holy archwiki first, before even starting to read this article.

There are already so many references for this pacman on the internet. This blog article is just another reference.


Getting Started With Docker

As usual, first, we do attach docker process.

$ docker pull dock0/arch

Docker Pull Arch

$ docker image list  

  --filter "reference=*/arch:*"
  --format 'table {{.Repository}}\t{{.Size}}'

REPOSITORY          SIZE
dock0/arch          870MB
$ docker run -it dock0/arch
root@f77ea94688d1:/# exit
exit

Docker Arch: Running Docker

$ docker ps 

  --format 'table {{.Image}}\t{{.Names}}\t{{.Status}}'

IMAGE               NAMES               STATUS
dock0/arch          musing_pike         Up About a minute

Docker Arch: Docker ps

$ docker start musing_pike
musing_pike
$ docker attach musing_pike
[root@37f48ad6a711 /]# 

Docker Arch: Getting Started


Package Management

Arch Linux use .pkg.tar.xz extension for package.

ALPM Frontend, ASP and AUR Helper

ALPM = “Arch Linux Package Management”

Note that ABS tools is deprecated.

Pacman: C

ASP: BASH

Cower: C

Package Query: C

AURA: Haskell

Pacaur: BASH/C

Packer: BASH

Yaourt: BASH/C

Get Help

Read the fine manual.

This one show nothing.

$ pacman --help

And this one show a lot.

$ man help

Note that with minimal install in docker, we do not have man-db and less yet.


Updating System

First Thing First

First thing to do is updating my system as usual.

OS Release

Make sure it is Arch that we are using.

There is /etc/os-release in Manjaro and KaOS, But Arch utilized an empty file /etc/arch-release to indicate that this is an arch distribution. I guess since Arch is rolling release, there is no need for release number.

$ cat /etc/arch-release 

Other Arch based may have different file, such as /etc/artix-release .

The Riddle

What is pacman -Syu ? And What is pacman -Syyuu anyway ? Of course there is man pacman that explain it all. After reading the manual we can have something like pacman --sync --refresh --quiet --sysupgrade --force.

We can separate the pacman -Syu into few smaller steps.

  • Update

  • List Upgradable

  • Download

  • Upgrade

  • Common Form

Refresh Update

$ pacman -Sy
:: Synchronizing package databases...
 core                     124.4 KiB   138K/s 00:01 [##########] 100%
 extra                   1651.5 KiB   109K/s 00:15 [##########] 100%
 community                  4.0 MiB  55.4K/s 01:14 [##########] 100%

Equal to:

$ pacman --sync --refresh
:: Synchronizing package databases...
 core is up to date
 extra is up to date
 community is up to date

Docker pacman: refresh

From the manual “ Passing two –refresh or -y flags will force a refresh of all package databases, even if they appear to be up-to-date.

$ pacman -Syy

List Upgradable

$ pacman -Qu

Equal to:

$ pacman --query --upgrades
archlinux-keyring 20170611-1 -> 20170823-1
coreutils 8.27-1 -> 8.28-1
curl 7.55.1-1 -> 7.55.1-2
e2fsprogs 1.43.5-1 -> 1.43.6-1
expat 2.2.3-1 -> 2.2.4-1
gcc-libs 7.1.1-4 -> 7.2.0-2
glibc 2.25-7 -> 2.26-3
gnupg 2.1.23-1 -> 2.2.0-1
gnutls 3.5.14-1 -> 3.5.15-1
iana-etc 20170512-1 -> 20170824-1
icu 59.1-1 -> 59.1-2
iproute2 4.12.0-2 -> 4.13.0-1
libgcrypt 1.8.0-1 -> 1.8.1-1
libldap 2.4.44-5 -> 2.4.45-4
libpsl 0.17.0-2 -> 0.18.0-1
linux-api-headers 4.10.1-1 -> 4.12.7-1
lz4 1:1.7.5-1 -> 1:1.8.0-1
ncurses 6.0+20170527-1 -> 6.0+20170902-1
p11-kit 0.23.7-1 -> 0.23.8-1
pacman-mirrorlist 20170729-1 -> 20170907-1
pcre2 10.23-1 -> 10.30-1
perl 5.26.0-1 -> 5.26.0-4
perl-error 0.17025-1 -> 0.17025-2
sqlite 3.20.0-1 -> 3.20.1-1

Docker pacman: upgradable

Download Upgrade

$ pacman -Suw
$ pacman --sync --sysupgrade --downloadonly
:: Starting full system upgrade...
resolving dependencies...

Packages (24) archlinux-keyring-20170823-1  coreutils-8.28-1
              curl-7.55.1-2  e2fsprogs-1.43.6-1  expat-2.2.4-1
              gcc-libs-7.2.0-2  glibc-2.26-3  gnupg-2.2.0-1
              gnutls-3.5.15-1  iana-etc-20170824-1  icu-59.1-2
              iproute2-4.13.0-1  libgcrypt-1.8.1-1
              libldap-2.4.45-4  libpsl-0.18.0-1
              linux-api-headers-4.12.7-1  lz4-1:1.8.0-1
              ncurses-6.0+20170902-1  p11-kit-0.23.8-1
              pacman-mirrorlist-20170907-1  pcre2-10.30-1
              perl-5.26.0-4  perl-error-0.17025-2  sqlite-3.20.1-1

Total Download Size:  63.59 MiB

:: Proceed with download? [Y/n]

Docker pacman: download

You may add --noconfirm if you wish. this one not asking for PGP confirmation anymore.

Docker pacman: confirm

Upgrade

This command will install package, and download if necessary. This is a process with long verbose output, I have to split out to three figures.

This is why the first figure output looks pretty similar with the download command above since it works on the same upgradable packages. But the next figure is different.

$ pacman -Su

Equal to:

$ pacman --sync --sysupgrade

Docker pacman: sysupgrade

Common Form

Consider put all them command above together. You can combine update dan upgrade in single command. I usually only use this single command.

$ pacman -Syu
:: Synchronizing package databases...
 core is up to date
 extra is up to date
 community is up to date
:: Starting full system upgrade...
 there is nothing to do

Docker pacman: -Syu


Package IRSIF

Install, Remove, Search, Info, File

Package Install

Installing in Arch is just --sync with target. Consider our favorite example package below. This will also have a verbose long output.

$ pacman -S man-db nano less sudo

Or other favorites package.

$ pacman --sync man-db nano less sudo         
warning: less-487-1 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...

Packages (7) file-5.32-1  groff-1.22.3-7  libpipeline-1.4.2-1
             less-487-1  man-db-2.7.6.1-2  nano-2.8.7-1
             sudo-1.8.21.p2-1

Total Download Size:    4.27 MiB
Total Installed Size:  21.87 MiB
Net Upgrade Size:      21.67 MiB

:: Proceed with installation? [Y/n]

Docker pacman: sync target

You can also download, and install later, with color

$ pacman -Sw wget curl --color always
...
Packages (2) curl-7.55.1-2  wget-1.19.1-2

Total Download Size:  0.57 MiB
...
$ pacman -S wget curl --color always
...
Packages (2) curl-7.55.1-2  wget-1.19.1-2

Total Installed Size:  4.02 MiB
Net Upgrade Size:      2.59 MiB
...

And you can also combine with system upgrade.

$ pacman -Syu htop ncdu fish vim
:: Synchronizing package databases...
 core is up to date
 extra                   1651.4 KiB   263K/s 00:06 [##########] 100%
 community                  4.0 MiB   190K/s 00:22 [##########] 100%
:: Starting full system upgrade...
resolving dependencies...
looking for conflicting packages...

Packages (8) bc-1.07.1-1  gpm-1.20.7-8  inetutils-1.9.4-5
             vim-runtime-8.0.1092-1  fish-2.6.0-1  htop-2.0.2-2
             ncdu-1.12-1  vim-8.0.1092-1

Total Download Size:    8.52 MiB
Total Installed Size:  39.99 MiB

:: Proceed with installation? [Y/n]

Docker pacman: sysupgrade target

Package Removal

We many cases to be shown here.

Consider this fish, no package has any dependency to this friendly water creature.

$ pacman -R fish

Equal to:

$ pacman --remove fish
checking dependencies...

Packages (1) fish-2.6.0-1

Total Removed Size:  8.15 MiB

:: Do you want to remove these packages? [Y/n]

We can also remove any its dependency as well by using --recursive option.

$ pacman -Rs fish

Equal to:

$ pacman --remove --recursive fish
checking dependencies...

Packages (3) bc-1.07.1-1  inetutils-1.9.4-5  fish-2.6.0-1

Total Removed Size:  9.35 MiB

:: Do you want to remove these packages? [Y/n]

Docker pacman: Remove Recursive

Consider this groff case, that is dependency of man-db. Have a look at how ALPM manage dependency, this command will send error notification message.

$ pacman --remove groff
checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: man-db: removing groff breaks dependency 'groff'

It can be solved by using --cascade option.

$ pacman -Rc groff

Equal to:

$ pacman --remove --cascade groff
checking dependencies...

Packages (2) man-db-2.7.6.1-2  groff-1.22.3-7

Total Removed Size:  10.39 MiB

:: Do you want to remove these packages? [Y/n]

Docker pacman: Remove Cascade

If you wish, you can have a cleaner removal.

$ pacman -Rcs groff
checking dependencies...

Packages (3) libpipeline-1.4.2-1  man-db-2.7.6.1-2  groff-1.22.3-7

Total Removed Size:  10.50 MiB

:: Do you want to remove these packages? [Y/n] 

It is just an example. We do not realy need to delete it.

In short, pacman -[Q|S]s.

There are two kind of pacman searches,

  • local query search

  • repository sync search

Local query search.

$ pacman -Qs ncdu

Equal to:

$ pacman --query --search ncdu
local/ncdu 1.12-1
    Disk usage analyzer with an ncurses interface

Docker pacman: Query Search

And repository search.

$ pacman -Ss ncdu

Equal to:

$ pacman --sync --search ncdu
community/ncdu 1.12-1 [installed]
    Disk usage analyzer with an ncurses interface

Docker pacman: Sync Search

There are also some AUR search command that we will discuss later.

Package Show Info

In short, pacman -[Q|S][i|ii].

Pretty straightforward.

$ pacman -Qi ncdu

Equal to:

$ pacman --query --info ncdu
Name            : ncdu
Version         : 1.12-1
Description     : Disk usage analyzer with an ncurses interface

Docker pacman: Sync Info

And repository search. With slightly different output, the additional Repository field.

$ pacman -Si ncdu

Equal to:

$ pacman --sync --info ncdu
Repository      : community
Name            : ncdu
Version         : 1.12-1
Description     : Disk usage analyzer with an ncurses interface

Change Log

I rarely use this feature.

$ pacman -Qc jq

Equal to:

$ pacman --query --changelog jq
Changelog for jq:
1.5-4:
fix CVE-2015-8863 (FS#50330)

1.5-2:
add oniguruma for regexp support

1.5-1:
upstream update

1.4-1:
move from AUR into [community]

Docker pacman: changelog

List Files

Pretty straightforward using -Qi. Note that -Si is totally different task.

$ pacman --query --list ncdu
ncdu /usr/
ncdu /usr/bin/
ncdu /usr/bin/ncdu
ncdu /usr/share/
ncdu /usr/share/licenses/
ncdu /usr/share/licenses/ncdu/
ncdu /usr/share/licenses/ncdu/LICENSE
ncdu /usr/share/man/
ncdu /usr/share/man/man1/
ncdu /usr/share/man/man1/ncdu.1.gz

Docker pacman: query list

Listing package files also can be achieved using pkgfile.

$ pkgfile --update
:: Updating 3 repos...
  download complete: core                 [   703.3 KiB  92.9K/s  2 remaining]
  download complete: extra                [     7.3 MiB   117K/s  1 remaining]
  download complete: community            [    16.7 MiB   176K/s  0 remaining]
:: download complete in 97.48s            <    24.7 MiB   260K/s  3 files    >
:: waiting for 1 process to finish repacking repos...

Docker Arch: pkgfile update

$ pkgfile --list ncdu
community/ncdu	/usr/
community/ncdu	/usr/bin/
community/ncdu	/usr/bin/ncdu
community/ncdu	/usr/share/
community/ncdu	/usr/share/licenses/
community/ncdu	/usr/share/licenses/ncdu/
community/ncdu	/usr/share/licenses/ncdu/LICENSE
community/ncdu	/usr/share/man/
community/ncdu	/usr/share/man/man1/
community/ncdu	/usr/share/man/man1/ncdu.1.gz

Docker Arch: pkgfile list

Verify

You can verify integrity of a package.

$ pacman -Qkk ncdu

Equal to:

$ pacman --query --check --check ncdu
ncdu: 10 total files, 0 altered files

Docker pacman: query check

Package as File

You can examine downloaded package.

$ wget -c http://kambing.ui.ac.id/archlinux/community/os/x86_64/ncdu-1.12-1-x86_64.pkg.tar.xz

And gather information from the file directly

$ pacman --query --file ncdu-1.12-1-x86_64.pkg.tar.xz

Equal To:

$ pacman -Qp ncdu-1.12-1-x86_64.pkg.tar.xz
ncdu 1.12-1

Docker Arch: pacman query file

You can also query file with list -Qpl or info -Qpi.

$ pacman -Qpl ncdu-1.12-1-x86_64.pkg.tar.xz
ncdu /usr/
ncdu /usr/bin/
ncdu /usr/bin/ncdu
ncdu /usr/share/
ncdu /usr/share/licenses/
ncdu /usr/share/licenses/ncdu/
ncdu /usr/share/licenses/ncdu/LICENSE
ncdu /usr/share/man/
ncdu /usr/share/man/man1/
ncdu /usr/share/man/man1/ncdu.1.gz

Docker Arch: pacman query file list

If you are a curious person, you can even extract the package.

$ tar -Jxvf ncdu-1.12-1-x86_64.pkg.tar.xz 
.PKGINFO
.BUILDINFO
.MTREE
usr/
usr/bin/
usr/share/
usr/share/licenses/
usr/share/man/
usr/share/man/man1/
usr/share/man/man1/ncdu.1.gz
usr/share/licenses/ncdu/
usr/share/licenses/ncdu/LICENSE
usr/bin/ncdu

What’s Next

pacman is a complete package management, one command rule all, and it is also very fast. So many commands that this topic deserve its own long article. Consider finish reading [ Part Two ].