Merge remote-tracking branch 'github/pr/536'.
[gentoo.git] / net-misc / minidlna / minidlna-1.1.4.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 inherit eutils linux-info systemd toolchain-funcs user
8
9 DESCRIPTION="DLNA/UPnP-AV compliant media server"
10 HOMEPAGE="http://minidlna.sourceforge.net/"
11 SRC_URI="mirror://sourceforge/${PN}/${PV}/${P}.tar.gz
12         https://dev.gentoo.org/~xmw/${PN}-gentoo-artwork.patch.xz"
13
14 LICENSE="BSD GPL-2"
15 SLOT="0"
16 KEYWORDS="amd64 arm x86"
17 IUSE="netgear readynas"
18
19 RDEPEND="dev-db/sqlite:3
20         media-libs/flac
21         media-libs/libexif
22         media-libs/libid3tag
23         media-libs/libogg
24         media-libs/libvorbis
25         virtual/ffmpeg
26         virtual/jpeg:0"
27 DEPEND="${RDEPEND}
28         virtual/pkgconfig"
29
30 CONFIG_CHECK="~INOTIFY_USER"
31
32 pkg_setup() {
33         local my_is_new="yes"
34         [ -d "${EPREFIX}"/var/lib/${PN} ] && my_is_new="no"
35         enewgroup ${PN}
36         enewuser ${PN} -1 -1 /var/lib/${PN} ${PN}
37         if [ -d "${EPREFIX}"/var/lib/${PN} ] && [ "${my_is_new}" == "yes" ] ; then
38                 # created by above enewuser command w/ wrong group and permissions
39                 chown ${PN}:${PN} "${EPREFIX}"/var/lib/${PN} || die
40                 chmod 0750 "${EPREFIX}"/var/lib/${PN} || die
41                 # if user already exists, but /var/lib/minidlna is missing
42                 # rely on ${D}/var/lib/minidlna created in src_install
43         fi
44
45         linux-info_pkg_setup
46 }
47
48 src_prepare() {
49         sed -e "/log_dir/s:/var/log:/var/log/${PN}:" \
50                 -e "/db_dir/s:/var/cache/:/var/lib/:" \
51                 -i ${PN}.conf || die
52
53         epatch "${WORKDIR}"/${PN}-gentoo-artwork.patch
54
55         epatch_user
56 }
57
58 src_configure() {
59         econf \
60                 --disable-silent-rules \
61                 --with-db-path=/var/lib/${PN} \
62                 --with-log-path=/var/log/${PN} \
63                 --enable-tivo \
64                 $(use_enable netgear) \
65                 $(use_enable readynas)
66 }
67
68 src_install() {
69         default
70
71         insinto /etc
72         doins ${PN}.conf
73
74         newconfd "${FILESDIR}"/${PN}-1.0.25.confd ${PN}
75         newinitd "${FILESDIR}"/${PN}-1.1.2.initd ${PN}
76         systemd_newunit "${FILESDIR}"/${PN}-1.1.2.service ${PN}.service
77         echo "d /run/${PN} 0755 ${PN} ${PN} -" > "${T}"/${PN}.conf
78         systemd_dotmpfilesd "${T}"/${PN}.conf
79
80         dodir /var/{lib,log}/${PN}
81         fowners ${PN}:${PN} /var/{lib,log}/${PN}
82         fperms 0750 /var/{lib,log}/${PN}
83
84         dodoc AUTHORS NEWS README TODO
85         doman ${PN}d.8 ${PN}.conf.5
86 }
87
88 pkg_postinst() {
89         elog "minidlna now runs as minidlna:minidlna (bug 426726),"
90         elog "logfile is moved to /var/log/minidlna/minidlna.log,"
91         elog "cache is moved to /var/lib/minidlna."
92         elog "Please edit /etc/conf.d/${PN} and file ownerships to suit your needs."
93 }