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

Script to repair the info dir file with correct sections

This script repairs the info dir file by extracting install-info
invocations from postinst files.
Obviously this is quite klugy but just looping over the installed files
does not work because they would get all put in the "Miscellaneous"
section; it would be better if all packages wrote this info in some kind
of database.
Also this script does not work for Emacs packages that put info files in
a directory of their own and use a for loop to install them; however,
the current script supports Emacs21 as a special case.
The script requires perl.

It can be found at http://ldb.ods.org/freesw_debian_repair-info.html
License is GPL as specified on http://ldb.ods.org/license.html
Since it is small here is a copy of the current version:

if test "$1" == "-h" || test "$1" == "--help"; then
	echo "Usage: repair-info [--auto]"
	echo "Generates a script to repair the info dir file and runs it if --auto is specified."
	exit 0
tempdir=`mktemp -d`
echo '#!/bin/sh'>$tempdir/repair-info-generic.sh
cat /var/lib/dpkg/info/*.postinst|perl -e '$ignore = 0; while(<>) {chomp; if(/install-info/) {/^\s*install-info/ and $ignore = 0;} else {abort;}; $ignore and next; if(!/\\\s*$/) {$ignore = 1;}; /^#/ or print "$_\n";}'>>$tempdir/repair-info-generic.sh
echo '#!/bin/sh'>$tempdir/repair-info-emacs21.sh
if test -f /var/lib/dpkg/info/emacs21.postinst; then
	cat /var/lib/dpkg/info/emacs21.postinst|perl -e '$ignore = 0; while(<>) {m,#!/bin/sh, && next; /update-alternatives/ && last; print $_;}'>>$tempdir/repair-info-emacs21.sh
cat ->$tempdir/repair-info.sh <<EOF
if test -d $tempdir; then
echo "Backing up existing dir file in \$backup"
mv -f /usr/share/info/dir \$backup
touch /usr/share/info/dir
rm -f /usr/share/info/dir.lock
cleanup-info /usr/share/info # install-info hangs otherwise
cleanup-info /usr/share/info # install-info messes up even if starts from stracth
chmod +x $tempdir/repair-info*.sh
if test "$1" == "-a" || test "$1" == "--auto"; then
	if test $UID == 0; then
		echo "Running $tempdir/repair-info.sh"
		echo "Give root password to run $tempdir/repair-info.sh"
		su -c "$tempdir/repair-info.sh"
	echo "Now su to root and run $tempdir/repair-info.sh"

Attachment: signature.asc
Description: This is a digitally signed message part

Reply to: