ZAURUS HOME PAGE        RASPBERRY PI PAGE        LINUX COMMANDS        LINUX SCRIPTING

RUNNING PACMAN WITHOUT INTERNET

INTRODUCTION
 
FIRST STEPS
 
    CREATE EXTERNAL REPOSITORY
 
    TRANSFER REPOSITORY MEDIA OR FILES
 
    CONFIGURE PACMAN
 
SYNCING WITH REPOSITORY
 
    UPDATE LOCAL SYNC FILES
 
    OBTAIN LIST OF FILES REQUIRED TO SYNC SYSTEM
 
    DOWNLOAD ADDITIONAL FILES FOR SYNCING
 
    FINISH SYNCING WITH REPOSITORY
 
INSTALLING NEW PACKAGES
 
    DETERMINE PACKAGE DEPENDENCIES
 
    LOCATE REQUIRED DEPENDENCIES
 
    INSTALL PACKAGES
 
TROUBLESHOOTING
 
ADDITIONAL OPTIONS
 
ADDITIONAL READING

INTRODUCTION

This page is meant to serve as a guide for individuals needing to install or upgrade packages on Arch linux systems that do not have internet access, and especially for users of Arch Linux Arm on the Raspberry Pi. It will be essential that you have access to some computer that has access to the Internet, in order to query the online repositories and download packages and their dependencies. However, this work does not have to be done on the target system.

All examples below are from running Arch Linux Arm on the Raspberry Pi. and instructions have only been tested on a Pi, but in many or most cases, should apply to other Arch systems as well.

Your Raspberry Pi does not need to be connected to a network, either, to perform offline package installation. You simply need to be able to put the packages and their dependencies on external media that you can then attach to your Pi to be accessed, if you are unable to transfer them over a network connection of some sort. Some steps would certainly be more efficient and easier if your Raspberry Pi does have some sort of internet or network access, but neither is essential.

There are other guides which take slightly different approaches to doing this, most of which assume particular configurations that may not apply in all cases, so this was written on the assumption that the target system has no networking ability at all, and that the PC you will be using to obtain packages does not run ArchLinux. If your system has either of these helpful characteristics, you may want to read those guides as well, some of which I have listed in the additional reading section below.

And, it almost goes without saying that you should consult the appropriate man pages to find out more details about options and syntax. The man pages of most interest will be pacman, pacman.conf and repo-add. If the man pages are hard for you to understand, see the additional reading section below which also provides links to other how-to and wiki pages about running pacman.

There are basically three or four types of packages you may want to put in a local custom repository: packages created by you, packages found in official Arch Linux repositories, and packages found on the web that are not in official repositories. Packages you wish to install from the GIT and AUR repositories are another category, because packages from these other official sources cannot be installed without using other software such as Yaourt or makepkg to turn them into tar.xz packages that can then be installed by Pacman.

The examples given on this page will be specific to the Raspberry Pi running ArchLinuxArm, since that is the system being used by the author. It is a work in progress, and more examples will be added as time goes on. So, do check back, if an explanation is too terse for you, to see if I have added more detail as I work on improving the utility of the page for pacman novices.

And feel free to PM me at RaspberryPi.org to report any errors or confusing sections on this page. I have done my best to try to make the instructions user friendly for someone new to Arch Linux, but this was not easy and I am sure there could be improvements in the presentation. Please do PM me if you have any more helpful suggestions.

FIRST STEPS

CREATE EXTERNAL REPOSITORY

1. Pick an official repository from which to retrieve packages. People usually use a repository that is near them geographically, and you will need to look for one that supports the architecture of your target system. The best way to do that is to consult the mirror list which is usually to be found in the following file:

/etc/pacman.d/mirrorlist

There will be different URLs for the mirrors found in the above file, to obtain packages for the old soft float and new hard float installations. And you must use the mirror list from your Raspberry Pi or other target system, the mirror list found on another computer running Arch Linux will have links to mirrors that have packages for a different architecture and which will not run on your Raspberry Pi.

If you are running an up-to-date ArchLinuxArm system on the Raspberry Pi, you will be using armv6h architecture. Older distributions that have not been updated will not be able to use packages compiled to run on armv6h, so be sure to use packages obtained from the official mirror list found on your target system, the Raspberry Pi, before downloading any packages.

If you are do not have access to a system that can access the mirror list on your SD card, and will be running an up to date kernel, then you can try the following links:

http://mirror.archlinuxarm.org/armv6h/
http://eu.mirror.archlinuxarm.org/armv6h/
http://us.mirror.archlinuxarm.org/armv6h/

2. Examine the repository to determine which optional packages you wish to install. You can do this by pointing your browser to the main repository, using a search engine, or downloading the package database lists and then either using a browser on your Pi, or using the command line tool "grep" to find packages with specific keywords or patterns in their names.

If you are not sure what packages you want, you may wish to peruse the following wiki page, which is a great resource for getting an idea of what packages are available for Arch Linux, to help you decide what optional packages to install. Most of the packages on the wiki are also available for Arch Linux Arm and the Raspberry Pi.

https://wiki.archlinux.org/index.php/List_of_Applications

3. Download up to date db files from the official repository to a medium of choice that you can transfer to the target system. This could be, for example, an SD card, a CF card, a USB stick, or a thumb drive. The db files provide pacman with crucial information about currently available packages, and pacman needs to compare your system to the current db files, in order to see what packages need updating.

I am sure many of you may wish to skip this step, but be forewarned - at some point, applications and packages are highly likely to break and cause problems with your system if you do not allow pacman to sync your system with updates from current the db files before you install or upgrade specific packages of choice.

For the Raspberry Pi, the files you need to obtain 5 db files in order to update your system. Note that the ArchWiki says that we need to download both the db.tar.gz and the db file for each directory, but that is not true for the Raspberry Pi, you only need to download the following five files:

URL-OF-MIRROR/alarm/alarm.db
URL-OF-MIRROR/aur/aur.db.
URL-OF-MIRROR/community/community.db
URL-OF-MIRROR/core/core.db
URL-OF-MIRROR/extra/extra.db

Note that if you are using wget to download the db files, it will add numbers at the end of the file names if there already are db files in the directory you are downloading them to. To keep this from happening, it is best to either remove or rename the old db files before you run wget. So, for example, when I ran the following wget command in a directory that already had db files in it, I ended up with the newest files being given a numerical suffix, as shown in the results of the ls command below.

[alarmpi ~] ls -l /mnt/repository/*\.db*
-rwxr-xr-x 1 root root 7188 Apr 3 04:24 /mnt/repository/alarm.db
-rwxr-xr-x 1 root root 7057 May 17 09:50 /mnt/repository/alarm.db.1
-rwxr-xr-x 1 root root 19247 Apr 3 04:28 /mnt/repository/aur.db
-rwxr-xr-x 1 root root 17441 May 17 09:55 /mnt/repository/aur.db.1
-rwxr-xr-x 1 root root 505090 Apr 3 04:28 /mnt/repository/community.db
-rwxr-xr-x 1 root root 531652 May 17 09:54 /mnt/repository/community.db.1
-rwxr-xr-x 1 root root 40420 Apr 3 04:24 /mnt/repository/core.db
-rwxr-xr-x 1 root root 42321 May 17 09:51 /mnt/repository/core.db.1
-rwxr-xr-x 1 root root 505948 Apr 3 04:26 /mnt/repository/extra.db
-rwxr-xr-x 1 root root 522794 May 17 09:53 /mnt/repository/extra.db.1
[alarmpi ~]

Do not try to save bandwidth by downloading the db.tar.gz files instead of the db files themselves. In fact, both versions are identical in size, and if you try to unpack the db.tar.gz files, you will end up creating many subdirectories in /var/lib/pacman/sync with an inordinate number of files that are not needed except for development. So, it is best to simply download the db files unless you really need the other files.

4. If you have a custom repository containing packages you have compiled yourself or downloaded from the web, which are not in the official Arch Linux Arm repository, you will need to create a custom db file with the following command. This step will not be necessary if you have very few custom packages and do not mind using pacman's --upgrade option to upgrade these packages individually. (NOTE I have not tested this step, for more details about it see the man pages for repo-add and pacman, and other pages in the suggested reading section below):

cd /path/to/customrepository
repo-add customrepository.tar.gz *.pkg.tar.gz

5. Download all required packages, as well as any desired packages and dependencies, to the same medium and directory where you put the db files in the previous step. If you do not yet know what packages and dependencies you need or want, you can wait until you know what they are to obtain and add them to your local repository. More details about determining package dependencies are in the section below about determining package dependencies.

TRANSFER REPOSITORY MEDIA OR FILES

6. After downloading the packages and db files from the internet, you need to either transfer the files or the media containing them, to your Raspberry Pi. There are several ways to accomplish this task. The standard approaches are:
 

7. Determine the path to your local repository or repositories.

If you are using external media and if automounting occurs, you can identify the path for your external media by running the "df" command both before and after attaching the media containing your custom repository. Examine the output, and you should see a new listing after attaching the card or disk or stick.

Here is example output of the df command, before I mounted external media on my Pi.

[alarmpi ~] df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs          1.7G  1.1G  490M  70% /
/dev/root       1.7G  1.1G  490M  70% /
devtmpfs         84M     0   84M   0% /dev
tmpfs           232M     0  232M   0% /dev/shm
tmpfs           232M  284K  232M   1% /run
tmpfs           232M     0  232M   0% /sys/fs/cgroup
tmpfs           232M     0  232M   0% /tmp
/dev/mmcblk0p1   90M   28M   63M  31% /boot 
[alarmpi ~]

And below is the output of the df command, after I mounted an SD card. Note that it mounted on /dev/sdb1, and the file system is located at /mnt/repository.

[alarmpi ~] df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs          1.7G  1.1G  490M  70% /
/dev/root       1.7G  1.1G  490M  70% /
devtmpfs         84M     0   84M   0% /dev
tmpfs           232M     0  232M   0% /dev/shm
tmpfs           232M  300K  232M   1% /run
tmpfs           232M     0  232M   0% /sys/fs/cgroup
tmpfs           232M     0  232M   0% /tmp
/dev/mmcblk0p1   90M   28M   63M  31% /boot
/dev/sdb1       489M  489M   96K 100% /mnt/repository
[alarmpi ~]

If you do not see a new line in the output of df showing the external media, a number of steps will be required. If you are not running as root, you may need to use sudo to perform most of these steps.
 

  1. Run the dmesg command to determine the device name for the media. You will be looking for a line, near the end of the output, that looks like or contains something like the following example. In this case, the external media has two partitions, one is sda1 and the other is sda2. Their full device references are /dev/sda1 and /dev/sda2:
     
        [ 8234.009033] sda: sda1 sda2
     
    If there is only one partition and the device mounts on /dev/sdb1, the line will look something like:
     
        [ 8234.009043] sdb: sdb1

     
    My favorite way to identify the device reference is to run dmesg and pipe the output through grep. If you have just inserted the media. then the last line referring to sda or sdb or sdc or any other sd device will probably be the one that is the external device that was just mounted. However, this shortcut will not work if the device is not seen by your system as an "sd" device. The last line in the output of the following command will be the device reference of the most recently added "special device":
     
        dmesg|grep sd
     
    Or you can narrow your results to the lines showing just the lines showing the partition scans of devices as follows:
     
        dmesg|grep sd[abcdef]1
     
  2. Create mount points (i.e., directories) if they do not already exist.
      On the Raspberry Pi, external media is often mounted in the /media/ directory. But you are free to mount devices in any other new directory name you choose to create, /mnt and /media are simply standard names often used. Here are some examples:
     
        [alarmpi ~] mkdir /media/sda1
        [alarmpi ~] mkdir /media/sda2
        [alarmpi ~] mkdir /media/repository
        [alarmpi ~] mkdir /media/custom
     
    Remember that if you are not running as root, you will need to use the sudo command:
     
        [alarmpi ~] sudo mkdir /mnt/usbstick
        [alarmpi ~] sudo mkdir /mnt/cfcard
     
    If you get an error such as the following, when trying to create mount points, you will probably need to create the parent directories. In the following example, the first attempt failed because there is no /media directory. I then created /media, after which I could create the /media/custom directory without error:
     
        [alarmpi ~] mkdir /media/custom
        mkdir: Cannot create directory `/media/custom': No such file or directory
        [alarmpi ~]
        [alarmpi ~] mkdir /media
        [alarmpi ~] mkdir /media/custom

     
  3. Once you know the device reference and mount point, you can mount the file system with the mount command. If you are not running as root, you will need to use sudo or su. In the first example, the repository is in vfat format. In the second example, it was created on a Linux system and is in ext4 format.
     
        [alarmpi ~] mount /dev/sda1 -t vfat /media/custom
        [alarmpi ~] mount /dev/sdb1 -t ext4 /mnt/repository

     
  4. Add appropriate entry or entries to /etc/fstab, if you want the device to mount automatically when you insert it on your Raspberry Pi. If your repository is seen as device /dev/sda1, then the following would be the fstab entry to mount it, if it was in vfat format. You can give the mount point any name you wish, such as in the second line below, which assigns /dev/sdb1 to /media/custom. However, you will need to make sure that you have created directories for any mount points which do not already exist in your system:
     
        /dev/sda1 /media/sda1 vfat defaults 0 0
        /dev/sdb1 /media/custom vfat defaults 0 0
     
    After creating your /etc/fstab entry, you will need to run the mount command, using the device name rather than the mount point, if the media has not already been mounted.
     
        [alarmpi ~] mount /dev/sda1
        [alarmpi ~] mount /dev/sdb2
     
    If your system complains that the device is not in fstab, as mentioned above, you can try something the following, assuming you have already created a directory called /media/repository, and that the file system is vfat. If the directory name you want to use or file system type is different, modify this example accordingly
     
        [alarmpi ~] mount /dev/sda1 -t vfat /media/repository

CONFIGURE PACMAN

8. You will need to tell pacman where to find your local repository. But, before modifying your pacman configuration file /etc/pacman.conf, make a backup copy of the original file. This is very likely to come in handy later, when you need to update your system offline. You can name the backup copy anything you want. I chose to add the suffix ".orig" as a reminder to myself that this is the original pacman.conf that has not yet been customized by me. The "-p" option for the "copy" command is important so you can maintain the date that the original pacman.conf file was created.

[alarmpi ~] cp -p /etc/pacman.conf /etc/pacman.conf.orig

9. If you are not going to give pacman any routine access at all to the online package mirrors, you may wish to comment out the URLs of the online repositories in pacman.conf, to avoid getting error messages when pacman attempts to find the mirrors. When you do this, you must leave the names of the sections intact, and just comment out the URLs.

However, pacman will not run without error unless you give it some locations where it can look for packages and files from the basic core, extra, aur, alarm, and community directories. Since I put all my packages from all five directories in one directory on my local repository, I have successfully put the location of that repository into pacman.conf as a location for all five of these directories, as follows. If you create separate directories for each of the five basic directories in the official mirror, then you would provide those specific path names instead.

[core]
#SigLevel = PackageRequired
#Include = /etc/pacman.d/mirrorlist
Server = file:///media/sda1
 
[extra]
#SigLevel = PackageOptional
#Include = /etc/pacman.d/mirrorlist
Server = file:///media/sda1
 
[community]
#SigLevel = PackageOptional
#Include = /etc/pacman.d/mirrorlist
Server = file:///media/sda1
 
[alarm]
#SigLevel = PackageOptional
#Include = /etc/pacman.d/mirrorlist
Server = file:///media/sda1
 
[aur]
#SigLevel = PackageOptional
#Include = /etc/pacman.d/mirrorlist
Server = file:///media/sda1

***IMPORTANT*** Make sure you use three slashes for your local server media as shown in the above examples. Otherwise, pacman will not be able to find your local files.

10. If you have compiled packages yourself, or downloaded custom packages that are not in the official repository for your distribution, add the path to your local repository or repositories to /etc/pacman.conf. There is a section near the bottom of /etc/pacman.conf, providing an example of a custom repository entry.

[custom]
#SigLevel = Optional TrustAll
#Server = file:///home/custompkgs

For example, if you have put these custom packages in a custom repository called repository, and it is located on external media as /media/sda1, you could modify your pacman.conf as follows. Be sure to not change the slashes from "///" to "//" in the listing. Pacman expects three slashes and will not find your local custom repository if you do not use three slashes in the path.

[custom]
#SigLevel = Optional TrustAll
#Server = file:///home/custompkgs
Server = file:///media/sda1/repository

Note that you can have more than one custom repository, listed in one section, or add more sections with unique names.

#SigLevel = Optional TrustAll
Server = file:///media/sda1/repository
Server = file:///media/sdb1/
 
[mypackages]
#SigLevel = Optional TrustAll
Server = file:///media/mypackages

***NOTE*** If your local repository does not contain any custom packages, do not create a separate unique entry for it in pacman.conf. Doing so is not necessary and will cause problems with the final syncing. The way to tell pacman where to find the packages you have already downloaded from the official Arch Linux Arm repository is to enter it's location in the pacman.conf sections for alarm, aur, community, core and extra as explained in step 9 above.

SYNCING WITH REPOSITORY

Keeping your system updated by syncing with the official ArchLinuxArm repository is essential if you want to take advantage of bug fixes and new features. Plus, if you want to install any new packages that depend on features only available on an updated system, they will not run properly until you sync your system.

UPDATE LOCAL SYNC FILES

11. In order to keep your system up to date, you need to transfer the db files you have downloaded and created, to the appropriate directory on your Raspberry Pi or other target ArchLinux system. (See the above section 3 with details about downloading db files, and section 5 about transferring files if you skipped those steps.) The following command will copy the current db files to pacman's sync directory, if you have not already transferred them.

cp -p PATH-TO-DB-FILES/{alarm.db,aur.db,community.db,core.db,extra.db} /var/lib/pacman/sync/

If you have done this properly, you should see output from the following "ls -l" command showing db files with current dates on them:

[alarmpi ~] ls -l /var/lib/pacman/sync/
total 1004
-rw-r--r-- 1 root root   6237 Mar  8 16:50 alarm.db
-rw-r--r-- 1 root root  17762 Mar  4 11:58 aur.db
-rw-r--r-- 1 root root 487358 Mar  9 19:11 community.db
-rw-r--r-- 1 root root  40376 Mar  9 17:23 core.db
-rw-r--r-- 1 root root 470163 Mar  9 18:41 extra.db
[alarmpi ~]

OBTAIN LIST OF FILES REQUIRED TO SYNC SYSTEM

12. You now can use pacman's print option to create a list of any files required to update your system, without actually updating until later in the process, when you are ready.

The standard command to find out what packages are needed to update an Arch Linux system would be as follows, but we do not want to use this because we do not have online access. The letter "y" yanks the current db files from the online mirrors, but we have already taken care of placing those files in the sync directory (see the above section about updating local sync files). The standard command for creating a package list online is:

pacman -Syup --noconfirm > pkglist.txt

A slightly better approach is to use the following command, as it does not require online access:

pacman -Sup --noconfirm > pkglist.txt

However, the problem with a package list created this second way, is that the output will not include online repository URLs unless you have both run the command on an ArchLinux system which actually has access to the online mirrors, and have downloaded the db files from a mirror and transferred them to your Raspberry Pi. But there is a solution, so keep reading.

Also note that if you have created a local repository, Pacman will not perform the -Sup operation unless there is also a db file for your local repository. To get around this, you could temporarily both comment out the lines in /etc/pacman.conf that refer to your local repository or repositories, and enable the standard repository mirror list, and then change the contents back after running the -Syup command. However, there is an easier, more reliable way to handle these problems.

Pacman gives us the option of specifying an alternative configuration file. So, if you have saved a copy of the original configuration file before customizing /etc/pacman.conf, you can simply tell pacman to use that original configuration file when creating a package list for you. So, in order to get the desired list of packages required for updating our system, which will be based on the official repository db files that we have already placed in /var/lib/pacman/sync/, we can, instead, run "pacman -Sup", if we also specify an alternative configuration file that only references the standard mirror list.

pacman -Sup --noconfirm --config FILENAME > pkglist.txt

In my case, where I have saved a copy of the original pacman.conf file and called this copy pacman.conf.orig, I enter the following command, which executes without error, and provides me with a list of urls for all packages required to sync my system. Note there will be no output if you have not updated your db files, other than the line saying ":: Starting full system upgrade", which appears whether or not any upgrade actually occurs:

pacman -Sup --noconfirm --config /etc/pacman.conf.orig > pkglist.txt
:: Starting full system upgrade...

If you run the above command, the resulting file pkglist.txt should include the URLs of all packages needed to update your system. But remember, you must have specified a configuration file that uses the standard mirrors, and have already placed updated db files in the pacman sync directory for it to work as intended.

DOWNLOAD ADDITIONAL FILES NEEDED FOR SYNCING

13. Once you have completed identifying all packages required for updating your system, move the medium back to a computer with internet access. But remember to first unmount it with the "umount" command.

14. Use wget, or another tool of your choice, for downloading the files. You should try to download the files needed as soon as possible after downloading the sync db files because the repository is constantly getting updated. And, if you delay downloading the files for hours or days after you obtain the db files, chances are fairly high that some of the packages you have on your list will have been superceded by more recent versions.

If this happens, you may wish to download as many of the files as you can, before going back and obtaining the more recent files. Note that if you do not obtain recent copies of all the files on your package list, it can hamper your ability to automate the update process.

Sometimes I find wget telliing me that a package can not be found, even though the package is in the main repository list at the moment I get that error message. If that happens, is most likely is because the mirror you are using is in the process of updating. What I have done in this case, is simply retrieve the problematic files from a different mirror, or wait a few minutes before attempting to download the file again.

Anyhow, if you are going to use wget to download the packages for you, and have created a list of required files to update your system, you do not have to edit out the additional information in the package list you have created, you can simply use wget's -i option. Be sure to position yourself in the directory to which you want to place the downloaded files, by using the "cd" command. On a linux system, you could enter the following commands. Use the ampersand "&" at the end of the wget command, if you wish to have continued access to the command line while wget is in process. For other useful options, read the man page for wget.

cd /mnt/repository/
wget -i pkglist.txt &

However, when I used this -i option with wget, it did come back and complain that it could not find the words on the page that were not urls. So, it may be better to go ahead and edit out everything other than the urls on the page. These errors will not keep wget from downloading packages, but they are annoying to have in the output. We may be able to use various command line flags for wget that will keep it from generating these errors on words that are not URLs, but I have not researched those possibilities at this point.

If computer memory or online access time is limited, you may wish to examine the sizes of the files you are preparing to download. You can do this by using a browser or search engine to study the contents of the various mirror lists. But another option, if you have downloaded the index files for each directory, is to use command line tools to pull out the information you need.

I use grep to do this, as well as to automate the extraction of the full URLs for dependencies from the results.

[alarmpi ~] grep \>strace *html | sed 's/\(.*\)\.html:.*<a href="\(.*[xg]z\)">.*/wget http:\/\/us.mirror.archlinuxarm.org\/armv6h\/\1\/\2/'
wget http://us.mirror.archlinuxarm.org/armv6h/extra/strace-4.7-1-armv6h.pkg.tar.xz
[alarmpi ~]
[alarmpi ~] grep \>glib2- *html | sed 's/\(.*\)\.html:.*<a href="\(.*xz\)">.*/wget http:\/\/us.mirror.archlinuxarm.org\/armv6h\/\1\/\2/'
wget http://us.mirror.archlinuxarm.org/armv6h/community/glib2-docs-2.32.1-1-any.pkg.tar.xz
wget http://us.mirror.archlinuxarm.org/armv6h/core/glib2-2.34.3-1-armv6h.pkg.tar.xz
[alarmpi ~] grep \>glib2-[012345678] *html | sed 's/\(.*\)\.html:.*<a href="\(.*xz\)">.*/wget http:\/\/us.mirror.archlinuxarm.org\/armv6h\/\1\/\2/'
wget http://us.mirror.archlinuxarm.org/armv6h/core/glib2-2.34.3-1-armv6h.pkg.tar.xz
[alarmpi ~]

FINISH SYNCING WITH REPOSITORY

15. As mentioned above, it is highly recommended that you sync your system with the repository before installing any new packages. But, because there is always the risk of your system getting compromised if there are issues that occur during the update process, you should be sure to make a backup first. Making a full system backup is also essential because, with the way that Arch works, with it's rolling releases, there is always the risk that an application will not work the way you like after an update. If you have a full system backup, and downgrading does not work as you would like, you can always revert to that backup, and wait until undesired bugs have been fixed to perform your sync with the repository.

16. Then, once you have created a list of the packages needed to update your system, downloaded all the packages, and placed them in your local repository, all as explained above, you can use either of two basic methods for complete syncing your system with the repository. Please post on the Raspberry Pi Arch forum or PM me if you have problems or encounter errors.
 
There are two basic approaches for performing the actual syncing your system with the repository. For more details about the first method, please see the suggested reading below. I have primarily used the second method on my main SD card, at this point, because there have been issues with updating various optional packages that I have installed, but I have also succeeded in using the first method when running it on a relatively new image on which I had only installed about a half dozen optional packages in addition to the vanilla image. Please PM me at raspberrypi.org, especially if you find errors or have suggestions for improving this section.

(1) Place all the downloaded packages in a local repository you have listed in /etc/pacman.conf (as in steps 8 and 9 above), and then issue the following command.:
 
   pacman -Su
 
NOTE: I have only been able to get this method to work when I have been quick enough in downloading all packages required for a complete update before some of them disappeared from the repository due to some of them getting superceded by updating that occurred between the time I downloaded my db files and went back to the repository to retrieve the file. I also think we may not be able to successfully run pacman -Su if we have installed any packages that are more recent that the db files we have.
 
(2) The other method, which can work quite well if there are only a few packages required to update your system, is to use pacman -U. You can use this method no matter how many packages are required to update your system, it simply can be more tedious than the first method if there are a lot of packages involved. This second method is the one that I have used the most, for updating my system, because it has given me a little more control over the process and enabled me to get around installation problems and bugs more easily. You could theoretically install all the packages needed to update your system with this method, but the above method may be less work and less subject to error and other problems:
 
   pacman -U path-to/package1.tar.xz path-to/package2.tar.xz path-to/package3.tar.xz path-to/package1.tar.xz path-to/package4.tar.xz
 
To simply things using this second method, I created my package lists for the pacman -U commands by using grep on the original package list to first pull out the list of packages needed from the alarm directory. Then I used sed to turn that into a list with package names only, and the "tr" command to put all the package names into one line. Then I changed to the directory containing those packages, and issued pacman -U from there.
 
Note I can either copy and paste the output of the following, route it to a file, or use it on the same line as my pacman -U. The first example shows me routing the output to a file and then sending it to pacman
 
   cd /mnt/repository/packages
   grep \/alarm\/ mypackagelist.txt | sed 's/.*\///' | tr '\n' ' ' > alarmpackages.txt
   cat alarmpackages.txt | pacman -U -
 
This next example shows me creating the list and feeding it to pacman directly. Make sure to use a single back tick to enclose the grep, sed and tr commands if you choose this method:
 
   cd /mnt/repository/packages
   pacman -U `grep \/alarm\/ mypackagelist.txt | sed 's/.*\///' | tr '\n' ' '`

If you choose to use this second method to sync your system, and there are too many packages needed to place them all in one call to pacman, then it would be wise to first upgrade all the packages in the alarm and then, immediately, in the core directories, before the other ones. If you are unable to upgrade all of the packages in both alarm and core immediately, then, if any of the following packages appear on your package list, put their current versions in your first call to pacman, to make sure that the basic minimal system upgrade is completed in one step:

raspberrypi-firmware
raspberrypi-firmware-bootloader
raspberrypi-firmware-bootloader-x
raspberrypi-emergency-kernel
raspberrypi-firmware-examples
raspberrypi-firmware-tools
linux-headers-raspberrypi
linux-raspberrypi
linux-api-headers

Note that it is best to upgrade the whole system at once, and that the kind of partial syncing I discuss using, in the latter part of method (2) above, is definitely frowned upon. However, if you are totally unable to perform the syncing properly, I have provided you with one possible alternative approach, to help you in your efforts to figure out how to upgrade your system without too much confusion if you are unable to upgrade properly.

INSTALLING NEW PACKAGES

DETERMINE PACKAGE DEPENDENCIES

17. You can use pacman to determine the dependencies of packages not yet installed on your system. In order to do this, for files in a local repository, you can enter the following command, which will provide a simple list of the dependencies, along with the location of the package you intend to install:

pacman -Up PATH-TO-YOUR-PACKAGE/PACKAGE-NAME

If you do not yet have Arch installed, it is also possible to research dependencies on the web. But researching dependencies is not quick and easy, especially in cases where there may be quite a few layers of dependencies.

If you are researching package dependencies before getting your Pi, and do not have access to another Arch Linux system, you can enter the name of the package you are interested in, into a web search engine, and then click on the name of each dependency to find out it's dependencies. The search terms I used to find the archlinux package repository pages for each package, when doing this with google, were:

archlinux dependencies maintainer PACKAGENAME

Yes, package installation is much easier if the Raspberry Pi has Internet access, because then pacman can do all the hard work. But when that was not possible, web research worked quite well for me, in enabling me to have packages with their dependencies, already downloaded and ready to install, once my Pi arrived.

But now that I have ArchLinux installed, I ask pacman to tell me the dependencies. It is possible to use the Query option for pacman, to get a list of dependencies for a package, but it only provides the first level of dependencies, and does not list the dependencies of the dependencies themselves. Using pacman -Up is a better way to get a more complete list of package dependencies for a package which has not yet been installed, but you will need to have a copy of the package that pacman can access, in order to perform this operation.

[alarmpi ~] pacman -Up PATH-TO-PACKAGE/PACKAGENAME

Also note that not all packagers follow the rule of listing all levels of dependencies. So, even when you do your very best to obtain all required dependencies, you may discover that more packages are required in order to install or run a particular application, than are listed as dependencies. In that case, you may need to start the application from the command line, and paste the error messages into a search engine, to find out what additional package or packages are required.

Once a package has been installed, it's dependencies can also be checked with the ldd command, but ldd also only looks for first level dependencies, and will not tell you which package those dependencies are contained in, if they are combined with other utilities in a package.

LOCATE REQUIRED DEPENDENCIES

18. See the section above about identifying dependencies, if you have not already done so. In order to get the URLs for the new packages you wish to install, along with their dependencies, I suggest downloading the index files for the core, extra, community, alarm and aur directories on your preferred mirror. I suggest using a tool such as wget or curl to obtain copies of these index files, as follows. To obtain the index files for the package directories from your mirror of choice, if you are using wget, you would enter:

wget -O alarm.html URL-OF-MIRROR/alarm/
wget -O aur.html URL-OF-MIRROR/aur/
wget -O community.html URL-OF-MIRROR/communityt/
wget -O core.html URL-OF-MIRROR/core/
wget -O extra.html URL-OF-MIRROR/extra/

As an example, here is the actual wget command I use to obtain the index file for the alarm directory from the US mirror for armv6h:

wget -O alarm.html http://us.mirror.archlinuxarm.org/armv6h/alarm/

Then, to create the URL for a desired package, I use grep and feed the results thru sed, to automate the extraction of the full URLs for dependencies from the results. I have put the code into a script, to make typing easier for me, but am simply reproducing the code I use here, to simplify the explanation. You would substitute the URL of your chosen mirror for the URLs in the examples below:

[alarmpi ~] grep \>strace *html | sed 's/\(.*\)\.html:.*<a href="\(.*[xg]z\)">.*/wget http:\/\/us.mirror.archlinuxarm.org\/armv6h\/\1\/\2/'
wget http://us.mirror.archlinuxarm.org/armv6h/extra/strace-4.7-1-armv6h.pkg.tar.xz
[alarmpi ~]
[alarmpi ~] grep \>glib2- *html | sed 's/\(.*\)\.html:.*<a href="\(.*xz\)">.*/wget http:\/\/us.mirror.archlinuxarm.org\/armv6h\/\1\/\2/'
wget http://us.mirror.archlinuxarm.org/armv6h/community/glib2-docs-2.32.1-1-any.pkg.tar.xz
wget http://us.mirror.archlinuxarm.org/armv6h/core/glib2-2.34.3-1-armv6h.pkg.tar.xz
[alarmpi ~] grep \>glib2-[012345678] *html | sed 's/\(.*\)\.html:.*<a href="\(.*xz\)">.*/wget http:\/\/us.mirror.archlinuxarm.org\/armv6h\/\1\/\2/'
wget http://us.mirror.archlinuxarm.org/armv6h/core/glib2-2.34.3-1-armv6h.pkg.tar.xz
[alarmpi ~]

INSTALL PACKAGES

19. Once you complete downloading the official database files, and all desired packages and dependencies, move the medium back to the target system.

20. Back Up Your Target System! I cannot overemphasize the importance of backing up your system before running any pacman updates. While most Arch updates can be rolled back to prior versions if they are broken, there are occasionally instances where the entire file system can get badly corrupted. Think twice before you decide to skip this step. If you have put a lot of work into anything on your system, make sure you have a good backup before risking losing all of that work.

21. Run pacman. If you have everything you need to install a package, including it's dependencies, in your local repository, I have been told it can be installed with the -S option, but I have not been able to get that to work for initial offline installation of a package. So, to install a package, I recommend the following command:

pacman -U /path/to/package/your-package-vers ion.pkg.tar.xz

Pacman will respond with a listing including any required dependencies, all listed as "Targets," and ask you if you wish to proceed with installation. At this point, you can enter Y or n.

If you enter Y, pacman will proceed with installation without querying you again if all the dependencies are found.

The following is example output from attempting to install a package for which I did not yet have the dependencies, and in which I had not yet commented out the URLs of the standard mirror lists:

[root@alarmpi ~]# pacman -U /media/custom/wvdial-1.61-4-arm.pkg.tar.xz
loading packages...
resolving dependencies...
looking for inter-conflicts...

Targets (3): wvstreams-4.6.1-5 xplc-0.3.13-4
wvdial-1.61-4

Total Download Size: 1.04 MiB
Total Installed Size: 8.10 MiB

Proceed with installation? [Y/n] Y
:: Retrieving packages from community...
error: failed retrieving file 'xplc-0.3.13-4-arm.pkg.tar.xz' from mirror.archlinuxarm.org : Could not resolve host: mirror.archlinuxarm.org;
Unknown error
warning: failed to retrieve some files from community
error: failed retrieving file 'wvstreams-4.6.1-5-arm.pkg.tar.xz' from mirror.archlinuxarm.org
: Could not resolve host: mirror.archlinuxarm.org; Unknown error
warning: failed to retrieve some files from community
error: failed to commit transaction (download library error)
Errors occurred, no packages were upgraded.
[root@alarmpi ~]

To keep pacman from hunting for online repositories, I commented out the URLs of the online repositories in my pacman.conf. And to have it automatically retrieve the dependencies I had placed in my local repository, the command to run pacman was the same, the only difference was that I had placed the dependencies in my local repository and declared it in my pacman.conf. For more details about these steps, see steps 8 and 9 in the section above about about configuring pacman.

[root@alarmpi ~] pacman -U /path/to/package/package_name-version.pkg.tar.xz

TROUBLESHOOTING

In most cases, problems with installing and upgrading packages with pacman can be resolved by making sure that you have the most recent copies of all required packages. On an Arch system with internet access, you would do "pacman -Syyu". The best you can do if your system does not have internet access, is to repeat the steps above, refreshing the db files and index files from the mirrors, and then trying again with the most recent files.

In some cases, it may be helpful to have pacman ignore dependency version checks when installing a package, and then using the pactree command to find out missing dependencies for the package. If you have downloaded the most recent versions of a package and it's dependency, and pacman will not install the package because it is looking for an older version of a dependency, then you will want to have pacman bypass dependency version checks.

If you get output that looks like the following, and have made a more recent version of the dependency available to pacman, bypassing dependency version checks to install your package may be helpful.

error: failed retrieving file 'gtk2-2.24.14-1-armv6h.pkg.tar.xz' from disk : Couldn't open file /mnt/repository/gtk2-2.24.14-1-armv6h.pkg.tar.xz
warning: failed to retrieve some files from extra
error: failed to commit transaction (download library error)
Errors occurred, no packages were upgraded.

To install the package without dependency version checks, I would issue the following command:

pacman -U /mnt/repository/libunique-1.1.6-5-armv6h.pkg.tar.xz -d

To install the package bypassing all dependency checks, I would issue the following command:

pacman -U /mnt/repository/libunique-1.1.6-5-armv6h.pkg.tar.xz -d -d

Then, after running the above commands and installing the package, you can run pactree to create a dependency tree, which will indicate which dependencies have not been satisfied.

pactree PACKAGENAME

Since the output of the above command can be lengthy, I like piping it to grep so I can see what dependencies I still need to install. There will be no output unless there are missing dependencies:

pactree PACKAGENAME | grep resolv

Here is an example of the output I obtained after installing libunique without dependency checking and running pactree. It told me that I needed to install gtk2:

[alarmpi ~] pactree libunique | grep resolv
   |--gtk2 [unresolvable]
[alarmpi ~]

If the above steps do not resolve your difficulties, then copy and paste your errors into a google search, with quotes around the error, and see if you can find a solution already posted on the web. But just put one line at a time into the search engine, each line is a separate error.

For example, I could not upgrade most of the packages from the "extra" directory, due to file and library conflicts. But, pasting the errors into google, I saw that other arch linux users had posted queries about the same problem with a recent update, and that a bug had been reported upstream that had not been fixed until after I had updated my db and package files.

The solution in many of these cases, where a bug has been reported, is to wait a few days until the bug is fixed and then start the syncing process over again.

If no one else has posted a query about your error with a possible solution then, after making sure that you have the most recent files required to sync your system, take your query to IRC or to one of the online Arch Linux or Raspberry Pi forums or mailing lists for help.

If a package breaks after an upgrade, then you would follow the same steps as above. If that does not work, you can revert to an earlier version of the package if you have saved copies of the original versions of the package and it's dependencies, either by leaving them in pacman's cache (/var/cache/pacman/pkg) or in your local repository. The problem should still be reported, but until it gets fixed, you would use the following command to downgrade your package to the version that was working for you (not tested by author, see man and wiki pages for more information):

pacman -Suu PACKAGENAME

If you get error messages such as the following, it will mean that you still need to put a copy of the db file for the specific repository into a location that was properly declared in pacman.conf, and is accessible to pacman. See the sections above about configuring pacman and updating local sync files:

warning: database file for 'custom' does not exist
warning: database file for 'repository' does not exist
error: failed to prepare transaction (could not find database)

ADDITIONAL OPTIONS

This is a short list of selected options that have special relevance to running pacman offline. For a complete list of pacman's options, type "man pacman" or read an online man page, such as one listed in the recommended reading section below.

If you have an internet connection for your Raspberry Pi or other Arch Linux system, but would prefer to download packages now, and install them later when your system is not online, you can use the -w option to only download packages without installing or upgrading any of them.

pacman -w PACKAGE1 PACKAGE2 PACKAGE3

If you are having difficulty figuring out the dependencies for a package, and it has already been installed, you can run a dependency test on it, using either of the following two commands:

pacman -T PACKAGENAME
pacman --deptest PACKAGENAME

ADDITIONAL READING

Reading or at least skimming through the man pages for pacman, pacman.conf, and repo-add, are essential for knowledgeable use of pacman. You can access them on any arch system by entering the following commands.

[alarmpi ~] man pacman
[alarmpi ~] man pacman.conf
[alarmpi ~] man repo-add

If you do not have access to an arch system to read the man pages, and wish to read online versions of the man pages relevant to running pacman, here are links to the official man pages.

http://www.archlinux.org/pacman/pacman.8.html
 
http://www.archlinux.org/pacman/pacman.conf.5.html
 
http://www.archlinux.org/pacman/repo-add.8.html

If you are a beginner, or new to using pacman, the following wiki pages can probably help in understanding the process better, and discussing options not mentioned above. However, as is true with all wiki pages, there may be errors, so make sure to back up all your work, in case any of the suggested procedures do not have the desired effects on your system. Note that the "Offline_Installation_of_Packages" wiki page is especially out of date and has some errors, but is still a classic reference.

https://wiki.archlinux.org/index.php/Pacman
 
https://wiki.archlinux.org/index.php?title=Offline_Installation_of_Packages
 
https://wiki.archlinux.org/index.php?title=Offline_Installation_of_Packages&oldid=238004
 
https://wiki.archlinux.org/index.php/Downgrading_Packages

The following two wiki pages discuss methods for sharing downloaded packages on a LAN:

https://wiki.archlinux.org/index.php?title=Local_repository&oldid=210878
 
https://wiki.archlinux.org/index.php/Custom_local_repository_with_ABS_and_gensync

If you are an advanced user, you may want to look at the following script which is supposed to automate some of pacman offline usage.

https://github.com/boyska/pacman-offline
 
https://github.com/boyska/pacman-offline/blob/master/pacman-offline.sh
 
RAW CODE: https://raw.github.com/dracorp/offline-upgrade/master/offline-upgrade.sh

 

Last Revised May 29, 2013