pacdiff
Merge updated configuration files after package updates
TLDR
Review files that need maintenance in interactive mode
Use sudo and sudoedit to remove and merge files
Review files needing maintenance, creating .bakups of the original if you (O)verwrite
Use a specific editor to view and merge configuration files (default is vim -d)
Scan for configuration files with locate instead of using pacman database
Display help
SYNOPSIS
pacdiff
DESCRIPTION
pacdiff is a utility from the pacman-contrib package for Arch Linux. Its primary function is to help system administrators manage configuration file changes after a system upgrade or package installation.
When pacman updates a package, it may encounter situations where a configuration file provided by the package has changed, but the user has also modified their local version of that file. To prevent overwriting user customizations, pacman saves the new package version as a .pacnew file (e.g., foo.conf.pacnew) or saves the user's old version as a .pacsave file. pacdiff scans for these files (as well as .pacorig files, though less common) and presents them to the user, typically opening them in a diff viewer (like vimdiff, meld, or standard diff) to allow for merging, keeping the old/new version, or deleting the temporary file. This ensures that system configuration files are kept up-to-date while preserving user-specific modifications.
CAVEATS
- Requires manual intervention for each detected configuration file, which can be time-consuming after large upgrades.
- Incorrectly merging or choosing the wrong version of a configuration file can lead to system instability or broken functionality.
- pacdiff relies on environment variables like DIFFPROG, EDITOR, or PAGER being set. If these are not configured to an interactive diff tool (e.g., vimdiff, meld), the default behavior might be less user-friendly (e.g., standard diff output followed by less).
HOW IT WORKS
pacdiff scans key system directories, most notably /etc, for files ending with .pacnew, .pacsave, and .pacorig. For each such file found, it identifies its original counterpart and then typically prompts the user with a set of options.
INTERACTIVE PROMPT OPTIONS
When pacdiff finds a modified configuration file, it presents a prompt. Common options include:
- y: View the differences between the current file and the .pacnew/.pacsave file in the configured diff program.
- n: Skip this file and proceed to the next one.
- v: View the file in a pager (e.g., less) without opening a diff tool.
- d: Delete the .pacnew or .pacsave file, effectively keeping the current version and discarding the new/old package version.
- q: Quit pacdiff.
CONFIGURING DIFF PROGRAM
The behavior of pacdiff when viewing differences is determined by environment variables, in order of precedence:
- DIFFPROG: If set, pacdiff will use this command (e.g., DIFFPROG=vimdiff pacdiff or globally setting it in your shell profile).
- EDITOR: If DIFFPROG is not set, pacdiff falls back to using the program specified by EDITOR (e.g., EDITOR=vim).
- PAGER: If neither DIFFPROG nor EDITOR is set, it may use PAGER for viewing.
- Default: If none of the above are set, pacdiff will typically use standard diff for comparisons and less for viewing. For an interactive and efficient workflow, setting DIFFPROG to a visual diff tool like vimdiff, meld, or kdiff3 is highly recommended.
HISTORY
pacdiff is an integral part of the pacman-contrib package, which provides a collection of helpful scripts and tools for the Arch Linux package manager, pacman. It has been a standard utility for Arch Linux users for many years, evolving alongside pacman to address the crucial aspect of configuration file management during system updates. Its design is minimalist, focusing on identifying the relevant files and then delegating the actual merging or comparison work to external diff programs configured by the user.