Просмотр исходного кода

scripts/install-info.pl: Several fixes:
* Move /usr/info/dir to /usr/share/info/dir.
* Improve message when locking and /usr/share/info/dir doesn't exist.
* Use /var/backups/infodir.bak if the above doesn't exist.
* Allow for relative filenames, and add a --remove-exactly option.
* Use section from the .info file if --section is not given.
* Include current filename in error messages.
* Format /usr/share/info/dir entries to uniform width.
* --calign|--align|--maxwidth are now ignored.

Adam Heath лет назад: 25
Родитель
Сommit
d97c87f600
5 измененных файлов с 98 добавлено и 27 удалено
  1. 12 0
      ChangeLog
  2. 15 0
      debian/changelog
  3. 9 0
      debian/dpkg.postinst
  4. 3 3
      scripts/install-info.8
  5. 59 24
      scripts/install-info.pl

+ 12 - 0
ChangeLog

@@ -1,3 +1,15 @@
+Sat Sep 15 20:19:57 CDT 2001 Adam Heath <doogie@debian.org>
+
+  * scripts/install-info.pl: Several fixes:
+    * Move /usr/info/dir to /usr/share/info/dir.
+    * Improve message when locking and /usr/share/info/dir doesn't exist.
+    * Use /var/backups/infodir.bak if the above doesn't exist.
+    * Allow for relative filenames, and add a --remove-exactly option.
+    * Use section from the .info file if --section is not given.
+    * Include current filename in error messages.
+    * Format /usr/share/info/dir entries to uniform width.
+    * --calign|--align|--maxwidth are now ignored.
+
 Wed Sep 12 18:45:57 CDT 2001 Adam Heath <doogie@debian.org>
 Wed Sep 12 18:45:57 CDT 2001 Adam Heath <doogie@debian.org>
 
 
   Fixes for building of dpkg-static.deb.
   Fixes for building of dpkg-static.deb.

+ 15 - 0
debian/changelog

@@ -37,6 +37,21 @@ dpkg (1.10) unstable; urgency=low
   * Update French translation
   * Update French translation
   * Add --showformat and --show options to dpkg-deb and dpkg-query to
   * Add --showformat and --show options to dpkg-deb and dpkg-query to
     allow one to customize the output format
     allow one to customize the output format
+  * several install-info cleanups:
+    * Move /usr/info/dir to /usr/share/info/dir.  Closes: #67174.
+    * If /usr/share/info doesn't exist, print a message saying so,
+      instead of the confusing "couldn't lock" error.  Closes: #2531.
+    * If /usr/share/info/dir doesn't exist, try to copy the backup from
+      /var/backups/infodir.bak.
+    * Add a --remove-exactly option, and allow for relative filenames.
+      Closes: #92650.
+    * Use the section from the .info file if --section is not given.
+      Closes: #76100.
+    * Error messages now include the filename being processed.
+      Closes: #66735
+    * /usr/share/info/dir now has it's entries formatted to even widths. 
+      Closes: #11228
+    * --calign|--align|--maxwidth are now ignored.
 
 
  -- Wichert Akkerman <wakkerma@debian.org>  Mon, 20 Aug 2001 14:54:38 +0200
  -- Wichert Akkerman <wakkerma@debian.org>  Mon, 20 Aug 2001 14:54:38 +0200
 
 

+ 9 - 0
debian/dpkg.postinst

@@ -234,3 +234,12 @@ fi
 
 
 mv $newdb/status.new $newdb/status
 mv $newdb/status.new $newdb/status
 
 
+if test -f /usr/info/dir
+then
+	echo "Moving /usr/info/dir to /usr/share/info/dir, and creating"
+	echo "/usr/info/dir symlink."
+	cp -a /usr/info/dir /usr/share/info/dir
+	ln -f ../share/info/dir /usr/info/dir
+fi
+
+

+ 3 - 3
scripts/install-info.8

@@ -159,7 +159,7 @@ be located in
 The default is
 The default is
 .BR /usr/info .
 .BR /usr/info .
 .TP
 .TP
-.BI \-\-align= nnn
+.BI \-\-align= nnn " [deprecated]"
 Specifies that the first line of the description should be indented at
 Specifies that the first line of the description should be indented at
 least
 least
 .I nnn
 .I nnn
@@ -168,13 +168,13 @@ because of the length of the
 .B dir
 .B dir
 menu entry details it may be offset more.  The default is 27.
 menu entry details it may be offset more.  The default is 27.
 .TP
 .TP
-.BI \-\-calign= nnn
+.BI \-\-calign= nnn " [deprecated]"
 Specifies that the second and subsequent lines of the description
 Specifies that the second and subsequent lines of the description
 should be indented at least
 should be indented at least
 .I nnn
 .I nnn
 characters.  The default is 29.
 characters.  The default is 29.
 .TP
 .TP
-.BI \-\-maxwidth= nnn
+.BI \-\-maxwidth= nnn " [deprecated]"
 Specifies that the maximum width for the Info file is
 Specifies that the maximum width for the Info file is
 .IR nnn .
 .IR nnn .
 This is used when wordwrapping the descriptive text.
 This is used when wordwrapping the descriptive text.

+ 59 - 24
scripts/install-info.pl

@@ -1,5 +1,7 @@
 #!/usr/bin/perl --
 #!/usr/bin/perl --
 
 
+use Text::Wrap;
+
 # fixme: --dirfile option
 # fixme: --dirfile option
 # fixme: sort entries
 # fixme: sort entries
 # fixme: send to FSF ?
 # fixme: send to FSF ?
@@ -25,10 +27,10 @@ usage: install-info [--version] [--help] [--debug] [--maxwidth=nnn]
 END
 END
 }
 }
 
 
-$infodir='/usr/info';
+$infodir='/usr/share/info';
 $maxwidth=79;
 $maxwidth=79;
-$align=27;
-$calign=29;
+$Text::Wrap::columns=$maxwidth;
+$backup='/var/backups/infodir.bak';
 
 
 $menuentry="";
 $menuentry="";
 $description="";
 $description="";
@@ -73,14 +75,12 @@ while ($ARGV[0] =~ m/^--/) {
         }
         }
         $sectionre= shift(@ARGV);
         $sectionre= shift(@ARGV);
         $sectiontitle= shift(@ARGV);
         $sectiontitle= shift(@ARGV);
-    } elsif (m/^--maxwidth=([0-9]+)$/) {
-        $maxwidth= $1;
-    } elsif (m/^--align=([0-9]+)$/) {
-        $align= $1;
-    } elsif (m/^--calign=([0-9]+)$/) {
-        $calign= $1;
+    } elsif (m/^--(c?align|maxwidth)=([0-9]+)$/) {
+	warn( "$name: $1 deprecated(ignored)\n" );
     } elsif (m/^--infodir=/) {
     } elsif (m/^--infodir=/) {
         $infodir=$';
         $infodir=$';
+    } elsif (m/^--info-file=/) {
+        $filename=$';
     } elsif (m/^--menuentry=/) {
     } elsif (m/^--menuentry=/) {
         $menuentry=$';
         $menuentry=$';
     } elsif (m/^--info-dir=/) {
     } elsif (m/^--info-dir=/) {
@@ -94,7 +94,10 @@ while ($ARGV[0] =~ m/^--/) {
 
 
 if (!@ARGV) { &version; print STDERR "\n"; &usage; exit 1; }
 if (!@ARGV) { &version; print STDERR "\n"; &usage; exit 1; }
 
 
-$filename= shift(@ARGV);
+if ( !$filename ) {
+	$filename= shift(@ARGV);
+	$name = "$name($filename)";
+}
 if (@ARGV) { print STDERR "$name: too many arguments\n"; &usage; exit 1; }
 if (@ARGV) { print STDERR "$name: too many arguments\n"; &usage; exit 1; }
 
 
 if ($remove) {
 if ($remove) {
@@ -133,8 +136,8 @@ if (!$remove) {
         while(<IF>) {
         while(<IF>) {
 	    m/^START-INFO-DIR-ENTRY$/ && last;
 	    m/^START-INFO-DIR-ENTRY$/ && last;
 	    m/^INFO-DIR-SECTION (.+)$/ && do {
 	    m/^INFO-DIR-SECTION (.+)$/ && do {
-		$sectiontitle = $1		unless defined($sectiontitle);
-		$sectionre = '^'.quotemeta($1)	unless defined($sectionre);
+		$sectiontitle = $1		unless ($sectiontitle);
+		$sectionre = '^'.quotemeta($1)	unless ($sectionre);
 	    }
 	    }
 	}
 	}
         while(<IF>) { last if m/^END-INFO-DIR-ENTRY$/; $asread.= $_; }
         while(<IF>) { last if m/^END-INFO-DIR-ENTRY$/; $asread.= $_; }
@@ -209,22 +212,11 @@ $name: unable to determine description for \`dir' entry - giving up
         }
         }
 
 
         $align--; $calign--;
         $align--; $calign--;
-        $lprefix= length($cprefix);
-        if ($lprefix < $align) {
-            $cprefix .= ' ' x ($align - $lprefix);
-            $lprefix= $align;
-        }
-        $prefix= "\n". (' 'x $calign);
         $cwidth= $maxwidth+1;
         $cwidth= $maxwidth+1;
 
 
         for $_ (split(/\s+/,$description)) {
         for $_ (split(/\s+/,$description)) {
             $l= length($_);
             $l= length($_);
             $cwidth++; $cwidth += $l;
             $cwidth++; $cwidth += $l;
-            if ($cwidth > $maxwidth) {
-                $infoentry .= $cprefix;
-                $cwidth= $lprefix+1+$l;
-                $cprefix= $prefix; $lprefix= $calign;
-            }
             $infoentry.= ' '; $infoentry .= $_;
             $infoentry.= ' '; $infoentry .= $_;
         }
         }
 
 
@@ -235,8 +227,21 @@ $name: unable to determine description for \`dir' entry - giving up
     }
     }
 }
 }
 
 
+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")) {
 if (!$nowrite && !link("$infodir/dir","$infodir/dir.lock")) {
-    die "$name: failed to lock dir for editing! $!\n".
+    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/dir.lock ?\n" : '');
 }
 }
 
 
@@ -368,6 +373,35 @@ if (!$remove) {
             unless $quiet;
             unless $quiet;
     }
     }
 }
 }
+$length = 0;
+
+$j = -1;
+for ($i=0; $i<=$#work; $i++) {
+	$_ = $work[$i];
+	chomp;
+	if ( m/^(\* *[^:]+: *\(\w[^\)]*\)[^.]*\.)[ \t]*(.*)/ ) {
+		$length = length($1) if ( length($1) > $length );
+		$work[++$j] = $_;
+	} elsif ( m/^[ \t]+(.*)/ ) {
+		$work[$j] = "$work[$j] $1";
+	} else {
+		$work[++$j] = $_;
+	}
+}
+@work = @work[0..$j];
+
+@newwork = ();
+foreach ( @work ) {
+	if ( m/^(\* *[^:]+: *\(\w[^\)]*\)[^.]*\.)[ \t]*(.*)/ ||
+		m/^([ \t]+)(.*)/ ) {
+		$_ = $1 . ( " " x ( $length - length($1) + 1 ) ) . $2;
+		push @newwork, split( "\n", wrap('', " " x ( $length + 1 ), $_ ) );
+	} else {
+		push @newwork, $_;
+	}
+}
+@work = @newwork;
+print join("\n",@newwork);
 
 
 if (!$nowrite) {
 if (!$nowrite) {
     open(NEW,"> $infodir/dir.new") || &ulquit("create $infodir/dir.new: $!");
     open(NEW,"> $infodir/dir.new") || &ulquit("create $infodir/dir.new: $!");
@@ -380,6 +414,7 @@ if (!$nowrite) {
     rename("$infodir/dir.new","$infodir/dir") ||
     rename("$infodir/dir.new","$infodir/dir") ||
         &ulquit("install new $infodir/dir: $!");
         &ulquit("install new $infodir/dir: $!");
 unlink("$infodir/dir.lock") || die "$name: unlock $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 {
 sub ulquit {