From 17584285d296acaa80f131ca0e8b75eff675962b Mon Sep 17 00:00:00 2001
From: fafryd <dz1125.bug.tracker@gmail.com>
Date: Sun, 20 May 2018 14:30:43 +0200
Subject: [PATCH] v2 FS#58644

---
 hw/xfree86/common/meson.build | 13 +++++++++++++
 hw/xfree86/meson.build        | 12 +++++++-----
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/hw/xfree86/common/meson.build b/hw/xfree86/common/meson.build
index 514999ff6..0eff6e488 100644
--- a/hw/xfree86/common/meson.build
+++ b/hw/xfree86/common/meson.build
@@ -1,3 +1,16 @@
+if get_option('suid_wrapper')
+    x_sh = configure_file(
+        input: '../Xorg.sh.in',
+        output: 'Xorg',
+        configuration: conf_data,
+    )
+    install_data(
+       x_sh,
+       install_mode: 'rwxr-xr-x',
+       install_dir: join_paths(get_option('prefix'), get_option('bindir')),
+    )
+endif
+
 srcs_xorg_common = [
     'xf86fbBus.c',
     'xf86noBus.c',
diff --git a/hw/xfree86/meson.build b/hw/xfree86/meson.build
index cacf56d4c..d1295d404 100644
--- a/hw/xfree86/meson.build
+++ b/hw/xfree86/meson.build
@@ -145,11 +145,13 @@ if get_option('suid_wrapper')
         install_dir: get_option('libexecdir'),
         # install_mode: ['r-sr-xr-x', 0, 0],
     )
-    configure_file(
-        input: 'Xorg.sh.in',
-        output: 'Xorg',
-        configuration: conf_data,
-        install_dir: join_paths(get_option('prefix'), get_option('bindir')),
+     meson.add_install_script(
+        'sh', '-c',
+        'chmod u+s @0@@1@/@2@'.format(
+            '${DESTDIR}',
+            join_paths(get_option('prefix'), get_option('libexecdir')),
+            'Xorg.wrap'
+        )
     )
 endif
 
-- 
2.17.0

