This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=2a0bb88b546b36a35dc56cc65dee51f18afaf5bd commit 2a0bb88b546b36a35dc56cc65dee51f18afaf5bd Author: Guillem Jover <[email protected]> AuthorDate: Thu Mar 17 19:29:06 2022 +0100 dpkg-db-backup: Check for required commands before starting We need several commands not provided by dpkg, which might not be available on the system, at least on non-Debian systems, such as «savelog». We might eventually provide a replacement for that one, but until then, it is best to check explicitly to avoid silent breakage. --- src/dpkg-db-backup.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/dpkg-db-backup.sh b/src/dpkg-db-backup.sh index de42d2114..dbb0d6ca0 100755 --- a/src/dpkg-db-backup.sh +++ b/src/dpkg-db-backup.sh @@ -15,10 +15,19 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. +PROGNAME=$(basename "$0") ADMINDIR=/var/lib/dpkg BACKUPSDIR=/var/backups ROTATE=7 +PKGDATADIR_DEFAULT=src +PKGDATADIR="${DPKG_DATADIR:-$PKGDATADIR_DEFAULT}" + +# shellcheck source=src/sh/dpkg-error.sh +. "$PKGDATADIR/sh/dpkg-error.sh" + +setup_colors + while [ $# -ne 0 ]; do case "$1" in --rotate=*) @@ -28,6 +37,13 @@ while [ $# -ne 0 ]; do shift done +# Check for required commands availability. +for cmd in tar savelog; do + if ! command -v $cmd >/dev/null; then + error "cannot find required program '$cmd'" + fi +done + dbdir="$ADMINDIR" # Backup the N last versions of dpkg databases containing user data. -- Dpkg.Org's dpkg

