1PORTNAME?=		inn
2PORTVERSION?=		2.7.2
3PORTREVISION?=		0
4CATEGORIES=		news
5MASTER_SITES=		ISC
6MASTER_SITE_SUBDIR?=	${PORTNAME}
7
8MAINTAINER=	ports@MidnightBSD.org
9COMMENT=	InterNetNews -- the Internet meets Netnews
10WWW=		https://www.eyrie.org/~eagle/software/inn/
11
12LICENSE=	gpl2+ mit bsd3
13LICENSE_COMB=	multi
14
15BUILD_DEPENDS=	p5-GD>=0:graphics/p5-GD \
16		p5-MIME-Tools>=0:mail/p5-MIME-Tools
17
18RUN_DEPENDS:=	${BUILD_DEPENDS}
19
20USE_RC_SUBR=	innd
21SUB_FILES=	pkg-install
22
23USES=		cpe gmake libtool perl5 uidfix
24CPE_VENDOR=	isc
25
26CONFLICTS?=	inn-current
27
28OPTIONS_DEFINE=		BERKELEYDB BLACKLISTD GNUPG KERBEROS PYTHON SASL \
29			SQLITE KEYWORDS LARGE_FILES OPENSSL SETGID_INEWS \
30			TAGGED_HASH UUCP_RNEWS DOCS EXAMPLES
31OPTIONS_DEFAULT=	BERKELEYDB BLACKLISTD GNUPG PYTHON SQLITE KEYWORDS \
32			OPENSSL LARGE_FILES SETGID_INEWS UUCP_RNEWS
33OPTIONS_SUB=		yes
34
35KERBEROS_DESC=		Enable Kerberos v5 (for auth_krb5)
36PYTHON_DESC=		Enable support for embedded Python
37SASL_DESC=		Enable SASL (for imapfeed authentication)
38SQLITE_DESC=		Enable SQLite (for ovsqlite overview method)
39TAGGED_HASH_DESC=	Use tagged hash table for history
40LARGE_FILES_DESC=	Support for files larger than 2GB
41KEYWORDS_DESC=		Automatic keyword generation support
42BERKELEYDB_DESC=	Enable BerkeleyDB (for ovdb overview method)
43BLACKLISTD_DESC=	Enable blacklistd support
44OPENSSL_DESC=		Enable OpenSSL (for NNTP over TLS/SSL support)
45GNUPG_DESC=		GnuPG support (for pgpverify control message)
46UUCP_RNEWS_DESC=	Install rnews suitable for use with net/freebsd-uucp
47SETGID_INEWS_DESC=	Enable posting articles locally for all users
48
49BLACKLISTD_CONFIGURE_WITH=	blacklist
50
51.if ${BRANCH:U} == 2.8
52PLIST_SUB+=		SNAPSHOT=""
53.else
54EXTRA_PATCHES+=		${FILESDIR}/extra-patch-lib_innconf.c
55PLIST_SUB+=		SNAPSHOT="@comment "
56.endif
57
58VARBASE?=	/var
59
60.include "Makefile.layout"
61
62HAS_CONFIGURE=		yes
63CONFIGURE_ENV+=		LOCALBASE=${LOCALBASE}
64CONFIGURE_ENV+=		ac_cv_prog_AWK="${AWK}"
65CONFIGURE_ARGS+=	--mandir=${PREFIX}/share/man		\
66			--prefix=${INN_NEWSBASE}		\
67			--with-spool-dir=${INN_NEWSSPOOL}	\
68			--with-log-dir=${INN_LOGDIR}		\
69			--with-tmp-dir=${INN_TMPDIR}		\
70			--sysconfdir=${INN_CONFDIR}		\
71			--with-run-dir=${INN_RUNDIR}		\
72			--with-db-dir=${INN_DBDIR}		\
73			--datarootdir=${INN_SHAREDIR}		\
74			--with-perl
75
76UUCP_RNEWS_RUN_DEPENDS=	uucp:net/freebsd-uucp
77
78INNLIB_LONG?=		9.0.1
79LIBVER_LONG?=		3.0.8
80LIBSTORAGEVER_LONG?=	3.1.2
81PLIST_SUB+=		LIBVER=${LIBVER_LONG:R:R} LIBVER_LONG=${LIBVER_LONG} \
82			INNLIB=${INNLIB_LONG:R:R} INNLIB_LONG=${INNLIB_LONG} \
83			LIBSTORAGEVER=${LIBSTORAGEVER_LONG:R:R} LIBSTORAGEVER_LONG=${LIBSTORAGEVER_LONG}
84
85.include <bsd.mport.options.mk>
86
87.if ${PORT_OPTIONS:MSQLITE}
88USES+=			sqlite
89CONFIGURE_ARGS+=	--with-sqlite3=${LOCALBASE}
90PLIST_SUB+=		SQLITE=""
91
92TO_BE_STRIPPED+=	bin/ovsqlite-server
93CONFIG_FILES+=		ovsqlite.conf
94.else
95CONFIGURE_ARGS+=	--without-sqlite3
96PLIST_SUB+=		SQLITE="@comment "
97.endif
98
99.if ${PORT_OPTIONS:MBERKELEYDB}
100USES+=			bdb
101CONFIGURE_ARGS+=	--with-bdb=${LOCALBASE} \
102			--with-bdb-lib=${LOCALBASE}/lib \
103			--with-bdb-include=${BDB_INCLUDE_DIR}
104.endif
105
106.if ${PORT_OPTIONS:MKERBEROS}
107.    if exists(${LOCALBASE}/bin/krb5-config)
108LIB_DEPENDS+=		libgssapi_krb5.so:security/krb5
109CONFIGURE_ARGS+=	--with-krb5=${LOCALBASE}
110.    else
111CONFIGURE_ARGS+=	--with-krb5=/usr
112.    endif
113CONFIGURE_ENV+=		ac_cv_search_krb5_parse_name="-lcrypt -lcrypto -lkrb5 -lasn1 -lroken -lhx509"
114CONFIGURE_ENV+=		ac_cv_func_krb5_init_ets=yes
115.else
116CONFIGURE_ARGS+=	--without-krb5
117.endif
118
119.if ${PORT_OPTIONS:MKEYWORDS}
120CONFIGURE_ARGS+=	--enable-keywords
121.endif
122
123.if ${PORT_OPTIONS:MLARGE_FILES}
124CONFIGURE_ARGS+=	--enable-largefiles
125.    if ${PORT_OPTIONS:MTAGGED_HASH}
126IGNORE=			cannot be compiled with both LARGE_FILES and TAGGED_HASH: please re-run make config
127.    endif
128.endif
129
130.if ${PORT_OPTIONS:MPYTHON}
131USES+=			python
132CONFIGURE_ARGS+=	--with-python
133.endif
134
135.if ${PORT_OPTIONS:MSASL}
136CONFIGURE_ARGS+=	--with-sasl=${LOCALBASE}
137LIB_DEPENDS+=		libsasl2.so:security/cyrus-sasl2
138.endif
139
140.if ${PORT_OPTIONS:MTAGGED_HASH}
141CONFIGURE_ARGS+=	--enable-tagged-hash
142DBZ_FILES=		dir pag
143PLIST_SUB+=		WITH_TAGGED_HASH=""
144PLIST_SUB+=		WITHOUT_TAGGED_HASH="@comment "
145.else
146DBZ_FILES=		dir hash index
147PLIST_SUB+=		WITH_TAGGED_HASH="@comment "
148PLIST_SUB+=		WITHOUT_TAGGED_HASH=""
149.endif
150SUB_LIST+=		DBZ_FILES="${DBZ_FILES}"
151
152.if ${PORT_OPTIONS:MOPENSSL}
153USES+=		ssl
154CONFIGURE_ARGS+=	--with-openssl=${OPENSSLBASE}
155.endif
156
157.if ${PORT_OPTIONS:MGNUPG}
158# Although pgpverify needs gpgv/gpgv2,
159# checking 'gpg' is the shortest way to check any version of GnuPG installed.
160BUILD_DEPENDS+=		gpg:security/gnupg
161RUN_DEPENDS+=		gpg:security/gnupg
162.endif
163
164.if ${PORT_OPTIONS:MSETGID_INEWS}
165PLIST_SUB+=		MODE_INEWS="2555"
166.else
167PLIST_SUB+=		MODE_INEWS=""
168.endif
169PORTDOCS=	CONTRIBUTORS HACKING INSTALL LICENSE MANIFEST NEWS README TODO
170
171TO_BE_STRIPPED+=	bin/actsync bin/archive bin/auth/passwd/auth_krb5 \
172	bin/auth/passwd/ckpasswd bin/auth/passwd/radius bin/auth/resolv/domain \
173	bin/auth/resolv/ident bin/batcher bin/buffchan bin/buffindexed_d \
174	bin/convdate bin/ctlinnd bin/cvtbatch bin/expire bin/expireover \
175	bin/fastrm bin/filechan bin/getlist bin/grephistory bin/imapfeed \
176	bin/inews bin/innbind bin/innconfval bin/innd bin/inndf bin/innfeed \
177	bin/innxbatch bin/innxmit bin/makedbz bin/makehistory bin/ninpaths \
178	bin/nnrpd bin/nntpget bin/ovdb_init bin/ovdb_monitor bin/ovdb_server \
179	bin/ovdb_stat bin/overchan bin/prunehistory bin/rnews \
180	bin/rnews.libexec/decode bin/rnews.libexec/encode bin/shlock \
181	bin/shrinkfile bin/sm bin/tdx-util bin/tinyleaf \
182	lib/libinn.so.${INNLIB_LONG} lib/libinnhist.so.${LIBVER_LONG} \
183	lib/libstorage.so.${LIBSTORAGEVER_LONG}
184
185CONFIG_FILES+=	actsync.cfg actsync.ign buffindexed.conf control.ctl \
186	control.ctl.local cycbuff.conf distrib.pats distributions expire.ctl \
187	localgroups incoming.conf inn.conf innfeed.conf innreport.conf \
188	innshellvars.local innshellvars.pl.local innshellvars.tcl.local \
189	innwatch.ctl moderators news2mail.cf newsfeeds nocem.ctl nnrpd.track \
190	nntpsend.ctl ovdb.conf passwd.nntp readers.conf send-uucp.cf \
191	storage.conf subscriptions
192
193SUB_LIST+=	EGDIR="${EXAMPLESDIR:C,^${PREFIX},\\$\\${PREFIX},}"
194PLIST_SUB+=	ETCFILES="${CONFIG_FILES}"
195
196.include <bsd.port.pre.mk>
197
198GID?=	${.MAKE.GID}
199
200post-patch:
201	@${REINPLACE_CMD} -E 's!\$$[{(]PATHETC[})]!${EXAMPLESDIR}!g' \
202	                  ${WRKSRC}/site/Makefile
203	@${REINPLACE_CMD} -e '/^#pragma/d' ${WRKSRC}/*/*.c
204.if ${PORT_OPTIONS:MBERKELEYDB}
205	@${REINPLACE_CMD} -e 's!-ldb!-ldb-${BDB_VER}!' ${WRKSRC}/configure
206.endif
207	@${ECHO_CMD} '/^$$D$$(PATH_HISTORY)' >  ${WRKDIR}/ex.script
208	@${ECHO_CMD} '+'                     >> ${WRKDIR}/ex.script
209	@${ECHO_CMD} 'mark t'                >> ${WRKDIR}/ex.script
210	@${ECHO_CMD} '/^$$'                  >> ${WRKDIR}/ex.script
211	@${ECHO_CMD} "'t, d"                 >> ${WRKDIR}/ex.script
212	@${ECHO_CMD} 'wq!'                   >> ${WRKDIR}/ex.script
213	@cd ${WRKDIR} && ex ${WRKSRC}/site/Makefile < ex.script > /dev/null
214
215pre-install:
216#	@${SETENV} "PKG_PREFIX=${PREFIX}" ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
217	${MKDIR} ${FAKE_DESTDIR}${INN_DBDIR} \
218		${FAKE_DESTDIR}${EXAMPLESDIR} \
219		${FAKE_DESTDIR}${EXAMPLESDIR}/db
220	${REINPLACE_CMD} -e '/^RUNASUSER	*=/s/news/${UID}/'	\
221		-e '/^RUNASGROUP	*=/s/news/${GID}/'	\
222		-e '/^RNEWSGROUP	*=/s/news/${GID}/'	\
223		${WRKSRC}/Makefile.global
224
225post-build:
226	${FIND} ${WRKSRC} -name "inn.conf" \
227	    | ${XARGS} ${REINPLACE_CMD} -e 's/^pathhost:.*/pathhost:               host.example.com/'
228
229post-install:
230.for FILE in ${TO_BE_STRIPPED}
231	-${TEST} -f ${INN_NEWSBASE}/${FILE} && \
232		${STRIP_CMD} ${INN_NEWSBASE}/${FILE}
233.endfor
234	${MKDIR} ${INN_NEWSSPOOL}
235	${MKDIR} ${INN_CONFDIR}
236.for FILE in ${CONFIG_FILES}
237	${CP} -p ${EXAMPLESDIR}/${FILE} ${INN_CONFDIR}/${FILE}.sample
238.endfor
239	${MKDIR} ${INN_DBDIR}
240.for FILE in active active.times newsgroups
241	${MV} ${INN_DBDIR}/${FILE} \
242		${INN_DBDIR}/${FILE}.sample
243.endfor
244	${MKDIR} ${DOCSDIR}
245.for FILE in ${PORTDOCS}
246	${INSTALL_DATA} ${WRKSRC}/${FILE} ${DOCSDIR}
247.endfor
248
249.include <bsd.port.post.mk>
250