From 75f31c7a5d9c8fc44cf9432a23873cc8b55d036f Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Mon, 26 Sep 2016 22:09:16 +0000
Subject: zoneminder: update to 1.30. refs #1004

---
 abs/core/zoneminder/PKGBUILD                | 179 ++++++++++++++++------------
 abs/core/zoneminder/__changelog             |  16 +--
 abs/core/zoneminder/httpd-zoneminder.conf   |   6 +-
 abs/core/zoneminder/zoneminder-tmpfile.conf |   1 +
 abs/core/zoneminder/zoneminder.install      |  45 +------
 abs/core/zoneminder/zoneminder.service      |   7 +-
 6 files changed, 120 insertions(+), 134 deletions(-)
 create mode 100644 abs/core/zoneminder/zoneminder-tmpfile.conf

diff --git a/abs/core/zoneminder/PKGBUILD b/abs/core/zoneminder/PKGBUILD
index e5c6b5d..e48da09 100644
--- a/abs/core/zoneminder/PKGBUILD
+++ b/abs/core/zoneminder/PKGBUILD
@@ -1,4 +1,4 @@
-# Contributor: Troy Will                 <troydwill@gmail.com>
+# Maintainer: 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>
@@ -6,120 +6,151 @@
 # Contributor: Ross melin                <rdmelin@gmail.com>
 # Contributor (Parabola): Márcio Silva   <coadde@lavabit.com>
 # Contributor (Parabola): André Silva    <emulatorman@lavabit.com>
+# Contributor: Charles Spence IV         <cspence@unomaha.edu>
+# Contributor: Joe Julian                <me@joejulian.name>     
 # Orginally based on a Debian Squeeze package
-     
-pkgbase=zoneminder
+_pkgname=zoneminder
 pkgname=zoneminder
-pkgver=1.28.0
-pkgrel=5
+pkgver=1.30.0.r107.g66ae5c5
+pkgrel=1
 pkgdesc='Capture, analyse, record and monitor video security cameras'
-arch=( i686 x86_64 mips64el arm )
-     
+arch=( i686 x86_64 mips64el arm armv7h )
 backup=( etc/zm.conf )
 url="https://github.com/ZoneMinder/ZoneMinder/releases"
 license=( GPL )
-     
 depends=(
-    lighttpd
-    cambozola
-    gnutls
-    mysql
-    perl-archive-zip
-    perl-date-manip
-    perl-dbd-mysql
-    perl-dbi
-    perl-expect
-    perl-libwww
-    perl-mime-lite
-    perl-mime-tools
-    perl-php-serialization
-    perl-net-sftp-foreign
-    perl-sys-mmap
-    perl-time-modules
-    perl-x10
-    php
-    #php-apache
-    php-gd
-    php-mcrypt
+    mysql perl-dbd-mysql perl-dbi
+    lighttpd php php-gd php-mcrypt perl-php-serialization
+    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
 )
-
 makedepends=(
-    netpbm
-    cmake
+    cmake make gcc netpbm
 )
-
 optdepends=(
     netpbm
+    cambozola
+    perl-time-modules
+    perl-x10
+    perl-astro-suntime
 )
-     
-install=$pkgbase.install
+install=$pkgname.install
      
 source=(
-    https://github.com/ZoneMinder/ZoneMinder/archive/v$pkgver.tar.gz
+    git://github.com/$_pkgname/$_pkgname.git
+    git://github.com/FriendsOfCake/crud.git
     httpd-zoneminder.conf
     zoneminder.service
+    zoneminder-tmpfile.conf
     zm.include
-    zm.sysctrl.conf    
+    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
+}
+
 build() {
-    cd $srcdir/ZoneMinder-$pkgver
+    cd $srcdir/$_pkgname
 
-    cmake -DCMAKE_INSTALL_PREFIX=/usr \
-        -DZM_CGIDIR=/data/srv/httpd/cgi-bin \
-        -DZM_WEBDIR=/data/srv/httpd/zoneminder \
-        -DZM_WEB_USER=http \
-        -DZM_CONTENTDIR=/var/cache/zoneminder \
-        -DZM_LOGDIR=/var/log/zoneminder \
-        -DZM_RUNDIR=/var/run/zm \
-        -DZM_TMPDIR=/var/tmp \
-        -DZM_SOCKDIR=/data/srv/zoneminder/socks/ .
+    # ZM_PERL_SUBPREFIX=/lib/perl5 flag added to force Perl modules
+    # to /usr/lib/perl5/ on non i686 architectures
     
+    cmake -DCMAKE_INSTALL_PREFIX=/usr \
+          -DZM_PERL_SUBPREFIX=/lib/perl5 \
+          -DZM_WEBDIR=/data/srv/httpd/zoneminder \
+          -DZM_CGIDIR=/data/srv/httpd/cgi-bin \
+          -DZM_WEB_USER=http \
+          -DZM_CONTENTDIR=/var/cache/zoneminder \
+          -DZM_LOGDIR=/var/log/zoneminder \
+          -DZM_RUNDIR=/run/zoneminder \
+          -DZM_TMPDIR=/var/lib/zoneminder/temp \
+          -DZM_SOCKDIR=/data/srv/zoneminder/sock .
+     
     make V=0
 }
      
 package() {
 
-    cd $srcdir/ZoneMinder-$pkgver
+    cd $srcdir/$_pkgname
 
     DESTDIR=$pkgdir make install
 
+    # Change Polkit directory permissions to Arch Linux policy
+    chmod -v 700 $pkgdir/usr/share/polkit-1/rules.d/
+    chown -v polkitd $pkgdir/usr/share/polkit-1/rules.d/
+
     # BEGIN CREATE_ZONEMINDER_DIRECTORIES
-    mkdir -p $pkgdir/var/run/zm
-    chown -v http.http $pkgdir/var/run/zm
-    mkdir -p $pkgdir/var/{cache/$pkgbase,log/$pkgbase}
-    mkdir -p $pkgdir/data/srv/zoneminder/socks
-    chown -Rv http.http $pkgdir/{etc/zm.conf,var/{cache/$pkgbase,log/$pkgbase}}
-    chown -Rv http.http $pkgdir/data/srv/zoneminder/socks
-    chmod 0700 $pkgdir/etc/zm.conf
+    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_TMPDIR=/var/lib/zoneminder/temp
+    mkdir -pv          $pkgdir/var/lib/zoneminder/temp
+    chown -v http.http $pkgdir/var/lib/zoneminder/temp
+    
+    chown -v  http.http $pkgdir/etc/zm.conf 
+    chmod 0700          $pkgdir/etc/zm.conf
     # END CREATE_ZONEMINDER_DIRECTORIES
 
-    # Make content directories in /var/cache/zoneminder and link them
+    # Make content directories in /var/cache/zoneminder and to link them in /srv/httpd/zoneminder
     for i in events images temp; do
-        mkdir $pkgdir/var/cache/$pkgbase/$i
-        # chown -v    http.http                $pkgdir/var/cache/$pkgbase/$i
-        ln -s /var/cache/$pkgbase/$i         $pkgdir/data/srv/httpd/$pkgbase/$i
-        chown -v --no-dereference http.http  $pkgdir/data/srv/httpd/$pkgbase/$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/$pkgbase
+    ln -sv /data/srv/httpd/cgi-bin $pkgdir/data/srv/httpd/$pkgname
 
-    chown -h http.http $pkgdir/data/srv/httpd/{cgi-bin,$pkgbase,$pkgbase/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/$pkgbase
+    # 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-$pkgbase.conf $pkgdir/etc/httpd/conf/extra
-    mkdir -p $pkgdir/usr/lib/systemd/system
-    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     
+    # 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/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
+    
+    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
 
     #LinHES stuff
     #lighttpd zm include
@@ -129,9 +160,3 @@ package() {
     #gen_light_conf
     install -D -m0744 ${srcdir}/zm_gen_light.conf $pkgdir/etc/gen_light_conf.d/zoneminder.conf
 }
-md5sums=('b0317c6fe003de9a0c7c76078b0adc2b'
-         'dcaa22b9030bc7b5b76568dbe8ea9eca'
-         'bb801be691cbe1ed98f395b2ebe5c882'
-         '9d93f9b7b0a1384df533efde19ed3021'
-         'c528e75443ae421cb7f63e12350c692a'
-         '81cb12b36616a299ec808ac70a809ec2')
diff --git a/abs/core/zoneminder/__changelog b/abs/core/zoneminder/__changelog
index 8b30691..f039892 100644
--- a/abs/core/zoneminder/__changelog
+++ b/abs/core/zoneminder/__changelog
@@ -1,17 +1,19 @@
+PKGBUILD: modified AUR zoneminder-git
 PKGBUILD: remove apache
 PKGBUILD: add lighttpd
 PKGBUILD: remove php-apache
 PKGBUILD: change mariadb to mysql
+PKGBUILD: remove vlc
 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 file
-Removed modifications of php.ini
-Remove php and mysql notes
-Added remove/add of zm.include in post install/remove
-added install_db
-add http to video group
-gen_light_include.py
+.install: Remove modifications of php.ini
+.install: Remove php and mysql notes
+.install: Remove/Add of zm.include in post install/remove
+.install: Add install_db()
+.install: Add http to video group
+.install: Add gen_light_include.py
 --
diff --git a/abs/core/zoneminder/httpd-zoneminder.conf b/abs/core/zoneminder/httpd-zoneminder.conf
index cdb7722..41b364f 100644
--- a/abs/core/zoneminder/httpd-zoneminder.conf
+++ b/abs/core/zoneminder/httpd-zoneminder.conf
@@ -1,4 +1,4 @@
-# /etc/httpd/conf/extra/httpd-zm.conf
+# /etc/httpd/conf/extra/httpd-zoneminder.conf
 # Config for zoneminder web app
 
 Alias /zm "/srv/http/zoneminder"
@@ -7,8 +7,8 @@ Alias /zm "/srv/http/zoneminder"
   AllowOverride None
   Order allow,deny
   Allow from all
-  # The code unfortunately uses short tags in many places
-  php_value short_open_tag On
+  # Provide PHP directory and file access, see http://php.net/manual/en/ini.core.php#ini.open-basedir
+  php_admin_value open_basedir "/tmp/:/etc/zm.conf:/srv/http/zoneminder/:/var/cache/zoneminder/:/var/lib/zoneminder/:/var/log/zoneminder/"
 </Directory>
 
 ScriptAlias /cgi-bin "/srv/http/cgi-bin"
diff --git a/abs/core/zoneminder/zoneminder-tmpfile.conf b/abs/core/zoneminder/zoneminder-tmpfile.conf
new file mode 100644
index 0000000..84362b5
--- /dev/null
+++ b/abs/core/zoneminder/zoneminder-tmpfile.conf
@@ -0,0 +1 @@
+d /run/zoneminder 0755 http http -
diff --git a/abs/core/zoneminder/zoneminder.install b/abs/core/zoneminder/zoneminder.install
index a086b96..5d5459a 100644
--- a/abs/core/zoneminder/zoneminder.install
+++ b/abs/core/zoneminder/zoneminder.install
@@ -11,52 +11,13 @@ install_db() {
             echo 'grant lock tables, alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql
         fi
     else
-        echo "Will only init the database for  StandAlone or Master_backend LinHES systems"
+        echo "Will only init the database for StandAlone or Master_backend LinHES systems"
     fi
     }
 
-pre_install() {
-    set -e
-    abort=false
-    if [ -L /data/srv/httpd/zoneminder/events ]; then
-        l=$(readlink /data/srv/httpd/zoneminder/events)
-        if [ $l != /var/cache/zoneminder/events ]; then
-            abort=true
-        fi
-    fi
-    if [ -L /data/srv/httpd/zoneminder/images ]; then
-        l=$(readlink /data/srv/httpd/zoneminder/images)
-        if [ $l != /var/cache/zoneminder/images ]; then
-            abort=true
-        fi
-    fi
-    if [ $abort = true ]; then
-        cat >&2 << EOF
-Aborting installation of zoneminder due to non-default symlinks in
-/data/srv/httpd/zoneminder for the images and/or events directory, which could
-result in loss of data. Please move your data in each of these directories to
-/var/cache/zoneminder before installing zoneminder from the package.
-EOF
-        exit 1
-    fi
-    exit 0
-}
-
 post_install() {
-    if [[ -d /var/log/zoneminder ]]; then
-        chmod 0755 /var/log/zoneminder
-        chown http.http /var/log/zoneminder
-    else
-        mkdir -m 0755 /var/log/zoneminder
-        chown http.http /var/log/zoneminder
-    fi
-    if [[ -d /tmp/zm ]]; then
-        chmod 0700 /tmp/zm
-        chown http.http /tmp/zm
-    else
-        mkdir -m 0700 /tmp/zm
-        chown http.http /tmp/zm
-    fi
+
+    systemd-tmpfiles --create zoneminder.conf
 
     #---LinHES Stuff
     usermod -G video http
diff --git a/abs/core/zoneminder/zoneminder.service b/abs/core/zoneminder/zoneminder.service
index 1314521..48268f1 100644
--- a/abs/core/zoneminder/zoneminder.service
+++ b/abs/core/zoneminder/zoneminder.service
@@ -1,6 +1,3 @@
-# ZoneMinder systemd unit file
-# This file is intended to work with all Linux distributions
-
 [Unit]
 Description=ZoneMinder CCTV recording and security system
 After=network.target mysqld.service httpd.service
@@ -11,8 +8,8 @@ User=http
 Type=forking
 ExecStart=/usr/bin/zmpkg.pl start
 ExecReload=/usr/bin/zmpkg.pl restart
-ExecStop=/bin/bash -c '[[ "$(/usr/bin/pgrep zmdc.pl)" > 0 ]] && /usr/bin/zmpkg.pl stop'
-PIDFile="/var/run/zm/zm.pid"
+ExecStop=/usr/bin/zmpkg.pl stop
+PIDFile=/run/zoneminder/zm.pid
 
 [Install]
 WantedBy=multi-user.target
-- 
cgit v0.12