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

 
#SRC_URI="http://github.com/bitly/nsq/archive/v${PV}.zip"
EGIT_REPO_URI="https://github.com/bitly/nsq.git"
IUSE="pynsq supervisor"
SLOT='0' 
#KEYWORDS="~amd64"
[[ ${PV} == *9999* ]] || KEYWORDS="~amd64 ~arm ~ppc ~x86 ~amd64-linux ~x86-linux"
DEPEND="dev-lang/go
	pynsq? ( dev-python/pynsq )
	supervisor? ( app-admin/supervisor )
	"
# include functions from eutils 
inherit eutils

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

}

src_unpack() {
    git clone https://github.com/bitly/nsq.git ${A} || die "Failed to get source"
    cd nsq
    if [ ${PV} != 9999 ]; then
	    git checkout v${PV}
    fi
    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 
	fi
	return	
}


pkg_postinst() {
	go get github.com/bitly/nsq/nsq || 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 ProjectModifiedEvent.java.
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.