2024-05-17 23:40 UTC
  • Xyne


Description: Pacman-independent portable package downloader with dependency resolution.
Latest Version: 2014
Source Code: src/
  • any
  • python3
Optional Dependencies:
  • pyalpm: support for generating JSON provider databases
Arch Repositories:
  • [xyne-any]
  • [xyne-i686]
  • [xyne-x86_64]
AUR Page: bacpac
Arch Forum Thread: 160069


A while ago I found the (new?) JSON query interface for packages in the official repos and I made a note to do something with it. Now I have.

This script can be used to download packages with nearly full dependency resolution without Pacman. It “only” relies on Python 3. The idea is that it can be used to download required packages on just about any other system if you break your Arch system and don’t have a (recent) live CD for whatever reason. Once you get the packages you’ll have to extract them manually (although that may change later, but probably not).

I say “nearly full dependency resolution” because there is no automatic way to get information about providers, so the user needs to supply this. For example, if something relies on “sh”, you will need to know that you can pass “bash” as an argument. For example, to fully resolve all of Pacman’s dependencies, you will need to issue this command

$ bacpac pacman bash gawk

to resolve the “sh” and “awk” dependencies.

Bacpac provides a way to partially automate dependency resolution by using a provider database in JSON format. Pyalpm is required to generate the database (see below) but not to use it. If the provider database is used then bacpac should fully resolve dependencies:

$ bacpac --use-providers providers.json pacman


  • Versioned dependencies are not supported and are treated naïvely.
  • Pacman install scripts are not supported.
  • Optional rebuilding of the local database is rudimentary and should be used with caution.

Useful Scripts and Examples

Usage Examples

Download a copy of the providers.json file for these examples.

Arch Linux without working Pacman

Re-install pacman and all of its dependencies with bacpac, then re-install them with pacman to ensure consistency.

bacpac --use-providers providers.json --root / pacman
pacman -S $(pactree -l pacman)

Non-Arch Linux system

Install packages to a specified directory that can be copied to the root directory of the broken Arch Linux system. Use chroot to test the directory first.

bacpac --use-providers providers.json --root foo
chroot foo

Once in the changeroot, check that pacman works and then configure the chroot as necessary.

Help Message

$ bacpac --metadata-dir /tmp/bacpac.meta --help

usage: bacpac [-h] [-a <architecture>] [-d] [-i] [-p] [-r <dirpath>] [-v] [-y]
              [--asdeps] [--cachedir <dirpath>] [--noconfirm]
              [--gen-providers] [--use-providers <filepath>]
              [--metadata-dir <dirpath>]
              [<pkgname> ...]

Download Pacman packages and their dependencies.

positional arguments:
  <pkgname>             Packages to download or extract. Groups are not
                        supported. When using the "--extract" option, the
                        arguments should be filepaths to the package archives
                        instead of package names.

  -h, --help            show this help message and exit
  -a <architecture>, --arch <architecture>
                        System architecture. Default: x86_64.
  -d, --nodeps          Skip dependencies.
  -i, --info            Print package information.
  -p, --print           Print file URLs instead of downloading them.
  -r <dirpath>, --root <dirpath>
                        If set, packages will be extracted to this directory.
  -v, --verbose         Enable verbose mode.
  -y, --refresh         Refresh cached metadata.
  --asdeps              Indicate that the selected packages should be
                        extracted ("installed") as dependencies.
  --cachedir <dirpath>  Download directory for package archives.
  --noconfirm           Suppress interactive dialogues (e.g. provider

  --gen-providers       Create a database of provider packages in JSON format
                        (pyalpm required).
  --use-providers <filepath>
                        Use a database of provider packages for dependency
  --metadata-dir <dirpath>
                        Path to cached package metadata. Default: bacpac.meta.

Providers Database

$ bacpac --metadata-dir /tmp/bacpac.meta --gen-providers > providers.json




  • Added extraction (i.e. basic “installation”) support.
  • Added metadata caching.
  • Added custom mirrorlist support. (Bacman mirrorlists are not interchangeable with Pacman mirrorlists)
  • Added new options.
echo | sed 's/\./@/'
XHTML 1.0 Strict CSS level 3 Atom 1.0