From 3bc1543f9e1f3f2352a5663fcec496d11b7692a1 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Thu, 26 Dec 2019 19:36:33 -0600 Subject: [PATCH 01/11] build rpms on every commit --- utils/packpack/startpackpack.sh | 50 +++++++++++++++------------------ 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/utils/packpack/startpackpack.sh b/utils/packpack/startpackpack.sh index 4721e6480..e6b68f66d 100755 --- a/utils/packpack/startpackpack.sh +++ b/utils/packpack/startpackpack.sh @@ -293,43 +293,37 @@ if [ "${TRAVIS}" == "true" ]; then fi checksanity -# We don't want to build packages for all supported distros after every commit -# Only build all packages when executed via cron -# See https://docs.travis-ci.com/user/cron-jobs/ - # Steps common to Redhat distros if [ "${OS}" == "el" ] || [ "${OS}" == "fedora" ]; then - if [ "${TRAVIS_EVENT_TYPE}" == "cron" ] || [ "${TRAVIS}" != "true" ]; then - commonprep - echo "Begin Redhat build..." + commonprep + echo "Begin Redhat build..." - setrpmpkgname + setrpmpkgname - ln -sfT distros/redhat rpm + ln -sfT distros/redhat rpm - # The rpm specfile requires the Crud submodule folder to be empty - rm -rf web/api/app/Plugin/Crud - mkdir web/api/app/Plugin/Crud + # The rpm specfile requires the Crud submodule folder to be empty + rm -rf web/api/app/Plugin/Crud + mkdir web/api/app/Plugin/Crud - reporpm="rpmfusion-free-release" - dlurl="https://download1.rpmfusion.org/free/${OS}/${reporpm}-${DIST}.noarch.rpm" + reporpm="rpmfusion-free-release" + dlurl="https://download1.rpmfusion.org/free/${OS}/${reporpm}-${DIST}.noarch.rpm" - # Give our downloaded repo rpm a common name so redhat_package.mk can find it - if [ -n "$dlurl" ] && [ $? -eq 0 ]; then - echo "Retrieving ${reporpm} repo rpm..." - curl $dlurl > build/external-repo.noarch.rpm - else - echo "ERROR: Failed to retrieve ${reporpm} repo rpm..." - echo "Download url was: $dlurl" - exit 1 - fi - - setrpmchangelog - - echo "Starting packpack..." - execpackpack + # Give our downloaded repo rpm a common name so redhat_package.mk can find it + if [ -n "$dlurl" ] && [ $? -eq 0 ]; then + echo "Retrieving ${reporpm} repo rpm..." + curl $dlurl > build/external-repo.noarch.rpm + else + echo "ERROR: Failed to retrieve ${reporpm} repo rpm..." + echo "Download url was: $dlurl" + exit 1 fi + setrpmchangelog + + echo "Starting packpack..." + execpackpack + # Steps common to Debian based distros elif [ "${OS}" == "debian" ] || [ "${OS}" == "ubuntu" ] || [ "${OS}" == "raspbian" ]; then commonprep From 28a6e7199223d72af06952c7e695c4144ac13d2e Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Fri, 27 Dec 2019 09:04:02 -0600 Subject: [PATCH 02/11] deploy raspbian builds to debian target folder --- utils/packpack/rsync_xfer.sh | 53 ++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/utils/packpack/rsync_xfer.sh b/utils/packpack/rsync_xfer.sh index a912079e0..9d9a16056 100755 --- a/utils/packpack/rsync_xfer.sh +++ b/utils/packpack/rsync_xfer.sh @@ -2,7 +2,7 @@ # We don't deploy during eslint checks, so exit immediately if [ "${DIST}" == "eslint" ]; then - exit 0 + exit 0 fi # Check to see if this script has access to all the commands it needs @@ -17,33 +17,26 @@ for CMD in sshfs rsync find fusermount mkdir; do fi done -# See https://docs.travis-ci.com/user/cron-jobs/ -# -# TO-DO: Deploy after ever commit for rpm builds after pacakge signing & repo creation is containerized -# -if [ "${TRAVIS_EVENT_TYPE}" == "cron" ] || [ "${OS}" == "debian" ] || [ "${OS}" == "ubuntu" ]; then - - if [ "${OS}" == "debian" ] || [ "${OS}" == "ubuntu" ]; then - targetfolder="debian/master/mini-dinstall/incoming" - else - targetfolder="travis" - fi - - echo - echo "Target subfolder set to $targetfolder" - echo - - echo "Running \$(rsync -v -e 'ssh -vvv' build/*.{rpm,deb,dsc,tar.xz,changes} zmrepo@zmrepo.zoneminder.com:${targetfolder}/ 2>&1)" - rsync -v --ignore-missing-args -e 'ssh -vvv' build/*.{rpm,deb,dsc,tar.xz,changes} zmrepo@zmrepo.zoneminder.com:${targetfolder}/ 2>&1 - if [ "$?" -eq 0 ]; then - echo - echo "Files copied successfully." - echo - else - echo - echo "ERROR: Attempt to rsync to zmrepo.zoneminder.com failed!" - echo "See log output for details." - echo - exit 99 - fi +if [ "${OS}" == "debian" ] || [ "${OS}" == "ubuntu" ] || [ "${OS}" == "raspbian" ]; then + targetfolder="debian/master/mini-dinstall/incoming" +else + targetfolder="travis" +fi + +echo +echo "Target subfolder set to $targetfolder" +echo + +echo "Running \$(rsync -v -e 'ssh -vvv' build/*.{rpm,deb,dsc,tar.xz,changes} zmrepo@zmrepo.zoneminder.com:${targetfolder}/ 2>&1)" +rsync -v --ignore-missing-args -e 'ssh -vvv' build/*.{rpm,deb,dsc,tar.xz,changes} zmrepo@zmrepo.zoneminder.com:${targetfolder}/ 2>&1 +if [ "$?" -eq 0 ]; then + echo + echo "Files copied successfully." + echo +else + echo + echo "ERROR: Attempt to rsync to zmrepo.zoneminder.com failed!" + echo "See log output for details." + echo + exit 99 fi From 77f026a3895c15f4deed75849acc063bdf754faf Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Fri, 27 Dec 2019 09:12:49 -0600 Subject: [PATCH 03/11] exclude external-repo.noarch.rpm during deployments --- utils/packpack/rsync_xfer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/packpack/rsync_xfer.sh b/utils/packpack/rsync_xfer.sh index 9d9a16056..c4b6f93e1 100755 --- a/utils/packpack/rsync_xfer.sh +++ b/utils/packpack/rsync_xfer.sh @@ -28,7 +28,7 @@ echo "Target subfolder set to $targetfolder" echo echo "Running \$(rsync -v -e 'ssh -vvv' build/*.{rpm,deb,dsc,tar.xz,changes} zmrepo@zmrepo.zoneminder.com:${targetfolder}/ 2>&1)" -rsync -v --ignore-missing-args -e 'ssh -vvv' build/*.{rpm,deb,dsc,tar.xz,changes} zmrepo@zmrepo.zoneminder.com:${targetfolder}/ 2>&1 +rsync -v --ignore-missing-args --exclude 'external-repo.noarch.rpm' -e 'ssh -vvv' build/*.{rpm,deb,dsc,tar.xz,changes} zmrepo@zmrepo.zoneminder.com:${targetfolder}/ 2>&1 if [ "$?" -eq 0 ]; then echo echo "Files copied successfully." From 276428be59211b985206a2cd541943e3e2783618 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Fri, 27 Dec 2019 16:39:24 -0600 Subject: [PATCH 04/11] el8 needs php-json --- distros/redhat/zoneminder.spec | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/distros/redhat/zoneminder.spec b/distros/redhat/zoneminder.spec index ffaa075a3..6715f7b26 100644 --- a/distros/redhat/zoneminder.spec +++ b/distros/redhat/zoneminder.spec @@ -14,11 +14,16 @@ # This will tell zoneminder's cmake process we are building against a known distro %global zmtargetdistro %{?rhel:el%{rhel}}%{!?rhel:fc%{fedora}} -# Fedora >= 25 needs apcu backwards compatibility module -%if 0%{?fedora} >= 25 +# Fedora needs apcu backwards compatibility module +%if 0%{?fedora} %global with_apcu_bc 1 %endif +# Newer php's keep json functions in a subpackage +%if 0%{?fedora} || 0%{?rhel} >= 8 +%global with_php_json 1 +%endif + # The default for everything but el7 these days %global _hardened_build 1 @@ -105,7 +110,7 @@ Summary: Common files for ZoneMinder, not tied to a specific web server Requires: php-mysqli Requires: php-common Requires: php-gd -%{?fedora:Requires: php-json} +%{?with_php_json:Requires: php-json} Requires: php-pecl-apcu %{?with_apcu_bc:Requires: php-pecl-apcu-bc} Requires: cambozola From 0aa82a74ecb064f2826311002c56ccc9c534c4d1 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Fri, 27 Dec 2019 17:13:13 -0600 Subject: [PATCH 05/11] remove support for f29 builds --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f6c2dea02..59a62888d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,6 @@ install: env: - SMPFLAGS=-j4 OS=el DIST=7 - SMPFLAGS=-j4 OS=el DIST=8 DOCKER_REPO=knnniggett/packpack - - SMPFLAGS=-j4 OS=fedora DIST=29 - SMPFLAGS=-j4 OS=fedora DIST=30 - SMPFLAGS=-j4 OS=fedora DIST=31 - SMPFLAGS=-j4 OS=ubuntu DIST=trusty DOCKER_REPO=iconzm/packpack From 00cedc92d2ca07861f5f25d9370b91825b87d3e6 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sat, 28 Dec 2019 08:37:16 -0600 Subject: [PATCH 06/11] fix typo --- src/zm_ffmpeg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index 6b6036db5..c0a3d6bb0 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -81,7 +81,7 @@ void FFMPEGInit() { av_log_set_callback(log_libav_callback); Info("Enabling ffmpeg logs, as LOG_DEBUG+LOG_FFMPEG are enabled in options"); } else { - Info("Not enabling ffmpeg logs, as LOG_FFMPEG and/or LOG_DEBUG is disabled in options, or this monitor not part of your debug targets"); + Info("Not enabling ffmpeg logs, as LOG_FFMPEG and/or LOG_DEBUG is disabled in options, or this monitor is not part of your debug targets"); av_log_set_level(AV_LOG_QUIET); } #if !LIBAVFORMAT_VERSION_CHECK(58, 9, 0, 64, 0) From 2301103da5db7cb835cdac7b8b1e42fe16e97f22 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sat, 28 Dec 2019 09:49:42 -0600 Subject: [PATCH 07/11] use small, non-zero values, for image buffer & pre & post buffers --- web/includes/Monitor.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/includes/Monitor.php b/web/includes/Monitor.php index cc51926fd..ad0247a1b 100644 --- a/web/includes/Monitor.php +++ b/web/includes/Monitor.php @@ -59,10 +59,10 @@ class Monitor extends ZM_Object { 'LabelX' => 0, 'LabelY' => 0, 'LabelSize' => 1, - 'ImageBufferCount' => 100, + 'ImageBufferCount' => 20, 'WarmupCount' => 0, - 'PreEventCount' => 0, - 'PostEventCount' => 0, + 'PreEventCount' => 5, + 'PostEventCount' => 5, 'StreamReplayBuffer' => 0, 'AlarmFrameCount' => 1, 'SectionLength' => 600, From bbcd1846e7b42571690f57a3520a96e7e13eefda Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 29 Dec 2019 12:44:30 -0500 Subject: [PATCH 08/11] Fix hang caused by using %d instead of PRIu64 in formatting string --- src/zm_ffmpeg.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index c0a3d6bb0..f0b3dc76e 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -291,17 +291,18 @@ static void zm_log_fps(double d, const char *postfix) { #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) void zm_dump_codecpar ( const AVCodecParameters *par ) { - Debug(1, "Dumping codecpar codec_type(%d) codec_id(%d %s) codec_tag(%d) width(%d) height(%d) bit_rate(%d) format(%d = %s)", - par->codec_type, - par->codec_id, - avcodec_get_name(par->codec_id), - par->codec_tag, - par->width, - par->height, - par->bit_rate, - par->format, - ((AVPixelFormat)par->format == AV_PIX_FMT_NONE ? "none" : av_get_pix_fmt_name((AVPixelFormat)par->format)) -); + Debug(1, "Dumping codecpar codec_type(%d %s) codec_id(%d %s) codec_tag(%" PRIu32 ") width(%d) height(%d) bit_rate(%" PRIu64 ") format(%d %s)", + par->codec_type, + av_get_media_type_string(par->codec_type), + par->codec_id, + avcodec_get_name(par->codec_id), + par->codec_tag, + par->width, + par->height, + par->bit_rate, + par->format, + (((AVPixelFormat)par->format == AV_PIX_FMT_NONE) ? "none" : av_get_pix_fmt_name((AVPixelFormat)par->format)) + ); } #endif From 2581b8619524e3c3556a41720b334b985c016f19 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 29 Dec 2019 12:44:59 -0500 Subject: [PATCH 09/11] add more content to the error message when can't sws_scale. Also fix problem when using 32bit on arm instead of 24bit, apparently 0 is a valid return result from sws_scale. Also change the alignment in av_image_fill_arrays. At some point we cahnged it to 32bit aligned, but in 1.32 we didn't align at all. Not sure if it matters . --- src/zm_ffmpeg_camera.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index ef4dfc057..cdb8a40b7 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -1089,7 +1089,7 @@ int FfmpegCamera::transfer_to_image( #if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0) int size = av_image_fill_arrays( output_frame->data, output_frame->linesize, - directbuffer, imagePixFormat, width, height, 32); + directbuffer, imagePixFormat, width, height, 1); if ( size < 0 ) { Error("Problem setting up data pointers into image %s", av_make_error_string(size).c_str()); @@ -1128,8 +1128,8 @@ int FfmpegCamera::transfer_to_image( mConvertContext, input_frame->data, input_frame->linesize, 0, mVideoCodecContext->height, output_frame->data, output_frame->linesize); - if ( ret <= 0 ) { - Error("Unable to convert format %u %s linesize %d height %d to format %u %s linesize %d at frame %d codec %u %s : code: %d", + if ( ret < 0 ) { + Error("Unable to convert format %u %s linesize %d height %d to format %u %s linesize %d at frame %d codec %u %s lines %d: code: %d", input_frame->format, av_get_pix_fmt_name((AVPixelFormat)input_frame->format), input_frame->linesize, mVideoCodecContext->height, imagePixFormat, @@ -1137,6 +1137,7 @@ int FfmpegCamera::transfer_to_image( output_frame->linesize, frameCount, mVideoCodecContext->pix_fmt, av_get_pix_fmt_name(mVideoCodecContext->pix_fmt), + mVideoCodecContext->height, ret ); return -1; From b5e3dbd415fa8c59eec9bc8e2261ef4dde2754fb Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 29 Dec 2019 12:52:34 -0500 Subject: [PATCH 10/11] put back 32bit alignment with a comment as to why --- src/zm_ffmpeg_camera.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index cdb8a40b7..6578b0b2d 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -1087,9 +1087,10 @@ int FfmpegCamera::transfer_to_image( return -1; } #if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0) + // From what I've read, we should align the linesizes to 32bit so that ffmpeg can use SIMD instructions too. int size = av_image_fill_arrays( output_frame->data, output_frame->linesize, - directbuffer, imagePixFormat, width, height, 1); + directbuffer, imagePixFormat, width, height, 32); if ( size < 0 ) { Error("Problem setting up data pointers into image %s", av_make_error_string(size).c_str()); From ce7b62c825a949c4d9446f32737fac51332870f8 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 29 Dec 2019 14:13:49 -0600 Subject: [PATCH 11/11] Fixed unquoted variable which was failing to correctly detect error case This was discovered when there was a DNS failure (it's always DNS) and it caused a syntax error on line 178. I changed it to use -z to check for a zero length string, as suggested by the man page. Putting $VERSION in double quotes would also be a valid fix. Here's what the script looks like when it fails: ./do_debian_package.sh --snapshot=stable --type=local --interactive=no Doing local build Defaulting to bionic for distribution Defaulting to ZoneMinder upstream git fatal: not a git repository (or any of the parent directories): .git fatal: not a git repository (or any of the parent directories): .git Latest stable branch is git clone https://github.com/ZoneMinder/ZoneMinder.git ZoneMinder_zoneminder_release Cloning into 'ZoneMinder_zoneminder_release'... fatal: unable to access 'https://github.com/ZoneMinder/ZoneMinder.git/': Could not resolve host: github.com ./do_debian_package.sh: line 172: cd: ZoneMinder_zoneminder_release: No such file or directory fatal: not a git repository (or any of the parent directories): .git cat: ZoneMinder_zoneminder_release/version: No such file or directory ./do_debian_package.sh: line 178: [: ==: unary operator expected Doing local release zoneminder_ mv: cannot stat 'ZoneMinder_zoneminder_release': No such file or directory Error status code is: 0 Setting up build dir failed. --- utils/do_debian_package.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/do_debian_package.sh b/utils/do_debian_package.sh index 3e20b303a..b60996a78 100755 --- a/utils/do_debian_package.sh +++ b/utils/do_debian_package.sh @@ -175,7 +175,7 @@ cd ../ VERSION=`cat ${GITHUB_FORK}_zoneminder_release/version` -if [ $VERSION == "" ]; then +if [ -z "$VERSION" ]; then exit 1; fi; if [ "$SNAPSHOT" != "stable" ] && [ "$SNAPSHOT" != "" ]; then