SUMMARY="A tool to find not-installed applications"
DESCRIPTION="Command-not-found hooks into the command_not_found_handle  \
to inform end users where to find an application if they don't have it. \
It can also check for typos (a feature of zsh)."
HOMEPAGE="https://github.com/jrabbit/haiku-cnf"
COPYRIGHT="2011 Jrabbit"
LICENSE="GNU GPL v2"
REVISION="3"
srcGitRev="db1be8b57dedff781dc68caa46f403d88c5eedb9"
SOURCE_URI="$HOMEPAGE/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="a1ce4e6c8a7307c0d5c1e65a90b3d2a7ba9d16d9506a70aab1005129333d6121"
SOURCE_FILENAME="haiku-cnf-$portVersion-$srcGitRev.tar.gz"
SOURCE_DIR="haiku-cnf-$srcGitRev"
PATCHES="command_not_found-0.0.1~git.patchset"

ARCHITECTURES="any"

PROVIDES="
	command_not_found = $portVersion
	cmd:command_not_found = $portVersion
	"
REQUIRES="
	haiku
	cmd:python
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:python
	"

BUILD()
{
	true
}

INSTALL()
{
	install -d $binDir $dataDir/profile.d
	install -m 0755 haiku_cnf.py $binDir/command_not_found

	cat > $dataDir/profile.d/command-not-found.sh << EOF
command_not_found_handle() {
	if command -v command_not_found >/dev/null 2>&1; then
		command_not_found "\$1"
		return "\$?"
	else
		echo "\$1: command not found: try pkgman install cmd:\$1"
		return 127 # bash return code for command not found
	fi
}
EOF
}
