# krb5, http://web.mit.edu/kerberos/

name=krb5
version=1.6.3
release=1
source=(http://web.mit.edu/kerberos/dist/${name}/1.5/${name}-${version}-signed.tar 
kdc kadm5.acl)

build() {
	
	# krb5's tarball contains a PGP signature and a tar.gz file--we have to un-tar both balls.
	tar xf ${name}-${version}-signed.tar
	tar xzf ${name}-${version}.tar.gz
	
	# do the usual--the source directory is a subdir of the tarball root, though.
	cd ${name}-${version}/src
	./configure \
		CPPFLAGS="-I/usr/include/et" \
		--with-system-et \
		--prefix=/usr \
		--sysconfdir=/etc \
		--localstatedir=/var/lib \
		--mandir=/usr/share/man \
		--enable-shared \
		--enable-dns \
		--enable-dns-for-kdc \
		--enable-dns-for-realm \
		--disable-nls \
		--with-system-ss \
		--without-krb4 \
		--enable-kdc-replay-cache
	make
	make DESTDIR=${PKG} install
	
	# krb5 has kerberos-enabled versions of common network login utilities and services--we rename them with a "k" prefix to avoid name conflicts.
	for file in telnet ftp rcp rlogin rsh uuclient; do
		mv ${PKG}/usr/bin/$file ${PKG}/usr/bin/k${file}
	done
	for file in ftpd telnetd uuserver; do
		mv ${PKG}/usr/sbin/$file ${PKG}/usr/sbin/k${file}
	done
	for file in telnet.1 ftp.1 rcp.1 rsh.1 rlogin.1 telnetd.8 ftpd.8; do
		mv ${PKG}/usr/share/man/man`echo $file | cut -f2 -d.`/$file ${PKG}/usr/share/man/man`echo $file | cut -f2 -d.`/k${file}
	done
	
	# create directories for configuration and library-esque files.
	mkdir -p \
		${PKG}/etc \
		${PKG}/etc/rc.d \
		${PKG}/var/lib/krb5kdc
	
	# move the example configuration files to their proper, CRUX-ish locations.
	mv ${PKG}/usr/share/examples/krb5/kdc.conf ${PKG}/var/lib/krb5kdc
	mv ${PKG}/usr/share/examples/krb5/krb5.conf ${PKG}/etc
	rm -Rf ${PKG}/usr/share/examples
	
	# edit the example configuration files to CRUX-ish standards, and remove krb4 directives.
	sed -i -e 's|/usr/local/var|/var/lib|g' ${PKG}/var/lib/krb5kdc/kdc.conf
	sed -i -e 's|krb4_.*||g' ${PKG}/etc/krb5.conf
	
	# move the additional configuration files (included with the port) to their locations.
	install -m 644 ${SRC}/kadm5.acl ${PKG}/var/lib/krb5kdc/
	install -m 755 ${SRC}/kdc $PKG/etc/rc.d/
}

# End of file.
