+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>
Fixes for building of dpkg-static.deb.
* Update French translation
* Add --showformat and --show options to dpkg-deb and dpkg-query to
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
#!/usr/bin/perl --
+use Text::Wrap;
+
# fixme: --dirfile option
# fixme: sort entries
# fixme: send to FSF ?
END
}
-$infodir='/usr/info';
+$infodir='/usr/share/info';
$maxwidth=79;
-$align=27;
-$calign=29;
+$Text::Wrap::columns=$maxwidth;
+$backup='/var/backups/infodir.bak';
$menuentry="";
$description="";
}
$sectionre= 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=/) {
$infodir=$';
+ } elsif (m/^--info-file=/) {
+ $filename=$';
} elsif (m/^--menuentry=/) {
$menuentry=$';
} elsif (m/^--info-dir=/) {
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 ($remove) {
while(<IF>) {
m/^START-INFO-DIR-ENTRY$/ && last;
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.= $_; }
}
$align--; $calign--;
- $lprefix= length($cprefix);
- if ($lprefix < $align) {
- $cprefix .= ' ' x ($align - $lprefix);
- $lprefix= $align;
- }
- $prefix= "\n". (' 'x $calign);
$cwidth= $maxwidth+1;
for $_ (split(/\s+/,$description)) {
$l= length($_);
$cwidth++; $cwidth += $l;
- if ($cwidth > $maxwidth) {
- $infoentry .= $cprefix;
- $cwidth= $lprefix+1+$l;
- $cprefix= $prefix; $lprefix= $calign;
- }
$infoentry.= ' '; $infoentry .= $_;
}
}
}
+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".
+ print STDERR "$name: failed to lock dir for editing! $!\n".
($! =~ m/exists/i ? "try deleting $infodir/dir.lock ?\n" : '');
}
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) {
open(NEW,"> $infodir/dir.new") || &ulquit("create $infodir/dir.new: $!");
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";
}
sub ulquit {