sys-process/glances: 3.1.4.1-r1 amd64 stable, bug #720368
[gentoo.git] / www-apps / webdavcgi / webdavcgi-1.1.1.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit eutils toolchain-funcs versionator
7
8 DESCRIPTION="A Perl CGI for accessing and sharing files, or calendar/addressbooks via WebDAV."
9 HOMEPAGE="http://webdavcgi.sourceforge.net/"
10 SRC_URI="mirror://sourceforge/${PN}/${P}.tar.bz2"
11
12 LICENSE="GPL-3+"
13
14 # Provide slotting on minor versions. WebDAV CGI is a web application which
15 # can be shared by multiple instances and thus major updates shouldn't be
16 # enforced to all users/instances at the same time.
17 SLOT="$(get_version_component_range 1-2)"
18
19 KEYWORDS="~amd64"
20 IUSE="afs git kerberos ldap mysql pdf postgres rcs samba +sqlite +suid"
21
22 DEPEND=""
23 RDEPEND="afs? ( net-fs/openafs )
24         dev-lang/perl
25         dev-perl/Archive-Zip
26         dev-perl/CGI
27         dev-perl/DateTime
28         dev-perl/DateTime-Format-Human-Duration
29         dev-perl/File-Copy-Link
30         dev-perl/JSON
31         dev-perl/List-MoreUtils
32         dev-perl/MIME-tools
33         dev-perl/PerlIO-gzip
34         dev-perl/Quota
35         dev-perl/TimeDate
36         dev-perl/URI
37         dev-perl/UUID-Tiny
38         dev-perl/XML-Simple
39         git? ( dev-vcs/git )
40         kerberos? ( virtual/krb5 )
41         ldap? ( dev-perl/perl-ldap )
42         media-gfx/graphicsmagick[perl]
43         media-libs/exiftool
44         mysql? ( dev-perl/DBD-mysql )
45         pdf? ( app-text/ghostscript-gpl )
46         postgres? ( dev-perl/DBD-Pg )
47         rcs? ( dev-perl/Rcs )
48         samba? ( net-fs/cifs-utils dev-perl/Filesys-SmbClient )
49         sqlite? ( dev-perl/DBD-SQLite )
50         virtual/perl-File-Spec
51         virtual/perl-Module-Load
52         || ( virtual/httpd-cgi virtual/httpd-fastcgi )"
53
54 REQUIRED_USE="|| ( mysql postgres sqlite )"
55
56 CGIBINDIR="cgi-bin"
57
58 src_compile() {
59         if use suid; then
60                 WEBDAVWRAPPERS="webdavwrapper" # Standard UID/GID wrapper
61
62                 use afs      && WEBDAVWRAPPERS+=" webdavwrapper-afs"
63                 use kerberos && WEBDAVWRAPPERS+=" webdavwrapper-krb"
64
65                 export WEBDAVWRAPPERS
66
67                 local wrapper
68                 for wrapper in ${WEBDAVWRAPPERS}; do
69                         $(tc-getCC) ${LDFLAGS} ${CFLAGS} \
70                                 -o "${CGIBINDIR}/${wrapper}" \
71                                 "helper/${wrapper}.c" || die "compile ${wrapper} failed"
72                 done
73         fi
74 }
75
76 src_install() {
77         exeinto "/usr/libexec/${PN}-${SLOT}/${CGIBINDIR}"
78         newexe "${CGIBINDIR}/logout-dist" "logout"
79         doexe "${CGIBINDIR}/webdav.pl"
80
81         use afs   && doexe "${CGIBINDIR}/afswrapper"
82         use samba && doexe "${CGIBINDIR}/smbwrapper"
83
84         if use suid; then
85                 # In order to change the user and group ID at runtime, the webdavwrapper
86                 # needs to be run as root (set-user-ID and set-group-ID bit)
87                 exeopts -o root -g root -m 6755
88
89                 local wrapper
90                 for wrapper in ${WEBDAVWRAPPERS}; do
91                         einfo "Installing UID/GID wrapper ${wrapper}"
92                         doexe "${CGIBINDIR}/${wrapper}"
93                 done
94
95                 # reset install opts
96                 exeopts
97         else
98                 ewarn "You have the 'suid' USE flag disabled"
99                 ewarn "WebDAV CGI won't be able to switch user ids"
100         fi
101
102         local confDir='etc'
103         local webdavConfDir="/etc/${PN}-${SLOT}/default"
104
105         export WEBDAVCONFIG="${webdavConfDir}/webdav.conf"
106
107         insinto "${webdavConfDir}"
108         doins "${confDir}/mime.types"
109         newins "${FILESDIR}/webdav-${SLOT}.conf" "webdav.conf"
110
111         local installBaseDir="/usr/share/${PN}-${SLOT}"
112         local currentDir
113         for currentDir in htdocs lib locale templates; do
114                 insinto "${installBaseDir}/${currentDir}"
115                 doins -r "${currentDir}"/*
116         done
117
118         if use mysql || use postgres; then
119                 local sqlDir='sql'
120                 insinto "${installBaseDir}/${sqlDir}"
121                 use mysql    && doins "${sqlDir}/mysql.sql"
122                 use postgres && doins "${sqlDir}/postgresql.sql"
123         fi
124
125         if use sqlite; then
126                 # Directory where the SQLite database resides
127                 local sqliteRootDir="/var/lib/${PN}/${SLOT}"
128                 keepdir "${sqliteRootDir}"
129
130                 # Default database directory where all users are able to create and
131                 # share the databases, this can be changed within the config file and
132                 # restricted to user/group only access if required.
133                 export SQLITEDIR="${sqliteRootDir}/default"
134                 keepdir "${SQLITEDIR}"
135                 fperms 1777 "${SQLITEDIR}"
136         fi
137
138         # Create default temporary directories, writable by all users
139         export TMPDIRS="trash thumbnails optimized"
140         for tmpDir in ${TMPDIRS}; do
141                 keepdir "/var/tmp/${PN}/${SLOT}/default/${tmpDir}"
142                 fperms 1777 "/var/tmp/${PN}/${SLOT}/default/${tmpDir}"
143         done
144
145         export APACHEEXAMPLECONFIG="apache-webdavcgi-${SLOT}-example.conf"
146         dodoc CHANGELOG
147         dodoc etc/webdav.conf.complete
148         dodoc "${FILESDIR}/${APACHEEXAMPLECONFIG}"
149         dodoc -r "doc/"
150 }
151
152 pkg_postinst() {
153         ewarn "In order to allow different users to create and share files,"
154         ewarn "some directories were installed with world write access by default."
155         ewarn "To set restrictive permissions, add all WebDAV CGI users to a"
156         ewarn "common group, and allow access to the following directories by this"
157         ewarn "group only."
158         ewarn "Temp directories:    /var/tmp/${PN}/${SLOT}/default/*"
159         use sqlite && ewarn "SQLite directory:    ${SQLITEDIR}"
160
161         elog
162         elog "The WebDAV CGI config is located at ${WEBDAVCONFIG}."
163         elog
164         elog "An example Apache HTTP server configuration snippet is available in"
165         elog "${ROOT%/}/usr/share/doc/${PF} in the file ${APACHEEXAMPLECONFIG}"
166         elog
167         elog "An important note to systemd user's running the Apache HTTP server:"
168         elog "The default apache2.service will be started with private file system"
169         elog "namespaces for /var/tmp and /tmp enabled (PrivateTmp=true)."
170         elog "This means that you either need to disable PrivateTmp, relocate the"
171         elog "directories starting with /var/tmp within ${WEBDAVCONFIG}"
172         elog "or pre-create the directory structure with a user defined systemd"
173         elog "companion unit using the JoinsNamespaceOf directive."
174         elog
175         elog "To disable the private file system namespace, override the existing"
176         elog "service:"
177         elog "systemctl edit apache2.service"
178         elog "[Service]"
179         elog "PrivateTmp=false"
180
181         einfo
182         einfo "Detailed installation and configuration instructions can be found at"
183         einfo "http://webdavcgi.sourceforge.net/"
184 }