From dd4865b22d5884b74b70ed3992286654c4986f31 Mon Sep 17 00:00:00 2001
From: John Marino <marino@FreeBSD.org>
Date: Thu, 5 Jun 2014 22:21:43 +0000
Subject: japanese/xgate: nightmarish stage support added.

* Removed FreeBSD 7 and earlier condition
* Switched from @exec/@unexec to @sample keywords
* Moved /var/log/xgate creation/deletion to plist
* Converted patches to unix CR
* Used DOS2UNIX for entire package
* Used @owner, @group instead of broken %%WWW???%% in plist
* Used UIDFIX and TAR:tgz
* Moved conf file renames from post-extract to post-patch where it belongs
* Removed NOPORTDOCS and used DOCS option instead
* Removed <pre>, <post>, replaced with <options>
* Lots of portlint petting

Verified in Redports
---
 japanese/xgate/Makefile                  | 48 +++++++++++------------
 japanese/xgate/files/patch-log.conf      | 18 +++++++++
 japanese/xgate/files/patch-log.conf-dist | 18 ---------
 japanese/xgate/files/patch-web.xml       | 20 +++++-----
 japanese/xgate/pkg-plist                 | 65 ++++++++++++--------------------
 5 files changed, 73 insertions(+), 96 deletions(-)
 create mode 100644 japanese/xgate/files/patch-log.conf
 delete mode 100644 japanese/xgate/files/patch-log.conf-dist

diff --git a/japanese/xgate/Makefile b/japanese/xgate/Makefile
index adde1c5cd0b5..09b23bbefe6c 100644
--- a/japanese/xgate/Makefile
+++ b/japanese/xgate/Makefile
@@ -3,16 +3,17 @@
 
 PORTNAME=	xgate
 PORTVERSION=	3.7pl6
+PORTREVISION=	1
 CATEGORIES=	japanese mail www java
 MASTER_SITES=	http://www.orangesoft.co.jp/index.php/download_file/-/192/
 DISTNAME=	${PORTNAME}pkg${PORTVERSION}
-EXTRACT_SUFX=	.tgz
 
 MAINTAINER=	ports@FreeBSD.org
-COMMENT=	xGate webmail system implemented by Servlet over IMAP4/POP3
+COMMENT=	Webmail system xGate implemented by Servlet over IMAP4/POP3
 
 RUN_DEPENDS=	${APP_HOME}/bin/bootstrap.jar:${PORTSDIR}/www/tomcat6
 
+USES=		uidfix dos2unix tar:tgz
 NO_BUILD=	yes
 USE_JAVA=	yes
 JAVA_VERSION=	1.6+
@@ -20,7 +21,9 @@ SHAREOWN=	www
 SHAREGRP=	www
 
 PLIST_SUB=	T=${APP_HOME:S|^${LOCALBASE}/||} \
-		WWWUID=${WWWUID} WWWGID=${WWWGID}
+		WWWUID=${WWWOWN} WWWGID=${WWWGRP}
+
+OPTIONS_DEFINE=	DOCS
 
 PORTDOCS=	AdminGuide.pdf \
 		BasicPkgInstallGuide.pdf \
@@ -41,8 +44,7 @@ PORTDOCS=	AdminGuide.pdf \
 
 RESTRICTED=	Commercial license
 
-NO_STAGE=	yes
-.include <bsd.port.pre.mk>
+.include <bsd.port.options.mk>
 
 APP_HOME!=	${MAKE} -C ${PORTSDIR}/www/tomcat6 -VAPP_HOME
 
@@ -67,31 +69,23 @@ CNFLSTS=	account/admin.ndt	\
 
 post-extract:
 	@${MKDIR} ${WRKSRC}/xgate
-.if ${OSVERSION} < 800000
-	@${UNZIP_CMD} ${WRKSRC}/xgate.war -d ${WRKSRC}/xgate
-.else
-	@${TAR} xvf ${WRKSRC}/xgate.war -C ${WRKSRC}/xgate
-.endif
-.for conf in ${CNFLSTS}
-	@cd ${WRKSRC}/xgate/WEB-INF && ${MV} ${conf} ${conf}-dist
-.endfor
+	@${TAR} -xvf ${WRKSRC}/xgate.war -C ${WRKSRC}/xgate
 
 post-patch:
-	${FIND} ${WRKSRC} -name \*.orig -print0 | ${XARGS} -0 ${RM}
-
-do-install:
-	${INSTALL} -d -o ${WWWOWN} -g ${WWWGRP} /var/log/xgate
-	${INSTALL} -d -o ${WWWOWN} -g ${WWWGRP} ${APP_HOME}/webapps/${PORTNAME}
-	@cd ${WRKSRC}/${PORTNAME} && ${COPYTREE_SHARE} \* ${APP_HOME}/webapps/${PORTNAME}
 .for conf in ${CNFLSTS}
-	@cd ${APP_HOME}/webapps/xgate/WEB-INF && \
-		[ ! -f ${conf} ] && ${CP} -p ${conf}-dist ${conf} || ${TRUE}
-.endfor
-.if !defined(NOPORTDOCS)
-	@${MKDIR} ${DOCSDIR}
-.for docf in ${PORTDOCS}
-	@${INSTALL_DATA} ${WRKSRC}/docs/${docf} ${DOCSDIR}
+	@cd ${WRKSRC}/xgate/WEB-INF && ${MV} ${conf} ${conf}.sample
 .endfor
+	${FIND} ${WRKSRC} -name \*.orig -delete
+
+do-install:
+	${MKDIR} ${STAGEDIR}${APP_HOME}/webapps/${PORTNAME}
+	@cd ${WRKSRC}/${PORTNAME} && \
+		${COPYTREE_SHARE} \* ${STAGEDIR}${APP_HOME}/webapps/${PORTNAME}
+.if ${PORT_OPTIONS:MDOCS}
+	@${MKDIR} ${STAGEDIR}${DOCSDIR}
+.  for docf in ${PORTDOCS}
+	@${INSTALL_DATA} ${WRKSRC}/docs/${docf} ${STAGEDIR}${DOCSDIR}
+.  endfor
 .endif
 
-.include <bsd.port.post.mk>
+.include <bsd.port.mk>
diff --git a/japanese/xgate/files/patch-log.conf b/japanese/xgate/files/patch-log.conf
new file mode 100644
index 000000000000..9da03e57e7ee
--- /dev/null
+++ b/japanese/xgate/files/patch-log.conf
@@ -0,0 +1,18 @@
+--- xgate/WEB-INF/conf/log.conf.orig	Wed Nov 16 11:35:47 2005
++++ xgate/WEB-INF/conf/log.conf	Wed Nov 16 11:38:07 2005
+@@ -2,7 +2,7 @@
+ #Fri Oct 10 17:21:19 JST 2003
+ log4j.appender.A.layout.ConversionPattern=%d{MM/dd HH\:mm\:ss} [%-5p] %m%n
+ log4j.appender.E.DatePattern='.'yyyy-MM-dd
+-log4j.appender.E.File=/usr/local/xgate/log/logfile.html
++log4j.appender.E.File=/var/log/xgate/logfile.html
+ log4j.appender.D.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} [%-5p]/ %m%n
+ log4j.appender.A.DatePattern='.'MM/dd
+ log4j.appender.A.layout=org.apache.log4j.PatternLayout
+@@ -12,5 +12,5 @@
+ log4j.appender.E.layout=org.apache.log4j.HTMLLayout
+ log4j.appender.A=org.apache.log4j.ConsoleAppender
+ log4j.appender.D.layout=org.apache.log4j.PatternLayout
+-log4j.appender.D.File=/usr/local/xgate/log/logfile.txt
++log4j.appender.D.File=/var/log/xgate/logfile.txt
+ log4j.rootCategory=DEBUG,D,A
diff --git a/japanese/xgate/files/patch-log.conf-dist b/japanese/xgate/files/patch-log.conf-dist
deleted file mode 100644
index 7844b77224b9..000000000000
--- a/japanese/xgate/files/patch-log.conf-dist
+++ /dev/null
@@ -1,18 +0,0 @@
---- xgate/WEB-INF/conf/log.conf-dist.orig	Wed Nov 16 11:35:47 2005
-+++ xgate/WEB-INF/conf/log.conf-dist	Wed Nov 16 11:38:07 2005
-@@ -2,7 +2,7 @@
- #Fri Oct 10 17:21:19 JST 2003
- log4j.appender.A.layout.ConversionPattern=%d{MM/dd HH\:mm\:ss} [%-5p] %m%n
- log4j.appender.E.DatePattern='.'yyyy-MM-dd
--log4j.appender.E.File=/usr/local/xgate/log/logfile.html
-+log4j.appender.E.File=/var/log/xgate/logfile.html
- log4j.appender.D.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} [%-5p]/ %m%n
- log4j.appender.A.DatePattern='.'MM/dd
- log4j.appender.A.layout=org.apache.log4j.PatternLayout
-@@ -12,5 +12,5 @@
- log4j.appender.E.layout=org.apache.log4j.HTMLLayout
- log4j.appender.A=org.apache.log4j.ConsoleAppender
- log4j.appender.D.layout=org.apache.log4j.PatternLayout
--log4j.appender.D.File=/usr/local/xgate/log/logfile.txt
-+log4j.appender.D.File=/var/log/xgate/logfile.txt
- log4j.rootCategory=DEBUG,D,A
diff --git a/japanese/xgate/files/patch-web.xml b/japanese/xgate/files/patch-web.xml
index 591303ba2450..14afe48e16a1 100644
--- a/japanese/xgate/files/patch-web.xml
+++ b/japanese/xgate/files/patch-web.xml
@@ -1,13 +1,13 @@
 --- xgate/WEB-INF/web.xml.orig	Sat Dec 17 23:52:08 2005
 +++ xgate/WEB-INF/web.xml	Sun Dec 18 15:17:15 2005
 @@ -90,6 +90,10 @@
-         <session-timeout>10</session-timeout>
-     </session-config>
-     <mime-mapping>
-+        <extension>html</extension>
-+        <mime-type>text/html;charset=Shift_JIS</mime-type>
-+    </mime-mapping>
-+    <mime-mapping>
-         <extension>hdml</extension>
-         <mime-type>text/x-hdml;charset=Shift_JIS</mime-type>
-     </mime-mapping>
+         <session-timeout>10</session-timeout>
+     </session-config>
+     <mime-mapping>
++        <extension>html</extension>
++        <mime-type>text/html;charset=Shift_JIS</mime-type>
++    </mime-mapping>
++    <mime-mapping>
+         <extension>hdml</extension>
+         <mime-type>text/x-hdml;charset=Shift_JIS</mime-type>
+     </mime-mapping>
diff --git a/japanese/xgate/pkg-plist b/japanese/xgate/pkg-plist
index d7b03a968d85..77d68fd9ed1f 100644
--- a/japanese/xgate/pkg-plist
+++ b/japanese/xgate/pkg-plist
@@ -1,11 +1,9 @@
+@owner %%WWWUID%%
+@group %%WWWGID%%
 %%T%%/webapps/xgate/META-INF/MANIFEST.MF
 %%T%%/webapps/xgate/WEB-INF/LICENSE.jakarta-struts
-@unexec if cmp -s %D/%%T%%/webapps/xgate/WEB-INF/account/admin.ndt %D/%%T%%/webapps/xgate/WEB-INF/account/admin.ndt-dist; then rm -f %D/%%T%%/webapps/xgate/WEB-INF/account/admin.ndt; fi
-%%T%%/webapps/xgate/WEB-INF/account/admin.ndt-dist
-@exec [ ! -f %B/admin.ndt ] && cp -p %B/%f %B/admin.ndt
-@unexec if cmp -s %D/%%T%%/webapps/xgate/WEB-INF/account/license.dat %D/%%T%%/webapps/xgate/WEB-INF/account/license.dat-dist; then rm -f %D/%%T%%/webapps/xgate/WEB-INF/account/license.dat; fi
-%%T%%/webapps/xgate/WEB-INF/account/license.dat-dist
-@exec [ ! -f %B/license.dat ] && cp -p %B/%f %B/license.dat
+@sample %%T%%/webapps/xgate/WEB-INF/account/admin.ndt.sample
+@sample %%T%%/webapps/xgate/WEB-INF/account/license.dat.sample
 %%T%%/webapps/xgate/WEB-INF/address/readme.txt
 %%T%%/webapps/xgate/WEB-INF/classes/com/happysize/net/radius/Radiusproto.class
 %%T%%/webapps/xgate/WEB-INF/classes/com/happysize/net/radius/Simple_radius_client.class
@@ -740,39 +738,23 @@
 %%T%%/webapps/xgate/WEB-INF/classes/jp/co/orangesoft/xgate/web/WebMessageDisplayVisitor.class
 %%T%%/webapps/xgate/WEB-INF/classes/jp/co/orangesoft/xgate/web/WebReportMessageDisplayVisitor.class
 %%T%%/webapps/xgate/WEB-INF/classes/jp/co/orangesoft/xgate/web/WebWriter.class
-%%T%%/webapps/xgate/WEB-INF/conf/access.dat
-%%T%%/webapps/xgate/WEB-INF/conf/access.dat-dist
-%%T%%/webapps/xgate/WEB-INF/conf/address.data
-%%T%%/webapps/xgate/WEB-INF/conf/address.data-dist
-%%T%%/webapps/xgate/WEB-INF/conf/address.map
-%%T%%/webapps/xgate/WEB-INF/conf/address.map-dist
-%%T%%/webapps/xgate/WEB-INF/conf/admin.ldif
-%%T%%/webapps/xgate/WEB-INF/conf/admin.ldif-dist
-%%T%%/webapps/xgate/WEB-INF/conf/admin_group.ldif
-%%T%%/webapps/xgate/WEB-INF/conf/admin_group.ldif-dist
-%%T%%/webapps/xgate/WEB-INF/conf/createuser.conf
-%%T%%/webapps/xgate/WEB-INF/conf/createuser.conf-dist
-%%T%%/webapps/xgate/WEB-INF/conf/device_match.conf
-%%T%%/webapps/xgate/WEB-INF/conf/device_match.conf-dist
-%%T%%/webapps/xgate/WEB-INF/conf/entry.data
-%%T%%/webapps/xgate/WEB-INF/conf/entry.data-dist
-%%T%%/webapps/xgate/WEB-INF/conf/extra.types
-%%T%%/webapps/xgate/WEB-INF/conf/extra.types-dist
-%%T%%/webapps/xgate/WEB-INF/conf/group.data
-%%T%%/webapps/xgate/WEB-INF/conf/group.data-dist
-%%T%%/webapps/xgate/WEB-INF/conf/group.map
-%%T%%/webapps/xgate/WEB-INF/conf/group.map-dist
+@sample %%T%%/webapps/xgate/WEB-INF/conf/access.dat.sample
+@sample %%T%%/webapps/xgate/WEB-INF/conf/address.data.sample
+@sample %%T%%/webapps/xgate/WEB-INF/conf/address.map.sample
+@sample %%T%%/webapps/xgate/WEB-INF/conf/admin.ldif.sample
+@sample %%T%%/webapps/xgate/WEB-INF/conf/admin_group.ldif.sample
+@sample %%T%%/webapps/xgate/WEB-INF/conf/createuser.conf.sample
+@sample %%T%%/webapps/xgate/WEB-INF/conf/device_match.conf.sample
+@sample %%T%%/webapps/xgate/WEB-INF/conf/entry.data.sample
+@sample %%T%%/webapps/xgate/WEB-INF/conf/extra.types.sample
+@sample %%T%%/webapps/xgate/WEB-INF/conf/group.data.sample
+@sample %%T%%/webapps/xgate/WEB-INF/conf/group.map.sample
 %%T%%/webapps/xgate/WEB-INF/conf/javacat.properties
-%%T%%/webapps/xgate/WEB-INF/conf/ldap.map
-%%T%%/webapps/xgate/WEB-INF/conf/ldap.map-dist
-%%T%%/webapps/xgate/WEB-INF/conf/log.conf
-%%T%%/webapps/xgate/WEB-INF/conf/log.conf-dist
-%%T%%/webapps/xgate/WEB-INF/conf/terminal.dat
-%%T%%/webapps/xgate/WEB-INF/conf/terminal.dat-dist
-%%T%%/webapps/xgate/WEB-INF/conf/user.data
-%%T%%/webapps/xgate/WEB-INF/conf/user.data-dist
-%%T%%/webapps/xgate/WEB-INF/conf/xgate.conf
-%%T%%/webapps/xgate/WEB-INF/conf/xgate.conf-dist
+@sample %%T%%/webapps/xgate/WEB-INF/conf/ldap.map.sample
+@sample %%T%%/webapps/xgate/WEB-INF/conf/log.conf.sample
+@sample %%T%%/webapps/xgate/WEB-INF/conf/terminal.dat.sample
+@sample %%T%%/webapps/xgate/WEB-INF/conf/user.data.sample
+@sample %%T%%/webapps/xgate/WEB-INF/conf/xgate.conf.sample
 %%T%%/webapps/xgate/WEB-INF/dhklib/CMap/78-EUC-H
 %%T%%/webapps/xgate/WEB-INF/dhklib/CMap/78-EUC-V
 %%T%%/webapps/xgate/WEB-INF/dhklib/CMap/78-H
@@ -2069,7 +2051,9 @@
 %%T%%/webapps/xgate/wml/Xmas.png
 %%T%%/webapps/xgate/wml/index.jsp
 %%T%%/webapps/xgate/wml/index_e.jsp
-@dirrmtry %%DOCSDIR%%
+@exec mkdir -p /var/log/xgate
+@owner
+@group
 @dirrm %%T%%/webapps/xgate/wml
 @dirrm %%T%%/webapps/xgate/pda/img
 @dirrm %%T%%/webapps/xgate/pda
@@ -2178,5 +2162,4 @@
 @dirrm %%T%%/webapps/xgate/WEB-INF
 @dirrm %%T%%/webapps/xgate/META-INF
 @dirrm %%T%%/webapps/xgate
-@unexec rmdir /var/log/xgate 2>/dev/null || true
-@exec install -d -o %%WWWUID%% -g %%WWWGID%% /var/log/xgate
+@unexec rm -rf /var/log/xgate 2>/dev/null || true
-- 
cgit debian/1.2.3+git2.25.1-1-2-gaceb0