Skip to content

Latest commit

 

History

History
707 lines (632 loc) · 29.5 KB

zoneminder-aur.org

File metadata and controls

707 lines (632 loc) · 29.5 KB

zoneminder PKGBUILD

TANGLE zoneminder/PKGBUILD

<<CONTRIBUTORS>>
<<PACKAGE_VERSION_DATA>>
backup=( etc/zm.conf )
url="https://github.com/ZoneMinder/ZoneMinder/releases"
license=( GPL )
<<DEPENDENCIES>>
install=$_pkgname.install

<<SOURCES>>
     
<<BUILD>>
     
<<PACKAGE>>

TANGLE httpd-zoneminder.conf

<<httpd-zoneminder.conf>>

TANGLE zoneminder.service

<<zoneminder.service>>

TANGLE zoneminder.install

<<zoneminder.install>>

TANGLE php.ini.sed

<<PHP.INI.SED>>

TANGLE httpd.conf.sed

<<HTTPD.CONF.SED>>

  1. fix /tmp/zoneminder

zoneminder GIT PKGBUILD

TANGLE zoneminder-git/PKGBUILD

<<CONTRIBUTORS>>
<<PACKAGE_VERSION_DATA_GIT>>
backup=( etc/zm.conf )
url="https://github.com/ZoneMinder/ZoneMinder/releases"
license=( GPL )
<<DEPENDENCIES>>
install=$_pkgname.install
     
<<SOURCES-GIT>>
     
<<pkgver-git>>

<<BUILD-GIT>>
     
<<PACKAGE-GIT>>

TANGLE httpd-zoneminder.conf

<<httpd-zoneminder.conf>>

TANGLE zoneminder.service

<<zoneminder.service>>

TANGLE zoneminder.install

<<zoneminder.install>>

TANGLE php.ini.sed

<<PHP.INI.SED>>

TANGLE httpd.conf.sed

<<HTTPD.CONF.SED>>

  1. fix /tmp/zoneminder

Chunks

CONTRIBUTORS

# Maintainer: Troy Will <troydwill at gmail dot com>
# Contributor: Charles Spence IV         <[email protected]>
# Contributor: /dev/rs0                  </dev/[email protected]>
# Contributor: Jacek Burghardt           <[email protected]>
# Contributor: Vojtech Aschenbrenner     <[email protected]>
# Contributor: Jason Gardner             <[email protected]>
# Contributor: Ross melin                <[email protected]>
# Contributor (Parabola): Márcio Silva   <[email protected]>
# Contributor (Parabola): André Silva    <[email protected]>
# Orginally based on a Debian Squeeze package

pkgver-git

See https://wiki.archlinux.org/index.php/VCS_package_guidelines#The_pkgver.28.29_function

pkgver() {
    cd "$_pkgname"
    printf "%s.r%s.%s.%s" "$pkgver" "$(git rev-list --count HEAD)" "$pkgrel" "$(git rev-parse --short HEAD)"
}

PACKAGE VERSION DATA

_pkgname=zoneminder
pkgname=zoneminder
pkgver=1.28.0
pkgrel=11
pkgdesc='Capture, analyse, record and monitor video security cameras'
<<ARCH>>

PACKAGE VERSION DATA GIT

_pkgname=zoneminder
pkgname=zoneminder-git
pkgver=1.28.0
pkgrel=11
pkgdesc='Capture, analyse, record and monitor video security cameras'
<<ARCH>>

ARCH

arch=( i686 x86_64 mips64el arm armv7h )

DEPENDENCIES

depends=(
    mariadb perl-dbd-mysql perl-dbi
    apache php php-apache php-gd php-mcrypt perl-php-serialization
    perl-libwww perl-net-sftp-foreign
    ffmpeg vlc perl-sys-mmap
    gnutls polkit
    perl-expect perl-archive-zip perl-date-manip
    perl-mime-lite perl-mime-tools
)
makedepends=(
    cmake make gcc netpbm
)
optdepends=(
    netpbm
    cambozola
    perl-time-modules
    perl-x10-zoneminder
    perl-astro-suntime-zoneminder
)

SOURCES

See https://github.com/ZoneMinder/ZoneMinder/releases

source=(
    https://github.com/ZoneMinder/ZoneMinder/archive/v$pkgver.tar.gz
    httpd-zoneminder.conf
    zoneminder.service
)
sha256sums=('b9ee65635753e094dcad6cdb480acc42bff8b8f023ee008790883a4308273ca2'
            '6e7155fc145e29351ec97f2b0c8d493fff871129a7e4c139d07bf6a9fc977919'
            '7eb2f26246e240e23502da44854d5ed14485aa11bc448ad73e9b57fee13f00a3')
source=(
    git://github.com/$_pkgname/$_pkgname.git
    httpd-zoneminder.conf
    zoneminder.service
)
# Because the source is not static, skip Git checksum:
sha256sums=('SKIP'
            '6e7155fc145e29351ec97f2b0c8d493fff871129a7e4c139d07bf6a9fc977919'
            '7eb2f26246e240e23502da44854d5ed14485aa11bc448ad73e9b57fee13f00a3')

httpd-zoneminder.conf file:/etc/httpd/conf/extra/httpd-zoneminder.conf

# /etc/httpd/conf/extra/httpd-zoneminder.conf
# Config for zoneminder web app

Alias /zm "/srv/http/zoneminder"
<Directory "/srv/http/zoneminder">
  Options -Indexes +MultiViews +FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from all
  # The code unfortunately uses short tags in many places
  php_value short_open_tag On
</Directory>

ScriptAlias /cgi-bin "/srv/http/cgi-bin"
<Directory "/srv/http/cgi-bin">
  AllowOverride None
  Options +ExecCGI +FollowSymLinks
  Order allow,deny
  Allow from all
</Directory>

# Provide PHP access to important directories
php_admin_value open_basedir "/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/zm.conf:/srv/http/zoneminder/:/var/cache/zoneminder/:/srv/zoneminder/socks/:/var/log/zoneminder/"

zoneminder.service

# ZoneMinder systemd unit file for Arch Linux

[Unit]
Description=ZoneMinder CCTV recording and security system
After=network.target mysqld.service httpd.service
Requires=mysqld.service httpd.service

[Service]
User=http
Type=forking
ExecStart=/usr/bin/zmpkg.pl start
ExecReload=/usr/bin/zmpkg.pl restart
ExecStop=/usr/bin/zmpkg.pl stop
PIDFile="/srv/zoneminder/zm.pid"

[Install]
WantedBy=multi-user.target

zoneminder.install

post_install() {
    # edit /etc/php.ini for Zoneminder
    sed -e '
    <<PHP.INI.SED>>
    ' /etc/php/php.ini > /etc/php/php.ini.zoneminder

    # edit /etc/httpd/conf/httpd.conf for Zoneminder
    sed -e '
    <<HTTPD.CONF.SED>>
    ' /etc/httpd/conf/httpd.conf > /etc/httpd/conf/httpd.conf.zoneminder
    
    cat << EOF

  <<POST_INSTALL_MYSQL_INSTRUCTIONS_CHUNK>>

  <<POST_INSTALL_PHP_INSTRUCTIONS_CHUNK>>

  <<POST_INSTALL_APACHE_INSTRUCTIONS_CHUNK>>
EOF
}

post_upgrade() {
    post_install
    /usr/bin/zmupdate.pl -f >/dev/null
}

<<POST_REMOVE_CHUNK>>

POST_INSTALL_MYSQL_INSTRUCTIONS_CHUNK

Zoneminder database setup:
--------------------------
Zoneminder operation requires a database named 'zm' which is defined in /usr/share/zoneminder/db/zm_create.sql

Create the Zoneminder database (with a password):
  "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"
  "echo 'grant lock tables, alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/my.cnf -p mysql"
(or without a password):
  "mysqladmin --defaults-file=/etc/mysql/my.cnf -f reload"
  "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"

POST_INSTALL_PHP_INSTRUCTIONS_CHUNK

PHP configuration
-----------------
* Check and make sure these are uncommented in /etc/php/php.ini: 
  extension=ftp.so
  extension=gd.so
  extension=gettext.so
  extension=mcrypt.so
  extension=openssl.so
  extension=pdo_mysql.so
  extension=sockets.so
  extension=zip.so
* Add /etc/zm.conf, /srv/http/zoneminder, /var/cache/zoneminder, and /srv/zoneminder/socks to open_basedir in the zoneminder vhosts configuration file in apache:
  php_admin_value open_basedir "/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/zm.conf:/srv/http/zoneminder/:/var/cache/zoneminder/:/srv/zoneminder/socks/:/var/log/zoneminder/"
* Set your timezone in php.ini:
  date.timezone = <your_country>/<your_city>

POST_INSTALL_APACHE_INSTRUCTIONS_CHUNK

Apache configuration
--------------------
Edit /etc/httpd/conf/httpd.conf and add the line:
  "LoadModule php5_module modules/libphp5.so"
and:
  "Include /etc/httpd/conf/extra/php5_module.conf"
  "Include /etc/httpd/conf/extra/httpd-zoneminder.conf"

  1. fix /tmp/zoneminder

POST_REMOVE_CHUNK

post_remove() {
    if [[ -d /tmp/zoneminder ]]; then
        rm -vr /tmp/zoneminder
    fi
    # sed -i -e '
    # /^open_basedir/ s/:\/srv\/http\/zoneminder//;
    # /^open_basedir/ s/:\/srv\/http\/zoneminder\///;
    # ' /etc/php/php.ini || read
    # sed -i -e '
    # /^# ZoneMinder/d;
    # /Include \/etc\/httpd\/conf\/extra\/httpd-zoneminder.conf/d;
    # ' /etc/httpd/conf/httpd.conf || read

    cat << EOF
Note:
==> To clean Zoneminder mysql database, run as root (with password):
==> "echo 'delete from user where User="zmuser";' | mysql --defaults-file=/etc/mysql/my.cnf -p mysql"
==> "echo 'delete from db where User="zmuser";' | mysql --defaults-file=/etc/mysql/my.cnf -p mysql"
==> "mysqladmin --defaults-file=/etc/mysql/my.cnf -p -f drop zm"
==> (or without password):
==> "echo 'delete from user where User="zmuser";' | mysql --defaults-file=/etc/mysql/my.cnf mysql"
==> "echo 'delete from db where User="zmuser";' | mysql --defaults-file=/etc/mysql/my.cnf mysql"
==> "mysqladmin --defaults-file=/etc/mysql/my.cnf -f drop zm"

==> Disable http with php if it isn't needed with others servers, 
==> comment or remove that lines in /etc/httpd/conf/httpd.conf:
==> "LoadModule php5_module modules/libphp5.so"
==> "Include /etc/httpd/conf/extra/php5_module.conf"

==> Remove line in /etc/httpd/conf/httpd.conf:
==> "Include /etc/httpd/conf/extra/httpd-zoneminder.conf"

==> Disable php with mysql if it isn't needed with others servers, 
==> comment that lines in /etc/php/php.ini:
==> "extension=mysql.so"
==> "extension=gd.so"
==> "extension=gettext.so"
==> "extension=mcrypt.so"
==> "extension=mysqli.so"
==> "extension=sockets.so"
==> "date.timezone = <my_country>/<my_city>"

==> Remove log files and "zoneminder" directory in "/var/log/zoneminder".

==> Backup and remove "events", "images" and "temp" dirs in "/var/cache/zoneminder".
EOF
}

BUILD

Changelog

Removed –enable-crashtrace=no because “WARNING: unrecognized options: –enable-crashtrace”

2014-09-28 ZM_RUNDIR Location of transient process files, default: /var/run/zm

Config Table #1

Arch LinuxDebian Sid
–prefix/usr/usr
–enable-crashtracenono
–enable-debugno
–enable-mmapyesyes
–sysconfdir/etc/etc/zm
–with-cgidir/srv/http/cgi-bin/usr/lib/cgi-bin
–with-extralibs‘-L/usr/lib -L/usr/lib/mysql’
–with-libarchlib
–with-ffmpeg/usr
–with-mysql/usr/usr
–with-webdir/srv/http/$pkgname/usr/share/zoneminder
–with-webgrouphttpwww-data
–with-webhostlocalhost
–with-webuserhttpwww-data
–host$(DEB_HOST_GNU_TYPE)
–build$(DEB_BUILD_GNU_TYPE)
–mandir\$${prefix}/share/man
–infodir\$${prefix}/share/info
–ffmpeg/usr

Config Table #2

./configureArch Linux ./configureCMAKECMAKE DefaultDebian Sid
–prefix/usrYCMAKE_INSTALL_PREFIX/usr
–enable-crashtracenoYno
–enable-debugnoN
–enable-mmapyesYZM_NO_MMAPdefault: OFFyes
–sysconfdir/etcN/etc/zm
–with-cgidir/srv/http/cgi-binYZM_CGIDIR<prefix>/libexec/zoneminder/cgi-bin/usr/lib/cgi-bin
–with-extralibs‘-L/usr/lib -L/usr/lib/mysql’NCMAKE_LIBRARY_PATH
–with-libarchlibN
–with-ffmpeg/usrN
–with-mysql/usrN/usr
–with-webdir/srv/http/zoneminderYZM_WEBDIR/usr/share/zoneminder/www/usr/share/zoneminder
–with-webgrouphttpN
–with-webuserhttpYZM_WEB_USERwww-data
–host$(DEB_HOST_GNU_TYPE)
–build$(DEB_BUILD_GNU_TYPE)
–mandir\$${prefix}/share/man
–infodir\$${prefix}/share/info
–ffmpeg/usr
ZM_RUNDIR /var/run/zm
ZM_TMPDIR /tmp/zm
ZM_LOGDIR /var/log/zm
ZM_WEBDIR<prefix>/share/zoneminder/www
/var/cache/zoneminderXZM_CONTENTDIR (events and images)/var/lib/zoneminder
ZM_DB_HOST localhost
ZM_DB_NAME zm
ZM_DB_USER zmuser
ZM_DB_PASS zmpass
ZM_WEB_GROUP

BUILD chunk

build() {
    cd $srcdir/ZoneMinder-$pkgver

    <<CMAKE_CHUNK>>
}

BUILD-GIT chunk

build() {
    cd $srcdir/$_pkgname

    <<CMAKE_CHUNK>>
}

CMAKE_CHUNK

# 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=/srv/http/zoneminder \
      -DZM_CGIDIR=/srv/http/cgi-bin \
      -DZM_WEB_USER=http \
      -DZM_CONTENTDIR=/var/cache/zoneminder \
      -DZM_LOGDIR=/var/log/zoneminder \
      -DZM_RUNDIR=/srv/zoneminder \
      -DZM_TMPDIR=/srv/zoneminder/tmp \
      -DZM_SOCKDIR=/srv/zoneminder/socks .

make V=0

PACKAGE

PACKAGE-GIT chunk

package() {

    cd $srcdir/$_pkgname

    DESTDIR=$pkgdir make install

    <<POLKIT_PERMISSIONS_CHUNK>>

    <<CREATE_ZONEMINDER_DIRECTORIES>>

    <<CREATE_AND_LINK_CONTENT_FOLDERS>>

    <<CREATE_CGI_BIN_LINK>>

    <<CHANGE_OWNER_AND_GROUP>>

    <<LINK_CAMBOZOLA>>

    <<INSTALL_CONF_FILES>>

}

PACKAGE chunk

package() {

    cd $srcdir/ZoneMinder-$pkgver

    DESTDIR=$pkgdir make install

    <<POLKIT_PERMISSIONS_CHUNK>>

    <<CREATE_ZONEMINDER_DIRECTORIES>>

    <<CREATE_AND_LINK_CONTENT_FOLDERS>>

    <<CREATE_CGI_BIN_LINK>>

    <<CHANGE_OWNER_AND_GROUP>>

    <<LINK_CAMBOZOLA>>

    <<INSTALL_CONF_FILES>>

}

CREATE_ZONEMINDER_DIRECTORIES chunk

# BEGIN CREATE_ZONEMINDER_DIRECTORIES
mkdir -pv           $pkgdir/var/{cache/zoneminder,log/zoneminder}
chown -Rv http.http $pkgdir/var/{cache/zoneminder,log/zoneminder}

mkdir -pv          $pkgdir/srv/zoneminder/socks
chown -v http.http $pkgdir/srv/zoneminder/socks

mkdir -pv          $pkgdir/srv/zoneminder/tmp
chown -v http.http $pkgdir/srv/zoneminder/tmp

chown -v  http.http $pkgdir/etc/zm.conf 
chmod 0700          $pkgdir/etc/zm.conf
# END CREATE_ZONEMINDER_DIRECTORIES
/srv
/srv/http
/srv/http/cgi-bin
/etc
/etc/rc.d
/etc/httpd
/etc/httpd/conf
/etc/httpd/conf/extra
/usr
/usr/share
/usr/share/db
/usr/share/license
/usr/lib
/usr/lib/systemd
/usr/lib/systemd/system
/var
/var/cache
/var/log
Change Log
mkdir (2014-09-19)

removed

mkdir -p $pkgdir/{etc/{httpd/conf/extra,rc.d},srv/http/{cgi-bin,$pkgname},usr/{lib/systemd/system,share/{license/$pkgname,$pkgname/db}},var/{cache/$pkgname,log/$pkgname}}

and replaced with

mkdir -p $pkgdir/var/{cache/$pkgname,log/$pkgname}

CREATE_AND_LINK_CONTENT_CONTENT_FOLDERS chunk

# Make content directories in /var/cache/zoneminder and to link them in /srv/http/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/srv/http/$_pkgname/$i
    chown -v --no-dereference http.http               $pkgdir/srv/http/$_pkgname/$i
done

CREATE_CGI_BIN_LINK

# Create a link to the Zoneminder cgi binaries
ln -sv /srv/http/cgi-bin $pkgdir/srv/http/$_pkgname

CHANGE_OWNER_AND_GROUP chunk

chown -h http.http $pkgdir/srv/http/{cgi-bin,$_pkgname,$_pkgname/cgi-bin}

LINK_CAMBOZOLA chunk

# Link Cambozola
# ln -s /usr/share/cambozola/cambozola.jar $pkgdir/srv/http/$_pkgname

INSTALL_CONF_FILES chunk

# Install configuration files
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     

POLKIT_PERMISSIONS_CHUNK

# 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/

ERROR TABLE

ERRORFIX
09191105mv: cannot stat ‘/home/troy/rcs/zoneminder-aur/FRI/pkg/zoneminder/srv/http/zoneminder/events’: No such file or directory# mv $pkgdir/srv/http/$pkgname/$i $pkgdir/var/cache/$pkgname/$i

Development Log

09191113test and document mkdir -p $pkgdir/{etc/{httpd/conf/extra,rc.d},srv/http/{cgi-bin,$pkgname},usr/{lib/systemd/system,share/{license/$pkgname,$pkgname/db}},var/{cache/$pkgname,log/$pkgname}}

Test and Document

SED Transformations

HTTPD.CONF.SED

<<MOD_MPM_PREFORK.SED>>

<<MOD_CGI.SED>>

<<LIBPHP5.SED>>

<<HTTPD-ZONEMINDER.CONF.SED>>    

MOD_MPM_PREFORK.SED

# Use mod_mpm_prefork instead of mod_mpm_event.so (FS#39218).
s|^LoadModule mpm_event_module modules/mod_mpm_event.so$|#&\nLoadModule mpm_prefork_module modules/mod_mpm_prefork.so|;

MOD_CGI.SED

# Zoneminder requires cgi
\|^#LoadModule cgi_module modules/mod_cgi.so$| s|#||;

LIBPHP5.SED

# libphp5
\|^LoadModule php5_module modules/libphp5.so$|d;
s|^#*LoadModule rewrite_module modules/mod_rewrite.so$|&\nLoadModule php5_module modules/libphp5.so|;
\|^Include /etc/httpd/conf/extra/php5_module.conf|d;
s|^Include conf/extra/httpd-default.conf$|&\nInclude /etc/httpd/conf/extra/php5_module.conf|;

HTTPD-ZONEMINDER.CONF.SED

# Include httpd-zoneminder.conf
\|^Include /etc/httpd/conf/extra/httpd-zoneminder.conf$|d;
s|^# Server-pool management (MPM specific)$|\nInclude /etc/httpd/conf/extra/httpd-zoneminder.conf\n&|;

PHP.INI.SED

# Enable these libraries by removing the leading comment character
\|^;extension=ftp.so$|       s|^;||;
\|^;extension=gd.so$|        s|^;||;
\|^;extension=gettext.so$|   s|^;||;
\|^;extension=mcrypt.so$|    s|^;||;
\|^;extension=openssl.so$|   s|^;||;
\|^;extension=pdo_mysql.so$| s|^;||;
\|^;extension=sockets.so$|   s|^;||;
\|^;extension=zip.so$|       s|^;||;
# Enable these libraries by removing the leading comment character
\|^;extension=pdo_mysql.so$| s|^;||;
\|^;extension=gd.so$|        s|^;||;
\|^;extension=gettext.so$|   s|^;||;
\|^;extension=mcrypt.so$|    s|^;||;
\|^;extension=sockets.so$|   s|^;||;
\|^;extension=openssl.so$|   s|^;||;
\|^;extension=ftp.so$|       s|^;||;
\|^;extension=zip.so$|       s|^;||;

perl-astro-suntime-zoneminder

Changelog

Thursday, January 22, 2015

  1. Removed open_basedir sed transformation
    # Add zoneminder paths to open_basedir
    s|^open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/$|&:/etc:/srv/http/zoneminder/:/var/cache/zoneminder/:/srv/zoneminder/socks:/var/log/zoneminder|;
        

Wednesday, January 14, 2015

-DZM_PERL_SUBPREFIX=/lib/perl5 with help of Charles Spence IV to force Perl modules

I noticed that while installing the package with pacman, a couple warnings appear:

warning: directory permissions differ on usr/share/polkit-1/rules.d filesystem: 700 package: 755 warning: directory ownership differs on usr/share/polkit-1/rules.d filesystem: 102:0 package: 0:0

These warnings can be fixed by including these three lines on the end of the package() section:

chmod 700 $pkgdir/usr/share/polkit-1/rules.d/ chown polkitd $pkgdir/usr/share/polkit-1/rules.d/