aboutsummaryrefslogtreecommitdiff
blob: 85af08699885081a8ba101703eac6afa0caefcda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id: prepinfo 1912 2005-08-25 03:54:42Z ferringb $

if [ -z "$1" ] ; then
	z="${D}usr/share/info"
else
	if [ -d "${D}$1/share/info" ] ; then
		z="${D}$1/share/info"
	else
		z="${D}$1/info"
	fi
fi

[ ! -d "${z}" ] && exit 0

rm -f "${z}"/dir{,.old}{,.info{,.gz,.bz2,.Z}}

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 "prepinfo: error fixing links: please set PORTAGE_COMPRESS_SUFFIX in make.conf" 1>&2
		       exit 1;;
	esac
fi

echo "info: ${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS}"

for x in `find "${z}"/ \( -type f -or -type l \) -maxdepth 1 -mindepth 1 2>/dev/null` ; do
	if [ -L "${x}" ] ; then
		# Symlink ...
		mylink=${x}
		linkto=$(readlink "${x}")

		if [ "${linkto##*.}" != "${suffix}" ] ; then
			linkto="${linkto}.${suffix}"
		fi
		if [ "${mylink##*.}" != "${suffix}" ] ; then
			mylink="${mylink}.${suffix}"
		fi

		echo "fixing GNU info symlink: ${mylink##*/}"
		ln -snf "${linkto}" "${mylink}"
		if [ "${x}" != "${mylink}" ] ; then
			echo "removing old symlink: ${x##*/}"
			rm -f "${x}"
		fi
	else
		if [ "${x##*.}" != "${suffix}" ] ; then
			echo "compressing GNU info page: ${x##*/}"
			"${PORTAGE_COMPRESS}" ${PORTAGE_COMPRESS_FLAGS} -f "${x}"
		fi
	fi
done