summaryrefslogtreecommitdiff
blob: 5e37ec293f715227ed3b60d07b4575c6e1930005 (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
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

inherit autotools eutils linux-info systemd toolchain-funcs user

DESCRIPTION="DLNA/UPnP-AV compliant media server"
HOMEPAGE="https://sourceforge.net/projects/minidlna/"
SRC_URI="mirror://sourceforge/minidlna/${PV}/${P}.tar.gz
	https://dev.gentoo.org/~xmw/minidlna-gentoo-artwork.patch.xz"

LICENSE="BSD GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~arm ~x86"
IUSE="avahi libav netgear readynas"

RDEPEND="dev-db/sqlite:3
	media-libs/flac:=
	media-libs/libexif:=
	media-libs/libid3tag:=
	media-libs/libogg:=
	media-libs/libvorbis:=
	virtual/jpeg:0=
	avahi? ( net-dns/avahi )
	libav? ( media-video/libav:0= )
	!libav? ( media-video/ffmpeg:0= )"
DEPEND="${RDEPEND}
	virtual/pkgconfig"

CONFIG_CHECK="~INOTIFY_USER"

PATCHES=( "${WORKDIR}"/minidlna-gentoo-artwork.patch
	"${FILESDIR}"/${P}-buildsystem.patch )

src_prepare() {
	sed -e "/log_dir/s:/var/log:/var/log/minidlna:" \
		-e "/db_dir/s:/var/cache/:/var/lib/:" \
		-i minidlna.conf || die

	default

	eautoreconf
}

src_configure() {
	econf \
		--disable-silent-rules \
		--with-db-path=/var/lib/minidlna \
		--with-log-path=/var/log/minidlna \
		--enable-tivo \
		$(use_enable avahi ) \
		$(use_enable netgear) \
		$(use_enable readynas)
}

src_install() {
	default

	#bug 536532
	dosym /usr/sbin/minidlnad /usr/bin/minidlna

	insinto /etc
	doins minidlna.conf

	newconfd "${FILESDIR}"/minidlna-1.0.25.confd minidlna
	newinitd "${FILESDIR}"/minidlna-1.1.5.initd minidlna
	systemd_newunit "${FILESDIR}"/minidlna-1.1.2.service minidlna.service
	echo "d /run/minidlna 0755 minidlna minidlna -" > "${T}"/minidlna.conf
	systemd_dotmpfilesd "${T}"/minidlna.conf

	keepdir /var/{lib,log}/minidlna

	dodoc AUTHORS NEWS README TODO
	doman minidlnad.8 minidlna.conf.5
}

pkg_preinst() {
	local my_is_new="yes"
	[ -d "${EPREFIX}"/var/lib/minidlna ] && my_is_new="no"

	enewgroup minidlna
	enewuser minidlna -1 -1 /var/lib/minidlna minidlna

	fowners minidlna:minidlna /var/{lib,log}/minidlna
	fperms 0750 /var/{lib,log}/minidlna

	if [ -d "${EPREFIX}"/var/lib/minidlna ] && [ "${my_is_new}" == "yes" ] ; then
		# created by above enewuser command w/ wrong group and permissions
		chown minidlna:minidlna "${EPREFIX}"/var/lib/minidlna || die
		chmod 0750 "${EPREFIX}"/var/lib/minidlna || die
		# if user already exists, but /var/lib/minidlna is missing
		# rely on ${D}/var/lib/minidlna created in src_install
	fi
}

pkg_postinst() {
	elog "minidlna now runs as minidlna:minidlna (bug 426726),"
	elog "logfile is moved to /var/log/minidlna/minidlna.log,"
	elog "cache is moved to /var/lib/minidlna."
	elog "Please edit /etc/conf.d/minidlna and file ownerships to suit your needs."
}