From cff11ad5411c527f9c3a9b69dcaf54a50d8855bb Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Thu, 19 Apr 2018 16:36:24 +0000
Subject: zoneminder: update to 1.30.4

---
 abs/core/zoneminder/PKGBUILD                       | 141 +++++++++------------
 abs/core/zoneminder/__changelog                    |   6 +-
 abs/core/zoneminder/fabs.patch                     |  11 ++
 abs/core/zoneminder/log.txt                        |  23 ++++
 abs/core/zoneminder/uio.patch                      |  22 ++++
 .../zm_rtp_ctrl.h.quick_fix_for_gcc6.diff          |   4 +
 6 files changed, 126 insertions(+), 81 deletions(-)
 create mode 100644 abs/core/zoneminder/fabs.patch
 create mode 100644 abs/core/zoneminder/log.txt
 create mode 100644 abs/core/zoneminder/uio.patch
 create mode 100644 abs/core/zoneminder/zm_rtp_ctrl.h.quick_fix_for_gcc6.diff

diff --git a/abs/core/zoneminder/PKGBUILD b/abs/core/zoneminder/PKGBUILD
index c0bb186..4aca47d 100644
--- a/abs/core/zoneminder/PKGBUILD
+++ b/abs/core/zoneminder/PKGBUILD
@@ -1,4 +1,5 @@
-# Maintainer: Troy Will <troydwill at gmail dot com>
+# Maintainer: Mesmer <mesmer@fisica.if.uff.br>
+# Contributor: Troy Will <troydwill at gmail dot com>
 # Contributor: /dev/rs0                  </dev/rs0@secretco.de.com>
 # Contributor: Jacek Burghardt           <jacek@hebe.us>
 # Contributor: Vojtech Aschenbrenner     <v@asch.cz>
@@ -11,91 +12,64 @@
 # Orginally based on a Debian Squeeze package
 _pkgname=zoneminder
 pkgname=zoneminder
-pkgver=1.30.2.r45.ga43adc2
-pkgrel=2
+pkgver=1.30.4
+pkgrel=1
 pkgdesc='Capture, analyse, record and monitor video security cameras'
 arch=( i686 x86_64 mips64el arm armv7h )
 backup=( etc/zm.conf )
 url="https://github.com/ZoneMinder/ZoneMinder/releases"
 license=( GPL )
 depends=(
-    ffmpeg gnutls lighttpd mysql
-    perl-archive-zip
-    perl-class-std-fast
-    perl-data-dump
-    perl-data-uuid
-    perl-date-manip
-    perl-dbd-mysql
-    perl-dbi
-    perl-device-serialport
-    perl-expect
-    perl-io-socket-multicast
-    perl-libwww
-    perl-mime-lite
-    perl-mime-tools
-    perl-net-sftp-foreign
-    perl-php-serialization
-    perl-sys-cpu
-    perl-sys-meminfo
-    perl-sys-mmap
-    perl-wsdl
-    php php-gd php-mcrypt
-    polkit
+    mysql perl-dbd-mysql perl-dbi
+    lighttpd php php-gd perl-php-serialization php-apcu
+    perl-libwww perl-net-sftp-foreign
+    ffmpeg perl-sys-mmap
+    gnutls polkit
+    perl-expect perl-archive-zip perl-date-manip
+    perl-mime-lite perl-mime-tools
+    perl-sys-meminfo perl-sys-cpu
 )
 makedepends=(
-    cmake make gcc netpbm
+    cmake netpbm git 
 )
 optdepends=(
+    'php-apcu-bci: Bring back the API for android control'
     netpbm
     cambozola
     perl-time-modules
     perl-x10
     perl-astro-suntime
 )
-install=$pkgname.install
-     
+install=$_pkgname.install
+
 source=(
-    git://github.com/$_pkgname/$_pkgname.git
-    git://github.com/FriendsOfCake/crud.git
+    https://github.com/ZoneMinder/ZoneMinder/archive/$pkgver.tar.gz
     httpd-zoneminder.conf
     zoneminder.service
+    uio.patch
+    fabs.patch
     zoneminder-tmpfile.conf
     zm.include
     zm.sysctrl.conf
     zm_gen_light.conf
 )
-# Because the source is not static, skip Git checksum:
-sha256sums=('SKIP'
-            'SKIP'
-            'ff7382b38ac07dadead0ad4d583e3dbcf8da4aaa06b76d048ee334f69f95db67'
-            '043d77a995553c533d62f48db4b719d29cf6c7074f215d866130e97be57ed646'
-            'cc8af737c3c07750fc71317c81999376e4bbb39da883780164a8747b3d7c95a7'
-            '894c3f43fb9d77aec9edaed98bc556c90bed9326de57bc17cd33b44ab7818335'
-            'bb50ad6411426d90df00568b967bf762844978cd34b84435ecbfc0d652c67b42'
-            'eafcd625248731382506622eb3ff9b736b670f601692386723bd63275cacc781'
-           )
-     
-pkgver() {
-    cd "$_pkgname"
-    # See https://wiki.archlinux.org/index.php/VCS_package_guidelines#The_pkgver.28.29_function
-    git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
-}
+
 
 prepare () {
-    cd $srcdir/$_pkgname
-    git submodule init
-    git config submodule.web/api/app/Plugin/Crud.url $srcdir/crud
-    git config submodule.web/api/app/Plugin/Crud.branch 3.0
-    git submodule update
+    cd $srcdir/zoneminder-$pkgver/web/api/app/Plugin/
+    if [ ! -d "crud" ]; then
+    git clone -b 3.0 https://github.com/FriendsOfCake/crud.git
+    mkdir -p Crud
+    mv  crud/* Crud
+    fi
+    patch $srcdir/zoneminder-$pkgver/src/zm_image.cpp < $srcdir/fabs.patch
+    patch $srcdir/zoneminder-$pkgver/src/zm_comms.h < $srcdir/uio.patch
 }
 
 build() {
-    cd $srcdir/$_pkgname
-
-    # ZM_PERL_SUBPREFIX=/lib/perl5 flag added to force Perl modules
-    # to /usr/lib/perl5/ on non i686 architectures
-    
-    cmake -DCMAKE_INSTALL_PREFIX=/usr \
+   cd $srcdir/zoneminder-$pkgver
+   
+   cmake -DCMAKE_INSTALL_PREFIX=/usr \
           -DZM_PERL_SUBPREFIX=/lib/perl5 \
           -DZM_WEBDIR=/data/srv/httpd/zoneminder \
           -DZM_CGIDIR=/data/srv/httpd/cgi-bin \
@@ -104,14 +78,14 @@ build() {
           -DZM_LOGDIR=/var/log/zoneminder \
           -DZM_RUNDIR=/run/zoneminder \
           -DZM_TMPDIR=/var/lib/zoneminder/temp \
-          -DZM_SOCKDIR=/data/srv/zoneminder/sock .
+          -DZM_SOCKDIR=/var/lib/zoneminder/sock .
      
     make V=0
-}
+} 
      
 package() {
 
-    cd $srcdir/$_pkgname
+    cd $srcdir/zoneminder-$pkgver
 
     DESTDIR=$pkgdir make install
 
@@ -123,9 +97,9 @@ package() {
     mkdir -pv           $pkgdir/var/{cache/zoneminder,log/zoneminder}
     chown -Rv http.http $pkgdir/var/{cache/zoneminder,log/zoneminder}
     
-    # corresponds to -DZM_SOCKDIR=/data/srv/zoneminder/sock
-    mkdir -pv          $pkgdir/data/srv/zoneminder/sock
-    chown -v http.http $pkgdir/data/srv/zoneminder/sock
+    # corresponds to -DZM_SOCKDIR=/var/lib/zoneminder/sock
+    mkdir -pv          $pkgdir/var/lib/zoneminder/sock
+    chown -v http.http $pkgdir/var/lib/zoneminder/sock
     
     # corresponds to -DZM_TMPDIR=/var/lib/zoneminder/temp
     mkdir -pv          $pkgdir/var/lib/zoneminder/temp
@@ -135,35 +109,34 @@ package() {
     chmod 0700          $pkgdir/etc/zm.conf
     # END CREATE_ZONEMINDER_DIRECTORIES
 
-    # Make content directories in /var/cache/zoneminder and to link them in /srv/httpd/zoneminder
+    # Make content directories in /var/cache/zoneminder and to link them in /data/srv/httpd/zoneminder
     for i in events images temp; do
-        mkdir              $pkgdir/var/cache/$pkgname/$i
-        chown -v http.http $pkgdir/var/cache/$pkgname/$i
-        ln -s                     /var/cache/$pkgname/$i $pkgdir/data/srv/httpd/$pkgname/$i
-        chown -v --no-dereference http.http               $pkgdir/data/srv/httpd/$pkgname/$i
+        mkdir              $pkgdir/var/cache/$_pkgname/$i
+        chown -v http.http $pkgdir/var/cache/$_pkgname/$i
+        ln -s                     /var/cache/$_pkgname/$i $pkgdir/data/srv/httpd/$_pkgname/$i
+        chown -v --no-dereference http.http               $pkgdir/data/srv/httpd/$_pkgname/$i
     done
 
     # Create a link to the Zoneminder cgi binaries
-    ln -sv /data/srv/httpd/cgi-bin $pkgdir/data/srv/httpd/$pkgname
+    ln -sv /data/srv/httpd/cgi-bin $pkgdir/data/srv/httpd/$_pkgname
 
-    chown -h http.http $pkgdir/data/srv/httpd/{cgi-bin,$pkgname,$pkgname/cgi-bin}
+    chown -h http.http $pkgdir/data/srv/httpd/{cgi-bin,$_pkgname,$_pkgname/cgi-bin}
 
     # Link Cambozola
-    # ln -s /usr/share/cambozola/cambozola.jar $pkgdir/data/srv/httpd/$pkgname
+    # ln -s /usr/share/cambozola/cambozola.jar $pkgdir/data/srv/httpd/$_pkgname
 
     # Install configuration files
-    # don't need these in LinHES as we use lighttpd not apache
-    #mkdir -p                                        $pkgdir/etc/httpd/conf/extra
-    #install -D -m 644 $srcdir/httpd-$pkgname.conf  $pkgdir/etc/httpd/conf/extra
+    mkdir -p                                        $pkgdir/etc/httpd/conf/extra
+    install -D -m 644 $srcdir/httpd-$_pkgname.conf  $pkgdir/etc/httpd/conf/extra
     
     mkdir -p                                        $pkgdir/usr/lib/systemd/system
-    install -D -m 644 $srcdir/$pkgname.service     $pkgdir/usr/lib/systemd/system
+    install -D -m 644 $srcdir/$_pkgname.service     $pkgdir/usr/lib/systemd/system
     
-    install -D -m 644 COPYING                       $pkgdir/usr/share/license/$pkgname
-    install -D -m 644 db/zm*.sql                    $pkgdir/usr/share/$pkgname/db
+    install -D -m 644 COPYING                       $pkgdir/usr/share/license/$_pkgname
+    install -D -m 644 db/zm*.sql                    $pkgdir/usr/share/$_pkgname/db
     
-    mkdir -p                                        $pkgdir/usr/share/doc/$pkgname
-    # install -D -m 644 $srcdir/README              $pkgdir/usr/share/doc/$pkgname
+    mkdir -p                                        $pkgdir/usr/share/doc/$_pkgname
+    # install -D -m 644 $srcdir/README              $pkgdir/usr/share/doc/$_pkgname
 
     install -Dm644 ../zoneminder-tmpfile.conf "$pkgdir"/usr/lib/tmpfiles.d/zoneminder.conf
 
@@ -174,4 +147,14 @@ package() {
     install -o root -g root -D -m0755 $srcdir/zm.sysctrl.conf $pkgdir/etc/sysctl.d/zm.conf
     #gen_light_conf
     install -D -m0744 ${srcdir}/zm_gen_light.conf $pkgdir/etc/gen_light_conf.d/zoneminder.conf
+
 }
+md5sums=('1e61836e7d938710801f4fb2b2deaaae'
+         '2a0d1ff33567946b7a8ac1242270c8cc'
+         '85baafb00bbb1bcd04cfae899b6cd395'
+         'b2454d4fab43813e8e660ea4709a3102'
+         '327d49273d41dc5bbd9f74defb0dc924'
+         'b4aa4f6881c571e873574907983a82db'
+         '9d93f9b7b0a1384df533efde19ed3021'
+         'c528e75443ae421cb7f63e12350c692a'
+         '81cb12b36616a299ec808ac70a809ec2')
diff --git a/abs/core/zoneminder/__changelog b/abs/core/zoneminder/__changelog
index f039892..f4d2281 100644
--- a/abs/core/zoneminder/__changelog
+++ b/abs/core/zoneminder/__changelog
@@ -1,16 +1,18 @@
-PKGBUILD: modified AUR zoneminder-git
 PKGBUILD: remove apache
 PKGBUILD: add lighttpd
 PKGBUILD: remove php-apache
 PKGBUILD: change mariadb to mysql
 PKGBUILD: remove vlc
+PKGBUILD: remove php-mcrypt
+PKGBUILD: add perl-sys-meminfo perl-sys-cpu
+PGKBUILD: add php-uapc
 PKGBUILD: change all /srv/ to /data/srv/ - cgidir webdir socks
 PKGBUILD: change all http to httpd dirs
 PKGBUILD: add zm.include for lighttpd
 PKGBUILD: add zm.sysctrl.conf  to set the shared mem
 PKGBUILD: add zm_gen_light.conf
 --
-.install: Remove modifications of php.ini
+.install: Remove modifications of php.ini & apache files
 .install: Remove php and mysql notes
 .install: Remove/Add of zm.include in post install/remove
 .install: Add install_db()
diff --git a/abs/core/zoneminder/fabs.patch b/abs/core/zoneminder/fabs.patch
new file mode 100644
index 0000000..b0a62e3
--- /dev/null
+++ b/abs/core/zoneminder/fabs.patch
@@ -0,0 +1,11 @@
+--- src/ZoneMinder-1.30.4/src/zm_image.cpp	2017-06-17 04:20:45.808503543 -0300
++++ src/ZoneMinder-1.30.4/src/zm_image.cpp.2	2017-06-17 04:20:40.221794330 -0300
+@@ -1659,7 +1659,7 @@
+         uint8_t *psrc = images[j]->buffer+c;
+ 
+ #ifndef SOLARIS
+-        if ( (unsigned)abs((*psrc)-RGB_VAL(ref_colour,c)) >= RGB_VAL(threshold,c) )
++        if ( (unsigned)fabs((*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
diff --git a/abs/core/zoneminder/log.txt b/abs/core/zoneminder/log.txt
new file mode 100644
index 0000000..09e54b1
--- /dev/null
+++ b/abs/core/zoneminder/log.txt
@@ -0,0 +1,23 @@
+==> Making package: zoneminder 1.30.4-1 (Fri Sep 15 20:35:45 UTC 2017)
+==> Checking runtime dependencies...
+==> Missing dependencies:
+  -> mariadb
+  -> perl-dbd-mysql
+  -> perl-dbi
+  -> apache
+  -> php
+  -> php-apache
+  -> php-gd
+  -> php-mcrypt
+  -> perl-libwww
+  -> vlc
+  -> perl-archive-zip
+  -> perl-date-manip
+  -> perl-mime-lite
+  -> perl-mime-tools
+==> Checking buildtime dependencies...
+==> Missing dependencies:
+  -> netpbm
+==> ERROR: Could not resolve all dependencies.
+
+==> ERROR: An unknown error has occurred. Exiting...
diff --git a/abs/core/zoneminder/uio.patch b/abs/core/zoneminder/uio.patch
new file mode 100644
index 0000000..a892e29
--- /dev/null
+++ b/abs/core/zoneminder/uio.patch
@@ -0,0 +1,22 @@
+--- src/ZoneMinder-1.30.4/src/zm_comms.h	2017-05-09 14:54:48.000000000 +0000
++++ src/ZoneMinder-1.30.4/src/zm_comms.fix.h	2017-09-15 20:49:46.992445289 +0000
+@@ -21,7 +21,6 @@
+ #define ZM_COMMS_H
+ 
+ #include "zm_exception.h"
+-
+ #include <string.h>
+ #include <unistd.h>
+ #include <netdb.h>
+@@ -31,11 +30,9 @@
+ #include <set>
+ #include <vector>
+ 
+-#if defined(BSD)
+ #include <sys/uio.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+-#endif
+ 
+ class CommsException : public Exception
+ {
diff --git a/abs/core/zoneminder/zm_rtp_ctrl.h.quick_fix_for_gcc6.diff b/abs/core/zoneminder/zm_rtp_ctrl.h.quick_fix_for_gcc6.diff
new file mode 100644
index 0000000..ae076e7
--- /dev/null
+++ b/abs/core/zoneminder/zm_rtp_ctrl.h.quick_fix_for_gcc6.diff
@@ -0,0 +1,4 @@
+126c126
+<             struct Bye
+---
+>             struct
-- 
cgit v0.12

