# $Id: Portfile,v 1.6 2005/04/21 00:27:01 jberry Exp $

PortSystem 1.0

name				blojsom
version				2.24

categories			java www
maintainers			jberry@opendarwin.org
platforms			darwin

description			A blogging package written in Java.
long_description	Blojsom is a full-featured, multi-user, multi-blog package written in Java \
					that was inspired by blosxom. blojsom aims to retain the simplicity \
					in design of its Perl-based "relative" while adding user flexibility \
					in areas such as the flavors, templating, plugins, and the ability to \
					run a multi-user blog with a single blojsom installation.
homepage			http://www.blojsom.com
				
distname			${name}-${version}-source
master_sites		sourceforge
checksums			md5 b5aef7e3ebd5840e2d757c61f21df52b

use_zip				yes
use_configure		no

depends_build		bin:ant:apache-ant
depends_lib			bin:java:kaffe

set blog_home		${prefix}/var/db/${name}
set blojsom_user	www
set blojsom_group	www

default_variants	+tomcat5

variant tomcat5 {
	depends_lib-append	port:tomcat5
}

extract.dir			${worksrcpath}
pre-extract {
	file mkdir "${worksrcpath}"
}

post-patch {
	set webInf ${worksrcpath}/war/WEB-INF
	reinplace s|blojsom-blog-home=|blojsom-blog-home=${blog_home}| ${webInf}/blojsom.properties
}
				
build.cmd			ant
build.target		war javadoc

destroot	{
	# Ensure needed directories
	xinstall -m 755 -d \
		${destroot}${prefix}/share/java \
		${destroot}${prefix}/share/doc
	
	# Make a place to store blog entries
	xinstall -m 775 -d ${destroot}${blog_home}/default
	destroot.keepdirs-append ${destroot}${blog_home}/default
	system "chown -R ${blojsom_user}:${blojsom_group} ${destroot}${blog_home}"
	system "chmod -R 775 ${destroot}${blog_home}"
		
	# Install the war where it can be found
	xinstall -m 644 \
		${worksrcpath}/distro/blojsom.war \
		${destroot}${prefix}/share/java
		
	# Install docs
	file copy ${worksrcpath}/docs/content ${destroot}${prefix}/share/doc/${name}

	# Install the war into the tomcat webapps directory
	if {[variant_isset tomcat5]} {
		set dest ${destroot}${prefix}/share/java/tomcat5/webapps/${name}
		
		# Extract the war into tomcat's webapps folder
		xinstall -m 755 -d ${dest}
		system "cd ${dest} && jar xf ${worksrcpath}/distro/blojsom.war"
		
		system "chown -R ${blojsom_user}:${blojsom_group} ${dest}"
		system "chmod -R 775 ${dest}"		
		
		# Do some cleanup on the directory to so that it'll work across upgrades
		set volatile "	WEB-INF/blojsom.properties
						WEB-INF/plugin.properties
						"
		foreach { f } ${volatile} {
			file rename ${dest}/${f} ${dest}/${f}.sample
		}
			
		ui_info "#"
		ui_info "# blojsom was copied into the tomcat5/webapps directory. "
		ui_info "# You may need to kick tomcat so that it'll be deployed."
		ui_info "#"
		ui_info "# The following configuration files have been installed with "
		ui_info "# a .sample suffix to prevent their being munged during upgrade. "
		ui_info "# You'll want to copy them to a like name, without the suffix, during "
		ui_info "# your configuration:"
		ui_info "#      [join ${volatile}]"
		ui_info "#"
	}
}
