1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-20 00:21:35 +00:00

New port: multimedia/zoneminder-h264

Zoneminder is an all-in-one GPL'd security and surveillance camera
solution. Fully web-based system for viewing and analyzing security
camera feeds. This version has H.264 support.

WWW: http://www.zoneminder.com/

PR:		214564
Submitted by:	Ivan <bsd@abinet.ru>
This commit is contained in:
Kurt Jaeger 2016-12-08 06:28:33 +00:00
parent 6c36bbbc4d
commit 4a2617de08
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=428104
15 changed files with 8156 additions and 0 deletions

View File

@ -454,5 +454,6 @@
SUBDIR += xvid
SUBDIR += yamdi
SUBDIR += zoneminder
SUBDIR += zoneminder-h264
.include <bsd.port.subdir.mk>

View File

@ -0,0 +1,123 @@
# $FreeBSD$
PORTNAME= zoneminder-h264
PORTVERSION= 1.30.20161104
DISTVERSIONSUFFIX= a2f782d
CATEGORIES= multimedia
MAINTAINER= bsd@abinet.ru
COMMENT= Complete security camera solution, fully web based with image analysis
LICENSE= GPLv2
ZM_DEPENDS= p5-DBI>=0:databases/p5-DBI \
p5-DBD-mysql>=0:databases/p5-DBD-mysql \
p5-Date-Manip>=0:devel/p5-Date-Manip \
p5-Test-LWP-UserAgent>=0:www/p5-Test-LWP-UserAgent \
p5-Sys-Mmap>=0:devel/p5-Sys-Mmap \
p5-LWP-Protocol-https>=0:www/p5-LWP-Protocol-https \
p5-Sys-CPU>=0:devel/p5-Sys-Cpu \
p5-Sys-MemInfo>=0:devel/p5-Sys-MemInfo \
p5-Data-Dump>=0:devel/p5-Data-Dump \
p5-SOAP-WSDL>=0:devel/p5-SOAP-WSDL \
p5-Data-UUID>=0:devel/p5-Data-UUID \
p5-IO-Socket-Multicast>=0:net/p5-IO-Socket-Multicast \
ffmpeg:multimedia/ffmpeg
BUILD_DEPENDS= ${ZM_DEPENDS}
LIB_DEPENDS= libx264.so:multimedia/libx264 \
libmp4v2.so:multimedia/mp4v2
RUN_DEPENDS= ${ZM_DEPENDS} \
p5-MIME-Tools>=0:mail/p5-MIME-Tools \
sudo:security/sudo \
zip:archivers/zip
USE_GITHUB= yes
GH_TUPLE= zoneminder:zoneminder:a2f782d \
FriendsOfCake:crud:c3976f1:crud
WRKSRC= ${WRKDIR}/ZoneMinder-${DISTVERSIONSUFFIX}
USES= cmake jpeg mysql perl5 php shebangfix ssl
USE_RC_SUBR= zoneminder
USE_PHP= json pdo_mysql session gd sockets
ONLY_FOR_ARCHS= amd64 i386
OPTIONS_DEFINE= NLS V4L DOCS
OPTIONS_SUB= yes
NLS_USES= gettext
NLS_CONFIGURE_ENABLE= nls
V4L_BUILD_DEPENDS= ${LOCALBASE}/include/linux/videodev2.h:multimedia/v4l_compat
V4L_LIB_DEPENDS= libv4l2.so:multimedia/libv4l
OPTIONS_DEFAULT= NLS
PLIST_SUB= WWWOWN="${WWWOWN}" WWWGRP="${WWWGRP}"
SHEBANG_FILES= scripts/zmaudit.pl.in \
scripts/zmcamtool.pl.in \
scripts/zmcontrol.pl.in \
scripts/zmdc.pl.in \
scripts/zmfilter.pl.in \
scripts/zmpkg.pl.in \
scripts/zmtelemetry.pl.in \
scripts/zmtrack.pl.in \
scripts/zmtrigger.pl.in \
scripts/zmupdate.pl.in \
scripts/zmvideo.pl.in \
scripts/zmwatch.pl.in \
scripts/zmx10.pl.in \
onvif/scripts/zmonvif-probe.pl
PORTDOCS= AUTHORS BUGS ChangeLog INSTALL NEWS README.FreeBSD TODO
CMAKE_ARGS+= -DZM_PERL_MM_PARMS=INSTALLDIRS=site \
-DZM_CONFIG_DIR=${PREFIX}/etc \
-DZM_WEBDIR=${WWWDIR} \
-DZM_CGIDIR=${WWWDIR}/cgi-bin \
-DZM_CONTENTDIR=${WWWDIR} \
-DHAVE_SENDFILE=0 \
-DZM_NO_CURL=ON \
-DZM_NO_LIBVLC=ON \
-DPCRE_LIBRARIES=0 \
-DGNUTLS_LIBRARIES=0 \
-DCMAKE_REQUIRED_INCLUDES:STRING="${LOCALBASE}/include"
.include <bsd.port.pre.mk>
.if ${OPSYS} == FreeBSD && ${OSVERSION} < 1000000 && ${ARCH} == i386
CFLAGS+= -msse
.endif
.if ${OPSYS} == FreeBSD && ${OSVERSION} < 1000000
LIB_DEPENDS+= libexecinfo.so:devel/libexecinfo
LDFLAGS+= -L${LOCALBASE}/lib
.endif
PKGMESSAGE= ${WRKDIR}/pkg-message
post-extract:
${CP} -R ${WRKSRC_crud}/* ${WRKSRC}/web/api/app/Plugin/Crud
${CP} ${FILESDIR}/README.FreeBSD ${WRKSRC}
${CP} ${FILESDIR}/README.FreeBSD ${PKGMESSAGE}
${REINPLACE_CMD} -e 's|/dev/shm|/tmp|g' ${WRKSRC}/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in
${REINPLACE_CMD} -e 's|E_ALL|E_ALL^E_NOTICE|g' ${WRKSRC}/web/index.php
pre-install:
${MKDIR} ${STAGEDIR}${WWWDIR}/images
${MKDIR} ${STAGEDIR}${WWWDIR}/events
${MKDIR} ${STAGEDIR}${WWWDIR}/temp
${MKDIR} ${STAGEDIR}${WWWDIR}/api/app/tmp
${MKDIR} ${STAGEDIR}/var/run/zm
${MKDIR} ${STAGEDIR}/var/tmp/zm
post-install:
${INSTALL_DATA} ${STAGEDIR}${PREFIX}/etc/zm.conf ${STAGEDIR}${PREFIX}/etc/zm.conf.sample
post-install-DOCS-on:
${MKDIR} ${STAGEDIR}${DOCSDIR}
cd ${WRKSRC} && ${INSTALL_MAN} ${PORTDOCS} ${STAGEDIR}${DOCSDIR}
.include <bsd.port.post.mk>

View File

@ -0,0 +1,5 @@
TIMESTAMP = 1478964450
SHA256 (zoneminder-zoneminder-1.30.20161104a2f782d-a2f782d_GH0.tar.gz) = 8d5cca78c934833c2f62efa451dc3127af2add7d2947b56a0ff37501dc1b8a32
SIZE (zoneminder-zoneminder-1.30.20161104a2f782d-a2f782d_GH0.tar.gz) = 9794587
SHA256 (FriendsOfCake-crud-c3976f1_GH0.tar.gz) = 7dfa29dd6dd95f05bca61bb05033f813828b7ab66f9d8793d306df0dd72471ce
SIZE (FriendsOfCake-crud-c3976f1_GH0.tar.gz) = 72961

View File

@ -0,0 +1,159 @@
ZoneMinder is a free, open source Closed-circuit television software
application developed for Unix-like operating systems which supports
IP, USB and Analog cameras.
New installs
============
ZoneMinder requires a MySQL (or MySQL forks) database backend and
a http server, capable to execute PHP and CGI scripts.
To simplify things, we assume, that you use MySQL and NGINX on
the same server.
1. Preliminary steps
1.1 Install databases/mysql56-server or newer
You may choose your favourite method - ports or packages here.
FreeBSD default setting use STRICT_TRANS_TABLES sql_mode. It's mandatory to disable it. Edit your my.cnf accordingly
The following SQL mode should be compatible with ZM:
sql_mode= NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
ZoneMinder use very simple queries, however it tends to write to
the database quite a lot depending on your capture mode and number
of cameras. So tweak your MySQL instance accordantly
Now, enable and start MySQL
sysrc mysql_server_enable="YES"
service mysql-server start
1.2 Install www/nginx
We provide an example for an HTTP install, however, you should use
HTTPS if you plan to expose your installation to the public. There
are plenty guides how to do it and security/letsencrypt.sh is a
good way to get a valid SSL certificate.
Your server block should include the following:
server {
root /usr/local/www/zoneminder;
try_files $uri $uri/ /index.php$is_args$args;
index index.php;
location = /cgi-bin/nph-zms {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/fcgiwrap/fcgiwrap.sock;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php-fpm.sock;
}
location /api {
rewrite ^/api/(.+)$ /api/index.php?p=$1 last;
}
}
1.2.1 ZoneMinder has it's own authentication system, however it's recommend to use NGINX basic
auth over HTTPS if you don't need fine grain control to ZoneMinder components.
1.2.2 If you choose ZoneMinder authentication, it's recommended to prohibit access to
image and events folder as it's possible to guess file names inside it.
location ~ ^/(?:images|events)/ {
deny all;
}
Enable and start NGINX
sysrc nginx_enable="YES"
service nginx start
1.3 Install www/fcgiwrap
As NGINX lacks it's own CGI wrapper, we need external one. Please
note that ZoneMinder's montage page use simultaneous access to all
cameras, so you need to use at least as many fcgiwrap workers as
your number of cameras. The following example assumes you have 4.
Enable and start FcgiWrap
sysrc fcgiwrap_enable="YES"
sysrc fcgiwrap_user="www"
sysrc fcgiwrap_flags="-c 4"
1.4 PHP is installed as a dependency to ZoneMinder. However, you should
tweak some of it's settings.
Edit /usr/local/etc/php-fpm.conf and set
listen = /var/run/php-fpm.sock
listen.owner = www
listen.group = www
env[PATH] = /usr/local/bin:/usr/bin:/bin
If you want to set another path for the socket file, make sure you
change it in your NGINX config well. The env[PATH] needs to be set
to locate the zip utility as ZoneMinder's export functions rely on
exec(). Sorry, chroot folks.
PHP throws warning if date.timezone option is not set. The best place
to do it is to create new ini file in /usr/local/etc/php with overrides
date.timezone = "UTC"
Enable and start php-fpm
sysrc php_fpm_enable="YES"
service php-fpm start
1.5 ZoneMinder constantly keeps the last N frames from its cameras to
preserve them when alarm occurs. This can be a performance hog if
placed on spindle drive. The best practice is put it on tmpfs.
See https://www.freebsd.org/cgi/man.cgi?query=tmpfs for more
information.
ZoneMinder will use /tmp for default. If you plan to change it, see
ZM_PATH_MAP setting.
Mapping /tmp to tmpfs is actually a recommended step under FreeBSD.
Edit /etc/fstab and add the following:
tmpfs /tmp tmpfs rw,nosuid,mode=01777 0 0
The size of temporary files depends on your number of cameras
number and frames you plan to keep. My 12 3Mbit cameras with 25
last frames consumes 6 GB.
2. ZoneMinder installation
Connect to MySQL under root and create zm user and populate database.
mysql -u root -p
CREATE DATABASE zm;
GRANT ALL PRIVILEGES ON zm.* TO 'zmuser'@'localhost' IDENTIFIED BY 'zmpass';
FLUSH PRIVILEGES;
quit;
mysql -u root -p zm < /usr/local/share/zoneminder/db/zm_create.sql
2.1 If you have chosen to change the ZoneMinder MySQL credentials to something
other than zmuser/zmpass then you must now edit /usr/local/etc/zm.conf. Change
ZM_DB_USER and ZM_DB_PASS to the values you created in the previous step.
Enable and start ZoneMinder
sysrc zoneminder_enable="YES"
service zoneminder start
Upgrades
========
1. Stop ZoneMinder
service zoneminder stop
2. Upgrade database
sudo -u www zmupdate.pl
3. Start ZoneMinder
service zoneminder start

View File

@ -0,0 +1,32 @@
--- CMakeLists.txt.orig 2016-10-03 17:21:50 UTC
+++ CMakeLists.txt
@@ -385,13 +385,13 @@ find_library(MYSQLCLIENT_LIBRARIES mysql
if(MYSQLCLIENT_LIBRARIES)
set(HAVE_LIBMYSQLCLIENT 1)
list(APPEND ZM_BIN_LIBS "${MYSQLCLIENT_LIBRARIES}")
- find_path(MYSQLCLIENT_INCLUDE_DIR mysql/mysql.h)
+ find_path(MYSQLCLIENT_INCLUDE_DIR mysql.h /usr/local/include/mysql /usr/include/mysql)
if(MYSQLCLIENT_INCLUDE_DIR)
include_directories("${MYSQLCLIENT_INCLUDE_DIR}")
set(CMAKE_REQUIRED_INCLUDES "${MYSQLCLIENT_INCLUDE_DIR}")
endif(MYSQLCLIENT_INCLUDE_DIR)
mark_as_advanced(FORCE MYSQLCLIENT_LIBRARIES MYSQLCLIENT_INCLUDE_DIR)
- check_include_file("mysql/mysql.h" HAVE_MYSQL_H)
+ check_include_file("mysql.h" HAVE_MYSQL_H)
if(NOT HAVE_MYSQL_H)
message(FATAL_ERROR
"ZoneMinder requires MySQL headers - check that MySQL development packages are installed")
@@ -711,13 +711,6 @@ endif(NOT ZM_WEB_GROUP)
message(STATUS "Using web user: ${ZM_WEB_USER}")
message(STATUS "Using web group: ${ZM_WEB_GROUP}")
-# Check for polkit
-find_package(Polkit)
-if(NOT POLKIT_FOUND)
- message(FATAL_ERROR
- "Running ZoneMinder requires polkit. Building ZoneMinder requires the polkit development package.")
-endif(NOT POLKIT_FOUND)
-
# Some variables that zm expects
set(ZM_PID "${ZM_RUNDIR}/zm.pid")
set(ZM_CONFIG "${ZM_CONFIG_DIR}/zm.conf")

View File

@ -0,0 +1,12 @@
--- misc/CMakeLists.txt.orig 2016-10-03 17:21:50 UTC
+++ misc/CMakeLists.txt
@@ -13,6 +13,7 @@ configure_file(zoneminder-tmpfiles.conf.
#install(FILES "${CMAKE_CURRENT_BINARY_DIR}/apache.conf" "${CMAKE_CURRENT_BINARY_DIR}/logrotate.conf" "${CMAKE_CURRENT_BINARY_DIR}/syslog.conf" DESTINATION "${CMAKE_INSTALL_DATADIR}/zoneminder/misc")
# Install Policykit rules and actions into the proper folders
-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/com.zoneminder.systemctl.policy" DESTINATION "${PC_POLKIT_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/polkit-1/actions")
-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/com.zoneminder.systemctl.rules" DESTINATION "${PC_POLKIT_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/polkit-1/rules.d")
+# polkit is not required for FreeBSD
+#install(FILES "${CMAKE_CURRENT_BINARY_DIR}/com.zoneminder.systemctl.policy" DESTINATION "${PC_POLKIT_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/polkit-1/actions")
+#install(FILES "${CMAKE_CURRENT_BINARY_DIR}/com.zoneminder.systemctl.rules" DESTINATION "${PC_POLKIT_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/polkit-1/rules.d")

View File

@ -0,0 +1,11 @@
--- scripts/CMakeLists.txt.orig 2016-10-03 17:21:50 UTC
+++ scripts/CMakeLists.txt
@@ -32,7 +32,7 @@ FOREACH(PERLSCRIPT ${perlscripts})
ENDFOREACH(PERLSCRIPT ${perlscripts})
# Install the perl scripts
-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zmaudit.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmcontrol.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmdc.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmfilter.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmpkg.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmtrack.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmtrigger.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmupdate.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmvideo.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmwatch.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmcamtool.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmsystemctl.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmtelemetry.pl" DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zmaudit.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmcontrol.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmdc.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmfilter.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmpkg.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmtrack.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmtrigger.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmupdate.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmvideo.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmwatch.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmcamtool.pl" "${CMAKE_CURRENT_BINARY_DIR}/zmtelemetry.pl" DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
if(NOT ZM_NO_X10)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zmx10.pl" DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
endif(NOT ZM_NO_X10)

View File

@ -0,0 +1,18 @@
--- src/zm_image.cpp.orig 2016-10-03 17:21:50 UTC
+++ src/zm_image.cpp
@@ -1649,12 +1649,9 @@ Image *Image::Highlight( unsigned int n_
for ( unsigned int j = 0; j < n_images; j++ )
{
uint8_t *psrc = images[j]->buffer+c;
-
-#ifndef SOLARIS
- if ( (unsigned)abs((*psrc)-RGB_VAL(ref_colour,c)) >= RGB_VAL(threshold,c) )
-#else
- if ( (unsigned)std::abs((*psrc)-RGB_VAL(ref_colour,c)) >= RGB_VAL(threshold,c) )
-#endif
+ unsigned int diff = ((*psrc)-RGB_VAL(ref_colour,c)) > 0 ? (*psrc)-RGB_VAL(ref_colour,c) : RGB_VAL(ref_colour,c) - (*psrc);
+
+ if (diff >= RGB_VAL(threshold,c))
{
count++;
}

View File

@ -0,0 +1,11 @@
--- src/zm_local_camera.cpp.orig 2016-10-03 17:21:50 UTC
+++ src/zm_local_camera.cpp
@@ -33,7 +33,7 @@
#include <limits.h>
/* Workaround for GNU/kFreeBSD */
-#if defined(__FreeBSD_kernel__)
+#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
#ifndef ENODATA
#define ENODATA ENOATTR
#endif

View File

@ -0,0 +1,14 @@
--- src/zm_local_camera.h.orig 2016-10-03 17:21:50 UTC
+++ src/zm_local_camera.h
@@ -41,6 +41,11 @@
#define VIDEO_MAX_FRAME 32
#endif
+// Required on systems with v4l1 but without v4l2 headers
+#ifndef VIDEO_MAX_FRAME
+#define VIDEO_MAX_FRAME 32
+#endif
+
#include "zm_ffmpeg.h"
//

View File

@ -0,0 +1,23 @@
--- src/zm_logger.cpp.orig 2016-11-03 11:08:37 UTC
+++ src/zm_logger.cpp
@@ -515,8 +515,9 @@ void Logger::logPrint( bool hex, const c
va_list argPtr;
struct timeval timeVal;
- const char * const file = basename(filepath);
-
+ char *filecopy = strdup(filepath);
+ const char * const file = basename(filecopy);
+
if ( level < PANIC || level > DEBUG9 )
Panic( "Invalid logger level %d", level );
@@ -635,6 +636,8 @@ void Logger::logPrint( bool hex, const c
abort();
exit( -1 );
}
+
+ free(filecopy);
}
}

View File

@ -0,0 +1,20 @@
--- src/zm_signal.cpp.orig 2016-10-03 17:21:50 UTC
+++ src/zm_signal.cpp
@@ -63,17 +63,9 @@ RETSIGTYPE zm_die_handler(int signal)
ucontext_t *uc = (ucontext_t *) context;
cr2 = info->si_addr;
#if defined(__x86_64__)
- #ifdef __FreeBSD_kernel__
ip = (void *)(uc->uc_mcontext.mc_rip);
- #else
- ip = (void *)(uc->uc_mcontext.gregs[REG_RIP]);
- #endif
#else
- #ifdef __FreeBSD_kernel__
ip = (void *)(uc->uc_mcontext.mc_eip);
- #else
- ip = (void *)(uc->uc_mcontext.gregs[REG_EIP]);
- #endif
#endif // defined(__x86_64__)
// Print the signal address and instruction pointer if available

View File

@ -0,0 +1,38 @@
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: zoneminder
# REQUIRE: LOGIN mysql
# KEYWORD: shutdown
#
# Add these lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# zoneminder_enable (bool): Set to NO by default.
# Set it to YES to enable zoneminder.
. /etc/rc.subr
name=zoneminder
rcvar=zoneminder_enable
load_rc_config $name
: ${zoneminder_enable="NO"}
command=%%PREFIX%%/bin/zmpkg.pl
pidfile=/var/run/zm/zm.pid
extra_commands="logrot version"
start_cmd="zm_cmd"
stop_cmd="zm_cmd"
status_cmd="zm_cmd"
logrot_cmd="zm_cmd"
version_cmd="zm_cmd"
zm_cmd() {
${command} ${rc_arg}
}
run_rc_command "$1"

View File

@ -0,0 +1,5 @@
Zoneminder is an all-in-one GPL'd security and surveillance camera
solution. Fully web-based system for viewing and analyzing security
camera feeds. This version has H.264 support.
WWW: http://www.zoneminder.com/

File diff suppressed because it is too large Load Diff