Making a port for ZoneMinder

Is the file zm.conf copied to the stage directory at an earlier step? It looks to me that you should instead copy the file from ${WRKSRC} but I haven't taken closer look at the port yet.
 
Is the file zm.conf copied to the stage directory at an earlier step? It looks to me that you should instead copy the file from ${WRKSRC} but I haven't taken closer look at the port yet.
ZM's cmake handles this. My original copy was in post-install.
I moved it back and make succeeded.
Code:
post-install:
  ${INSTALL_DATA} ${STAGEDIR}${PREFIX}/etc/zm.conf ${STAGEDIR}${PREFIX}/etc/zm.conf.sample
 
I have hooked two cameras 352x288 and a 1920x1080 cameras both using mjpg_streamer. Both camera work independently if I try to view them. However, if i try to view both at the same time in Montage view, i get the following error
Code:
2016-04-20 18:40:03.327655 zms 101702 ERR Unable to send raw frame 15: Broken pipe zm_event.cpp 1339
2016-04-20 18:39:54.378644 zms 101703 ERR Terminating, last frame sent time 1461195594.260157 secs more than maximum of 10.000000 zm_monitor.cpp 4392
2016-04-20 18:39:54.272880 zms 101703 ERR Unable to send stream frame: Broken pipe zm_monitor.cpp 4127
2016-04-20 18:39:54.228304 zms 100729 ERR Unable to send stream frame: Broken pipe zm_monitor.cpp 4127
 
You need to increase number of fcgiwrap workers. The default is 1, so, obviously, you can stream only 1 camera at the same time.
In rc.conf
Code:
fcgiwrap_flags="-c 4"
Set it to the sane limit, say, the number of monitors in your system, as every worker needs some memory.
 
I ran your port (from your github repo, commit ba8cb35) trough poudriere testport and it passed all the tests fine. You should make a habit of doing that yourself unless you are doing that already of course :)
 
Oh, sorry, I didn't realize you're fetching multiple distfiles. I changed the GH variables, so it didn't work for me. Then you should re-add this in my version of the port.
I have an issue when build depends are removed and replaced with run depends only.
The test
1. remove pkg delete p5-Sys-Mmap-0.17_1
2. try to build zoneminder
Code:
- Could NOT find PerlModules (missing:  PERLMODULES_SYS_MMAP_MODULE)
CMake Error at CMakeLists.txt:629 (message):
  Not all required perl modules were found on your system
Return BUILD_DEPENDS back ?
 
Good. :) But be sure to run portlint -ac from time to time. It wasn't happy that RUN_DEPENDS were set to BUILD_DEPENDS.
 
I ran your port (from your github repo, commit ba8cb35) trough poudriere testport and it passed all the tests fine. You should make a habit of doing that yourself unless you are doing that already of course :)
I tried poudriere some time ago and it was too complex for me, so I just use snapshot rollback under qemu-kvm.
Is poudriere can simulate i386 arch under x64 host? One of the issues I have is failure to build ZM under i386 and I don't have i386 guest yet. Maybe, I should give pourdrere a chance.

Good. :) But be sure to run portlint -ac from time to time. It wasn't happy that RUN_DEPENDS were set to BUILD_DEPENDS.
And I found why... USES knob pollutes RUN_DEPENDS with additional BUILD_DEPENDS it adds in this scheme.
 
I tried poudriere some time ago and it was too complex for me, so I just use snapshot rollback under qemu-kvm.
Is poudriere can simulate i386 arch under x64 host? One of the issues I have is failure to build ZM under i386 and I don't have i386 guest yet. Maybe, I should give pourdrere a chance.

Yes, you can create an i386 jail with poudriere and it will be as close as possible to compiling the port on a real i386 host. You can also use Synth for testing ( synth testport I think it is) purposes if that's easier for you to use, it should be equally rigorous in finding problems in ports.
 
Unfortunately ZM stopped working for me and i am getting the following error
Code:
FAT [Can't execute log entry 'insert into Logs ( TimeKey, Component, Pid, Level, Code, Message, File, Line ) values ( ?, ?, ?, ?, ?, ?, ?, NULL )': ]
 
Have you changed Pid column type to INT ? This is mandatory for ZM to operate under FreeBSD.
Generally, it's hard to determine the problem without actual values it tries to insert. Try to find them digging deeper on the logs or check mysql logs.
 
Were you able to get the zoneminder api working? I wanted to use the api for the zmNinja program. I created a temp path for the api
Code:
mkdir /tmp/zmtmp;  ln -s /tmp/zmtmp /usr/local/www/zoneminder/api/app/tmp; chown www:www /tmp/zmtmp
but http://zmserver/api/ gave me an CakePHP error
Code:
URL rewriting is not properly configured on your server. 1) Help me configure it 2) I don't / can't use URL rewriting

-------UPDATE-------
The errors didn't go away but the api works with the following in nginx

Code:
location /api/ {
  alias  /usr/local/www/zoneminder/api;
  rewrite ^/api(.+)$ /api/index.php?p=$1 last;
  }

Also, the package php56-gd needs to installed to show up up images in events. The CPU usage taken by zmc is quite high (100%) though when scrubbing an event.
 
Last edited by a moderator:
Thanks a lot for working on this!
 
Thankyouthankyouthankyou!! I was working on trying to get the (very) old 1.25 port running, and just saw the new port, this port commit is very timely..

I noticed that the PHP MySQL PDO extension was not built by default, but it is needed for the latest zoneminder to work properly. All I had to do was install lang/php56-extensions and enable the PDO_MYSQL option.

Really appreciate your work updating this port -- obviously several of us out here who wanted a working security cam solution for FreeBSD, and the initial experimentation with the FreeBSD zoneminder port is encouraging -- thank you!!

-M
 
zmNinja tries to run /cgi-bin/zms while the help message in the package gives a tip for setting up /cgi-bin/nph-zms in nginx.conf. I had to the additional config before zmNinja Montage worked
Code:
  location = /cgi-bin/zms {
  include fastcgi_params;
  fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_pass  unix:/var/run/fcgiwrap/fcgiwrap.sock;
  }
 
I have a problem updating ZM to latest version. Additional dep is required, APCu. Ports have 2 versions of APCu, one for php56, another is for 7.0. So I need a conditional check.
However, when I add .include <bsd.port.pre.mk> to Makefile, I receive
Code:
=======================<phase: check-sanity   >============================
/!\ zoneminder-1.30.4: Makefile errors /!\

you cannot include bsd.port[.pre].mk twice

Defining both PORTVERSION and DISTVERSION is wrong, only set one, if necessary,
set DISTNAME

*** Error code 1

What's the problem?
Code:
# $FreeBSD: head/multimedia/zoneminder/Makefile 440139 2017-05-05 03:17:31Z miwi $

PORTNAME=       zoneminder
PORTVERSION=    1.30.4
CATEGORIES=     multimedia

MAINTAINER=     bsd@abinet.ru
COMMENT=        Complete security camera solution, fully web based with image analysis

LICENSE=        GPLv2

CONFLICTS_INSTALL=      zoneminder-h264

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}
RUN_DEPENDS=    ${ZM_DEPENDS} \
                sudo:security/sudo \
                p5-Device-SerialPort>=0:comms/p5-Device-SerialPort \
                zip:archivers/zip

USE_GITHUB=     yes
GH_PROJECT=     ZoneMinder
GH_TUPLE=       FriendsOfCake:crud:c3976f1:crud

USES=           cmake jpeg mysql perl5 php shebangfix ssl
USE_RC_SUBR=    zoneminder
USE_PHP=        json pdo_mysql session gd sockets ctype opcache

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>

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.mk>
 
Ports have 2 versions of APCu, one for php56, another is for 7.0. So I need a conditional check.
No, you simply depend on USE_PHP and let the ports system figure out which of the versions is required.
 
Back
Top