bacpac

2014-05-09 14:55 UTC
  • Xyne

Metadata

Description:

Pacman-independent portable package downloader with dependency resolution.

Latest Version:

2013.6

Architecture:

  • any

Dependencies:

  • python3

Optional Dependencies:

  • pyalpm: support for generating JSON provider databases

Arch Repositories:

  • [xyne-any]
  • [xyne-i686]
  • [xyne-x86_64]

AUR ID:

68659

Arch Forum ID:

160069

Tags:

About

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

Caveats

  • 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> [<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.

optional arguments:
  -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.

Package Information Example

$ bacpac --metadata-dir /tmp/bacpac.meta -i pacman

{
  "arch": "x86_64",
  "build_date": "2014-05-04T02:49:10Z",
  "compressed_size": 594488,
  "conflicts": [
    "pacman-contrib"
  ],
  "depends": [
    "archlinux-keyring",
    "bash>=4.2.042-2",
    "curl>=7.19.4",
    "fakechroot",
    "fakeroot: for makepkg usage as normal user",
    "glibc>=2.17-2",
    "gpgme",
    "libarchive>=3.1.2",
    "pacman-mirrorlist",
    "python2"
  ],
  "epoch": 0,
  "filename": "pacman-4.1.2-6-x86_64.pkg.tar.xz",
  "flag_date": null,
  "groups": [
    "base",
    "base-devel"
  ],
  "installed_size": 3869696,
  "last_update": "2014-05-09T01:22:59.986Z",
  "licenses": [
    "GPL"
  ],
  "maintainers": [
    "dan",
    "dreisner"
  ],
  "packager": "allan",
  "pkgbase": "pacman",
  "pkgdesc": "A library-based package manager with dependency support",
  "pkgname": "pacman",
  "pkgrel": "6",
  "pkgver": "4.1.2",
  "provides": [
    "pacman-contrib"
  ],
  "replaces": [
    "pacman-contrib"
  ],
  "repo": "core",
  "url": "http://www.archlinux.org/pacman/"
}

Providers Database

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

providers.json

CHANGELOG

2013-03-30

  • 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.
Contact
echo xyne.archlinux.ca | sed 's/\./@/'
Feeds
Blog News
Validation
XHTML 1.0 Strict CSS level 3 Atom 1.0