summaryrefslogtreecommitdiff
blob: 6f2a61d25c7150406abc4a6e0a0409d74cea16ef (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

inherit eutils webapp

DESCRIPTION="Converts GNU .info files to HTML"
HOMEPAGE="http://info2html.sourceforge.net/"
SRC_URI="mirror://sourceforge/info2html/${P}.tar"

LICENSE="freedist"
# webapp.eclass deals with SLOTting
#SLOT="0"
IUSE=""
KEYWORDS="alpha amd64 hppa sparc x86"

RDEPEND="dev-lang/perl"

src_unpack() {
	local infos state line i
	unpack ${A}
	cd ${S}

	# filter user-provided data to prevent cross-frame/site scripting attacks
	# bug #91354 (fix from Werner Fink)
	epatch "${FILESDIR}"/info2html-2.0-xss.patch

	# Fixup INFODIR for paths in /etc/profile.env INFOPATH
	infos=$(grep "^export INFOPATH=" /etc/profile.env | tail -n 1 |\
				sed -e "s:^export INFOPATH=:INFOPATH=:;s:'::g")
	# Default path to /usr/share/info and /usr/local/share/info
	[[ -z ${infos} ]] && export infos="/usr/share/info"
	infos=( ${INFOPATH//:/ } )
	mv ${S}/info2html.conf ${S}/info2html.conf.orig
	touch ${S}/info2html.conf
	state="copy"
	inserted="no"
	while read line; do
		[[ ${line} == "@INFODIR = (" ]] && state="insert"
		[[ ${line} == ");" ]] && state="copy"
		case ${state} in
			"copy")
				echo ${line} >> ${S}/info2html.conf
				;;
			"insert")
				echo ${line} >> ${S}/info2html.conf
				for info in "${infos[@]}"; do
					echo "	'${info}'," >> ${S}/info2html.conf
				done
				echo "	'/usr/local/share/info'" >> ${S}/info2html.conf
				state="skip"
				inserted="yes"
				;;
			"skip")
				;;
		esac
	done < ${S}/info2html.conf.orig
	[[ ${state} == "copy" && ${inserted} == "yes" ]] ||
		die "Setting up info2html.conf failed"
}

src_install() {
	webapp_src_preinst

	exeinto ${MY_CGIBINDIR}
	cp info2html infocat info2html.css info2html.conf ${D}/${MY_CGIBINDIR}
	# README zapped by info2html-gentoo.patch; it only listed
	# the homepage so it doesn't add anything useful.
	# dodoc README

	webapp_src_install
}