From 2685e457d331c9644ca94eb53d471956fc8173eb Mon Sep 17 00:00:00 2001 From: Daniel Fullmer Date: Fri, 7 Feb 2020 19:06:22 -0500 Subject: [PATCH 1/4] zoneminder: 1.32.3 -> 1.34.3 --- pkgs/servers/zoneminder/default.nix | 13 ++++++++----- pkgs/servers/zoneminder/link-with-libdl.patch | 17 ----------------- 2 files changed, 8 insertions(+), 22 deletions(-) delete mode 100644 pkgs/servers/zoneminder/link-with-libdl.patch diff --git a/pkgs/servers/zoneminder/default.nix b/pkgs/servers/zoneminder/default.nix index e536ea0373cf..5ffb803d3a0e 100644 --- a/pkgs/servers/zoneminder/default.nix +++ b/pkgs/servers/zoneminder/default.nix @@ -78,19 +78,17 @@ let in stdenv.mkDerivation rec { pname = "zoneminder"; - version = "1.32.3"; + version = "1.34.3"; src = fetchFromGitHub { owner = "ZoneMinder"; repo = "zoneminder"; rev = version; - sha256 = "1sx2fn99861zh0gp8g53ynr1q6yfmymxamn82y54jqj6nv475njz"; + sha256 = "0jp7950v36gxxzkwdp5i0312s26czhfsl5ixdxfzn21cx31hhlg0"; }; patches = [ ./default-to-http-1dot1.patch - # Explicitly link with dynamic linking library to fix build - ./link-with-libdl.patch ]; postPatch = '' @@ -125,6 +123,10 @@ in stdenv.mkDerivation rec { substituteInPlace scripts/zmdbbackup.in \ --replace /usr/bin/mysqldump ${mysql.client}/bin/mysqldump + substituteInPlace scripts/zmupdate.pl.in \ + --replace "'mysql'" "'${mysql.client}/bin/mysql'" \ + --replace "'mysqldump'" "'${mysql.client}/bin/mysqldump'" + for f in scripts/ZoneMinder/lib/ZoneMinder/Config.pm.in \ scripts/zmupdate.pl.in \ src/zm_config.h.in \ @@ -133,7 +135,7 @@ in stdenv.mkDerivation rec { substituteInPlace $f --replace @ZM_CONFIG_SUBDIR@ /etc/zoneminder done - for f in includes/Event.php views/image.php skins/classic/views/image-ffmpeg.php ; do + for f in includes/Event.php views/image.php ; do substituteInPlace web/$f \ --replace "'ffmpeg " "'${ffmpeg}/bin/ffmpeg " done @@ -147,6 +149,7 @@ in stdenv.mkDerivation rec { DateManip DBI DBDmysql LWP SysMmap # run-time dependencies not checked at build-time ClassStdFast DataDump DeviceSerialPort JSONMaybeXS LWPProtocolHttps NumberBytesHuman SysCPU SysMemInfo TimeDate + CryptEksblowfish DataEntropy # zmupdate.pl ]); nativeBuildInputs = [ cmake makeWrapper pkgconfig ]; diff --git a/pkgs/servers/zoneminder/link-with-libdl.patch b/pkgs/servers/zoneminder/link-with-libdl.patch deleted file mode 100644 index 53aaf9b25f7d..000000000000 --- a/pkgs/servers/zoneminder/link-with-libdl.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -20,10 +20,10 @@ add_executable(zms zms.cpp) - include_directories(libbcrypt/include/bcrypt) - include_directories(jwt-cpp/include/jwt-cpp) - --target_link_libraries(zmc zm ${ZM_EXTRA_LIBS} ${ZM_BIN_LIBS}) --target_link_libraries(zma zm ${ZM_EXTRA_LIBS} ${ZM_BIN_LIBS}) --target_link_libraries(zmu zm ${ZM_EXTRA_LIBS} ${ZM_BIN_LIBS}) --target_link_libraries(zms zm ${ZM_EXTRA_LIBS} ${ZM_BIN_LIBS}) -+target_link_libraries(zmc zm ${ZM_EXTRA_LIBS} ${ZM_BIN_LIBS} ${CMAKE_DL_LIBS}) -+target_link_libraries(zma zm ${ZM_EXTRA_LIBS} ${ZM_BIN_LIBS} ${CMAKE_DL_LIBS}) -+target_link_libraries(zmu zm ${ZM_EXTRA_LIBS} ${ZM_BIN_LIBS} ${CMAKE_DL_LIBS}) -+target_link_libraries(zms zm ${ZM_EXTRA_LIBS} ${ZM_BIN_LIBS} ${CMAKE_DL_LIBS}) - - # Generate man files for the binaries destined for the bin folder - FOREACH(CBINARY zma zmc zmu) From 630de551ef46ec03d94c6a9c82f67c3abb8fa743 Mon Sep 17 00:00:00 2001 From: Daniel Fullmer Date: Fri, 21 Feb 2020 20:43:56 -0500 Subject: [PATCH 2/4] zoneminder: fix timezone detection --- pkgs/servers/zoneminder/default.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkgs/servers/zoneminder/default.nix b/pkgs/servers/zoneminder/default.nix index 5ffb803d3a0e..5da0d34e0f2e 100644 --- a/pkgs/servers/zoneminder/default.nix +++ b/pkgs/servers/zoneminder/default.nix @@ -135,10 +135,13 @@ in stdenv.mkDerivation rec { substituteInPlace $f --replace @ZM_CONFIG_SUBDIR@ /etc/zoneminder done - for f in includes/Event.php views/image.php ; do - substituteInPlace web/$f \ - --replace "'ffmpeg " "'${ffmpeg}/bin/ffmpeg " - done + for f in includes/Event.php views/image.php ; do + substituteInPlace web/$f \ + --replace "'ffmpeg " "'${ffmpeg}/bin/ffmpeg " + done + + substituteInPlace web/includes/functions.php \ + --replace "'date " "'${coreutils}/bin/date " ''; buildInputs = [ From cb5da4eacbffcc7fcb7178069bb14ac879c5999d Mon Sep 17 00:00:00 2001 From: Daniel Fullmer Date: Sun, 9 Feb 2020 13:28:32 -0500 Subject: [PATCH 3/4] nixos/zoneminder: update on startup if needed --- nixos/modules/services/misc/zoneminder.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nixos/modules/services/misc/zoneminder.nix b/nixos/modules/services/misc/zoneminder.nix index d7f7324580c0..d5b3537068d3 100644 --- a/nixos/modules/services/misc/zoneminder.nix +++ b/nixos/modules/services/misc/zoneminder.nix @@ -77,6 +77,8 @@ in { `config.services.zoneminder.database.createLocally` to true. Otherwise, when set to `false` (the default), you will have to create the database and database user as well as populate the database yourself. + Additionally, you will need to run `zmupdate.pl` yourself when + upgrading to a newer version. ''; webserver = mkOption { @@ -330,6 +332,8 @@ in { ${config.services.mysql.package}/bin/mysql < ${pkg}/share/zoneminder/db/zm_create.sql touch "/var/lib/${dirName}/db-created" fi + + ${zoneminder}/bin/zmupdate.pl -nointeractive ''; serviceConfig = { User = user; From ce34b927e0957e2ff2e8723aa2d73cbacd0563dd Mon Sep 17 00:00:00 2001 From: Daniel Fullmer Date: Fri, 21 Feb 2020 22:08:36 -0500 Subject: [PATCH 4/4] zoneminder: add patch to fix improper caching --- ...use-file-timestamp-in-cache-filename.patch | 32 +++++++++++++++++++ pkgs/servers/zoneminder/default.nix | 6 ++-- 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 pkgs/servers/zoneminder/0001-Don-t-use-file-timestamp-in-cache-filename.patch diff --git a/pkgs/servers/zoneminder/0001-Don-t-use-file-timestamp-in-cache-filename.patch b/pkgs/servers/zoneminder/0001-Don-t-use-file-timestamp-in-cache-filename.patch new file mode 100644 index 000000000000..6ca55a147688 --- /dev/null +++ b/pkgs/servers/zoneminder/0001-Don-t-use-file-timestamp-in-cache-filename.patch @@ -0,0 +1,32 @@ +From db38a11228eceea10dc97ecc87023b4919caa918 Mon Sep 17 00:00:00 2001 +From: Daniel Fullmer +Date: Fri, 21 Feb 2020 21:52:00 -0500 +Subject: [PATCH] Don't use file timestamp in cache filename + +Every file in the nix store has a timestamp of "1", meaning that the +filename would remain constant even when changing zoneminder versions. +This would mean that newer versions would use the existing symlink to an +older version of the source file. We replace SRC_HASH in nix with a +hash of the source used to build zoneminder to ensure this filename is +unique. +--- + web/includes/functions.php | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/web/includes/functions.php b/web/includes/functions.php +index 19567a5c1..0242c09bc 100644 +--- a/web/includes/functions.php ++++ b/web/includes/functions.php +@@ -2223,7 +2223,8 @@ function cache_bust($file) { + $parts = pathinfo($file); + global $css; + $dirname = preg_replace('/\//', '_', $parts['dirname']); +- $cacheFile = $dirname.'_'.$parts['filename'].'-'.$css.'-'.filemtime($file).'.'.$parts['extension']; ++ $srcHash = '@srcHash@'; ++ $cacheFile = $dirname.'_'.$parts['filename'].'-'.$css.'-'.$srcHash.'.'.$parts['extension']; + if ( file_exists(ZM_DIR_CACHE.'/'.$cacheFile) or symlink(ZM_PATH_WEB.'/'.$file, ZM_DIR_CACHE.'/'.$cacheFile) ) { + return 'cache/'.$cacheFile; + } else { +-- +2.25.1 + diff --git a/pkgs/servers/zoneminder/default.nix b/pkgs/servers/zoneminder/default.nix index 5da0d34e0f2e..93f22e77f870 100644 --- a/pkgs/servers/zoneminder/default.nix +++ b/pkgs/servers/zoneminder/default.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, fetchFromGitHub, fetchurl, cmake, makeWrapper, pkgconfig +{ stdenv, lib, fetchFromGitHub, fetchurl, substituteAll, cmake, makeWrapper, pkgconfig , curl, ffmpeg, glib, libjpeg, libselinux, libsepol, mp4v2, libmysqlclient, mysql, pcre, perl, perlPackages , polkit, utillinuxMinimal, x264, zlib , coreutils, procps, psmisc }: @@ -89,6 +89,7 @@ in stdenv.mkDerivation rec { patches = [ ./default-to-http-1dot1.patch + ./0001-Don-t-use-file-timestamp-in-cache-filename.patch ]; postPatch = '' @@ -141,7 +142,8 @@ in stdenv.mkDerivation rec { done substituteInPlace web/includes/functions.php \ - --replace "'date " "'${coreutils}/bin/date " + --replace "'date " "'${coreutils}/bin/date " \ + --subst-var-by srcHash "`basename $out`" ''; buildInputs = [