This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=25797abf7f08c7db8c380fa08338088dd5acac49

commit 25797abf7f08c7db8c380fa08338088dd5acac49
Author: Guillem Jover <[email protected]>
AuthorDate: Fri Sep 4 00:02:44 2020 +0200

    debian: Improve cron file robustness on missing or empty backup files
    
    Check whether the database files exist and ignore them otherwise. If
    some database file has been modified, but the current file being
    processed does not exist, created an empty backup so that they are
    all in sync with their sequence number.
    
    Closes: #969472
---
 debian/dpkg.cron.daily | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/debian/dpkg.cron.daily b/debian/dpkg.cron.daily
index 0a135f729..11124f7dd 100644
--- a/debian/dpkg.cron.daily
+++ b/debian/dpkg.cron.daily
@@ -9,15 +9,21 @@ if cd /var/backups ; then
   dbchanged=no
   dbfiles="arch status diversions statoverride"
   for db in $dbfiles ; do
-    if ! cmp -s "dpkg.${db}.0" "$dbdir/$db"; then
+    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
-      [ -e "$dbdir/$db" ] || continue
-      cp -p "$dbdir/$db" "dpkg.$db"
+      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

-- 
Dpkg.Org's dpkg

Reply via email to