Skip to content

Commit

Permalink
dpkg-imediff: start a merge editor when dpkg needs resolving a conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
hydrargyrum committed Oct 6, 2023
1 parent 4b08f50 commit 4d18c97
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This repository hosts various small personal tools.
- [`crc`](crc): basic CRC computation tool
- [`csv2json`](csv2json): transform CSV into JSON
- [`csv2table`](csv2table): pretty-print a CSV file with ASCII-art table
- [`dpkg-imediff`](dpkg-imediff): when dpkg interactively prompts for resolving a config file conflict, run this to start a merge editor
- [`exiforientergui`](exiforientergui): GUI to losslessly modify EXIF orientation of an image
- [`ffmcut`](ffmcut): ffmpeg wrapper to cut a video between 2 timestamps
- [`firefox-relay-tools/fxrelay-add`](firefox-relay-tools/fxrelay-add): add a Firefox Relay address
Expand Down
26 changes: 26 additions & 0 deletions dpkg-imediff/dpkg-imediff
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh -eu
# SPDX-License-Identifier: WTFPL

# When installing packages, dpkg needs to preserve modifications to files in
# /etc, but sometimes a config file was also modified in the package, leading
# to a conflict. dpkg prompts what to do:
# Y: overwrite modifications to /etc, force package content
# N: don't use package content, keep /etc modifications
# Z: start a shell
# imediff is an editor for resolving conflicts.
# So, use `Z` command and just start `dpkg-imediff`. imediff must be installed.

error () {
echo "error: $1" >&2
exit 1
}

if [ $# -gt 0 ]
then
error "$0 must be called within a dpkg conflict shell, without arguments"
elif [ -z "${DPKG_CONFFILE_OLD-}" ]
then
error "$0 must be called within a dpkg conflict shell"
fi

imediff -o "$DPKG_CONFFILE_OLD" "$DPKG_CONFFILE_OLD" "$DPKG_CONFFILE_NEW"

0 comments on commit 4d18c97

Please sign in to comment.