makedep

2014-08-01 00:46 UTC
  • Xyne

Metadata

Description:

Convert Pacman optional dependencies to real dependencies.

Latest Version:

2014.8

Architecture:

  • any

Dependencies:

  • python3
  • pyalpm<0.7
  • pacman<4.2

Arch Repositories:

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

AUR ID:

66455

Arch Forum ID:

156508

Tags:

About

Makedep modifies files in the Pacman local database to add user-defined dependencies to installed packages. The main purpose is to convert optional dependencies to true dependencies so that they can be installed as such and not appear as orphans in the output of pacman -Qdt. Usage is not limited to optional dependencies so any package can be made to depend on any other. This can be used to tie packages together so that they can be removed with a top-level package via pacman -Rc.... It may even be useful for creating empty packages to act as metapackages.

Examples

$ pacman -Qi picard chromaprint
Name           : picard
Version        : 1.1-1
...
Depends On     : python2-pyqt  mutagen  libofa  ffmpeg
Optional Deps  : libdiscid: CD lookup
                 chromaprint: fingerprinting

Name           : chromaprint
Version        : 0.7-1
...
Required By    : None
...
Install Reason : Installed as a dependency for another package



$ makedep picard -a chromaprint
updating picard-1.1-1



$ pacman -Qi picard chromaprint
Name           : picard
Version        : 1.1-1
...
Depends On     : python2-pyqt  mutagen  libofa  ffmpeg  chromaprint
Optional Deps  : libdiscid: CD lookup
                 chromaprint: fingerprinting

Name           : chromaprint
Version        : 0.7-1
...
Required By    : picard
...
Install Reason : Installed as a dependency for another package



$ makedep -s
picard
  chromaprint

Makedep can of course also remove added packages. See the help message for a full list of options.

Caveats

When a local package is upgraded, the local database files are replaced. Makedep can re-add dependencies with makedep -u. You could use the following script as a pacman wrapper for sync operations to automate this (replace /usr/bin/pacman with the path to your favorite Pacman wrapper:

#/bin/sh
/usr/bin/pacman -S "$@"
/usr/bin/makedep -u

Save that as e.g. pacman-S and then use it as follows:

# System upgrade
pacman-S -yu

# Install package
pacman-S foo

Technical Notes

Given that this modifies files in the local database, several precautions have been taken:

  • Both the pacman database and the makedep database are locked prior to operations that may change them.
  • Files are written to disk in an order that ensures that a crash between writes will not disrupt integrity.
  • Files are backed up prior to each write in case a crash occurs while writing a file.
  • Dependencies that cannot be satisfied by currently installed packages are refused.
  • Only dependencies that have been added to a package by makedep may be removed.
  • The package depends on the current version of both pacman and pyalpm so that it must be checked and updated if either of those packages change.

TODO

Explore the idea of metapackages further. It may be very useful in combination with a repackaging tool to maintain the same package set on different systems.

Help Message

$ makedep --help

usage: makedep [-h] [--config </path/to/pacman.conf>]
               [-a <pkgname> [<pkgname> ...]] [-c] [-p]
               [-r [<pkgname> [<pkgname> ...]]] [-s] [-u]
               [--add-as {deps,explicit}] [--remove-as {deps,explicit}]
               [--print-dbpath]
               [<pkgname> [<pkgname> ...]]

Add custom dependencies to installed Pacman packages. This is intended mainly
for optional dependencies, but it works with any package.

positional arguments:
  <pkgname>             Packages the metadata of which will be modified.

optional arguments:
  -h, --help            show this help message and exit
  --config </path/to/pacman.conf>
                        The path to a Pacman configuration file. This
                        determines the location of the database. Default:
                        /etc/pacman.conf
  -a <pkgname> [<pkgname> ...], --add <pkgname> [<pkgname> ...]
                        New dependencies to add to the target packages.
  -c, --clean           Remove entries for packages that are no longer
                        installed.
  -p, --purge           Remove all entries and reset the local database files.
  -r [<pkgname> [<pkgname> ...]], --remove [<pkgname> [<pkgname> ...]]
                        Dependencies to remove from the target packages. This
                        will only remove dependencies that have been
                        previously added with makedep. If no dependencies are
                        listed then all added dependencies will be removed.
  -s, --show            Show added dependencies for the given packages, or all
                        packages if none given.
  -u, --update          Re-apply changes to the local database. Run this after
                        upgrading packages.
  --add-as {deps,explicit}
                        Set the installation reason of the added dependencies.
  --remove-as {deps,explicit}
                        Set the installation reason of the removed
                        dependencies.
  --print-dbpath        Print the path to the makedep database for the current
                        operation.

Caveat: the arguments that accept lists (-a, -r) will consume all non-option
arguments that follow until the next option of the end of the list. Use "--"
to explicitly end the argument list when no other options will follow.

CHANGELOG

2014-07-28

  • restructured code

2014-07-26

  • updated string format operations to use format method
  • converted error to warning when adding uninstalled packages as dependencies
  • added option to remove all added dependencies for the target packages

2013-12-07

  • fixed help message for -u option
  • added help message epilog to explain list options (-a and -r)
  • added --add-as and --remove-as options for setting installation reasons
Contact
echo xyne.archlinux.ca | sed 's/\./@/'
Feeds
Blog News
Validation
XHTML 1.0 Strict CSS level 3 Atom 1.0