summaryrefslogtreecommitdiff
blob: babe4e042fa46d3fa3ab9c5c802d54deb3c779df (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit webapp eutils autotools

DESCRIPTION="Web search engine software for intranet and internet servers."
HOMEPAGE="http://search.mnogo.ru/"
SRC_URI="http://search.mnogo.ru/Download/${P}.tar.gz"

LICENSE="GPL-2"
KEYWORDS="~x86 ~amd64"
# TODO:
# Create use.local.dest with:
# www-apps/mnogosearch:zlib - enable HTTP Content encoding, this also enable cache support
# www-apps/mnogosearch:utf8 - Use UTF8 encoding instead of LATIN1.

IUSE="doc zlib ssl mysql postgres sqlite cjk utf8"

RDEPEND="zlib? ( sys-libs/zlib )
		ssl? ( dev-libs/openssl )
		sqlite? ( =dev-db/sqlite-2.8* )"
DEPEND="${RDEPEND}
		doc? ( app-text/openjade
				app-text/docbook-dsssl-stylesheets )
		mysql? ( dev-db/mysql )
		postgres? ( dev-db/postgresql )"

pkg_setup() {
	webapp_pkg_setup
	use mysql || use postgres || use sqlite || {
		ewarn "No database selected! indexing part will not be compiled!" ;
		ewarn "If it's incorrect, add mysql, postgres or sqlite in USE flags." ;
		ebeep ; }
}

src_unpack() {
	unpack ${A}
	epatch ${FILESDIR}/${P}-configure.in.patch
	epatch ${FILESDIR}/${PN}-indexer.conf.patch

	einfo Sedding files...

	find ${S} -name Makefile.am -exec \
	sed -i \
	-e "s:\$[(]DESTDIR[)]\$[(]prefix[)]/doc:$\(DESTDIR\)/usr/share/doc/${PF}:" \
	-e "s:datadir:pkgdatadir:" \{\} \; || die "sed of find Makefile.am failed"

	use utf8 && { sed -i \
	-e "s:^#LocalCharset UTF-8:LocalCharset UTF-8:" \
	${S}/etc/indexer.conf-dist || die "sed of indexer.conf-dist failed" ; }

	use utf8 && { sed -i \
	-e "s:^LocalCharset   iso-8859-1:LocalCharset   UTF-8:" \
	-e "s:^BrowserCharset iso-8859-1:BrowserCharset UTF-8:" \
	${S}/etc/search.htm-dist || die "sed of search.htm-dist failed" ; }

	sed -i \
	-e "s%e.g. http://www.mnogosearch.org,%e.g. http://www.gentoo.org,%" \
	-e 's:<td align="left">:<td align="center">:' \
	-e "s:bar@localhost/udm/:bar@localhost/mnogosearch/:" \
	${S}/etc/search.htm-dist || die "sed of search.htm-dist failed"

	sed -i \
	-e 's:UdmStrdup(UDM_CONF_DIR):UdmStrdup("../mnogosearch/"):' \
	${S}/src/search.c || die "sed of search.c failed"

	sed -i -e "s:-dist::" ${S}/etc/Makefile.am || die "sed -dist failed"
	cd ${S}/etc/
	rename -dist '' *-dist || \
	ewarn "rename failed... You'll have to rename -dist files by yourself."

	cd ${S}
	AT_M4DIR="build/m4"
	eautoreconf
}

src_compile() {
	econf $(use_with doc docs) \
	$(use_with ssl openssl) \
	$(use_with cjk extra-charsets all) \
	$(use_with zlib) \
	$(use_with mysql) \
	$(use_with postgres pgsql) \
	$(use_with sqlite sqlite /usr) \
	--sysconfdir=${MY_HOSTROOTDIR}/mnogosearch || die "./configure failed"

	emake || die "compilation failed"
}

src_install() {
	webapp_src_preinst
	make DESTDIR="${D}" install
	mv ${D}/usr/bin/search.cgi ${D}/${MY_CGIBINDIR}

	webapp_postinst_txt en ${FILESDIR}/postinstall-en.txt

	for CFG in $(find ${D}${MY_HOSTROOTDIR}/mnogosearch/*) ; do
		local configfile=${CFG/${D}/}
		webapp_configfile ${configfile}
	done

	webapp_src_install
}

pkg_postinst() {
	use mysql || use postgres || use sqlite || {
		ewarn "No database selected! indexing part is not compiled!" ;
		ewarn "If it's incorrect, add mysql, postgres or sqlite in USE flags." ; }
	echo
	webapp_pkg_postinst
}