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

Dependency

There are two main topics in package dependency, the dependency itself, and reverse dependency.

  • Dependency

    Package that required by: such as man-db need groff-base and other.

  • Reverse Dependency

    Package that require: such as groff-base needed by man-db or other.

Luckily both can be achieved with single command.

Using pacman

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

$ pacman --sync --info --info groff
..
Depends On      : perl  gcc-libs
Optional Deps   : netpbm: for use together with man -H command
                  interaction in browsers
                  psutils: for use together with man -H command
                  interaction in browsers
                  libxaw: for gxditview
Required By     : man-db
...

Docker pacman: Info groff

$ pacman -Qii man-db
Depends On      : bash  gdbm  zlib  groff  libpipeline  less
Optional Deps   : gzip [installed]
Required By     : None

Docker pacman: Info man-db

Test

Removing groff-base. We have already discuss this on package removal.

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

Using pactree

There is a cool official tool, the pactree.

$ pactree man-db --depth 2 --color
man-db
├─bash
│ ├─readline
│ ├─glibc
│ └─ncurses
├─gdbm
│ ├─glibc
│ └─bash provides sh
├─zlib
│ └─glibc
├─groff
│ ├─perl
│ └─gcc-libs
├─libpipeline
│ └─glibc
└─less
  ├─glibc
  ├─ncurses
  └─pcre

Docker pactree: Depth

It could also resolve reverse dependency well.

$ pactree groff --color --reverse
groff
└─man-db

Docker pactree: Reverse


Repository

Switch repository in Arch based is simple.

Configuration

Most of the time I manage repository using pacman.conf configuration directly in Arch based distribution. I don’t know if there is better way.

$ cat /etc/pacman.conf
# REPOSITORIES
#   - can be defined here or included from another file

[core]
Include = /etc/pacman.d/mirrorlist

[extra]
Include = /etc/pacman.d/mirrorlist

[community]
Include = /etc/pacman.d/mirrorlist

Docker Arch: pacman.conf

Case: Other distribution utilized ALPM may use different repository.

# Artix repos
[system]
Include = /etc/pacman.d/mirrorlist
[world]
Include = /etc/pacman.d/mirrorlist
[galaxy]
Include = /etc/pacman.d/mirrorlist

Case: Sometimes there is additional repository as well, inside /etc/apt/pacman.conf/ directory.

[archlinuxfr]
SigLevel = PackageOptional
Server = http://repo.archlinux.fr/$arch

[blackarch]
Server = http://blackarch.mirror.digitalpacific.com.au/blackarch/os/$arch
SigLevel = Optional

Mirror

Before you begin. This is the official documentation.

Mirror configuration is in /etc/pacman.d/mirrorlist. It is originnaly just consist one line.

$ cat /etc/pacman.d/mirrorlist
Server = https://mirrors.kernel.org/archlinux/$repo/os/$arch

Docker Arch: cat mirror

We can fill more repository from this mirror generator site.

  • https://www.archlinux.org/mirrorlist/

I filter the option for Indonesia only. Just append by copy paste the result under the original /etc/pacman.d/mirrorlist. Do not forget to uncomment.

I also append my other three favorite repositories as well.

Server = https://mirrors.kernel.org/archlinux/$repo/os/$arch

Server = http://kambing.ui.ac.id/archlinux/$repo/os/$arch
Server = ftp://archlinux.cbn.net.id/pub/archlinux/$repo/os/$arch
Server = http://archlinux.cbn.net.id/$repo/os/$arch

##
## Arch Linux repository mirrorlist
## Generated on 2017-09-13
##

## Indonesia
Server = http://mirror.devilzc0de.org/archlinux/$repo/os/$arch
Server = http://mirror.poliwangi.ac.id/archlinux/$repo/os/$arch
Server = http://suro.ubaya.ac.id/archlinux/$repo/os/$arch

Docker Arch: nano mirror

We are not done yet. Now we need to rank the mirror to find the fastest mirror. First backup the mirrorlist.

$ cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
$ rankmirrors /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist
$ /etc/pacman.d/mirrorlist
Server = http://suro.ubaya.ac.id/archlinux/$repo/os/$arch
Server = http://mirror.poliwangi.ac.id/archlinux/$repo/os/$arch
Server = http://kambing.ui.ac.id/archlinux/$repo/os/$arch
Server = https://mirrors.kernel.org/archlinux/$repo/os/$arch
Server = ftp://archlinux.cbn.net.id/pub/archlinux/$repo/os/$arch
Server = http://archlinux.cbn.net.id/$repo/os/$arch
Server = http://mirror.devilzc0de.org/archlinux/$repo/os/$arch

Docker Arch: rankmirrors

Do not forget to refresh.

$ pacman -Syy 

Group

ALPM has a very nice group support.

Blackarch Example

I have already wrote an article about this.

With BlackArch, you can install tools by category. One category today. And other category the day after. Until all completely installed. Or you can install only what you need. And keep our system clean.

But we are not talking about BlackArch here. Therefore I must make a more genreci example.

List Group

To show all group, just use --sync --group

$ pacman -Sg

Equal to:

$ pacman --sync --group

Docker pacman: List Group

Cool! Now we can install a specific group. I choose base-devel, as we need toolchain later for automatic compilation.

$ pacman --sync base-devel
:: There are 25 members in group base-devel:
:: Repository core
   1) autoconf  2) automake  3) binutils  4) bison  5) fakeroot
   6) file  7) findutils  8) flex  9) gawk  10) gcc  11) gettext
   12) grep  13) groff  14) gzip  15) libtool  16) m4  17) make
   18) pacman  19) patch  20) pkg-config  21) sed  22) sudo
   23) texinfo  24) util-linux  25) which

Enter a selection (default=all): 

Docker pacman: Install Group


Lock Package

Two method here

  • IgnorePkg to avoid change, upgrade or downgrade.

  • HoldPkg to avoid removal.

IgnorePkg

Consider an water creature case here that I installed from outdated repo. It will always be on the upgradable list.

$ pacman -Qu
fish 2.4.0-1 -> 2.6.0-1

Docker pacman: Outdated Package

Unless we explicitly ignore it, by using IgnorePkg in /etc/pacman.conf.

$ cat /etc/pacman.conf | grep fish
IgnorePkg    = fish

$ pacman -Qu
fish 2.4.0-1 -> 2.6.0-1 [ignored]

$ pacman -Su
:: Starting full system upgrade...
warning: fish: ignoring package upgrade (2.4.0-1 => 2.6.0-1)
 there is nothing to do

Docker pacman.conf: IgnoredPkg

I have been using this IgnorePkg to avoid driver upgrade for my SiS671 driver, because there was about one year that, the later driver does not work with xorg.

HoldPkg

What if I want this water creature to be always in my system ? We explicitly hold it, by using HoldPkg in /etc/pacman.conf.

$ cat /etc/pacman.conf | grep fish
HoldPkg      = fish

$ pacman -R fish
checking dependencies...
warning: fish is designated as a HoldPkg.
:: HoldPkg was found in target list. Do you want to continue? [y/N]

Docker pacman.conf: HoldPkg


System Wide

System Wide Information

List Packages

Listing packages handled by package manager, can be achieved by pacman -Sl. Note that pacman -Ql has a very different task.

$ pacman -Sl

Or

$ pacman --sync --list
core acl 2.2.52-4 [installed]
core archlinux-keyring 20170823-1 [installed]
core attr 2.4.47-3 [installed]
core autoconf 2.69-4 [installed]
core automake 1.15.1-1 [installed]
core b43-fwcutter 019-1
...
community zshdb 0.08-4
community zstd 1.3.0-1
community zsync 0.6.2-3
community zynaddsubfx 3.0.2-1

Docker pacman: List Packages

You can query only installed packages.

$ pacman --query
acl 2.2.52-4
apr 1.6.2-1
apr-util 1.6.0-1
archlinux-keyring 20170823-1
...
xz 5.2.3-1
zlib 1:1.2.11-2

Docker pacman: List Installed Packages

Search Files

Files owner

$ pacman --query --own xargs
/usr/bin/xargs is owned by findutils 4.6.0-2

Or:

$ pacman -Qo /usr/share/man/man1/ncdu.1.gz
/usr/share/man/man1/ncdu.1.gz is owned by ncdu 1.12-1

Docker Arch: pacman Query Owner

To find package that provide a specific file, you can utilize 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 --search /etc/man_db.conf 
core/man-db

Docker Arch: pkgfile package

Verify

Verify integrity of package database, such as dependencies and consistency. Since pacman 5.0, testdb has been replaced.

$ pacman -Dk
$ pacman -Dkk

Equal to:

$ pacman --database --check
$ pacman --database --check --check
error: missing 'yp-tools>=2.12-2' dependency for 'archboot'
error: missing 'wine' dependency for 'playonlinux'
error: missing 'wine' dependency for 'wine-mono'
error: missing 'wine' dependency for 'winetricks'

Docker Arch: pacman database check

You can also query check.

$ pacman --query --check

/var/lib

You can also examine /var/lib/pacman/local.

$ ls /var/lib/pacman/local/ncdu-1.12-1/
desc  files  mtree
$ cat /var/lib/pacman/local/ncdu-1.12-1/desc 
%NAME%
ncdu

%VERSION%
1.12-1

%DESC%
Disk usage analyzer with an ncurses interface
...

Docker Arch: cat /var/lib/pacman/local


History

This is most the forgotten part of package management, although it is not uncommon to notice messages.

The Log File

There are few log files.

  • /var/log/pacman.log

less or more is a good tool to read log file. Most likely you want the tail, latest transaction, at the bottom of the recorded event.

$ grc tail /var/log/pacman.log
[2017-09-13 21:48] [ALPM] installed gc (7.6.0-1)
[2017-09-13 21:48] [ALPM] installed guile (2.2.2-1)
[2017-09-13 21:48] [ALPM] installed make (4.2.1-2)
[2017-09-13 21:48] [ALPM] reinstalled pacman (5.0.2-2)
[2017-09-13 21:48] [ALPM] installed patch (2.7.5-1)
[2017-09-13 21:48] [ALPM] installed pkg-config (0.29.2-1)
[2017-09-13 21:48] [ALPM] reinstalled sudo (1.8.21.p2-1)
[2017-09-13 21:48] [ALPM] reinstalled which (2.21-2)
[2017-09-13 21:48] [ALPM] transaction completed
[2017-09-13 21:48] [ALPM] running 'texinfo-install.hook'...

Docker Arch: grc tail /var/log/pacman.log


Clean Up

Keep your system neat and tidy.

Cache

APT as default keep downloaded package.

Package Cache

  • /var/cache/pacman/pkg/ * -x86_64.pkg.tar.xz

  • /var/cache/abs/local/yaourtbuild/ * -x86_64.pkg.tar.xz

You can clean this directory by using

$ pacman -Sc

Equal to:

$ pacman --sync --clean
Packages to keep:
  All locally installed packages

Cache directory: /var/cache/pacman/pkg/
:: Do you want to remove all other packages from cache? [Y/n] y
removing old packages from cache...

Database directory: /var/lib/pacman/
:: Do you want to remove unused repositories? [Y/n] y
removing unused sync repositories...

Docker Arch: Cache Clean

Note that all package that you use will still in that directory. You can uninstall manually if you want. Please preserve system packages such as driver and kernel, just in case upgrade issue happened.

I personally like to collect important package to other directory, and remove all package manually.

Autoremove

ALPM has this very nice autoremove feature that is flexible but not easy to remember for daily basis.

Supposed that I just remove vim, without removing dependency.

$ pacman --remove vim

Now we can have this

$ pacman --query --deps --unrequired        
gpm 1.20.7-8
vim-runtime 8.0.1092-1

Docker Arch: pacman --query --deps --unrequired

Consider, not to be noisy this time. We have array of packages in a row.

$ pacman -Qdtq

Or

$ pacman --query --deps --unrequired  --quiet       
gpm
vim-runtime

Now we can remove recursively.

$ pacman -Qdtq | pacman -Rs -

Equal to:

$ pacman --query --deps --unrequired  --quiet | pacman  --remove --recursive -
checking dependencies...

Packages (2) gpm-1.20.7-8  vim-runtime-8.0.1092-1

Total Removed Size:  27.21 MiB

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

Docker Arch: Autoremove


Case

When chroot fail

Once I had a kernel panic, that caused by filesystem failure, due to electricity went out. This wasn’t the only misery, apparently chroot also failed miserably, with message input/output error, that means I cannot do pacman to reinstall missing files (mostly library).

This is when pacman -U -r, this command can have a target directory. It means we can install in different root location. After installing glibc from different partition (or live usb), I can chroot successfully. Later I can _pacman in chroot to replace some missing library files.

Note that image below does not run on docker, but real life problem solving.

Arch Case: case chroot


What’s Next

There are still, some interesting topic for ALPM. Consider finish reading [ Part Three ].

Thank you for reading