From bacac7cf54bdfdb41091a506dd1b158da08a2d78 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 8 Aug 2022 20:00:02 +0200 Subject: [PATCH] sigal: fix crash when building gallery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When building a gallery using `sigal build` the process would error out with an message along the lines of shutil.Error: [('/nix/store/…/static/css', '/…/_build/static/css', "[Errno 13] Permission denied: '/…/_build/static/css'"), … ] This is caused by `shutil.copytree` copying the permissions (555) of the directories in the Nix store and then attempting to make modifications to the copied directory. The patch makes the copy ignore the permissions of directories. --- .../misc/sigal/copytree-permissions.patch | 16 ++++++++++++++++ pkgs/applications/misc/sigal/default.nix | 2 ++ 2 files changed, 18 insertions(+) create mode 100644 pkgs/applications/misc/sigal/copytree-permissions.patch diff --git a/pkgs/applications/misc/sigal/copytree-permissions.patch b/pkgs/applications/misc/sigal/copytree-permissions.patch new file mode 100644 index 000000000000..352e1f0d2dcc --- /dev/null +++ b/pkgs/applications/misc/sigal/copytree-permissions.patch @@ -0,0 +1,16 @@ +diff -Nurp sigal-2.3.orig/sigal/writer.py sigal-2.3/sigal/writer.py +--- sigal-2.3.orig/sigal/writer.py 2022-08-08 19:43:10.934707194 +0200 ++++ sigal-2.3/sigal/writer.py 2022-08-08 19:44:57.542382532 +0200 +@@ -103,7 +103,11 @@ class AbstractWriter: + os.path.join(THEMES_PATH, 'default', 'static'), + os.path.join(self.theme, 'static'), + ): +- shutil.copytree(static_path, self.theme_path, dirs_exist_ok=True) ++ # https://stackoverflow.com/a/17022146/4935114 ++ orig_copystat = shutil.copystat ++ shutil.copystat = lambda x, y: x ++ shutil.copytree(static_path, self.theme_path, dirs_exist_ok=True, copy_function=shutil.copy) ++ shutil.copystat = orig_copystat + + if self.settings["user_css"]: + if not os.path.exists(self.settings["user_css"]): diff --git a/pkgs/applications/misc/sigal/default.nix b/pkgs/applications/misc/sigal/default.nix index 8289cc428db3..fb0a19dbb44a 100644 --- a/pkgs/applications/misc/sigal/default.nix +++ b/pkgs/applications/misc/sigal/default.nix @@ -14,6 +14,8 @@ python3.pkgs.buildPythonApplication rec { hash = "sha256-4Zsb/OBtU/jV0gThEYe8bcrb+6hW+hnzQS19q1H409Q="; }; + patches = [ ./copytree-permissions.patch ]; + propagatedBuildInputs = with python3.pkgs; [ # install_requires jinja2