[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#2904: install-info doesn't cope with nonexistent /usr/info/dir file



Hello,

Report: 2904
Status: Open, can be closed if patch is applied.
Analyse: install-info does misbehave when dir is not available.
Explanation:
 The point was made that install-info just gives up when no dir file is
 there, with a bad error message about file locking.
 However, install-info can't really recreate the file. It was suggested that
 install-info keeps a backup of the file. The following patch by Marcus
 (that's me) adds this feature and has a better diagnostic.
Patch:
--- install-info.old	Mon Feb  1 01:21:22 1999
+++ install-info	Fri Mar  5 20:58:21 1999
@@ -27,6 +27,7 @@
 $maxwidth=79;
 $align=27;
 $calign=29;
+$backup='/var/backups/infodir.bak';
 
 undef $menuentry;
 undef $quiet;
@@ -208,6 +209,19 @@
     }
 }
 
+if (!$nowrite && ! -e "$infodir/dir") {
+    if (-r $backup) {
+        print STDERR "$name: no file $infodir/dir, retrieving backup file $backup.\n";
+        if (system ("cp $backup $infodir/dir")) {
+            print STDERR "$name: copying $backup to $infodir/dir failed, giving up: $!\n";
+            exit 1;
+        }
+    } else {
+        print STDERR "$name: no backup file $backup available, giving up.\n";
+        exit 1;
+    }
+}
+
 if (!$nowrite && !link("$infodir/dir","$infodir/dir.lock")) {
     die "$name: failed to lock dir for editing! $!\n".
         ($! =~ m/exists/i ? "try deleting $infodir/dir.lock ?\n" : '');
@@ -339,6 +353,7 @@
     rename("$infodir/dir.new","$infodir/dir") ||
         &ulquit("$name: install new $infodir/dir: $!\n");
 unlink("$infodir/dir.lock") || die "$name: unlock $infodir/dir: $!\n";
+system ("cp $infodir/dir $backup") && warn "$name: couldn't backup $infodir/dir in $backup: $!\n";
 }
 
 sub ulquit {

Thank you,
Marcus

-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org   finger brinkmd@ 
Marcus Brinkmann              GNU    http://www.gnu.org     master.debian.org
Marcus.Brinkmann@ruhr-uni-bochum.de                        for public  PGP Key
http://homepage.ruhr-uni-bochum.de/Marcus.Brinkmann/       PGP Key ID 36E7CD09


Reply to: