about summary refs log tree commit diff
path: root/pkgs/servers/zoneminder
diff options
context:
space:
mode:
authorDaniel Fullmer <danielrf12@gmail.com>2020-02-21 22:08:36 -0500
committerDaniel Fullmer <danielrf12@gmail.com>2020-03-07 12:59:39 -0500
commitce34b927e0957e2ff2e8723aa2d73cbacd0563dd (patch)
treeb629fd765fc09dd2414c5baf482c33ece90ca633 /pkgs/servers/zoneminder
parentcb5da4eacbffcc7fcb7178069bb14ac879c5999d (diff)
zoneminder: add patch to fix improper caching
Diffstat (limited to 'pkgs/servers/zoneminder')
-rw-r--r--pkgs/servers/zoneminder/0001-Don-t-use-file-timestamp-in-cache-filename.patch32
-rw-r--r--pkgs/servers/zoneminder/default.nix6
2 files changed, 36 insertions, 2 deletions
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 0000000000000..6ca55a1476884
--- /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 <danielrf12@gmail.com>
+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 5da0d34e0f2ec..93f22e77f8700 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 = [