summaryrefslogtreecommitdiff
blob: 57e54f1f15a43c984d8d4f3d67a1bfec2356333e (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
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=4

inherit eutils toolchain-funcs webapp

DESCRIPTION="A Perl CGI for accessing and sharing files, or calendar/addressbooks via WebDAV"
HOMEPAGE="http://webdavcgi.sourceforge.net/"
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.bz2"

LICENSE="GPL-3"
SLOT="0"
WEBAPP_MANUAL_SLOT="yes"
KEYWORDS="~amd64"
IUSE="mysql postgres rcs samba +sqlite +suid"

DEPEND=""
RDEPEND="dev-perl/Archive-Zip
	dev-perl/File-Copy-Link
	dev-perl/PerlIO-gzip
	dev-perl/Quota
	dev-perl/TimeDate
	dev-perl/URI
	dev-perl/UUID-Tiny
	dev-perl/XML-Simple
	media-gfx/graphicsmagick[perl]
	mysql? ( dev-perl/DBD-mysql )
	virtual/perl-Module-Load
	postgres? ( dev-perl/DBD-Pg )
	rcs? ( dev-perl/Rcs )
	samba? ( dev-perl/Filesys-SmbClient )
	sqlite? ( dev-perl/DBD-SQLite )
	dev-perl/CGI
	virtual/perl-File-Spec"

need_httpd_cgi

REQUIRED_USE="|| ( mysql postgres sqlite )"

CGIBINDIR="cgi-bin"

src_prepare() {
	epatch "${FILESDIR}/${PV}-logout-var-expansion.patch"
}

src_compile() {
	if use suid; then
		# There are several webdavwrappers, TODO: make it configureable
		export WEBDAVWRAPPER="webdavwrapper"

		$(tc-getCC) ${LDFLAGS} ${CFLAGS} \
			-o "${CGIBINDIR}/${WEBDAVWRAPPER}" \
			helper/webdavwrapper.c || die "compile ${WEBDAVWRAPPER} failed"
	fi
}

src_install() {
	webapp_src_preinst

	local htdocsDir='htdocs'
	local confDir='etc'

	local installDirs="$confDir lib locale"

	insinto "${MY_HTDOCSDIR}"
	doins -r "${htdocsDir}"/*

	exeinto "${MY_CGIBINDIR}"
	newexe "${CGIBINDIR}/logout-dist" logout

	doexe "${CGIBINDIR}/webdav.pl"
	use suid && doexe "${CGIBINDIR}/${WEBDAVWRAPPER}"

	local currentDir
	for currentDir in ${installDirs}; do
		dodir "${MY_HOSTROOTDIR}/${currentDir}"
		insinto "${MY_HOSTROOTDIR}/${currentDir}"
		doins -r "${currentDir}"/*
	done

	webapp_configfile "${MY_HOSTROOTDIR}/${confDir}"/{webdav.conf-dist,mime.types}

	use mysql && webapp_sqlscript mysql sql/mysql.sql
	use postgres && webapp_sqlscript postgres sql/postgresql.sql

	dodoc CHANGELOG TODO
	dohtml -r doc/*

	webapp_hook_script "${FILESDIR}/reconfig"

	webapp_src_install

	# In order to change the user and group ID at runtime, the webdavwrapper
	# needs to be run as root (set-user-ID and set-group-ID bit)
	if use suid; then
		einfo "Setting SUID and SGID bit for ${WEBDAVWRAPPER}"
		fowners root:root "${MY_CGIBINDIR}/${WEBDAVWRAPPER}"
		fperms 6755 "${MY_CGIBINDIR}/${WEBDAVWRAPPER}"
		webapp_postinst_txt en "${FILESDIR}/postinstall-${WEBDAVWRAPPER}-en.txt"
		webapp_hook_script "${FILESDIR}/reconfig-suid"
	else
		ewarn "You have the 'suid' USE flag disabled"
		ewarn "WebDAV CGI won't be able to switch user ids"
		webapp_postinst_txt en "${FILESDIR}/postinstall-en.txt"
	fi
}