Package: dpkg
Version: 1.13.17
Followup-For: Bug #286275

The initial problem reported in this bug (that install-info does not
understand the --dir-file option), no longer appears to be true.
Unfortunately, the implementation of the --dir-file option is not
correct:  the script makes it an alias for the --info-dir option when
the former expects a filename and the latter expects a directory with an
assumed "dir" filename appended.  The failure condition is that anyone
using the --dir-file option properly gets an error referring to a
filename with an extra "/dir" (e.g. "/usr/local/info/dir/dir").

My fix is to change the $infodir variable to hold the name of the file,
not the directory with a bunch of appended "/dir" strings in the code.

The attached patch makes the following changes:

1. All instances of $infodir/dir were changed to $infodir .
2. Any resulting instances of "$infodir" (including the quotes) was
   changed to remove the unneeded double-quotes.
3. The initialization of $infodir gets a trailing /dir added.
4. The matching of --infodir and --info-dir was unified to use a
   single regex and to append /dir to the end of the specified dir.
5. Changed a call of "-s $infodir" to "-s _" because we can reuse
   the same stat info as a prior -e check.
6. Fixed the indentation of 4 lines.

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (900, 'testing'), (800, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-1-686
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)

Versions of packages dpkg depends on:
ii  coreutils [textutils]         5.94-1     The GNU core utilities
ii  libc6                         2.3.6-3    GNU C Library: Shared libraries an

dpkg recommends no packages.

-- no debconf information
--- /usr/sbin/install-info      2006-03-19 17:38:31.000000000 -0800
+++ /tmp/install-info   2006-04-11 13:39:54.000000000 -0700
@@ -29,7 +29,7 @@
 END
 }
 
-$infodir='/usr/share/info';
+$infodir='/usr/share/info/dir';
 $maxwidth=79;
 $Text::Wrap::columns=$maxwidth;
 $backup='/var/backups/infodir.bak';
@@ -80,14 +80,12 @@
         $sectiontitle= shift(@ARGV);
     } elsif (m/^--(c?align|maxwidth)=([0-9]+)$/) {
        warn( "$name: $1 deprecated(ignored)\n" );
-    } elsif (m/^--infodir=/) {
-        $infodir=$';
+    } elsif (m/^--info-?dir=/) {
+        $infodir=$' . '/dir';
     } elsif (m/^--info-file=/) {
         $filename=$';
     } elsif (m/^--menuentry=/) {
         $menuentry=$';
-    } elsif (m/^--info-dir=/) {
-        $infodir=$';
     } elsif (m/^--description=/) {
         $description=$';
     } elsif (m/^--dir-file=/) { # for compatibility with GNU install-info
@@ -250,21 +248,21 @@
     }
 }
 
-if (!$nowrite && ( ! -e "$infodir/dir" || ! -s "$infodir/dir" )) {
+if (!$nowrite && ( ! -e $infodir || ! -s _ )) {
     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";
+       print STDERR "$name: no file $infodir, retrieving backup file 
$backup.\n";
+       if (system ("cp $backup $infodir")) {
+           print STDERR "$name: copying $backup to $infodir failed, giving up: 
$!\n";
            exit 1;
        }
     } else {
         if (-r $default) {
            print STDERR "$name: no backup file $backup available, retrieving 
default file.\n";
            
-           if (system("cp $default $infodir/dir")) {
-               print STDERR "$name: copying $default to $infodir/dir failed, 
giving up: $!\n";
-       exit 1;
-    }
+           if (system("cp $default $infodir")) {
+               print STDERR "$name: copying $default to $infodir failed, 
giving up: $!\n";
+               exit 1;
+           }
        } else {
            print STDERR "$name: no backup file $backup available.\n";
            print STDERR "$name: no default file $default available, giving 
up.\n";
@@ -273,15 +271,15 @@
     }
 }
 
-if (!$nowrite && !link("$infodir/dir","$infodir/dir.lock")) {
+if (!$nowrite && !link($infodir,"$infodir.lock")) {
     print STDERR "$name: failed to lock dir for editing! $!\n".
-        ($! =~ m/exists/i ? "try deleting $infodir/dir.lock ?\n" : '');
+        ($! =~ m/exists/i ? "try deleting $infodir.lock ?\n" : '');
 }
 
-open(OLD,"$infodir/dir") || &ulquit("open $infodir/dir: $!");
+open(OLD,$infodir) || &ulquit("open $infodir: $!");
 @work= <OLD>;
-eof(OLD) || &ulquit("read $infodir/dir: $!");
-close(OLD) || &ulquit("close $infodir/dir after read: $!");
+eof(OLD) || &ulquit("read $infodir: $!");
+close(OLD) || &ulquit("close $infodir after read: $!");
 while (($#work >= 0) && ($work[$#work] !~ m/\S/)) { $#work--; }
 
 while (@work) {
@@ -443,22 +441,22 @@
 }
 
 if (!$nowrite) {
-    open(NEW,"> $infodir/dir.new") || &ulquit("create $infodir/dir.new: $!");
-    print(NEW @head,join("\n",@newwork)) || &ulquit("write $infodir/dir.new: 
$!");
-    close(NEW) || &ulquit("close $infodir/dir.new: $!");
-
-    unlink("$infodir/dir.old");
-    link("$infodir/dir","$infodir/dir.old") ||
-        &ulquit("cannot backup old $infodir/dir, giving up: $!");
-    rename("$infodir/dir.new","$infodir/dir") ||
-        &ulquit("install new $infodir/dir: $!");
-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";
+    open(NEW,"> $infodir.new") || &ulquit("create $infodir.new: $!");
+    print(NEW @head,join("\n",@newwork)) || &ulquit("write $infodir.new: $!");
+    close(NEW) || &ulquit("close $infodir.new: $!");
+
+    unlink("$infodir.old");
+    link($infodir,"$infodir.old") ||
+        &ulquit("cannot backup old $infodir, giving up: $!");
+    rename("$infodir.new",$infodir) ||
+        &ulquit("install new $infodir: $!");
+    unlink("$infodir.lock") || die "$name: unlock $infodir: $!\n";
+    system ("cp $infodir $backup") && warn "$name: couldn't backup $infodir in 
$backup: $!\n";
 }
 
 sub ulquit {
-    unlink("$infodir/dir.lock") ||
-        warn "$name: warning - unable to unlock $infodir/dir: $!\n";
+    unlink("$infodir.lock") ||
+        warn "$name: warning - unable to unlock $infodir: $!\n";
     die "$name: $_[0]\n";
 }
 

Reply via email to