Description: | Pacman-independent portable package downloader with dependency resolution. |
Latest Version: | 2014 |
Source Code: | src/ |
Architecture: |
|
Dependencies: |
|
Optional Dependencies: |
|
Arch Repositories: |
|
AUR Page: | bacpac |
Arch Forum Thread: | 160069 |
Tags: |
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
Download a copy of the providers.json file for these examples.
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)
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.
$ 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.
options:
-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
selection).
Metadata:
--gen-providers Create a database of provider packages in JSON format
(pyalpm required).
--use-providers <filepath>
Use a database of provider packages for dependency
resolution.
--metadata-dir <dirpath>
Path to cached package metadata. Default: bacpac.meta.
$ bacpac --metadata-dir /tmp/bacpac.meta --gen-providers > providers.json