pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

zoneminder: Rototill more



Module Name:	pkgsrc-wip
Committed By:	Greg Troxel <gdt%lexort.com@localhost>
Pushed By:	gdt
Date:		Mon May 29 06:33:23 2023 -0400
Changeset:	45e8b0bce6ed2b8b90f51b231bec9bc97c190bc2

Modified Files:
	zoneminder/COMMIT_MSG
	zoneminder/Makefile
	zoneminder/files/zoneminder.conf

Log Message:
zoneminder: Rototill more

Commit to cmake only; upstream has removed configure.ac.  Prune
CONFIGURE_ARGS after considering each one.

Reorganize Makefile into logical sections (other deps, perl, PHP, web
server, paths).

Move config to etc/zm, to accomodate zondeminder's use of
etc/zm/conf.d which would be irregular as etc/conf.d.

Allow a choice of apache or nginx, with the nginx support being
untested but a reasonable guess.   Do not allow building without a web
server, at least for now.

Separate CONTENTDIR and CACHEDIR.

Merge redundant path sections.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=45e8b0bce6ed2b8b90f51b231bec9bc97c190bc2

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 zoneminder/COMMIT_MSG            |  24 +--
 zoneminder/Makefile              | 336 +++++++++++++++++++++------------------
 zoneminder/files/zoneminder.conf |  52 ++++--
 3 files changed, 234 insertions(+), 178 deletions(-)

diffs:
diff --git a/zoneminder/COMMIT_MSG b/zoneminder/COMMIT_MSG
index f9ecc68328..5ba073f570 100644
--- a/zoneminder/COMMIT_MSG
+++ b/zoneminder/COMMIT_MSG
@@ -3,8 +3,13 @@ security/zoneminder: Update to 1.32.3
 Welcome to 2018.
 
 Packaging changes:
-  Upstream removed zmf; drop patch.
-  Depend on mp4v2.
+
+  - Change config to etc/zm from etc, and provide etc/zm/conf.d, because
+    migration from 1.30 writes there.
+  - Rototill hard the cmake build options, and try to document what
+    must be set as path configuration.
+  - Upstream removed zmf; drop patch.
+  - Depend on mp4v2.
 
 Upstream NEWS:
 
@@ -38,14 +43,14 @@ Upstream NEWS:
 
     Support for Redhat el6 distros and clones has been removed
 
-Upstream upgrade notes:
+Upstream upgrade notes (tweaked for pkgsrc):
 
     The upgrade scripts will take longer than normal to run,
-    especially if you have many events
+    especially if you have many events.
 
     Your previous settings on the Options -> Paths tab have been moved
-    into the file zmcustom.conf which is typically found under
-    /etc/zm/conf.d
+    into the file zmcustom.conf which is found under
+    ${PKGSYSCONFDIR}/etc/zm/conf.d
 
     Consider migrating your events folder from the former bind mount
     method to the new method under Options -> Storage
@@ -53,9 +58,6 @@ Upstream upgrade notes:
     You should no longer have symbolic links in your webroot
     folder. This resolves a long standing security issue.
 
-    The Apache config file has changed. This config file may or may
-    not update automatically. This depends on what distro you are
-    running and how you installed ZoneMinder. Please refer to the
-    documentation for your distro to learn what specific steps are
-    required.
+    The Apache config file has changed.  Hand merge it and review your
+    web setup.
 
diff --git a/zoneminder/Makefile b/zoneminder/Makefile
index f796d3e707..f786dbfac4 100644
--- a/zoneminder/Makefile
+++ b/zoneminder/Makefile
@@ -1,8 +1,8 @@
 # $NetBSD: Makefile,v 1.42 2019/06/18 12:36:59 gdt Exp $
 
 VERSION=	1.32.3
-PKGREVISION=	2
-# Sometimes the distfile unpacks to ZoneMinder and sometimes zoneminder.
+PKGREVISION=	3
+# Distfile is ZoneMinder but package and tarball contents are zoneminder.
 NAME_DIST=	ZoneMinder
 NAME_LOWER=	zoneminder
 
@@ -16,6 +16,7 @@ GITHUB_TYPE=	tag
 GITHUB_TAG=	${PKGVERSION_NOREV}
 
 # Submodules as per ZoneMinder's .gitmodules file
+# \todo Add CakePHP-Enum-Behavior.
 GITHUB_SUBMODULES=	FriendsOfCake crud v3.0.10 web/api/app/Plugin/Crud
 
 MAINTAINER=	dsainty%NetBSD.org@localhost
@@ -24,106 +25,106 @@ HOMEPAGE=	https://www.zoneminder.com/
 COMMENT=	Video camera security and surveillance solution
 LICENSE=	gnu-gpl-v2
 
-# NetBSD tar: Invalid header, starting valid header search.
-EXTRACT_USING=	gtar
-
-# ZoneMinder 1.30 seems to work fine on at least PHP 7.4.
-# ZoneMinder 1.32 with PHP 7.4 does not appear to have PHP-related problems.
-# Under PHP 8.0 <1.30 was logging at Error level type errors out of skin.js.
-# Under PHP 8.1 <1.30 was logging at Panic level that strftime is deprecated.
-#
-# Therefore 74 is the standard approach and it is \todo to try higher.
-PHP_VERSIONS_ACCEPTED=	74
-
-PKG_OPTIONS_VAR=	PKG_OPTIONS.zoneminder
-PKG_SUPPORTED_OPTIONS=	apache
-PKG_SUGGESTED_OPTIONS=	apache
+# ZoneMinder without a web server does not really make sense, and if
+# it did, what is omitted is surely not right.  For now, require a
+# choice of webserver.
+PKG_OPTIONS_VAR=		PKG_OPTIONS.zoneminder
+PKG_OPTIONS_REQUIRED_GROUPS=	webserver
+PKG_OPTIONS_GROUP.webserver=	apache nginx
+PKG_SUGGESTED_OPTIONS=		apache
 
 .include "../../mk/bsd.options.mk"
 
+## MAIN BUILD
+
+# As of 1.32, ZoneMinder has removed autoconf support.
 USE_CMAKE=	yes
 USE_LANGUAGES=	c c++
 USE_TOOLS+=	gmake perl pkg-config
 
-# zoneminder can depend on a number of perl modules depending on
-# configuration.  We take the view that if an installation can be
-# reasonably configured to use a module, that module should be a
-# dependency, absent some reason that it is so heavyweight that it
-# should be an option.  zoneminder discourages building from source
-# and does not appear to document the list of dependencies
-DEPENDS+=	p5-Archive-Zip-[0-9]*:../../archivers/p5-Archive-Zip
-DEPENDS+=	p5-Device-SerialPort-[0-9]*:../../comms/p5-Device-SerialPort
-DEPENDS+=	p5-DBD-mysql-[0-9]*:../../databases/p5-DBD-mysql
-DEPENDS+=	p5-Date-Manip-[0-9]*:../../devel/p5-Date-Manip
-DEPENDS+=	p5-PHP-Serialization-[0-9]*:../../devel/p5-PHP-Serialization
-DEPENDS+=	p5-Sys-Mmap-[0-9]*:../../devel/p5-Sys-Mmap
-DEPENDS+=	p5-MIME-Lite-[0-9]*:../../mail/p5-MIME-Lite
-DEPENDS+=	p5-MIME-tools-[0-9]*:../../mail/p5-MIME-tools
-DEPENDS+=	p5-Net-SFTP-Foreign-[0-9]*:../../net/p5-Net-SFTP-Foreign
-DEPENDS+=	p5-Sys-MemInfo-[0-9]*:../../sysutils/p5-Sys-MemInfo
-#DEPENDS+=	{perl>=5.7.3,p5-Time-HiRes-[0-9]*}:../../time/p5-Time-HiRes
-DEPENDS+=	p5-libwww-[0-9]*:../../www/p5-libwww
+# For now, lean to debugging.
+CMAKE_ARGS+=	-DCMAKE_VERBOSE_MAKEFILE=true
+CMAKE_ARGS+=	-DCMAKE_BUILD_TYPE=Debug
 
-# \todo: Decide to drop CONFIGURE_ARGS, validating that each has been
-# turned into cmake, once we are at a zoneminder version that does not
-# support autoconf (which maybe we are at already!).
-CONFIGURE_ARGS+=	--sysconfdir=${PKG_SYSCONFDIR}
-CMAKE_ARGS+=		-DZM_CONFIG_DIR=${PKG_SYSCONFDIR}
+## PATHS
 
+# zoneminder has a dizzying array of variables for various paths.
+# Consolidate the settings in an attempt to reduce confusion.
+
+# ZoneMinder prefers a subdirectory of etc. Further, it demands a
+# conf.d subdirectory within its config directory, which would be
+# irregular at top level.
+CMAKE_ARGS+=		-DZM_CONFIG_DIR=${PKG_SYSCONFDIR}/zm
+OWN_DIRS_PERMS+=	${PKG_SYSCONFDIR}/zm ${REAL_ROOT_USER} ${APACHE_GROUP} 775
+OWN_DIRS_PERMS+=	${PKG_SYSCONFDIR}/zm/conf.d ${REAL_ROOT_USER} ${APACHE_GROUP} 775
+
+# \todo We prepare a webroot, even without the apache option.
 ZM_HTTPD_ROOT=		share/zoneminder/htdocs
+CMAKE_ARGS+=		-DZM_WEBDIR=${PREFIX}/${ZM_HTTPD_ROOT:Q}
 PLIST_SUBST+=		ZM_HTTPD_ROOT=${ZM_HTTPD_ROOT:Q}
 PRINT_PLIST_AWK+=	{ gsub(/${ZM_HTTPD_ROOT:S|/|\\/|g}/, "$${ZM_HTTPD_ROOT}") }
 OWN_DIRS+=		${ZM_HTTPD_ROOT:Q}
+INSTALLATION_DIRS+=	share/zoneminder ${ZM_HTTPD_ROOT}
 
 ZM_HTTPD_CGIBIN=	libexec/zoneminder/cgi-bin
+CMAKE_ARGS+=		-DZM_CGIDIR=${PREFIX}/${ZM_HTTPD_CGIBIN:Q}
 PLIST_SUBST+=		ZM_HTTPD_CGIBIN=${ZM_HTTPD_CGIBIN:Q}
 PRINT_PLIST_AWK+=	{ gsub(/${ZM_HTTPD_CGIBIN:S|/|\\/|g}/, "$${ZM_HTTPD_CGIBIN}") }
 BUILD_DEFS+=		ZM_HTTPD_CGIBIN
 OWN_DIRS+=		${ZM_HTTPD_CGIBIN:Q}
-
-INSTALLATION_DIRS+=	share/zoneminder ${ZM_HTTPD_ROOT}
 INSTALLATION_DIRS+=	libexec/zoneminder ${ZM_HTTPD_CGIBIN}
 
 BUILD_DEFS+=		VARBASE
-CONFIGURE_ARGS+=	--with-webdir=${PREFIX}/${ZM_HTTPD_ROOT:Q}
-CMAKE_ARGS+=		-DZM_WEBDIR=${PREFIX}/${ZM_HTTPD_ROOT:Q}
-CONFIGURE_ARGS+=	--with-cgidir=${PREFIX}/${ZM_HTTPD_CGIBIN:Q}
-CMAKE_ARGS+=		-DZM_CGIDIR=${PREFIX}/${ZM_HTTPD_CGIBIN:Q}
-CONFIGURE_ARGS+=	--with-mysql=${BUILDLINK_PREFIX.mysql-client}
-CONFIGURE_ARGS+=	--localstatedir=${VARBASE}
-# TODO cmake localstate?
 CMAKE_ARGS+=		-DZM_RUNDIR=${VARBASE}/run/zm
+# \todo Consider a way to clean up on de-install as anything left
+# should just be removed.
+OWN_DIRS_PERMS+=	${VARBASE}/run/zm ${REAL_ROOT_USER} ${APACHE_GROUP} 775
+
 CMAKE_ARGS+=		-DZM_SOCKDIR=${VARBASE}/run/zm
+# \todo Consider /tmp vs /var/tmp.  For now, guess that it should
+# persist.
 CMAKE_ARGS+=		-DZM_TMPDIR=${VARBASE}/tmp/zm
 CMAKE_ARGS+=		-DZM_LOGDIR=${VARBASE}/log/zm
+OWN_DIRS_PERMS+=	${VARBASE/log/zm ${REAL_ROOT_USER} ${APACHE_GROUP} 775
+
+# \todo Define this per-OS; /var/shm is for NetBSD
+ZM_SHM=			/var/shm
+CMAKE_ARGS+=		-DZM_PATH_MAP=${ZM_SHM}
+
+# ZM wants both a "cache" directory and a "content" directory; the
+# latter seems to fit "/var/db".
+ZM_CACHE=		${VARBASE}/cache/zoneminder
+CMAKE_ARGS+=		-DZM_CACHEDIR=${ZM_CACHE}
+OWN_DIRS_PERMS+=	${ZM_CACHE} ${REAL_ROOT_USER} ${APACHE_GROUP} 775
+
+ZM_CONTENT=		${VARBASE}/db/zoneminder
+CMAKE_ARGS+=		-DZM_CONTENTDIR=${ZM_CONTENT}
+OWN_DIRS_PERMS+=	${ZM_CONTENT} ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 755
+CMAKE_ARGS+=		-DZM_DIR_EVENTS=${ZM_CONTENT}/events
+OWN_DIRS_PERMS+=	${ZM_CONTENT}/events ${REAL_ROOT_USER} ${APACHE_GROUP} 775
+CMAKE_ARGS+=		-DZM_DIR_IMAGES=${ZM_CONTENT}/images
+OWN_DIRS_PERMS+=	${ZM_CONTENT}/images ${REAL_ROOT_USER} ${APACHE_GROUP} 775
+
+# \todo Figure out temp - not in docs.
+OWN_DIRS_PERMS+=	${ZM_CONTENT}/temp ${REAL_ROOT_USER} ${APACHE_GROUP} 775
+
+## Dependencies other than perl and php.
 
 PTHREAD_AUTO_VARS=	yes
 .include "../../mk/pthread.buildlink3.mk"
 
-# This should probably be ffmpeg4 at least.  Defer until up-to-date.
+# This should probably be ffmpeg4 at least.
+# \todo Try higher versions with 1.32.
 .include "../../multimedia/ffmpeg2/buildlink3.mk"
-CONFIGURE_ARGS+=	--with-ffmpeg=${BUILDLINK_PREFIX.ffmpeg2}
-CONFIGURE_ENV+=		PATH_FFMPEG=${BUILDLINK_PREFIX.ffmpeg2}/bin/ffmpeg2
-CONFIGURE_ENV+=		OPT_FFMPEG=yes
-# TODO cmake?
-
 .if ${OPSYS} == "Darwin"
 SOEXT=	dylib
 .else
 SOEXT=	so
 .endif
-
 .for lib in AVFORMAT AVCODEC AVDEVICE AVUTIL SWSCALE
 CMAKE_ARGS+=	-D${lib}_INCLUDE_DIR=${BUILDLINK_PREFIX.ffmpeg2}/include/ffmpeg2
 CMAKE_ARGS+=	-D${lib}_LIBRARIES=${BUILDLINK_PREFIX.ffmpeg2}/lib/ffmpeg2/lib${lib:tl}.${SOEXT}
 .endfor
-
-# The backtrace requires Linux's unportable <execinfo.h> header.
-CONFIGURE_ARGS+=	--enable-crashtrace=no
-
-# Need Perl Sys::Mmap module for (default) mmap support.
-CONFIGURE_ARGS+=	--enable-mmap=no
-
 # This is somewhat awkward.  ffmpeg's libavformat/avformat.h requires
 # constant macros from stdint.h, but these are only defined under C++ if
 # __STDC_CONSTANT_MACROS is requested, so we have to do that on behalf
@@ -131,71 +132,71 @@ CONFIGURE_ARGS+=	--enable-mmap=no
 # build failures complaining about UINT64_T not being defined.
 CFLAGS+=		-D__STDC_CONSTANT_MACROS
 
-# Since MySQL uses openssl, use the same library instead of defaulting to
-# gnutls.
-CONFIGURE_ENV+=		ZM_SSL_LIB=openssl
+# MySQL uses openssl.  Force zoneminder not to choose otherwise by
+# finding libraries that are present but not buildlinked.
 CMAKE_ARGS+=		-DGNUTLS_LIBRARIES=""
-
-# Make sure cmake doesn't think libgcrypt is available (we use OpenSSL).
 CMAKE_ARGS+=		-DGCRYPT_LIBRARIES=""
 
-# Control where run-time state (PID file and sockets) get stored.
-# Default is "/var/run/zm", but we want to conform to VARBASE.
-CONFIGURE_ENV+=		ZM_RUNDIR=${VARBASE}/run/zm
-CONFIGURE_ENV+=		ZM_SOCKDIR=${VARBASE}/run/zm
-
-#
 # Darwin does have sendfile(), but the API differs from ZoneMinder's
 # expectation.
-#
-CONFIGURE_ARGS.Darwin+=	ac_cv_func_sendfile=no ac_cv_header_sys_sendfile_h=no
+# \todo Convert to cmake.
+# CONFIGURE_ARGS.Darwin+=	ac_cv_func_sendfile=no ac_cv_header_sys_sendfile_h=no
 
-.if !empty(PKG_OPTIONS:Mapache)
-.include "../../mk/apache.mk"
-
-PKG_USERS_VARS+=	APACHE_USER
-PKG_GROUPS_VARS+=	APACHE_GROUP
-BUILD_DEFS+=		APACHE_USER APACHE_GROUP
-
-# This directory contains no useful state, so use MAKE_DIRS instead of
-# OWN_DIRS.
-MAKE_DIRS_PERMS+=	${VARBASE}/run/zm ${REAL_ROOT_USER} ${APACHE_GROUP} 775
-
-CONFIGURE_ARGS+=	--with-webuser=${APACHE_USER}
-CMAKE_ARGS+=		-DZM_WEB_USER=${APACHE_USER}
-CONFIGURE_ARGS+=	--with-webgroup=${APACHE_GROUP}
-CMAKE_ARGS+=		-DZM_WEB_GROUP=${APACHE_GROUP}
-
-# If we're using Apache we're going to need PHP, and PHP extensions.
-.include "../../lang/php/phpversion.mk"
-DEPENDS+=	${APACHE_PKG_PREFIX}-${PHP_PKG_PREFIX}-[0-9]*:../../www/ap-php
-DEPENDS+=	${PHP_PKG_PREFIX}-gd-[0-9]*:../../graphics/php-gd
-DEPENDS+=	${PHP_PKG_PREFIX}-pdo_mysql-[0-9]*:../../databases/php-pdo_mysql
-DEPENDS+=	${PHP_PKG_PREFIX}-sockets-[0-9]*:../../net/php-sockets
-DEPENDS+=	${PHP_PKG_PREFIX}-json-[0-9]*:../../textproc/php-json
+# \todo After finding execinfo.h, cmake looks for and fails to find
+# "backtrace".
+# \todo Explain why we don't just depend on devel/libexecinfo.
+.if ${OPSYS} == "NetBSD" && exists(/usr/include/execinfo.h)
+LIBS+=		-lexecinfo
 .endif
 
-# \todo Somehow, this permission setup still fails.
-# This directory contains state, so use OWN_DIRS instead of MAKE_DIRS.
-ZM_CACHE=		${VARBASE}/cache/zoneminder
-OWN_DIRS_PERMS+=	${ZM_CACHE} ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 755
-OWN_DIRS_PERMS+=	${ZM_CACHE}/temp ${REAL_ROOT_USER} ${APACHE_GROUP} 775
-OWN_DIRS_PERMS+=	${ZM_CACHE}/images ${REAL_ROOT_USER} ${APACHE_GROUP} 775
-OWN_DIRS_PERMS+=	${ZM_CACHE}/events ${REAL_ROOT_USER} ${APACHE_GROUP} 775
-CMAKE_ARGS+=		-DZM_CONTENTDIR=${ZM_CACHE}
+## PERL
 
-# \todo Set "web cachedir"
-# -DZM_CACHEDIR=?
+PERL5_REQD+=		5.6.0
+
+# \todo Thoroughly review and rototill this section. 
+#
+# Arrange for module.mk to perform its magic here on top of the non-Perl
+# build tasks.
+#
+# Set ZM_PERL_MM_PARMS in order to inhibit NO_PACKLIST
+#
+#PERL5_CONFIGURE=	no
+#PERL5_CONFIGURE_DIRS=	${WRKSRC}/scripts/ZoneMinder
+#PERL5_CONFIGURE_DIRS+=	${WRKSRC}/onvif/proxy
+#PERL5_CONFIGURE_DIRS+=	${WRKSRC}/onvif/modules
+#PERL5_PACKLIST=	auto/ZoneMinder/.packlist
+#PERL5_PACKLIST+=	auto/ONVIF/.packlist
+#CMAKE_ARGS+=		-DZM_PERL_MM_PARMS="INSTALLDIRS=vendor"
+#.include "../../lang/perl5/module.mk"
 
+# ZoneMinder discourages building from source and does not appear to
+# document the list of dependencies.  We take the view that if an
+# installation can be reasonably configured to use a module, that
+# module should be a dependency, absent some reason that it is so
+# heavyweight that it should be an option.
+DEPENDS+=	p5-Archive-Zip-[0-9]*:../../archivers/p5-Archive-Zip
+DEPENDS+=	p5-Device-SerialPort-[0-9]*:../../comms/p5-Device-SerialPort
+DEPENDS+=	p5-DBD-mysql-[0-9]*:../../databases/p5-DBD-mysql
+DEPENDS+=	p5-Date-Manip-[0-9]*:../../devel/p5-Date-Manip
+DEPENDS+=	p5-PHP-Serialization-[0-9]*:../../devel/p5-PHP-Serialization
+DEPENDS+=	p5-Sys-Mmap-[0-9]*:../../devel/p5-Sys-Mmap
+DEPENDS+=	p5-MIME-Lite-[0-9]*:../../mail/p5-MIME-Lite
+DEPENDS+=	p5-MIME-tools-[0-9]*:../../mail/p5-MIME-tools
+DEPENDS+=	p5-Net-SFTP-Foreign-[0-9]*:../../net/p5-Net-SFTP-Foreign
+DEPENDS+=	p5-Sys-MemInfo-[0-9]*:../../sysutils/p5-Sys-MemInfo
+DEPENDS+=	p5-libwww-[0-9]*:../../www/p5-libwww
 
-# ZoneMinder scripts needing Perl $PATH patching AND interpreter patching
+# All perl scripts need interpreter patching (REPLACE_PERL), while a large
+# subset also need an include PATH line modified (ZM_REPLACE_PERL).
 ZM_REPLACE_PERL+=	scripts/zmaudit.pl.in
 ZM_REPLACE_PERL+=	scripts/zmcamtool.pl.in
 ZM_REPLACE_PERL+=	scripts/zmcontrol.pl.in
 ZM_REPLACE_PERL+=	scripts/zmdc.pl.in
 ZM_REPLACE_PERL+=	scripts/zmfilter.pl.in
+REPLACE_PERL+=		scripts/zmonvif-probe.pl.in
 ZM_REPLACE_PERL+=	scripts/zmpkg.pl.in
 ZM_REPLACE_PERL+=	scripts/zmstats.pl.in
+REPLACE_PERL+=		scripts/zmsystemctl.pl.in
 ZM_REPLACE_PERL+=	scripts/zmtelemetry.pl.in
 ZM_REPLACE_PERL+=	scripts/zmtrack.pl.in
 ZM_REPLACE_PERL+=	scripts/zmtrigger.pl.in
@@ -203,34 +204,66 @@ ZM_REPLACE_PERL+=	scripts/zmupdate.pl.in
 ZM_REPLACE_PERL+=	scripts/zmvideo.pl.in
 ZM_REPLACE_PERL+=	scripts/zmwatch.pl.in
 ZM_REPLACE_PERL+=	scripts/zmx10.pl.in
-
-# ZoneMinder scripts needing interpreter patching
 REPLACE_PERL+=	${ZM_REPLACE_PERL}
-REPLACE_PERL+=	scripts/zmonvif-probe.pl.in
-REPLACE_PERL+=	zmconfgen.pl.in
 
-#
 # The intention of zmsystemctl.pl is to use bin/pkexec to allow the
 # apache user to start and stop the ZoneMinder services on operating
-# systems using systemd and newer versions of Polkit than pkgsrc
-# currently has.
-#
-# If the base OS doesn't use systemd (e.g. anything not Linux), this
-# file shouldn't be used anyway.
-#
-# In pkgsrc we ignore the potentially absent pkexec interpreter in
-# this file.  If the base OS uses systemd, it probably also has pkexec
-# in its base installation.
-#
-
+# systems using systemd and adequately recent Polkit.  Rather than
+# trying to express dependencies, we just let it be and hope that it
+# will work in environments where it can.  In other environments, we
+# hope that no one runs the command.
 CHECK_INTERPRETER_SKIP+=	bin/zmsystemctl.pl
 
+# \todo Why isn't this just REPLACE_PERL?
 SUBST_CLASSES+=			systemd-perl
 SUBST_MESSAGE.systemd-perl=	Adjusting systemd pkexec perl.
 SUBST_STAGE.systemd-perl=	pre-configure
 SUBST_FILES.systemd-perl=	scripts/zmsystemctl.pl.in
 SUBST_SED.systemd-perl=		-e 's|/usr/bin/perl|${PERL5}|g'
 
+## PHP
+
+# ZoneMinder 1.32 with PHP 7.4 does not appear to have PHP-related problems.
+# Under PHP 8.0 <1.30 was logging at Error level type errors out of skin.js.
+# Under PHP 8.1 <1.30 was logging at Panic level that strftime is deprecated.
+#
+# Therefore 74 is the standard approach and it is \todo to try higher.
+PHP_VERSIONS_ACCEPTED=	74
+
+.include "../../lang/php/phpversion.mk"
+DEPENDS+=	${PHP_PKG_PREFIX}-pdo_mysql-[0-9]*:../../databases/php-pdo_mysql
+DEPENDS+=	${PHP_PKG_PREFIX}-gd-[0-9]*:../../graphics/php-gd
+DEPENDS+=	${PHP_PKG_PREFIX}-sockets-[0-9]*:../../net/php-sockets
+DEPENDS+=	${PHP_PKG_PREFIX}-json-[0-9]*:../../textproc/php-json
+
+## WEB
+
+# \todo We need to choose user/group, and somehow make this play well
+# with apache, nginx, and php_fpm.  For now, assume that anyone using
+# nginx/fpm will align that to APACHE_*, and treat the larger question
+# as beyond scope.
+PKG_USERS_VARS+=	APACHE_USER
+PKG_GROUPS_VARS+=	APACHE_GROUP
+BUILD_DEFS+=		APACHE_USER APACHE_GROUP
+
+CMAKE_ARGS+=		-DZM_WEB_USER=${APACHE_USER}
+CMAKE_ARGS+=		-DZM_WEB_GROUP=${APACHE_GROUP}
+CMAKE_ARGS+=		-DZM_PATH_ZMS=zm/cgi-bin/nph-zms
+
+.if !empty(PKG_OPTIONS:Mapache)
+.include "../../mk/apache.mk"
+DEPENDS+=	${APACHE_PKG_PREFIX}-${PHP_PKG_PREFIX}-[0-9]*:../../www/ap-php
+.endif
+.if !empty(PKG_OPTIONS:Mnginx)
+# \todo Actually test this option.
+DEPENDS+=	nginx-[0-9]*:../../www/nginx
+DEPENDS+=	${PHP_PKG_PREFIX}-fpm-[0-9]*:../../www/php-fpm
+.endif
+
+## PATH FIXUPS
+
+# Patch the db creation script so that default paths installed in the
+# db match how we have configured the package.
 SUBST_CLASSES+=			dbpaths-path
 SUBST_MESSAGE.dbpaths-path=	Adjusting default paths in configuration.
 SUBST_STAGE.dbpaths-path=	pre-configure
@@ -239,16 +272,17 @@ SUBST_SED.dbpaths-path=		-e 's|/usr/local/bin/|${PREFIX}/bin/|g'
 SUBST_SED.dbpaths-path+=	-e 's|/usr/bin|${PREFIX}/bin|g'
 SUBST_SED.dbpaths-path+=	-e 's|/cgi-bin/nph-zms|/zm/cgi-bin/nph-zms|g'
 
-#
-# Required to find the 'mysql' client executable, and may also use 'sudo' if
-# installed.
-#
+# In most perl scripts, set the path to include $prefix/bin, rather
+# than looking in /usr/local/bin, so that mysql, sudo, and so on are
+# found.  (Scripts are in ZM_REPLACE_PERL rather than just
+# REPLACE_PERL if they should get this substitution.)
 SUBST_CLASSES+=			script-path
 SUBST_MESSAGE.script-path=	Adjusting paths in scripts.
 SUBST_STAGE.script-path=	pre-configure
 SUBST_FILES.script-path=	${ZM_REPLACE_PERL}
 SUBST_SED.script-path=		-e "s|^\\([\$$]ENV{PATH} *= *'\\).*';\$$|\\1${PREFIX}/bin:/bin:/usr/bin';|g"
 
+# Substitute configured path in pkgsrc-provided apache config.
 SUBST_CLASSES+=		files
 SUBST_STAGE.files=	pre-configure
 SUBST_FILES.files=	zoneminder.conf
@@ -256,21 +290,23 @@ SUBST_SED.files=	-e "s|@ZM_HTTPD_ROOT@|${PREFIX}/${ZM_HTTPD_ROOT}|g"
 SUBST_SED.files+=	-e "s|@ZM_HTTPD_CGIBIN@|${PREFIX}/${ZM_HTTPD_CGIBIN}|g"
 SUBST_MESSAGE.files=	Fixing ZoneMinder configuration file for Apache.
 
-PLIST_VARS+=		rcd
+## INIT SCRIPTS
 
-.if ${INIT_SYSTEM} == "rc.d"
 # \todo Figure out if this is really for pkgsrc rc.d, and maybe write one for
 # files/
+
+PLIST_VARS+=		rcd
+
+.if ${INIT_SYSTEM} == "rc.d"
 PLIST.rcd=		yes
 # \todo fix
 #RCD_SCRIPTS+=		zoneminder
 .endif
 PRINT_PLIST_AWK+=	{ gsub(/^.+\/examples\/rc.d/, "$${PLIST.rcd}&"); }
 
-.if ${OPSYS} == "NetBSD" && exists(/usr/include/execinfo.h)
-LIBS+=		-lexecinfo
-.endif
+## PKGSRC PHASE FIXUPS
 
+# Pretend our apache config is part of the distribution.
 # Avoid conflict with C++20 <version> - intertwined with patch-CMakeLists.txt
 post-extract:
 	${CP} ${FILESDIR}/zoneminder.conf ${WRKSRC}/zoneminder.conf
@@ -280,33 +316,18 @@ post-extract:
 # should prevent this from being necessary.
 PRINT_PLIST_AWK+=	/.orig$$/ { next; }
 
-# After patching remove any .orig files because (for patched .pm files) they
-# end up going through the installation process.
+# After patching, remove .orig versions of .pm, because they are
+# wrongly installed due to wildcard rules.
 pre-configure:
 	${FIND} ${WRKSRC} -name "*.pm*.orig" -type f | ${XARGS} ${RM} -f
 
-#
-# Arrange for module.mk to perform its magic here on top of the non-Perl
-# build tasks.
-#
-# Set ZM_PERL_MM_PARMS in order to inhibit NO_PACKLIST
-#
-PERL5_REQD+=		5.6.0
-#PERL5_CONFIGURE=	no
-#PERL5_CONFIGURE_DIRS=	${WRKSRC}/scripts/ZoneMinder
-#PERL5_CONFIGURE_DIRS+=	${WRKSRC}/onvif/proxy
-#PERL5_CONFIGURE_DIRS+=	${WRKSRC}/onvif/modules
-#PERL5_PACKLIST=	auto/ZoneMinder/.packlist
-#PERL5_PACKLIST+=	auto/ONVIF/.packlist
-#CMAKE_ARGS+=		-DZM_PERL_MM_PARMS="INSTALLDIRS=vendor"
-#.include "../../lang/perl5/module.mk"
-
-#post-configure: perl5-configure
 
+# \todo Review if the cmake build now supports installation.
+# \todo Document the symlink game with ZM_CONTENT.
 EGDIR=			share/examples/${PKGBASE}
 DOCDIR=			share/doc/${PKGBASE}
 INSTALLATION_DIRS+=	${EGDIR} ${EGDIR}/config ${EGDIR}/apache
-CONF_FILES+=		${PREFIX}/${EGDIR}/config/zm.conf ${PKG_SYSCONFDIR}/zm.conf
+CONF_FILES+=		${PREFIX}/${EGDIR}/config/zm.conf ${PKG_SYSCONFDIR}/zm/zm.conf
 INSTALLATION_DIRS+=	bin share/examples/rc.d share/zoneminder/db
 INSTALLATION_DIRS+=	${DOCDIR}
 post-install:
@@ -318,9 +339,9 @@ post-install:
 	${INSTALL_DATA} ${WRKSRC}/db/*.sql ${DESTDIR}${PREFIX}/share/zoneminder/db/
 	rmdir ${DESTDIR}${PREFIX}/${ZM_HTTPD_ROOT:Q}/events || ${TRUE}
 	rmdir ${DESTDIR}${PREFIX}/${ZM_HTTPD_ROOT:Q}/images || ${TRUE}
-	${LN} -s ${ZM_CACHE}/temp ${DESTDIR}${PREFIX}/${ZM_HTTPD_ROOT:Q}/temp
-	${LN} -s ${ZM_CACHE}/events ${DESTDIR}${PREFIX}/${ZM_HTTPD_ROOT:Q}/events
-	${LN} -s ${ZM_CACHE}/images ${DESTDIR}${PREFIX}/${ZM_HTTPD_ROOT:Q}/images
+	${LN} -s ${ZM_CONTENT}/temp ${DESTDIR}${PREFIX}/${ZM_HTTPD_ROOT:Q}/temp
+	${LN} -s ${ZM_CONTENT}/events ${DESTDIR}${PREFIX}/${ZM_HTTPD_ROOT:Q}/events
+	${LN} -s ${ZM_CONTENT}/images ${DESTDIR}${PREFIX}/${ZM_HTTPD_ROOT:Q}/images
 	${INSTALL_DATA} files/README-pkgsrc.md ${DESTDIR}${PREFIX}/${DOCDIR}
 
 .include "../../mk/dlopen.buildlink3.mk"
@@ -328,6 +349,7 @@ post-install:
 .include "../../mk/mysql.buildlink3.mk"
 .include "../../mk/pthread.buildlink3.mk"
 .include "../../archivers/bzip2/buildlink3.mk"
+# \todo Consider graphics/libv4l.
 .include "../../devel/glib2/buildlink3.mk"
 .include "../../devel/pcre/buildlink3.mk"
 .include "../../devel/zlib/buildlink3.mk"
diff --git a/zoneminder/files/zoneminder.conf b/zoneminder/files/zoneminder.conf
index cf900e8632..c33a9ab369 100644
--- a/zoneminder/files/zoneminder.conf
+++ b/zoneminder/files/zoneminder.conf
@@ -1,17 +1,41 @@
-# This Apache configuration puts ZoneMinder under /zm.
-# Access is limited to localhost, as a safe default until
-# intentionally changed.
+# pkgsrc Apache configuration for zoneminder, intended to be copied to
+# ${PKG_SYSCONFDIR}/httpd and then included via
+# Include etc/httpd/zoneminder.conf
 
-ScriptAlias /zm/cgi-bin/ "@ZM_HTTPD_CGIBIN@/"
+# This configuration puts ZoneMinder under /zm.  Access is limited to
+# localhost, as a safe default until intentionally changed.
 
-<Directory "@ZM_HTTPD_CGIBIN@">
-  <RequireAny>
-    Require ip 127.0.0.1
-  </RequireAny>
-</Directory>
+LoadModule cgid_module lib/httpd/mod_cgid.so
+# \todo Consider fcgi intead.
+# <IfModule mod_fcgid.c>
+#   <Directory /usr/share/zoneminder/www>
+#     Options -Indexes +ExecCGI
+#     AllowOverride All
+#     AddHandler fcgid-script .php
+#     FCGIWrapper /usr/bin/php5-cgi
+#     Order allow,deny
+#     Allow from all
+#   </Directory>
+# </IfModule>
 
-Alias /zm "@ZM_HTTPD_ROOT@"
+LoadModule php7_module lib/httpd/mod_php7.so
+<FilesMatch \.php$>
+    SetHandler application/x-httpd-php
+</FilesMatch>
 
+# Upstream had
+# <IfModule mod_php5.c>
+#   <Directory /usr/share/zoneminder/www>
+#     Options -Indexes +FollowSymLinks
+#     <IfModule mod_dir.c>
+#       DirectoryIndex index.php
+#     </IfModule>
+#   </Directory>
+# </IfModule>
+
+# \todo Upstream does not set php_flags.
+# \todo Upstream sets Options.
+Alias /zm "@ZM_HTTPD_ROOT@"
 <Directory "@ZM_HTTPD_ROOT@">
   php_flag register_globals off
   php_flag short_open_tag on
@@ -20,3 +44,11 @@ Alias /zm "@ZM_HTTPD_ROOT@"
     Require ip 127.0.0.1
   </RequireAny>
 </Directory>
+
+ScriptAlias /zm/cgi-bin/ "@ZM_HTTPD_CGIBIN@/"
+
+<Directory "@ZM_HTTPD_CGIBIN@">
+  <RequireAny>
+    Require ip 127.0.0.1
+  </RequireAny>
+</Directory>


Home | Main Index | Thread Index | Old Index