From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
Date: Sat, 29 Jan 2022 00:32:33 +0000
Subject: [PATCH] build: Properly apply modes in meson_post_install.py

In our environment, the default umask is `0o022` so the `g+w` permission
is missing from the packaged `icons` directory.

Manipulate the umask to match the modes we want.

We can't just use `0` for everything because `makedirs` always uses
`0o777` for parent directories [since Python 3.7][1]. We also want to
keep `/var/lib` at `0o755`.

[1]: https://bugs.python.org/issue19930

Part-Of: https://gitlab.freedesktop.org/accountsservice/accountsservice/-/merge_requests/88
---
 meson_post_install.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meson_post_install.py b/meson_post_install.py
index 5cc2dc49b541..d8c3dd1ff81a 100644
--- a/meson_post_install.py
+++ b/meson_post_install.py
@@ -9,10 +9,12 @@ localstatedir = os.path.normpath(destdir + os.sep + sys.argv[1])
 # FIXME: meson will not track the creation of these directories
 #        https://github.com/mesonbuild/meson/blob/master/mesonbuild/scripts/uninstall.py#L39
 dst_dirs = [
+  (os.path.join(localstatedir, 'lib'), 0o755),
   (os.path.join(localstatedir, 'lib', 'AccountsService', 'icons'), 0o775),
   (os.path.join(localstatedir, 'lib', 'AccountsService', 'users'), 0o700),
 ]
 
 for (dst_dir, dst_dir_mode) in dst_dirs:
   if not os.path.exists(dst_dir):
+    os.umask(0o777 & ~dst_dir_mode)
     os.makedirs(dst_dir, mode=dst_dir_mode)
