summaryrefslogtreecommitdiff
path: root/pcr/zoneminder
diff options
context:
space:
mode:
authorMárcio Alexandre Silva Delgado <coadde@lavabit.com>2013-07-25 15:50:14 -0300
committerMárcio Alexandre Silva Delgado <coadde@lavabit.com>2013-07-25 15:50:14 -0300
commitac7074bacde3a27f3d5169b235e336420b39b349 (patch)
tree20097724c6561545930017d144b71c3d7ca60ee5 /pcr/zoneminder
parent1e4ccd765bfece9f1a74ab4957d667e81954e55f (diff)
zoneminder: fixing pkg
Diffstat (limited to 'pcr/zoneminder')
-rw-r--r--pcr/zoneminder/PKGBUILD209
-rw-r--r--pcr/zoneminder/sysctl-zoneminder.conf3
-rw-r--r--pcr/zoneminder/zoneminder.install69
3 files changed, 174 insertions, 107 deletions
diff --git a/pcr/zoneminder/PKGBUILD b/pcr/zoneminder/PKGBUILD
index bf03b4133..ede03dd77 100644
--- a/pcr/zoneminder/PKGBUILD
+++ b/pcr/zoneminder/PKGBUILD
@@ -7,27 +7,24 @@
# based of debian squeeze package
-pkgbase=zoneminder
+_automake=1.14
+
pkgname=zoneminder
pkgver=1.25.0
-pkgrel=27
+pkgrel=28
pkgdesc='Capture, analyse, record and monitor video security cameras'
arch=(
- i686
- x86_64
mips64el
- arm
-)
-backup=(
- etc/zm.conf
-)
-url="http://www.$pkgbase.com"
-license=(
- GPL
+ x86_64
+ i686
)
+backup=etc/zm.conf
+url=http://www.$pkgname.com
+license=GPL2
depends=(
apache
cambozola
+ ffmpeg
gnutls
mariadb
perl-archive-zip
@@ -48,108 +45,158 @@ depends=(
php-gd
php-mcrypt
)
-makedepends=(
- netpbm
-)
-optdepends=(
- netpbm
-)
-install=$pkgbase.install
+makedepends=netpbm
+optdepends=netpbm
+options=(!libtool)
+install=$pkgname.install
source=(
- http://www.$pkgbase.com/downloads/ZoneMinder-$pkgver.tar.gz
- httpd-$pkgbase.conf
- $pkgbase
- $pkgbase.service
- zoneminder-1.25.0-kernel35.patch
- zoneminder-1.25.0-gcc47.patch
- zoneminder-1.25.0-ffmpeg.patch
- zoneminder-1.25-text.patch
- zoneminder-1.25-fixwarning.patch
- zoneminder-1.25.0-gcrypt.patch
+ http://www.$pkgname.com/downloads/ZoneMinder-$pkgver.tar.gz
+ httpd-$pkgname.conf
+ $pkgname.service
+ sysctl-$pkgname.conf
+ $pkgname-$pkgver-ffmpeg.patch
+ $pkgname-$pkgver-gcrypt.patch
)
sha512sums=(
3e18993b0539729491052c97d8c94227ccc089eb40277c2f07682f30049033303c7cfe9734fdac6d33ae67df29c76eb72bf7fbb5dae8227e8831fa603b61c375
4ce0d8eba9d006d258f5b8a83920fc17f1f602b96518d37b7a47cd9b6eb84ef2587641a6ba839a469c3f0e33b46475866187279ae3f8be0d4054b074ee5d6b08
- ab4e1d5ddaf4d9cd53d6ca59d7965902afd6a2dc830fbbafa270736c52c2b3563075fee860bb0276466f96e9dbfb71b259ac45a4ae2e4ead8eaec154a0159eb0
cfb0eb87a989236c72741a496ddc6a73aa2696e5beaaca4836d3c231ddb24c7ef5e9f65e7afa49674f2115cbfa4a07c75486e1947ce294c816ddbb875f3b99cf
- 4fa79e49a3c04e9fdc9823792c6a28012002479c77ed41637bd2d21f089e4c15592bfcd5c24028f356c9f80d774a5080a6841e8e70a435d607e3089d0b121775
- 3da7d4d21dea166ea12b49e88a05a9f7a75790881a1f2d7588fa9e0e6ce592b4b5ee71994fa8b05236efeeb57890157a622c752c12a9059c2ee915adf3b4660d
+ 7330c179f1e2db815a675560d3d84648be02f7d0292f8cbe21d6033577fe688ed71ad23b5b8c9dc309395b45ebb554f9499e7a4b57091959b69679011fa59044
7fc2a4663c3103bef641be065bd7992a2b3dc0699f1b99dc2fdb34c1c48e58686e490d3ade523ef7c8e29b3f04109658eef652c26ff6ee3fb9aee65453bdb6c4
- 17b85051543c34a41c6b94ec8f46a10927aa4bc9554562650788c8257ffba8e362500cf3641708f2f9dabebc663a2d012fa9feacd7f9b33c637fbc965d405adf
- 8eab0a922968465fee8537dc035ce781e51dc84cc05259a32acb5bf59c618bc1700dbf4eec90717ed5959841def119357974d109df8d7450c12ca4ea8576e55c
8c9e7debcaf60be1c2dda656f95e497f6812d704edc3ca4a1c915a3b3c9dc1749c91d96bc2d60db7d90d5edfd9e2dfc39010dfe4feabfecfffd27f1fffc3d675
)
+prepare() {
+ cd $srcdir/ZoneMinder-$pkgver
+
+ # Patch for automake
+ sed -i "\|^am__api_version=| s|1[.]11|$_automake|;
+ " configure
+
+ # Patch for GCC
+ sed -i 's|^#include [<]errno[.]h[>]$|#include <errno.h>\n#include <unistd.h>|;
+ ' src/zm_logger.cpp
+ sed -i 's|^#include [<]pthread[.]h[>]$|#include <pthread.h>\n#include <unistd.h>|;
+ ' src/zm_thread.h
+ sed -i 's|^#include [<]fcntl[.]h[>]$|#include <fcntl.h>\n#include <limits.h>|;
+ ' src/zm_local_camera.cpp
+
+ # Patch for type cast in linux-libre kernel 3.5 and for wrong type "suppported"
+ sed -i 's|enum v4l2_buf_type type = v4l2_data[.]fmt[.]type|enum v4l2_buf_type type = (v4l2_buf_type)v4l2_data.fmt.type|;
+ s|suppported|supported|;
+ ' src/zm_local_camera.cpp
+
+ # configure crash on i686
+ [[ $CARCH != i686 ]] && {
+ # Patch for fixing warning
+ sed -i 's|pdest[+][+] = ([*]blend_ptr)\[[*]pdest]\[[*]psrc[+][+]]|pdest = (*blend_ptr)[*pdest][*psrc++];\n pdest++|;
+ ' src/zm_image.cpp
+ }
+
+ # Patch for support ffmpeg with <libavutil/mathematics.h>
+ #sed -i 's|^extern "C" {|extern "C" {\n#ifdef _STDINT_H\n#undef _STDINT_H\n#endif\n#include <stdint.h>|;
+ # s|^#include <libavutil/avutil[.]h>|#include <libavutil/avutil.h>\n#include <libavutil/mathematics.h>|;
+ # ' src/zm_ffmpeg.h
+
+ # Patch for support C library
+ #sed -i 's|^AM_CONFIG_HEADER(config[.]h)|AM_CONFIG_HEADER(config.h)\n\nAC_SUBST([AM_CXXFLAGS], [-D__STDC_CONSTANT_MACROS])|;
+ # s|^AC_CHECK_HEADERS(mysql/mysql[.]h,,AC_MSG_ERROR(zm requires MySQL headers - check that MySQL development packages are installed),)|AC_CHECK_HEADERS(mysql/mysql.h,,AC_MSG_ERROR(zm requires MySQL headers - check that MySQL development packages are installed),)\nAC_LANG_PUSH([C])|;
+ # s|^AC_CHECK_HEADERS(libswscale/swscale[.]h,,,)|AC_CHECK_HEADERS(libswscale/swscale.h,,,)\nAC_LANG_POP([C])|;
+ # ' configure.ac
+
+ # Patch for disable ZM_CHECK_FOR_UPDATES
+ sed -i '\|ZM_CHECK_FOR_UPDATES|,+1 s|yes|no|;
+ ' scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in
+
+ # Patch for support html5 video and flv
+ sed -i '\|ZM_MPEG_LIVE_FORMAT|,+1 s|swf|webm|;
+ \|ZM_MPEG_REPLAY_FORMAT|,+1 s|swf|webm|;
+ \|ZM_FFMPEG_FORMATS|,+1 s|mpg mpeg wmv asf avi[*] mov swf 3gp[*][*]|mpg mpeg wmv asf avi* mov flv swf 3gp** webm ogg h264|;
+ ' scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in
+
+ # Patch for change path run dir and for change ZM name to ZoneMinder
+ sed -i '\|ZM_PATH_SOCKS|,+1 s|TMP|RUN|;
+ \|ZM_WEB_TITLE_PREFIX|,+1 s|"ZM"|"ZoneMinder"|;
+ ' scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in
+
+ # Patch for v4l2 convert support
+ sed -i 's|^$ENV{SHELL} = '"'/bin/sh'"' if exists $ENV{SHELL}|$ENV{SHELL} = '"'/bin/sh'"' if exists $ENV{SHELL};\n$ENV{LD_PRELOAD} = '"'/usr/lib/libv4l/v4l2convert.so'"' |;
+ ' scripts/zmdc.pl.in
+
+ # Patch for add more socket tries
+ sed -i '\|^$max_socket_tries = | s|3|15|;
+ ' web/ajax/stream.php
+
+ # Patch for text
+ sed -i 's|if ( fwrite( buffer, n_bytes, 1, stdout ) )|if ( fwrite( buffer, n_bytes, 1, stdout ) != 1 )|;
+ ' src/zm_stream.cpp
+
+ # Patch for remove HACK in Makefile.*
+ sed -i '\|This is a HACK|d;
+ \|^install-data-hook:$|,+5 d;
+ s| install-data-hook||;
+ \|^uninstall-hook:$|,+5 d;
+ s| uninstall-hook||;
+ ' Makefile.{am,in}
+
+ # Patch
+ for _patch in ffmpeg gcrypt; do
+ patch -Np1 -F99 -i $srcdir/$pkgname-$pkgver-$_patch.patch
+ done
+}
+
build() {
cd $srcdir/ZoneMinder-$pkgver
- # Patch for change ZM name to ZoneMinder
- sed -i -e '/ZM_WEB_TITLE_PREFIX/,+1 s/"ZM"/"ZoneMinder"/'\
- scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in || read
- sed -i -e '/am__api_version=/ s/1.11/1.13.1/'\
- configure || read
- # Patch for add more socket tries
- sed -i -e '/$max_socket_tries/ s/3/15/'\
- web/ajax/stream.php || read
- # Patch for support html5 video and flv
- sed -i -e '/ZM_MPEG_LIVE_FORMAT/,+1 s/swf/webm/;/ZM_MPEG_REPLAY_FORMAT/,+1 s/swf/webm/;
- /ZM_FFMPEG_FORMATS/,+1 s/mpg mpeg wmv asf avi\* mov swf 3gp\*\*/mpg mpeg wmv asf avi\* mov flv swf 3gp\*\* webm ogg h264/'\
- scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in || read
- # Patch for wrong "suppported"
- sed -i -e 's/suppported/supported/'\
- src/zm_local_camera.cpp || read
-
-
- patch -Np1 -F99 -i ../zoneminder-1.25.0-kernel35.patch
- patch -Np1 -F99 -i ../zoneminder-1.25.0-gcc47.patch
- patch -Np1 -F99 -i ../zoneminder-1.25.0-ffmpeg.patch
- patch -Np1 -F99 -i ../zoneminder-1.25-text.patch
- patch -Np1 -F99 -i ../zoneminder-1.25-fixwarning.patch
- patch -Np1 -F99 -i ../zoneminder-1.25.0-gcrypt.patch
-
-export CXXFLAGS=-D__STDC_CONSTANT_MACROS
-./configure --prefix=/usr\
+
+ # ZM_RUNDIR need change to run dir
+ export CPPFLAGS="$CPPFLAGS -D__STDC_CONSTANT_MACROS"\
+ OPT_FFMPEG=yes\
+ PATH_FFMPEG=/usr/bin/ffmpeg\
+ ZM_LOGDIR=/var/log/$pkgname\
+ ZM_RUNDIR=/tmp/$pkgname\
+ ZM_SSL_LIB=libgcrypt\
+ ZM_TMPDIR=/tmp/$pkgname
+
+ ./configure --prefix=/usr\
--enable-crashtrace=no\
--enable-debug=no\
--enable-mmap=yes\
--sysconfdir=/etc\
--with-cgidir=/srv/http/cgi-bin\
--with-extralibs='-L/usr/lib -L/usr/lib/mysql'\
+ --with-ffmpeg=/usr\
--with-libarch=lib\
- --with-ffmpeg=/usr \
--with-mysql=/usr\
- --with-webdir=/srv/http/$pkgbase\
+ --with-webdir=/srv/http/$pkgname\
--with-webgroup=http\
--with-webhost=localhost\
- --with-webuser=http \
-
+ --with-webuser=http
make V=0
}
package() {
cd $srcdir/ZoneMinder-$pkgver
-
make DESTDIR=$pkgdir install
- mkdir -p $pkgdir/{etc/{httpd/conf/extra,rc.d},srv/http/{cgi-bin,$pkgbase},usr/{lib/systemd/system,share/{license/$pkgbase,$pkgbase/db}},var/{cache/$pkgbase,log/$pkgbase}}
- mkdir -p $pkgdir/srv/zoneminder/socks
- chown -R http.http $pkgdir/{etc/zm.conf,var/{cache/$pkgbase,log/$pkgbase}}
- chown -R http.http $pkgdir/srv/zoneminder/socks
- chmod 0700 $pkgdir/etc/zm.conf
+ mkdir -vp $pkgdir/{etc/{httpd/conf/extra,sysctl.d},srv/http/{cgi-bin,$pkgname/socks},usr/{lib/systemd/system,share/{licenses/$pkgname,$pkgname/db}},var/{cache/$pkgname,log/$pkgname}}
+ chown -vR http.http $pkgdir/{etc/zm.conf,srv/http/$pkgname/socks,var/{cache/$pkgname,log/$pkgname}}
+ chmod -v 0700 $pkgdir/etc/zm.conf
for i in events images temp; do
- mv $pkgdir/srv/http/$pkgbase/$i $pkgdir/var/cache/$pkgbase/$i
- ln -s /var/cache/$pkgbase/$i $pkgdir/srv/http/$pkgbase/$i
- chown -h http.http $pkgdir/srv/http/$pkgbase/$i
+ mv -v $pkgdir/srv/http/$pkgname/$i $pkgdir/var/cache/$pkgname/$i
+ ln -vs /var/cache/$pkgname/$i $pkgdir/srv/http/$pkgname/$i
+ chown -vh http.http $pkgdir/srv/http/$pkgname/$i
done
- ln -s /srv/http/cgi-bin $pkgdir/srv/http/$pkgbase
- chown -h http.http $pkgdir/srv/http/{cgi-bin,$pkgbase,$pkgbase/cgi-bin}
+ ln -vs /srv/http/cgi-bin $pkgdir/srv/http/$pkgname
+ chown -vh http.http $pkgdir/srv/http/{cgi-bin,$pkgname,$pkgname/cgi-bin}
- ln -s /usr/share/cambozola/cambozola.jar $pkgdir/srv/http/$pkgbase
+ ln -vs /usr/share/cambozola/cambozola.jar $pkgdir/srv/http/$pkgname
- install -D -m 644 $srcdir/httpd-$pkgbase.conf $pkgdir/etc/httpd/conf/extra
- install -D -m 644 $srcdir/$pkgbase $pkgdir/etc/rc.d
- install -D -m 644 $srcdir/$pkgbase.service $pkgdir/usr/lib/systemd/system
- install -D -m 644 COPYING $pkgdir/usr/share/license/$pkgbase
- install -D -m 644 db/zm*.sql $pkgdir/usr/share/$pkgbase/db
+ install -vDm644 $srcdir/httpd-$pkgname.conf $pkgdir/etc/httpd/conf/extra
+ install -vDm644 $srcdir/$pkgname.service $pkgdir/usr/lib/systemd/system
+ install -vDm644 $srcdir/sysctl-$pkgname.conf $pkgdir/etc/sysctl.d
+ install -vDm644 $srcdir/sysctl-$pkgname.conf $pkgdir/srv/http/$pkgname
+ install -vDm644 COPYING $pkgdir/usr/share/licenses/$pkgname
+ install -vDm644 db/zm*.sql $pkgdir/usr/share/$pkgname/db
}
diff --git a/pcr/zoneminder/sysctl-zoneminder.conf b/pcr/zoneminder/sysctl-zoneminder.conf
new file mode 100644
index 000000000..ec1407dee
--- /dev/null
+++ b/pcr/zoneminder/sysctl-zoneminder.conf
@@ -0,0 +1,3 @@
+# For Zoneminder Monitor
+#kernel.shmall = 524288000
+#kernel.shmmax = 524288000
diff --git a/pcr/zoneminder/zoneminder.install b/pcr/zoneminder/zoneminder.install
index 899e2a5d1..66109d5fa 100644
--- a/pcr/zoneminder/zoneminder.install
+++ b/pcr/zoneminder/zoneminder.install
@@ -1,3 +1,4 @@
+#!/usr/bin/bash
pre_install() {
set -e
abort=false
@@ -27,20 +28,20 @@ EOF
post_install() {
if [[ -d /var/log/zoneminder ]]; then
- chmod 0755 /var/log/zoneminder
- chown http.http /var/log/zoneminder
+ chmod -v 0755 /var/log/zoneminder
+ chown -v http.http /var/log/zoneminder
else
- mkdir -m 0755 /var/log/zoneminder
- chown http.http /var/log/zoneminder
+ mkdir -vm 0755 /var/log/zoneminder
+ chown -v http.http /var/log/zoneminder
fi
if [[ -d /tmp/zoneminder ]]; then
- chmod 0700 /tmp/zoneminder
- chown http.http /tmp/zoneminder
+ chmod -v 0700 /tmp/zoneminder
+ chown -v http.http /tmp/zoneminder
else
- mkdir -m 0700 /tmp/zoneminder
- chown http.http /tmp/zoneminder
+ mkdir -vm 0700 /tmp/zoneminder
+ chown -v http.http /tmp/zoneminder
fi
- sed -i -e '
+ sed -i '
/^;extension=mysql.so/ s/^;//;
/^#extension=mysql.so/ s/^#//;
/^;extension=mysqli.so/ s/^;//;
@@ -69,8 +70,11 @@ post_install() {
/^open_basedir/ s/:\/srv\/http\/zoneminder//;
/^open_basedir/ s/:\/srv\/http\/zoneminder\///;
/^open_basedir/ s/$/:\/srv\/http\/zoneminder/;
- ' /etc/php/php.ini || read
- sed -i -e '
+ /^open_basedir/ s/:\/var\/cache\/zoneminder//;
+ /^open_basedir/ s/:\/var\/cache\/zoneminder\///;
+ /^open_basedir/ s/$/:\/var\/cache\/zoneminder/;
+ ' /etc/php/php.ini
+ sed -i '
/^LoadModule php5_module modules\/libphp5.so/d;
/^LoadModule rewrite_module modules\/mod_rewrite.so/ s/$/\nLoadModule php5_module modules\/libphp5.so/;
/^# PHP 5/d;
@@ -78,11 +82,12 @@ post_install() {
/^Include \/etc\/httpd\/conf\/extra\/php5_module.conf/d;
/^Include \/etc\/httpd\/conf\/extra\/httpd-zoneminder.conf/d;
/^Include conf\/extra\/httpd-default.conf/ s/$/\n\n# PHP 5\n\Include \/etc\/httpd\/conf\/extra\/php5_module.conf\n\n# ZoneMinder\nInclude \/etc\/httpd\/conf\/extra\/httpd-zoneminder.conf/;
- ' /etc/httpd/conf/httpd.conf || read
+ ' /etc/httpd/conf/httpd.conf
+ gpasswd -a http video
cat << EOF
Note for mysql:
==> To run Zoneminder, you must install the database running mysql service (as root):
-==> "rc.d start mysqld" (in initscripts) or "systemctl start mysqld.service" (in systemd)
+==> "systemctl start mysqld.service"
==> and add Zoneminder database typing (with passsword):
==> "mysqladmin --defaults-file=/etc/mysql/my.cnf -p -f reload"
==> "cat /usr/share/zoneminder/db/zm_create.sql | mysql --defaults-file=/etc/mysql/my.cnf -p"
@@ -92,6 +97,11 @@ Note for mysql:
==> "cat /usr/share/zoneminder/db/zm_create.sql | mysql --defaults-file=/etc/mysql/my.cnf"
==> "echo 'grant lock tables, alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/my.cnf mysql"
+Note for sysctl:
+==> You must uncomment that line in /etc/sysctl.d/sysctl-zoneminder.conf:
+==> "kernel.shmall = 524288000"
+==> "kernel.shmmax = 524288000"
+
Note for php:
==> You must uncomment that line in /etc/php/php.ini:
==> "extension=mysql.so"
@@ -105,11 +115,11 @@ Note for php:
==> "extension=openssl.so"
==> "extension=ftp.so"
==> "extension=zip.so"
-==> check and add to open_basedir "/etc" and
-==> "/srv/http/zoneminder" like so
-==> "open_basedir = /home:/tmp:/usr/share/pear:/etc:/srv/http/zoneminder"
+==> check and add to open_basedir "/etc",
+==> "/srv/http/zoneminder" and "/var/cache/zoneminder" like so
+==> "open_basedir = /home:/tmp:/usr/share/pear:/etc:/srv/http/zoneminder:/var/cache/zoneminder"
==> and set your timezone in php.ini:
-==> "date.timezone = <your_country>/<your_city>"
+==> "date.timezone = <your_zone>/<your_city>"
Note for apache:
==> You must edit /etc/httpd/conf/httpd.conf and add the line:
@@ -122,21 +132,25 @@ EOF
post_upgrade() {
post_install
+ _mysqld=$(systemctl status mysqld.service | grep -o 'inactive (dead)')
+ [[ _mysqld == 'inactive (dead)' ]] && systemctl start mysqld.service
/usr/bin/zmupdate.pl -f >/dev/null
+ [[ _mysqld == 'inactive (dead)' ]] && systemctl stop mysqld.service
}
post_remove() {
- if [[ -d /tmp/zoneminder ]]; then
- rm -vr /tmp/zoneminder
- fi
- sed -i -e '
+ _zms=$(systemctl status zoneminder.service | grep -o 'active (running)')
+ [[ _zms == 'active (running)' ]] && systemctl stop zoneminder.service
+ [[ -d /tmp/zoneminder ]] && rm -vr /tmp/zoneminder
+ sed -i '
/^open_basedir/ s/:\/srv\/http\/zoneminder//;
/^open_basedir/ s/:\/srv\/http\/zoneminder\///;
- ' /etc/php/php.ini || read
- sed -i -e '
+ /^open_basedir/ s/:\/var\/cache\/zoneminder\///
+ ' /etc/php/php.ini
+ sed -i '
/^# ZoneMinder/d;
/Include \/etc\/httpd\/conf\/extra\/httpd-zoneminder.conf/d;
- ' /etc/httpd/conf/httpd.conf || read
+ ' /etc/httpd/conf/httpd.conf
cat << EOF
Note:
==> To clean Zoneminder mysql database, run as root (with password):
@@ -165,9 +179,12 @@ Note:
==> "extension=mysqli.so"
==> "extension=session.so"
==> "extension=sockets.so"
-==> "date.timezone = <my_country>/<my_city>"
+==> "date.timezone = <my_zone>/<my_city>"
+
+==> Drop http user on video group if it isn't needed with others servers:
+==> gpasswd -d http video
-==> Edit /etc/php/php.ini and remove "/etc" and "/srv/http/zoneminder"
+==> Edit /etc/php/php.ini and remove "/etc", "/srv/http/zoneminder" and "/var/cache/zoneminder"
==> in the "open_basedir".
==> Remove log files and "zonemider" directory in "/var/log/zoneminder".