Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Contributor: Nocifer <apmichalopoulos 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>
- # Contributor: Jason Gardner <buhrietoe@gmail.com>
- # 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
- # Cleaned up the place (unneeded variables, 3-space tabs, hardcoded ZoneMinder-$pkgver references instead of $pkgname-$pkgver ones, wrong upstream URL, wrong license, missing conflict with 'zoneminder-git', etc).
- #
- # Removed sources for redundant patches as they aren't relevant anymore (source files have been altered and/or already include the patch changes).
- #
- # Replaced git clone for CakePHP and Crud sources with published precompiled packages, as follows:
- # - CakePHP-Enum-Behaviour is pulled from the ZoneMinder repo, because a change is needed that has not yet been merged upstream.
- # - Crud is pulled from its official repo, since Pull Request #582 has been merged as required by the ZoneMinder devs.
- #
- # Adjusted dependencies using as reference the control files for Ubuntu 16.04 & Debian .deb packages provided by upstream.
- #
- # Changed the folder structure a bit (so it would be a good idea to not upgrade blindly an older installation with this PKGBUILD, unless you want to be left with redundant and untracked by pacman folders and/or files).
- #
- # Replaced Apache with Nginx.
- #
- # ZoneMinder now runs at localhost:8095, instead of localhost/zm (this can be changed by editing the provided Nginx conf file).
- #
- # Completely rehauled the setup procedure:
- # - The install script now takes into account the instructions in the INSTALL file provided by upstream.
- # - All extra files (systemd service, systemd tmpfile, server configuration) have been merged into the install script.
- # - ZoneMinder now works "out of the box": the database is automatically created, Nginx is automatically configured, PHP-FPM as well.
- pkgname=zoneminder
- pkgver=1.32.0
- pkgrel=1
- pkgdesc="Record, analyze and monitor CCTV cameras"
- arch=('x86_64')
- url="http://www.zoneminder.com"
- license=('GPL2')
- depends=('gnutls' 'polkit' 'ffmpeg' 'libmp4v2' 'fcgiwrap' 'mariadb' 'nginx-mainline' 'php-apcu' 'php-fpm' 'php-gd'
- 'perl-date-manip' 'perl-mime-lite' 'perl-mime-tools' 'perl-dbd-mysql' 'perl-archive-zip' 'perl-device-serialport' 'perl-image-info' 'perl-json-any'
- 'perl-libwww' 'perl-data-dump' 'perl-number-bytes-human' 'perl-file-slurp' 'perl-sys-meminfo' 'perl-sys-mmap'
- 'perl-class-load' 'perl-data-uuid' 'perl-io-socket-multicast' 'perl-soap-wsdl' 'perl-xml-parser'
- # Possible dependencies. They have not raised any red flags so far but I'm not 100% sure whether they're leftovers from previous ZoneMinder incarnations or if they're needed for proper runtime operation. For the time being I'm leaving them in.
- 'perl-php-serialization' 'perl-module-load-conditional' 'perl-net-sftp-foreign' 'perl-json-maybexs' 'perl-uri-encode' 'perl-sys-cpu')
- makedepends=('cmake')
- conflict=('zoneminder-git')
- install=$pkgname.install
- source=("https://github.com/ZoneMinder/ZoneMinder/archive/$pkgver.tar.gz"
- "https://github.com/ZoneMinder/CakePHP-Enum-Behavior/archive/1.0-zm.tar.gz"
- "https://github.com/FriendsOfCake/crud/archive/v3.2.0.tar.gz")
- sha256sums=('1d5cff0be7eefecdbf8b699220b49a2539427f401da3164eabaa569522843b24'
- 'dbd231e97b950c698f0f501d6a53c7291c9985e766b09e3afe00cfe69a969f44'
- '55be29e1eccb44d4ad0db8b23c37cec50f5341f8e498583d472ed1f0493876e3')
- prepare () {
- tar -zx -C $srcdir/$pkgname-$pkgver/web/api/app/Plugin/CakePHP-Enum-Behavior -f 1.0-zm.tar.gz --strip 1
- tar -zx -C $srcdir/$pkgname-$pkgver/web/api/app/Plugin/Crud -f v3.2.0.tar.gz --strip 1
- }
- build() {
- cd $pkgname-$pkgver
- # Added new ZM_CACHEDIR as required for v1.32.0
- cmake -DCMAKE_INSTALL_PREFIX=/usr \
- -DZM_CONFIG_DIR=/etc/$pkgname \
- -DZM_CONFIG_SUBDIR=/etc/$pkgname/conf.d \
- -DZM_RUNDIR=/run/$pkgname \
- -DZM_SOCKDIR=/run/$pkgname \
- -DZM_LOGDIR=/var/log/$pkgname \
- -DZM_CONTENTDIR=/var/lib/$pkgname \
- -DZM_CACHEDIR=/var/lib/$pkgname/cache \
- -DZM_TMPDIR=/var/lib/$pkgname/temp \
- -DZM_WEBDIR=/srv/$pkgname/www \
- -DZM_CGIDIR=/srv/$pkgname/cgi-bin \
- -DZM_WEB_USER=http .
- make
- }
- package() {
- cd $pkgname-$pkgver
- make DESTDIR=$pkgdir install
- # EXTREMELY HACKY solution to make the API work, because so far I haven't been able to translate the Apache .htaccess rewrites into a proper Nginx configuration (at least I *think* that's where the problem lies). This possibly breaks other things in the long run. Needs testing.
- sed -i 's|../../../includes/auth.php|../includes/auth.php|g' $pkgdir/srv/$pkgname/www/api/app/Controller/AppController.php
- sed -i 's|../../../includes/config.php|../includes/config.php|g' $pkgdir/srv/$pkgname/www/api/app/Config/bootstrap.php
- # Set Polkit directory permissions in accordance with Arch policy
- chmod 750 $pkgdir/usr/share/polkit-1/rules.d
- chown root:polkitd $pkgdir/usr/share/polkit-1/rules.d
- # Create ZM_LOGDIR
- mkdir -p $pkgdir/var/log/$pkgname
- chown -R http:http $pkgdir/var/log/$pkgname
- chmod -R 755 $pkgdir/var/log/$pkgname
- # Create ZM_CONTENTDIR and its subfolders
- mkdir -p $pkgdir/var/lib/$pkgname/{cache,events,images,temp}
- chown -R http:http $pkgdir/var/lib/$pkgname
- chmod -R 755 $pkgdir/var/lib/$pkgname
- # Run script provided by upstream to create and/or link the needed folders with correct permissions.
- ./zmlinkcontent.sh -z $pkgdir/etc/$pkgname/zm.conf -w $pkgdir/srv/$pkgname/www -l $pkgdir/var/log/$pkgname -t $pkgdir/var/lib/$pkgname/temp $pkgdir/var/lib/$pkgname
- # Link ZM_CGIDIR inside ZM_WEBDIR and set correct permissions for both of them
- ln -s /srv/$pkgname/cgi-bin $pkgdir/srv/$pkgname/www
- chown -Rh http:http $pkgdir/srv/$pkgname
- # Set correct permissions for ZM_CONFIG_DIR & ZM_CONFIG_SUBDIR
- chown -R http:http $pkgdir/etc/$pkgname
- chmod -R 755 $pkgdir/etc/$pkgname
- chmod 644 $pkgdir/etc/$pkgname/zm.conf
- chmod 644 $pkgdir/etc/$pkgname/conf.d/*
- # Nginx
- mkdir -p $pkgdir/etc/nginx/sites-{available,enabled}
- cat <<EOF >> $pkgdir/etc/nginx/sites-available/$pkgname.conf
- server {
- listen 8095;
- server_name localhost;
- root /srv/zoneminder/www;
- location /cache {
- gzip off;
- root /var/lib/zoneminder;
- }
- location /cgi-bin {
- gzip off;
- include fastcgi_params;
- fastcgi_param SCRIPT_FILENAME \$request_filename;
- fastcgi_intercept_errors on;
- fastcgi_pass unix:/run/fcgiwrap.sock;
- }
- location / {
- gzip off;
- index index.php;
- location /api {
- rewrite ^/api(.+)$ /api/index.php?p=\$1 last;
- }
- location ~ \.php$ {
- if (!-f \$request_filename) { return 404; }
- expires epoch;
- include fastcgi_params;
- fastcgi_param SCRIPT_FILENAME \$request_filename;
- fastcgi_index index.php;
- fastcgi_intercept_errors on;
- fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
- }
- location ~ \.(txt|log)$ {
- deny all;
- }
- location ~ \.(jpg|jpeg|gif|png|ico)$ {
- access_log off;
- expires 33d;
- }
- location ~ \.(m4a|mp4|mov)$ {
- mp4;
- mp4_buffer_size 5M;
- mp4_max_buffer_size 10M;
- }
- }
- }
- EOF
- ln -s /etc/nginx/sites-available/$pkgname.conf $pkgdir/etc/nginx/sites-enabled/$pkgname.conf
- # Systemd service
- # (in the future these hardcoded dependencies could be removed or, even better, a new standalone package could be created for use with remote servers)
- sed -i 's|mysqld.service httpd.service|mariadb.service nginx.service|g' misc/zoneminder.service
- mkdir -p $pkgdir/usr/lib/systemd/system
- install -D -m 644 misc/$pkgname.service $pkgdir/usr/lib/systemd/system/$pkgname.service
- # Systemd tmpfile
- sed -i '3d' misc/zoneminder-tmpfiles.conf
- mkdir -p $pkgdir/usr/lib/tmpfiles.d
- install -D -m 644 misc/$pkgname-tmpfiles.conf $pkgdir/usr/lib/tmpfiles.d/$pkgname.conf
- # PHP-FPM
- mkdir -p $pkgdir/etc/php/conf.d/
- cat <<EOF >> $pkgdir/etc/php/conf.d/$pkgname.ini
- extension=apcu
- extension=ftp
- extension=gd
- extension=gettext
- extension=pdo_mysql
- extension=sockets
- extension=zip
- date.timezone = UTC
- EOF
- # Misc
- install -D -m 644 COPYING $pkgdir/usr/share/license/$pkgname
- install -D -m 644 db/zm*.sql $pkgdir/usr/share/$pkgname/db
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement