summaryrefslogtreecommitdiff
blob: 4cff54ad9a717bf6e08baa5b519f7458c628cfa6 (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
122
123
124
125
126
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit eutils multilib python

PYTHON_DEPEND="2:2.5"
RESTRICT_PYTHON_ABIS="3.*"
EAPI="4"

MY_P="$P"
MY_P="${MY_P/sab/SAB}"
MY_P="${MY_P/_beta/Beta}"
MY_P="${MY_P/_rc/RC}"

DESCRIPTION="Binary Newsgrabber written in Python"
HOMEPAGE="http://www.sabnzbd.org/"
SRC_URI="mirror://sourceforge/sabnzbdplus/${MY_P}-src.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS=""
IUSE="+rar unzip rss +yenc ssl"

RDEPEND="
		>=dev-python/celementtree-1.0.5
		>=dev-python/cheetah-2.0.1
		>=app-arch/par2cmdline-0.4
		>=dev-python/cherrypy-3.2
		rar? ( >=app-arch/unrar-3.9.0 )
		unzip? ( >=app-arch/unzip-5.5.2 )
		yenc? ( >=dev-python/yenc-0.3 )
		ssl? ( >=dev-python/pyopenssl-0.7 
			dev-libs/openssl )"
DEPEND="${RDEPEND}
		app-text/dos2unix"

S="${WORKDIR}/${MY_P}"

HOMEDIR="${ROOT}var/lib/${PN}"
DHOMEDIR="/var/lib/${PN}"

pkg_setup() {
	enewgroup "${PN}"
	enewuser "${PN}" -1 -1 "${HOMEDIR}" "${PN}"
}

src_install() {

	cp "${FILESDIR}/${PN}.ini" "${S}" || die "copying sample ${PN}.ini"

	dodoc CHANGELOG.txt ISSUES.txt INSTALL.txt README.txt Sample-PostProc.sh Sample-PostProc.cmd

	insopts -m0660 -o root -g ${PN}
	newconfd "${FILESDIR}/${PN}.conf" "${PN}"

	newinitd "${FILESDIR}/${PN}.init" "${PN}"

	#SABnzbd >=0.6.0 write temp files when editing config from the web GUI, so directory needs to be writable by the SABnzbd process
	diropts -m0770 -o root -g ${PN}
	dodir /etc/${PN}

	insinto /etc/${PN}/
	insopts -m0660 -o root -g ${PN}
	doins "${PN}.ini" || die "newins ${PN}.ini"

	#Create all default dirs & mark with .keep so portage will not remove them
	keepdir ${DHOMEDIR}
	for i in admin cache complete download dirscan incomplete nzb_backup scripts; do
		keepdir ${DHOMEDIR}/${i}
	done

	#Create & assign ownership of SABnzbd default directories
	fowners -R root:${PN} ${DHOMEDIR}
	fperms -R 770 ${DHOMEDIR}

	#Create & assign ownership of SABnzbd log directory
	keepdir /var/log/${PN}
	fowners -R root:${PN} /var/log/${PN}
	fperms -R 770 /var/log/${PN}

	#Create & assign ownership of SABnzbd PID directory
	keepdir /var/run/${PN}
	fowners -R root:${PN} /var/run/${PN}
	fperms -R 770 /var/run/${PN}

	#Add themes & code into /usr/share
	dodir /usr/share/${P}
	insinto /usr/share/${P}
	for i in interfaces sabnzbd email locale po tools util;do
		doins -r $i
	done

	doins SABnzbd.py

	#create symlink to /usr/share/sabnzbd (minus version #)
	dosym /usr/share/${P} /usr/share/${PN}

	#Adjust permissions in python source directory for root:sabnzbd
	fowners -R root:${PN} /usr/share/${P}
	fperms -R 770 /usr/share/${P}
}

pkg_postinst() {
	python_mod_optimize /usr/share/${P}/sabnzbd

	einfo "SABnzbd has been installed with default directories in ${HOMEDIR}"
	einfo "Email templates can be found in: ${ROOT}usr/share/${P}/email"
	einfo ""
	einfo "By default, SABnzbd runs as the unprivileged user \"sabnzbd\"" 
	einfo "on port 8081 with no API key."
	einfo ""
	einfo "Be sure to that the \"sabnzbd\" user has the appropriate"
	einfo "permissions to read/write to any non-default directories" 
	einfo "if changed in ${PN}.ini"
	einfo ""
	einfo "Configuration files are accessible only to users in the \"sabnzbd\" group"
	einfo "Run 'gpasswd -a <user> sabnzbd' to add a  user to the sabnzbd group"
	einfo "so it can edit the appropriate configuration files"
	einfo ""
	ewarn "Please configure /etc/conf.d/${PN} before starting!"
	ewarn ""
	ewarn "Start with ${ROOT}etc/init.d/${PN} start"
	ewarn "Visit http://<host ip>:8081 to configure SABnzbd"
	ewarn "Default web username/password : sabnzbd/secret"
}