makedep

2022-07-15 12:40 UTC
  • Xyne

Metadata

Description: Convert Pacman optional dependencies to real dependencies.
Latest Version: 2014.8
Source Code: src/
Architecture:
  • any
Dependencies:
  • pacman
  • pyalpm
  • python3
Arch Repositories:
  • [xyne-any]
  • [xyne-i686]
  • [xyne-x86_64]
AUR Page: makedep
Arch Forum Thread: 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.

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.org | sed 's/\./@/'
Validation
XHTML 1.0 Strict CSS level 3 Atom 1.0