summaryrefslogtreecommitdiff
blob: 4708a35e9504c45bab1abd1875b0bcdb971d7e4a (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
113
114
115
116
117
118
119
120
121
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/media-sound/slimserver/slimserver-6.5.1.ebuild,v 1.1 2007/01/18 23:33:10 twp Exp $

inherit eutils

MY_P=SlimServer_v${PV}
DESCRIPTION="Slim Devices' SlimServer"
HOMEPAGE="http://www.slimdevices.com/slimserver/"
SRC_URI="http://www.slimdevices.com/downloads/${MY_P}/${MY_P}.no-cpan-arch.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="aac alac encode ffmpeg flac musepack ogg shorten"
DEPEND="sys-apps/findutils"
RDEPEND="
	>=dev-lang/perl-5.8.3
	>=virtual/mysql-5.0
	>=dev-perl/Compress-Zlib-1.41
	>=dev-perl/DBD-mysql-3.0007
	>=dev-perl/DBI-1.50
	>=dev-perl/Digest-SHA1-2.11
	dev-perl/GD
	>=dev-perl/HTML-Parser-3.48
	>=dev-perl/Template-Toolkit-2.14
	>=dev-perl/XML-Parser-2.34
	>=dev-perl/YAML-Syck-0.64
	>=net-misc/mDNSResponder-107
	>=virtual/perl-Time-HiRes-1.86
	aac? ( media-libs/faad2 )
	alac? ( media-sound/alac_decoder )
	encode? ( media-sound/lame )
	ffmpeg? ( media-video/ffmpeg )
	flac? ( media-libs/flac )
	musepack? ( media-sound/musepack-tools )
	ogg? ( media-sound/sox )
	shorten? ( media-sound/shorten )
	"
S="${WORKDIR}/${MY_P}"

pkg_setup() {
	if use ogg; then
		if ! built_with_use media-sound/sox ogg; then
			eerror "media-sound/sox not built with USE=ogg"
			die "media-sound/sox not built with USE=ogg"
		fi
	fi
	enewgroup slimserver || die
	enewuser slimserver -1 -1 /opt/slimserver slimserver || die
}

src_unpack() {
	unpack ${A}
	cd ${S}
	epatch ${FILESDIR}/slimserver-bootstrap-gentoo.patch || die
	epatch ${FILESDIR}/slimserver-mDNSResponderPosix-107.patch || die
	rm Bin/build-perl-modules.pl
	rm CPAN/YAML/Syck.pm
	rm MySQL/errmsg.{sys,txt}
	#rm -rf MySQL
}

src_install() {
	# copy all files
	dodir /opt/slimserver
	cp -r * ${D}/opt/slimserver
	# initialize preferences file
	dodir /etc
	touch ${D}/etc/slimserver.prefs
	#password=$(gawk '$1 == "dbpassword:" { print $2 }' ${R}/etc/slimserver.prefs)
	#[[ -z "${password}" || "${password}" == "''" ]] \
	#	&& password="${RANDOM}.${RANDOM}.${RANDOM}.${RANDOM}"
	#cat <<EOF > ${D}/etc/slimserver.prefs
	#--- 
	#dbsource: dbi:mysql:database=slimserver
	#dbusername: slimserver
	#dbpassword: ${password}
	#EOF
	fowners slimserver:slimserver /etc/slimserver.prefs
	# create symbolic links to local mysql files
	dosym ../../../usr/sbin/mysqld /opt/slimserver/Bin/mysqld
	dosym ../../../usr/share/mysql/english/errmsg.sys \
		/opt/slimserver/MySQL/errmsg.sys
	dosym ../../../usr/share/mysql/errmsg.txt \
		/opt/slimserver/MySQL/errmsg.txt
	# create symbolic link to local mDNSResponderPosix
	dosym ../../../usr/sbin/mDNSResponderPosix \
		/opt/slimserver/Bin/mDNSResponderPosix
	# install init scripts
	newconfd ${FILESDIR}/slimserver.conf.d slimserver
	newinitd ${FILESDIR}/slimserver.init.d slimserver
	# initialize /var/{cache,run}
	keepdir /var/{cache,run}/slimserver
	fowners slimserver:slimserver /var/{cache,run}/slimserver
	# initialize /var/log
	dodir /var/log
	touch ${D}/var/log/slimserver
	fowners slimserver:slimserver /var/log/slimserver
}

pkg_postinst() {
	#einfo "To create the SlimServer database, run"
	#einfo "\temerge --config =${CATEGORY}/${PF}"
	einfo "To start SlimServer, run"
	einfo "\t/etc/init.d/slimserver start"
	einfo "To start SlimServer automatically on boot, run:"
	einfo "\trc-update add slimserver default"
	httpport=$(gawk '$1 == "httpport:" { print $2 }' ${R}/etc/slimserver.prefs)
	einfo "To configure SlimServer, browse to:"
	einfo "\thttp://localhost:${httpport:-9000}/"
}

#pkg_config() {
#	einfo "Enter your mysql root password:"
#	dbpassword=$(gawk '$1 == "dbpassword:" { print $2 }' ${R}/etc/slimserver.prefs)
#	[[ "$password" == "''" ]] && dbpassword=
#	mysql -u root -p <<EOF
#create database slimserver;
#grant all on slimserver.* to slimserver identified by '${dbpassword}';
#EOF
#}