Your IP : 216.73.216.170


Current Path : /var/lib/dpkg/info/
Upload File :
Current File : //var/lib/dpkg/info/man-db.postinst

#!/bin/sh -e

. /usr/share/debconf/confmodule
db_version 2.0

run_mandb () {
    db_get man-db/auto-update
    [ "$RET" = true ] || return 0
    # start-stop-daemon isn't available when running from debootstrap.
    perl -e '@pwd = getpwnam("man"); $( = $) = $pwd[3]; $< = $> = $pwd[2];
	     exec "/usr/bin/mandb", @ARGV' -- "$@" || true
}

if [ "$1" = triggered ]; then
    # We don't print a status message here, as dpkg already said
    # "Processing triggers for man-db ...".
    run_mandb -pq
    exit 0
fi

[ "$1" = configure ] || exit 0

oldcatdir=/var/catman
catdir=/var/cache/man
maybesetuid='man mandb'
conffile=/etc/manpath.config

db_get man-db/install-setuid

# Sorry about this, but #98224 is right - statoverrides don't work as
# cleanly as I'd hoped here. I'm going to have to carry around some cruft
# for a while.
for x in $maybesetuid; do
    if dpkg --compare-versions "$2" eq 2.3.18-4 && \
	    [ "`dpkg-statoverride --list /usr/lib/man-db/$x`" = \
	      "man root 4755 /usr/lib/man-db/$x" ]; then
	dpkg-statoverride --remove /usr/lib/man-db/$x
    fi
done

if [ "$RET" = true ]; then
    # man and mandb are to be installed setuid man.
    owner=man:root
    mode=4755
else
    # man and mandb are not to be installed setuid.
    owner=root:root
    mode=0755
fi

for x in $maybesetuid; do
    # No statoverrides available or none exist for us ...
    if [ ! -x /usr/sbin/dpkg-statoverride ] || \
	    ! dpkg-statoverride --list /usr/bin/$x >/dev/null; then
	chown $owner /usr/bin/$x || true
	chmod $mode  /usr/bin/$x
    fi
done

if [ -e /etc/cron.daily/man.moved-by-preinst ]; then
    rm /etc/cron.daily/man.moved-by-preinst
fi
if [ -e /etc/cron.weekly/catman.moved-by-preinst ]; then
    rm /etc/cron.weekly/catman.moved-by-preinst
fi

if dpkg --compare-versions "$2" lt 2.3.18; then
    # /usr/local/man now mapped to /var/cache/man/oldlocal
    if [ -d $catdir/local ] && [ ! -d $catdir/oldlocal ]; then
	mv -f $catdir/local $catdir/oldlocal
    fi
fi

if [ -d $catdir ]; then
    # Catdirs sometimes used to be created with the wrong permissions.
    if dpkg --compare-versions "$2" lt 2.3.20-4; then
	chown -R man /var/cache/man || true
    fi
else
    # Old packages removed catpages on upgrade. The preinst hack should have
    # avoided this, but let's be sure.
    install -d -o man -g root -m 02755 $catdir
fi

build_db=0

if dpkg --compare-versions "$2" lt 2.3.16 || \
   ([ ! -f $catdir/index.db ] && [ ! -f $catdir/index.bt ]); then
    # All versions before 2.3.17.1-1 removed cat page hierarchies on
    # upgrade. Since then a preinst hack means upgrades from 2.3.16 or later
    # won't do this, but the hack is nasty enough that I don't want to
    # extend it back beyond then. Thus, we need to build the database from
    # scratch on old upgrades. This also covers fresh installs.
    build_db=1
elif dpkg --compare-versions "$2" lt 2.4.2-1; then
    # At 2.3.17.1-5, the database version number changed to 2.3.2.
    # At 2.4.0-1, the database version number changed to 2.4.1 and we
    # moved from libdb2 to libdb3.
    # At 2.4.2-1, we moved from libdb3 to libgdbm3.
    build_db=1

    # Clean up old btree databases from before 2.4.2-1. They're useless now.
    find /var/cache/man -name index.bt -print0 | xargs -0r rm -f
fi

if [ $build_db -eq 1 ]; then
    # Chances are we're being run from debootstrap, which will have problems
    # if mandb runs backgrounded for too long (bug #100616).
    echo "Building database of manual pages ..." >&2
    run_mandb -cq
else
    # Otherwise, just update the database in the foreground. It's unlikely
    # to take very long, and configuration needs to cover everything that
    # happens when we're triggered.
    echo "Updating database of manual pages ..." >&2
    run_mandb -pq
fi



exit 0