Merge pull request #217 from knnniggett/cmake_redhat

cmake support files for redhat/centos distros
This commit is contained in:
Kfir Itzhak 2013-10-19 13:03:16 -07:00
commit cdd2920767
4 changed files with 194 additions and 89 deletions

View File

@ -0,0 +1,57 @@
# CMakeLists.txt for the Redhat/CentOS Target Distro.
# Create the zoneminder service file
configure_file(zoneminder.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.service @ONLY)
# Download jscalendar & move files into position
file(DOWNLOAD http://softlayer-dal.dl.sourceforge.net/project/jscalendar/jscalendar/1.0/jscalendar-1.0.zip ${CMAKE_CURRENT_SOURCE_DIR}/jscalendar-1.0.zip LOG jsc_log STATUS download_jsc)
#message(STATUS "Log of jscalender script was: ${jsc_log}")
if(download_jsc EQUAL 0)
message(STATUS "Jscalander successfully downloaded. Installing...")
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/jscalendar.sh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ERROR_VARIABLE unzip_jsc)
message(STATUS "Status of jscalender script was: ${unzip_jsc}")
else(download_jsc EQUAL 0)
message(STATUS "Unable to download optional jscalander. Skipping...")
endif(download_jsc EQUAL 0)
# Download cambozola & move files into position
file(DOWNLOAD http://www.andywilcock.com/code/cambozola/cambozola-0.931.tar.gz ${CMAKE_CURRENT_SOURCE_DIR}/cambozola-0.931.tar.gz STATUS download_camb)
if(download_camb EQUAL 0)
message(STATUS "Cambozola successfully downloaded. Installing...")
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/cambozola.sh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ERROR_VARIABLE untar_camb)
message(STATUS "Status of cambozola script was: ${untar_camb}")
else(download_camb EQUAL 0)
message(STATUS "Unable to download optional Cambozola. Skipping...")
endif(download_camb EQUAL 0)
# Create several empty folders
file(MAKE_DIRECTORY sock swap zoneminder zoneminder-upload events images temp)
# Install the empty folders
#install(DIRECTORY run DESTINATION /var DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_WRITE GROUP_READ GROUP_EXECUTE WORLD_WRITE WORLD_READ WORLD_EXECUTE)
install(DIRECTORY sock swap DESTINATION /var/lib/zoneminder DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(DIRECTORY zoneminder DESTINATION /var/log DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(DIRECTORY zoneminder DESTINATION /run DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(DIRECTORY zoneminder-upload DESTINATION /var/spool DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(DIRECTORY events images temp DESTINATION /var/lib/zoneminder DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
# Create symlinks
install(CODE "execute_process(COMMAND ln -sf ../../../../var/lib/zoneminder/events \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/events\")")
install(CODE "execute_process(COMMAND ln -sf ../../../../var/lib/zoneminder/images \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/images\")")
install(CODE "execute_process(COMMAND ln -sf ../../../../var/lib/zoneminder/temp \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/temp\")")
# Install auxillary files required to run zoneminder on CentOS
install(FILES zoneminder.conf DESTINATION /etc/httpd/conf.d PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
install(FILES zm-logrotate_d DESTINATION /etc/logrotate.d RENAME zoneminder PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
install(FILES redalert.wav DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/sounds PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES zoneminder.service DESTINATION /etc/rc.d/init.d RENAME zoneminder PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
# Install jscalendar
if(unzip_jsc STREQUAL "")
install(DIRECTORY jscalendar-1.0/ DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/tools/jscalendar)
endif(unzip_jsc STREQUAL "")
# Install cambozola
if(untar_camb STREQUAL "")
install(FILES cambozola-0.931/dist/cambozola.jar DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www)
endif(untar_camb STREQUAL "")

7
distros/redhat/cambozola.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
tar -xvzf cambozola-0.931.tar.gz
mkdir -v cambozola-doc
cd cambozola-0.931
mv -v application.properties build.xml dist.sh *html LICENSE testPages/* ../cambozola-doc
rmdir -v testPages

View File

@ -1,7 +1,3 @@
%define cambrev 0.931
%define moorev 1.3.2
%define jscrev 1.0
%define zmuid $(id -un)
%define zmgid $(id -gn)
%define zmuid_final apache
@ -20,23 +16,10 @@ URL: http://www.zoneminder.com/
#Source0: https://github.com/ZoneMinder/ZoneMinder/archive/v%{version}.tar.gz
Source0: ZoneMinder-%{version}.tar.gz
Source1: jscalendar-%{jscrev}.zip
#Source1: http://downloads.sourceforge.net/jscalendar/jscalendar-%{jscrev}.zip
# Mootools is currently bundled in the zoneminder tarball
#Source2: mootools-core-%{moorev}-full-compat-yc.js
#Source2: http://mootools.net/download/get/mootools-core-%{moorev}-full-compat-yc.js
Patch1: zoneminder-1.26.0-defaults.patch
Source3: cambozola-%{cambrev}.tar.gz
#Source3: http://www.andywilcock.com/code/cambozola/cambozola-%{cambrev}.tar.gz
Patch1: zoneminder-runlevel.patch
Patch2: zoneminder-1.26.0-defaults.patch
# BuildRoot is depreciated and ignored
#BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: automake gnutls-devel bzip2-devel libtool
BuildRequires: cmake gnutls-devel bzip2-devel
BuildRequires: mysql-devel pcre-devel libjpeg-turbo-devel
BuildRequires: perl(Archive::Tar) perl(Archive::Zip)
BuildRequires: perl(Date::Manip) perl(DBD::mysql)
@ -78,86 +61,19 @@ too much degradation of performance.
%prep
%setup -q -n ZoneMinder-%{version}
# Unpack jscalendar and move some files around
%setup -q -D -T -a 1 -n ZoneMinder-%{version}
mkdir jscalendar-doc
pushd jscalendar-%{jscrev}
mv *html *php doc/* README ../jscalendar-doc
rmdir doc
popd
# Unpack Cambozola and move some files around
%setup -q -D -T -a 3 -n ZoneMinder-%{version}
mkdir cambozola-doc
pushd cambozola-%{cambrev}
mv application.properties build.xml dist.sh *html LICENSE testPages/* ../cambozola-doc
rmdir testPages
popd
%patch1 -p0 -b .runlevel
%patch2 -p0
%patch1 -p0 -b .defaults
%build
# Have to override CMAKE_INSTALL_LIBDIR for cmake < 2.8.7 due to this bug:
# https://bugzilla.redhat.com/show_bug.cgi?id=795542
%cmake -DCMAKE_INSTALL_LIBDIR:PATH=%{_lib} .
%cmake -DZM_TARGET_DISTRO="el6" -DCMAKE_INSTALL_LIBDIR:PATH=%{_lib} -DZM_PERL_SUBPREFIX="%{perl_vendorlib}" .
make %{?_smp_mflags}
# cmake does this for us
#%{__perl} -pi -e 's/(ZM_WEB_USER=).*$/${1}%{zmuid_final}/;'
# -e 's/(ZM_WEB_GROUP=).*$/${1}%{zmgid_final}/;' zm.conf
%install
install -d %{buildroot}/%{_localstatedir}/run
install -d %{buildroot}/etc/logrotate.d
export DESTDIR=%{buildroot}
#export INSTALLDIRS=vendor
make install
# Move perl files into rhel compliant locations
mkdir -p %{buildroot}/%{perl_vendorlib}
mv %{buildroot}%{perl_archlib}/ZoneMinder* %{buildroot}/%{perl_vendorlib}
rm -rf %{buildroot}%{_libdir}
# Remove misc folder
rm -rf %{buildroot}/%{_datadir}/%{name}/misc
install -m 755 -d %{buildroot}/%{_localstatedir}/log/zoneminder
for dir in events images temp
do
install -m 755 -d %{buildroot}/%{_localstatedir}/lib/zoneminder/$dir
if [ -d %{buildroot}/%{_datadir}/zoneminder/www/$dir ]; then
rmdir %{buildroot}/%{_datadir}/%{name}/www/$dir
fi
ln -sf ../../../..%{_localstatedir}/lib/zoneminder/$dir %{buildroot}/%{_datadir}/%{name}/www/$dir
done
install -m 755 -d %{buildroot}/%{_localstatedir}/lib/zoneminder/sock
install -m 755 -d %{buildroot}/%{_localstatedir}/lib/zoneminder/swap
install -m 755 -d %{buildroot}/%{_localstatedir}/spool/zoneminder-upload
install -D -m 755 scripts/zm %{buildroot}/%{_initrddir}/zoneminder
install -D -m 644 distros/redhat/zoneminder.conf %{buildroot}/%{_sysconfdir}/httpd/conf.d/zoneminder.conf
install -D -m 755 distros/redhat/redalert.wav %{buildroot}/%{_datadir}/%{name}/www/sounds/redalert.wav
install distros/redhat/zm-logrotate_d $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/%{name}
# Install jscalendar
install -d -m 755 %{buildroot}/%{_datadir}/%{name}/www/jscalendar
cp -rp jscalendar-%{jscrev}/* %{buildroot}/%{_datadir}/%{name}/www/jscalendar
# Install Cambozola
cp -rp cambozola-%{cambrev}/dist/cambozola.jar %{buildroot}/%{_datadir}/%{name}/www/
rm -rf cambozola-%{cambrev}
# Install mootools
pushd %{buildroot}/%{_datadir}/%{name}/www
#install -m 644 %{Source2} mootools-core-%{moorev}-full-compat-yc.js
#ln -s mootools-core-%{moorev}-full-compat-yc.js mootools.js
ln -f -s tools/mootools/mootools-core-%{moorev}-yc.js mootools-core.js
ln -f -s tools/mootools/mootools-more-%{moorev}.1-yc.js mootools-more.js
popd
%post
/sbin/chkconfig --add zoneminder
/sbin/chkconfig zoneminder on
@ -194,7 +110,8 @@ rm -rf %{_docdir}/%{name}-%{version}
%files
%defattr(-,root,root,-)
%doc AUTHORS BUGS ChangeLog COPYING LICENSE NEWS README.md distros/redhat/README.CentOS jscalendar-doc cambozola-doc distros/redhat/local_zoneminder.te
%doc AUTHORS BUGS ChangeLog COPYING LICENSE NEWS README.md distros/redhat/README.CentOS distros/redhat/jscalendar-doc
%doc distros/redhat/cambozola-doc distros/redhat/local_zoneminder.te
%config(noreplace) %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm.conf
%config(noreplace) %attr(644,root,root) %{_sysconfdir}/httpd/conf.d/zoneminder.conf
%config(noreplace) /etc/logrotate.d/%{name}
@ -219,6 +136,7 @@ rm -rf %{_docdir}/%{name}-%{version}
%{_bindir}/zmx10.pl
%{perl_vendorlib}/ZoneMinder*
%{perl_vendorlib}/x86_64-linux-thread-multi/auto/ZoneMinder*
%{_mandir}/man*/*
%dir %{_libexecdir}/%{name}
%{_libexecdir}/%{name}/cgi-bin
@ -237,6 +155,9 @@ rm -rf %{_docdir}/%{name}-%{version}
%changelog
* Sat Oct 19 2013 Andrew Bauer <knnniggett@users.sourceforge.net> - 1.26.4
- Streamline the cmake build. Move much code into cmakelist.txt file.
* Mon Oct 07 2013 Andrew Bauer <knnniggett@users.sourceforge.net> - 1.26.4
- Initial cmake build.

120
distros/redhat/zoneminder.in Executable file
View File

@ -0,0 +1,120 @@
#!/bin/sh
# description: ZoneMinder is the top Linux video camera security and surveillance solution. ZoneMinder is intended for use in single or multi-camera video security applications.Copyright: Philip Coombes, Corey DeLasaux 2003-2008
# chkconfig: - 99 00
# processname: zmpkg.pl
# Source function library.
. /etc/rc.d/init.d/functions
prog=ZoneMinder
ZM_CONFIG="@ZM_CONFIG@"
pidfile="@ZM_RUNDIR@"
LOCKFILE=/var/lock/subsys/zm
loadconf()
{
if [ -f $ZM_CONFIG ]; then
. $ZM_CONFIG
else
echo "ERROR: $ZM_CONFIG not found."
return 1
fi
}
loadconf
command="$ZM_PATH_BIN/zmpkg.pl"
start()
{
zmupdate || return $?
loadconf || return $?
#Make sure the directory for our PID folder exists or create one.
[ ! -d $pidfile ] \
&& mkdir -m 774 $pidfile \
&& chown $ZM_WEB_USER:$ZM_WEB_GROUP $pidfile
#Make sure the folder for the socks file exists or create one
GetPath="select Value from Config where Name='ZM_PATH_SOCKS'"
dbHost=`echo $ZM_DB_HOST | cut -d: -f1`
dbPort=`echo $ZM_DB_HOST | cut -d: -s -f2`
if [ "$dbPort" = "" ]
then
ZM_PATH_SOCK=`echo $GetPath | mysql -B -h$ZM_DB_HOST -u$ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'`
else
ZM_PATH_SOCK=`echo $GetPath | mysql -B -h$dbHost -P$dbPort -u$ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'`
fi
[ ! -d $ZM_PATH_SOCK ] \
&& mkdir -m 774 $ZM_PATH_SOCK \
&& chown $ZM_WEB_USER:$ZM_WEB_GROUP $ZM_PATH_SOCK
echo -n $"Starting $prog: "
$command start
RETVAL=$?
[ $RETVAL = 0 ] && success || failure
echo
[ $RETVAL = 0 ] && touch $LOCKFILE
return $RETVAL
}
stop()
{
loadconf
echo -n $"Stopping $prog: "
$command stop
RETVAL=$?
[ $RETVAL = 0 ] && success || failure
echo
[ $RETVAL = 0 ] && rm -f $LOCKFILE
}
zmstatus()
{
loadconf
result=`$command status`
if [ "$result" = "running" ]; then
echo "ZoneMinder is running"
$ZM_PATH_BIN/zmu -l
RETVAL=0
else
echo "ZoneMinder is stopped"
RETVAL=1
fi
}
zmupdate()
{
if [ -x $ZM_PATH_BIN/zmupdate.pl ]; then
$ZM_PATH_BIN/zmupdate.pl -f
fi
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'restart')
stop
start
;;
'condrestart')
loadconf
result=`$ZM_PATH_BIN/zmdc.pl check`
if [ "$result" = "running" ]; then
$ZM_PATH_BIN/zmdc.pl shutdown > /dev/null
rm -f $LOCKFILE
start
fi
;;
'status')
status httpd
status mysqld
zmstatus
;;
*)
echo "Usage: $0 { start | stop | restart | condrestart | status }"
RETVAL=1
;;
esac
exit $RETVAL