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=94c40083650228db47edb71135ccc08a1fa2f3ee commit 94c40083650228db47edb71135ccc08a1fa2f3ee Author: Guillem Jover <[email protected]> AuthorDate: Thu Aug 26 04:07:32 2021 +0200 dpkg-db-backup: New program factored out from Debian-specific daily cron This can be useful for other distributions and non-derivative systems that package dpkg. It will also make it possible to add native systemd timers and use a single shared implementation. --- debian/dpkg.cron.daily | 41 +--------------------- debian/dpkg.install | 1 + scripts/.gitignore | 1 + scripts/Makefile.am | 6 ++++ .../dpkg.cron.daily => scripts/dpkg-db-backup.sh | 0 t/shellcheck.t | 1 + 6 files changed, 10 insertions(+), 40 deletions(-) diff --git a/debian/dpkg.cron.daily b/debian/dpkg.cron.daily index 11124f7dd..c449bc3df 100644 --- a/debian/dpkg.cron.daily +++ b/debian/dpkg.cron.daily @@ -1,42 +1,3 @@ #!/bin/sh -dbdir=/var/lib/dpkg - -# Backup the 7 last versions of dpkg databases containing user data. -if cd /var/backups ; then - # We backup all relevant database files if any has changed, so that - # the rotation number always contains an internally consistent set. - dbchanged=no - dbfiles="arch status diversions statoverride" - for db in $dbfiles ; do - if ! [ -s "dpkg.${db}.0" ] && ! [ -s "$dbdir/$db" ]; then - # Special case the files not existing or being empty as being equal. - continue - elif ! cmp -s "dpkg.${db}.0" "$dbdir/$db"; then - dbchanged=yes - break - fi - done - if [ "$dbchanged" = "yes" ] ; then - for db in $dbfiles ; do - if [ -e "$dbdir/$db" ]; then - cp -p "$dbdir/$db" "dpkg.$db" - else - touch "dpkg.$db" - fi - savelog -c 7 "dpkg.$db" >/dev/null - done - fi - - # The alternatives database is independent from the dpkg database. - dbalt=alternatives - - # XXX: Ideally we'd use --warning=none instead of discarding stderr, but - # as of GNU tar 1.27.1, it does not seem to work reliably (see #749307). - if ! test -e ${dbalt}.tar.0 || - ! tar -df ${dbalt}.tar.0 -C $dbdir $dbalt >/dev/null 2>&1 ; - then - tar -cf ${dbalt}.tar -C $dbdir $dbalt >/dev/null 2>&1 - savelog -c 7 ${dbalt}.tar >/dev/null - fi -fi +/usr/libexec/dpkg/dpkg-db-backup diff --git a/debian/dpkg.install b/debian/dpkg.install index 6ca525256..5196e3967 100644 --- a/debian/dpkg.install +++ b/debian/dpkg.install @@ -14,6 +14,7 @@ usr/bin/dpkg-split usr/bin/dpkg-statoverride usr/bin/dpkg-trigger usr/bin/update-alternatives +usr/lib/dpkg/dpkg-db-backup usr/libexec/dpkg/ usr/share/dpkg/*table usr/share/dpkg/sh/dpkg-error.sh usr/share/lintian/profiles diff --git a/scripts/.gitignore b/scripts/.gitignore index 2acfbb282..286bb3576 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore @@ -4,6 +4,7 @@ dpkg-architecture dpkg-buildflags dpkg-buildpackage dpkg-checkbuilddeps +dpkg-db-backup dpkg-distaddfile dpkg-fsys-usrunmess dpkg-genbuildinfo diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 49a5c0cce..23f70b795 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -2,6 +2,10 @@ SUBDIRS = mk po +pkglibexec_SCRIPTS = \ + dpkg-db-backup \ + # EOL + sbin_SCRIPTS = \ dpkg-fsys-usrunmess @@ -31,6 +35,7 @@ EXTRA_DIST = \ dpkg-buildflags.pl \ dpkg-buildpackage.pl \ dpkg-checkbuilddeps.pl \ + dpkg-db-backup.sh \ dpkg-distaddfile.pl \ dpkg-fsys-usrunmess.pl \ dpkg-genbuildinfo.pl \ @@ -60,6 +65,7 @@ dist_zshcompletions_DATA = \ CLEANFILES = \ $(test_data_objects) \ + $(pkglibexec_SCRIPTS) \ $(sbin_SCRIPTS) \ $(bin_SCRIPTS) diff --git a/debian/dpkg.cron.daily b/scripts/dpkg-db-backup.sh old mode 100644 new mode 100755 similarity index 100% copy from debian/dpkg.cron.daily copy to scripts/dpkg-db-backup.sh diff --git a/t/shellcheck.t b/t/shellcheck.t index d2fcb2d22..c0a482104 100644 --- a/t/shellcheck.t +++ b/t/shellcheck.t @@ -37,6 +37,7 @@ my @files = qw( run-script debian/dpkg.cron.daily debian/dpkg.postrm + scripts/dpkg-db-backup.sh scripts/dpkg-maintscript-helper.sh scripts/dpkg-realpath.sh ); -- Dpkg.Org's dpkg

