PortSystem 1.0

name		zeroinstall-injector
version		1.7
revision	6
platforms	darwin freebsd linux
categories	sysutils
license		LGPL
maintainers	nomaintainer
description	The Zero Install Injector (0launch)
long_description \
The Zero Install Injector makes it easy for users to install software without \
needing root privileges. It takes the URL of a program and runs it (downloading \
it first if necessary). Any dependencies of the program are fetched in the same \
way. The user controls which version of the program and its dependencies to \
use.

homepage	http://0install.net
master_sites	sourceforge
master_sites.mirror_subdir	zero-install
use_bzip2	yes
checksums	md5 23e2adf699c52f8cdfbb7ad07d6c5568 \
		sha1 eabe6d1284522be4a5c2675807646f247a33ffac \
		rmd160 46ac65794f57146afed45582d4ff43f05ffe5bb9

depends_lib	path:bin/gpg:gnupg2
depends_run	bin:sudo:sudo

set python.branch	2.x
set python.bin		${prefix}/bin/python

variant python26 conflicts python27 description "use python 2.6" {
depends_lib-append	port:python26
depends_run-append	port:py26-pygtk

set python.branch	2.6
set python.bin		${prefix}/bin/python${python.branch}
}

variant python27 conflicts python26 description "use python 2.7" {
depends_lib-append	port:python27
depends_run-append	port:py27-pygtk

set python.branch	2.7
set python.bin		${prefix}/bin/python${python.branch}
}

if {![variant_isset python26]} {
	default_variants +python27
}

post-patch   {
	reinplace "s|'man/man1'|'share/man/man1'|" ${worksrcpath}/setup.py
	reinplace "s|local_0launch,|'${python.bin}', local_0launch,|" ${worksrcpath}/tests/testrun.py
}

use_configure	no
supported_archs	noarch

pre-build {
build.cmd	${python.bin} setup.py
build.target		build
}

pre-destroot {
destroot.cmd	${python.bin} setup.py
destroot.destdir	--prefix=${prefix} --skip-build --root=${destroot}
}

post-destroot   {
	reinplace "s|/usr/bin/env python|${python.bin}|" \
	          ${destroot}${prefix}/lib/python${python.branch}/site-packages/zeroinstall/0launch-gui/0launch-gui

	# move site-packages to wherever python is looking for it
	file mkdir ${destroot}[exec ${python.bin} -c "from distutils.sysconfig import get_python_lib; import os; print os.path.dirname(get_python_lib())"]
	file rename ${destroot}${prefix}/lib/python${python.branch}/site-packages \
	            ${destroot}[exec ${python.bin} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"]
}

pre-test {
test.run	yes
test.cmd	${python.bin}
test.dir	${worksrcpath}/tests
test.target	testall.py
}

livecheck.type  regex
livecheck.url   https://sourceforge.net/projects/zero-install/files/injector/
livecheck.regex /injector/(\\d+(?:\\.\\d+)*)/