Arch Linux - How to upgrade the system with pacman?

Posted in How To's by Shafkat Shahzad, M.Sc on November 22nd, 2009

Welcome to the tutorial guide. The guide will cover guidance on how to upgrade the system with pacman.

Before we go ahead with the upgrade, it is good to know what is pacman. Pacman is the package manager of Arch Linux. It manages the entire package system and handles installation, removal, package downgrade, custom compiled package handling, automatic dependency resolution, remote and local searches and much more.
Please note that Pacman is the most important tool in the Arch Linux toolbox for building the base.

Package Repositories and /etc/pacman.conf
Arch currently offers the following 4 repositories which are accessible through pacman. These are core, extra, testing and community.

Core
The simple principle behind this repository is to provide only one of each necessary tool for a base Arch Linux system; The GNU toolchain, the Linux kernel, one editor, one command line browser, etc. It contains all the packages that MUST be in perfect working order to ensure the system remains in a usable state.

extra
The extra repository contains all Arch packages that are not themselves necessary for a base Arch system

Testing
This repository contains packages that are candidates for the core]or extra repositories. Please note that only experienced users should use this repository.

Community
The community repository is maintained by the Trusted Users (TUs) and is simply the binary branch of the Arch User Repository.

AUR - unsupported
The AUR contains the unsupported branch, which cannot be accessed directly by pacman. AUR does not contain binary packages.

/etc/pacman.conf
Please note that the pacman will attempt to read /etc/pacman.conf each time it is invoked. This configuration file is divided into sections, or repositories.

Please note that the defaults should work, so modifying at this point may be unnecessary, but verification is always recommended.

# nano /etc/pacman.conf

Let’s view an example as provided below:
#
# /etc/pacman.conf
#
# See the pacman.conf(5) manpage for option and repository directives

#
# GENERAL OPTIONS
#
[options]
# The following paths are commented out with their default values listed.
# If you wish to use different paths, uncomment and update the paths.
#RootDir = /
#DBPath = /var/lib/pacman/
#CacheDir = /var/cache/pacman/pkg/
#LogFile = /var/log/pacman.log
HoldPkg = pacman glibc
# If upgrades are available for these packages they will be asked for first
SyncFirst = pacman
#XferCommand = /usr/bin/wget –passive-ftp -c -O %o %u
#XferCommand = /usr/bin/curl %u > %o

# Pacman won’t upgrade packages listed in IgnorePkg and members of IgnoreGroup
#IgnorePkg =
#IgnoreGroup =

#NoUpgrade =
#NoExtract =

# Misc options (all disabled by default)
#NoPassiveFtp
#UseSyslog
#ShowSize
#UseDelta
#TotalDownload
#
# REPOSITORIES
# - can be defined here or included from another file
# - pacman will search repositories in the order defined here
# - local/custom mirrors can be added here or in separate files
# - repositories listed first will take precedence when packages
# have identical names, regardless of version number
# - URLs will have $repo replaced by the name of the current repo
#
# Repository entries are of the format:
# [repo-name]
# Server = ServerName
# Include = IncludePath
#
# The header [repo-name] is crucial - it must be present and
# uncommented to enable the repo.
#

# Testing is disabled by default. To enable, uncomment the following
# two lines. You can add preferred servers immediately after the header,
# and they will be used before the default mirrors.
#[testing]
#Include = /etc/pacman.d/mirrorlist

[core]
# Add your preferred servers here, they will be used first
Include = /etc/pacman.d/mirrorlist

[extra]
# Add your preferred servers here, they will be used first
Include = /etc/pacman.d/mirrorlist

[community]
# Add your preferred servers here, they will be used first
Include = /etc/pacman.d/mirrorlist

# An example of a custom package repository. See the pacman manpage for
# tips on creating your own repositories.
#[custom]
#Server = file:///home/custompkgs

Please note that you can enable all desired repositories and for that you have to remove the # in front of the ‘Include =’ and ‘[repository]’ lines.

Also, when you choose repos, please ensure to uncomment both the repository header lines in brackets as well as the ‘Include =’ lines. If you fail to do so then the selected repository will be omitted.

/etc/pacman.d/mirrorlist
This provide a definition for the pacman repo mirrors and priorities.

If you want to build a mirrorlist then you can use the rankmirrors script as provided below:

/usr/bin/rankmirrors

This script will attempt to detect the mirrors which are closest to the installation machine based on the mirrors specified in /etc/pacman.d/mirrorlist.

This script may be run periodically, especially if the chosen mirrors provide inconsistent throughput and/or updates.

If you are interested in using pacman to install python, then please run following script:
# pacman -Sy python
cd to the /etc/pacman.d/ directory:
# cd /etc/pacman.d

run following script to backup the existing /etc/pacman.d/mirrorlist:
# cp mirrorlist mirrorlist.backup

In order to edit mirrorlist.backup and uncomment all mirrors on the same continent or within geographical proximity to test with rankmirrors, please run following script.
# nano mirrorlist.backup

You can also run the script against the mirrorlist.backup with the -n switch and redirect output to a new /etc/pacman.d/mirrorlist file:
# rankmirrors -n 6 mirrorlist.backup > mirrorlist
-n 6: rank the 6 fastest mirrors

If you would like to refresh the package lists then please follow the steps as provided below:
Please note that you need to create /etc/pacman.d/mirrorlist, by running following command:
/usr/bin/rankmirrors

Now, please run following command:
# pacman –Syy

If you pass two –refresh or -y flags, it will force pacman to refresh all package lists even if they are considered to be up to date.

Following command will update the entire the system.
# pacman –Syu

After executing the command “pacman -Syu”, the entire system will be updated.

If you would like to protect the configuration/system files from being overwritten during “pacman -Su”, please use the following option in the /etc/pacman.conf
NoUpgrade = etc/lilo.conf boot/grub/menu.lst

Learn about pacman
If you would like to learn about pacman then please run following command:
$ man pacman

If you are interested in speeding up the package retrieval then please install the powerpill. A powerpill is a pacman wrapper script which can speed up the package retrieval by using aria2c for concurrent/segmented downloads. The powerpill package can be installed by running following command:
# pacman -S powerpill

After installing the powerpill package, don’t forget to update the system by running following command:

# powerpill -Syu

You can Sync, refresh, and upgrade the entire new system with:
# pacman -Syu

Network Time Protocol
If you would like to set the system time then use OpenNTPD to sync the local clock to remote NTP servers. Please note that the OpenNTPD can also be added to the DAEMONS= array in /etc/rc.conf to provide this service at each boot.

If you followed the advise and guidance and guidance as provided in this tutorial guide then you would have successfully upgraded the Arch Linux system with pacman.

Bookmark Us
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • MisterWong
  • Netvouz
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • Wists

Leave a Comment