Package: dpkg
Version: 1.15.3.1
Severity: wishlist
Tags: patch

Currently the code responsible for creating the files in
/var/backups/dpkg.status.* is in /etc/cron.daily/standard, which belongs
to the cron package.

I'd suggest this functionality be brought into the dpkg package and
slightly better documented in the manpage.

The attached patch should be all that's needed.
I'm filling a simultaneous bug to cron to remove the code there, and
marking it as blocked by this bug.

Hope this helps spare another blind guy like myself who manages to bork
the status file and doesn't know about the backups[0].

Cheers

[0] http://costela.net/2009/08/restoring-a-wiped-out-dpkg-status-file/

-- 
Leo "costela" Antunes
[insert a witty retort here]

diff -urN dpkg-1.15.3.1/debian/dpkg.cron.daily dpkg-1.15.3.1.new/debian/dpkg.cron.daily
--- dpkg-1.15.3.1/debian/dpkg.cron.daily	1970-01-01 01:00:00.000000000 +0100
+++ dpkg-1.15.3.1.new/debian/dpkg.cron.daily	2009-08-14 00:43:10.000000000 +0200
@@ -0,0 +1,10 @@
+#!/bin/sh
+# code originally taken from /etc/cron.daily/standard
+
+if cd /var/backups ; then
+    if ! cmp -s dpkg.status.0 /var/lib/dpkg/status ; then
+            cp -p /var/lib/dpkg/status dpkg.status
+            savelog -c 7 dpkg.status >/dev/null
+    fi
+fi
+
diff -urN dpkg-1.15.3.1/debian/rules dpkg-1.15.3.1.new/debian/rules
--- dpkg-1.15.3.1/debian/rules	2009-07-08 11:06:35.000000000 +0200
+++ dpkg-1.15.3.1.new/debian/rules	2009-08-14 00:39:09.000000000 +0200
@@ -84,6 +84,7 @@
 	dh_testdir -a
 	dh_testroot -a
 	dh_install --sourcedir=debian/tmp -a
+	dh_installcron -a
 	dh_installlogrotate -a
 
 	install -d debian/dpkg/sbin
diff -urN dpkg-1.15.3.1/man/dpkg.1 dpkg-1.15.3.1.new/man/dpkg.1
--- dpkg-1.15.3.1/man/dpkg.1	2009-07-08 11:06:36.000000000 +0200
+++ dpkg-1.15.3.1.new/man/dpkg.1	2009-08-14 00:34:07.000000000 +0200
@@ -576,6 +576,9 @@
 whether a package is marked for removing or not, whether it is
 installed or not, etc. See section \fBINFORMATION ABOUT PACKAGES\fP
 for more info.
+
+The status file is backed up daily in \fI/var/backups\fP in case of file 
+corruption.
 .P
 The following files are components of a binary package. See \fBdeb\fP(5)
 for more information about them:

Reply via email to