dpkg-genbuildinfo: Parse Provides as virtual packages
[dpkg.git] / src / dpkg-db-keeper.sh
blob8c99a4c2038a6c9996cc52d5c2c64226766b93d3
1 #!/bin/sh
3 # Copyright © 2023 Guillem Jover <guillem@debian.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
18 PROGNAME=$(basename "$0")
19 ADMINDIR=/var/lib/dpkg
21 PKGDATADIR_DEFAULT=src
22 PKGDATADIR="${DPKG_DATADIR:-$PKGDATADIR_DEFAULT}"
24 # shellcheck source=src/sh/dpkg-error.sh
25 . "$PKGDATADIR/sh/dpkg-error.sh"
27 setup_colors
29 # This script is used to track any change in the dpkg database for later
30 # inspection, either as a matter of record tracking or to aid in debugging
31 # dpkg behavior. It can be installed as a post-invoke hook such as:
33 # ,--- /etc/dpkg/dpkg.cfg.d/db-keeper ---
34 # post-invoke "/usr/libexec/dpkg-db-keeper"
35 # `---
37 if [ -n "$DPKG_ROOT" ]; then
38 # Only operate on the main system.
39 exit 0
42 if ! command -v git >/dev/null; then
43 # Do nothing if there is no git.
44 exit 0
47 : "${DPKG_ADMINDIR:=/var/lib/dpkg}"
49 cd "$DPKG_ADMINDIR" || exit 0
51 if [ ! -e .git ]; then
52 # Initialize the git repo.
53 git init
56 git add -A
57 git commit -m 'Commit dpkg db updates'
59 exit 0