1#PORTREVISION=	0
2
3MAINTAINER=	ports@MidnightBSD.org
4COMMENT=	Version control system
5
6CONFLICTS_INSTALL=	subversion-lts
7
8USE_RC_SUBR=	svnserve
9
10PORTDOCS=	BUGS CHANGES COMMITTERS INSTALL README
11
12OPTIONS_DEFINE=	\
13		BDB		\
14		DOCS		\
15		NLS		\
16		SASL		\
17		SERF		\
18		STATIC		\
19		SVNSERVE_WRAPPER\
20		TEST		\
21		TOOLS
22
23OPTIONS_DEFAULT= SERF TOOLS
24
25SERF_DESC=		WebDAV/Delta-V (HTTP/HTTPS) repo access module
26STATIC_DESC=		Build static version (no shared libs)
27SVNSERVE_WRAPPER_DESC=	Enable svnserve wrapper (umask setter)
28TEST_DESC=		Run subversion test suite
29TOOLS_DESC=		Install several tools
30
31# Patches required for use with the FreeBSD Project repository only
32SVNSERVE_WRAPPER_EXTRA_PATCHES=	${PATCHDIR}/extra-patch-svnserve-wrapper
33
34USES+=			shebangfix python:2.7,env
35python_CMD=		${LOCALBASE}/bin/python2.7
36python_OLD_CMD+=	"/bin/env python"
37SHEBANG_REGEX=		./tools/.*
38
39.include "Makefile.common"
40
41SVNREPOS?=	/home/svn/repos
42SVNFSTYPE?=	fsfs
43SVNGROUP?=	svn
44SVNUSER?=	svn
45
46CONFIGURE_ARGS+=	--without-gnome-keyring \
47			--without-kwallet \
48			--with-apxs=no
49
50.if ${PORT_OPTIONS:MSVNSERVE_WRAPPER}
51SUB_LIST+=	SVNSERVE_BIN_EXT=".bin"
52PLIST_SUB+=	NO_SVNSERVE_WRAPPER="@comment "
53.else
54SUB_LIST+=	SVNSERVE_BIN_EXT=""
55PLIST_SUB+=	NO_SVNSERVE_WRAPPER=""
56.endif
57
58.if ${PORT_OPTIONS:MTEST}
59TEST_DEPENDS=	${PYTHON_PKGNAMEPREFIX}sqlite3>0:databases/py-sqlite3@${PY_FLAVOR}
60.endif
61
62.if ${PORT_OPTIONS:MSTATIC}
63.  if ${PORT_OPTIONS:MNLS}
64USES+=			gettext-tools
65.  endif
66.  if ${PORT_OPTIONS:MBDB}
67BDB_BUILD_DEPENDS=	yes
68.  endif
69OLD_LIB_DEPENDS:=	${LIB_DEPENDS:S!^!${LOCALBASE}/lib/!:C!(\.so|\.[0-9]+)?:!.a:!}
70BUILD_DEPENDS+=		${OLD_LIB_DEPENDS}
71LIB_DEPENDS=
72.endif
73
74.if ${PORT_OPTIONS:MBDB}
75CONFIGURE_ARGS+=	--enable-bdb6
76.else
77CONFIGURE_ARGS+=	--without-berkeley-db
78.endif
79
80.if make(repository)
81WITH_REPOSITORY_CREATION=	yes
82.endif
83
84.if defined(WITH_REPOSITORY_CREATION)
85MKREPOS_TARGET=	_mkrepos
86.endif
87
88pre-everything::
89	@${ECHO_MSG} ""
90.if defined(WITH_REPOSITORY_CREATION)
91	@${ECHO_MSG} "I will create (or use, if it exists) '${SVNUSER}' user and '${SVNGROUP}' group."
92	@${ECHO_MSG} "Make sure that all committers are its members."
93	@${ECHO_MSG} ""
94	@${ECHO_MSG} "Repository will be created at '${SVNREPOS}' with user '${SVNUSER}' and group '${SVNGROUP}'."
95	@${ECHO_MSG} "Type of repository will be '${SVNFSTYPE}'."
96	@${ECHO_MSG} "You could change these settings by defining SVNREPOS, SVNGROUP and SVNFSTYPE."
97.else
98	@${ECHO_MSG} "You can have the repository created for you by defining"
99	@${ECHO_MSG} "WITH_REPOSITORY_CREATION."
100	@${ECHO_MSG} ""
101	@${ECHO_MSG} "Make sure that:"
102	@${ECHO_MSG} "* all your svn users are members of a common group"
103	@${ECHO_MSG} "* this group is the group id of the db/ and locks/"
104	@${ECHO_MSG} "  subdirectories of your repository"
105	@${ECHO_MSG} "* the above subdirectories are writable by this group"
106.endif
107
108	@${ECHO_MSG} ""
109.if ${PORT_OPTIONS:MSTATIC}
110	@${ECHO_MSG} "Static binaries will be built."
111.endif # STATIC
112	@${ECHO_MSG} "Many useful scripts will be installed into ${DATADIR}"
113
114pre-configure:
115.if ${PORT_OPTIONS:MBDB}
116	@BDB_VERSION=`${APR_APU_DIR}/${APU_CONFIG} --db-version`; \
117	if [ "$${BDB_VERSION}" != "4" -a "$${BDB_VERSION}" != "5" -a "$${BDB_VERSION}" != "6" ] ; then \
118		${ECHO_MSG} "" ; \
119		${ECHO_MSG} 'You should build `'"devel/apr1' with Berkeley DB (4, 5 or 6) support to use subversion with it." ; \
120		${ECHO_MSG} 'Please rebuild `'"devel/apr1' with option "'`'"BDB' and try again." ; \
121		${ECHO_MSG} "" ; \
122		${ECHO_MSG} "Or you can disable Berkeley DB support. Only 'fs' repository backend will be available." ; \
123		${ECHO_MSG} "" ; \
124		${FALSE} ; \
125	fi
126.endif
127.if ${PORT_OPTIONS:MSTATIC}
128	@if ${GREP} -q ucol_close /usr/lib/libsqlite3.a ; then \
129		${ECHO_MSG} "" ; \
130		${ECHO_MSG} "You can not build static subversion if your SQLite3 is built with ICU enabled."; \
131		${ECHO_MSG} "Please, reinstall 'devel/sqlite3' port with disabled ICU support."; \
132		${ECHO_MSG} "" ; \
133		${FALSE} ; \
134	fi
135.endif
136
137post-configure:
138# Enable GNOME Keyring / KWallet support in main code, as it is harmless
139	@${REINPLACE_CMD} -E 's%.*#undef SVN_HAVE_(GNOME_KEYRING|KWALLET).*%#define SVN_HAVE_\1 1%' ${WRKSRC}/subversion/svn_private_config.h
140# ugly hack: save tools directory so we don't have to cleanup before installing
141	@${CP} -R ${WRKSRC}/tools ${WRKSRC}/tools.examples
142	@${CHMOD} -R a-st,o+rX ${WRKSRC}/tools.examples
143
144# takes a long time, and will fail but gives maintainer a good oversight
145.if ${PORT_OPTIONS:MTEST}
146test: build
147	-@make check -C ${WRKSRC}
148.endif
149
150post-build:
151	${MAKE} -C ${WRKSRC} tools ${MAKE_ARGS}
152
153post-install:	${MKREPOS_TARGET}
154	-@${STRIP_CMD} ${PREFIX}/bin/*
155	@${MKDIR} ${DATADIR}
156	(cd ${WRKSRC}/tools.examples && ${TAR} --exclude '*.in' -cf - * | ${TAR} -C ${DATADIR} -xof - )
157	@${MKDIR} ${DOCSDIR}
158	${INSTALL_MAN} ${PORTDOCS:S|^|${WRKSRC}/|} ${DOCSDIR}
159
160.if ${PORT_OPTIONS:MSTATIC}
161
162.else
163	-@${STRIP_CMD} ${PREFIX}/lib/*.so
164.endif
165	@${INSTALL_SCRIPT} ${FILESDIR}/svnserve.wrapper ${PREFIX}/bin/svnserve.sample
166	@${MAKE} -C ${WRKSRC} install-tools ${FAKE_MAKEARGS}
167	-@${STRIP_CMD} ${PREFIX}/bin/*
168
169# ===============================================================================
170repository:	_mkrepos
171
172_SVNGRPFILES=	db locks locks/db.lock locks/db-logs.lock
173SVNGRPFILES=	${_SVNGRPFILES:S,^,${SVNREPOS}/,}
174
175_mkrepos:	.USE
176.if !exists(${SVNREPOS})
177.if ${PORT_OPTIONS:MSVNSERVE_WRAPPER}
178	@if /usr/sbin/pw groupshow "${SVNGROUP}" >/dev/null 2>&1; then \
179	    ${ECHO_MSG} "You already have a group \"${SVNGROUP}\", so I will use it."; \
180	else \
181	    if /usr/sbin/pw groupadd ${SVNGROUP} -h -; \
182	    then \
183	        ${ECHO_MSG} "Added group \"${SVNGROUP}\"."; \
184	    else \
185	        ${ECHO_MSG} "Adding group \"${SVNGROUP}\" failed..."; \
186	        ${ECHO_MSG} "Please create it, and try again."; \
187	        ${FALSE}; \
188	    fi; \
189	fi
190	@if /usr/sbin/pw usershow "${SVNUSER}" >/dev/null 2>&1; then \
191	    ${ECHO_MSG} "You already have a user \"${SVNUSER}\", so I will use it."; \
192	else \
193	    if /usr/sbin/pw useradd ${SVNUSER} -h -; \
194	    then \
195	        ${ECHO_MSG} "Added user \"${SVNUSER}\"."; \
196	    else \
197	        ${ECHO_MSG} "Adding user \"${SVNUSER}\" failed..."; \
198	        ${ECHO_MSG} "Please create it, and try again."; \
199	        ${FALSE}; \
200	    fi; \
201	fi
202.endif
203	@${MKDIR} ${SVNREPOS}
204	@${PREFIX}/bin/svnadmin create --fs-type ${SVNFSTYPE} ${SVNREPOS}
205.if ${PORT_OPTIONS:MSVNSERVE_WRAPPER}
206	@${CHOWN} ${SVNUSER}:${SVNGROUP} ${SVNGRPFILES}
207	@${CHMOD} g+w ${SVNGRPFILES}
208	@for i in ${SVNREPOS}/db/* ; do \
209	    i=$${i##*/}; \
210	    case $$i in \
211	    DB_CONFIG|fs-type|uuid) ;; \
212	    *) ${CHOWN} -R ${SVNUSER}:${SVNGROUP} ${SVNREPOS}/db/$$i; \
213	       ${CHMOD} -R g+w ${SVNREPOS}/db/$$i; \
214	       ;; \
215	    esac; \
216	done
217.endif
218.endif
219
220svn-build-outputs-hack:
221	(cd ${WRKSRC} && ${PATCH} ${PATCH_DIST_ARGS} -p0 < ${PATCHDIR}/extra-patch-build.conf)
222	(cd ${WRKSRC} && python2.7 gen-make.py --release --installed-libs libsvn_client,libsvn_delta,libsvn_diff,libsvn_fs,libsvn_fs_x,libsvn_ra,libsvn_repos,libsvn_subr,libsvn_wc)
223	${MV} ${WRKSRC}/build-outputs.mk ${FILESDIR}/build-outputs.mk.addons
224
225.include <bsd.port.post.mk>
226