#!/bin/bash # Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/bin/prepman,v 1.12 2005/05/04 23:50:33 vapier Exp $ if [ -z "$1" ] ; then z="${D}usr/share/man" else z="${D}$1/man" fi [ ! -d "${z}" ] && exit 0 PORTAGE_COMPRESS=${PORTAGE_COMPRESS:-gzip} PORTAGE_COMPRESS_FLAGS=${PORTAGE_COMPRESS_FLAGS:--9} if [ -z "${PORTAGE_COMPRESS_SUFFIX}" ] ; then case ${PORTAGE_COMPRESS} in gzip) suffix="gz";; bzip2) suffix="bz2";; *) echo "prepman error: please set PORTAGE_COMPRESS_SUFFIX in make.conf" 1>&2 exit 1;; esac fi if [ -z "${prepallman_banner}" ] ; then echo "man: ${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS}" fi for x in `find "${z}"/ -type d 2>/dev/null` ; do for y in `find "${x}"/ \( -type f -or -type l \) ! -name '.keep' -maxdepth 1 -mindepth 1 2>/dev/null` ; do if [ -L "${y}" ] ; then # Symlink ... mylink=${y} linkto=$(readlink "${y}") # Do NOT change links to directories if [ -d "${z}/${linkto}" ] ; then continue fi if [ "${linkto##*.}" != "${suffix}" ] ; then linkto="${linkto}.${suffix}" fi if [ "${mylink##*.}" != "${suffix}" ] ; then mylink="${mylink}.${suffix}" fi echo " link fixed ${mylink##*/}" ln -snf "${linkto}" "${mylink}" if [ "${y}" != "${mylink}" ] ; then echo " link removed ${y##*/}" rm -f "${y}" fi else if [ "${y##*.}" != "${suffix}" ] && [ ! -d "${y}" ] ; then echo " compressing ${y##*/}" "${PORTAGE_COMPRESS}" ${PORTAGE_COMPRESS_FLAGS} -f "${y}" fi fi done done