nashedelo / net-misc / nsq / nsq-9999.ebuild

IUSE="pynsq supervisor"
[[ ${PV} == *9999* ]] || KEYWORDS="~amd64 ~arm ~ppc ~x86 ~amd64-linux ~x86-linux"
	pynsq? ( dev-python/pynsq )
	supervisor? ( app-admin/supervisor )
# include functions from eutils 
inherit eutils

pkg_setup() {
	if [ ! -f /usr/lib/go/src/pkg/ ]; then
		die "You need go-notify. Install it with 'go get' "
	elif [ ! -f /usr/lib/go/src/pkg/ ]; then
		die "You need go-simplejson. Install it with 'go get' "
	elif [ ! -f /usr/lib/go/src/pkg/ ]; then
		die "You need assert. Install it with 'go get' "
	#Create nsq user and group
        enewgroup nsq
        enewuser nsq -1 -1 /var/lib/nsq nsq


src_unpack() {
    git clone ${A} || die "Failed to get source"
    cd nsq
    if [ ${PV} != 9999 ]; then
	    git checkout v${PV}
    sed -i 's/PREFIX=\/usr\/local/PREFIX=\/usr/g' Makefile
    epatch "${FILESDIR}"/*.patch

src_compile() {
	cd "${PN}"
	emake || die "Compile failed"

src_install() {
	cd "${PN}"
	emake DESTDIR="${D}" install || die "Install failed"
	diropts -m 0770 -o nsq -g nsq
        keepdir /var/log/nsq
	if use supervisor; then
		diropts -o root -g root
		keepdir /etc/supervisor.d
		insinto /etc/supervisor.d/   
                doins "${FILESDIR}"/nsq.conf 

pkg_postinst() {
	go get || die "Failed to get nsq package for GO"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.