gnu: Add kafs-client
[jackhill/guix/guix.git] / gnu / packages / patches / libvirt-add-install-prefix.patch
CommitLineData
0d4ae86b
BW
1Patch from NixOS:
2https://raw.githubusercontent.com/NixOS/nixpkgs/b98031a49c66095dd1eb9185ecdaeeb5e3cd752d/pkgs/development/libraries/libvirt/0001-meson-patch-in-an-install-prefix-for-building-on-nix.patch
3
4From a896b0be849455edb83a9305dfec9b41447ef3e4 Mon Sep 17 00:00:00 2001
5From: Euan Kemp <euank@euank.com>
6Date: Thu, 14 Jan 2021 00:32:00 -0800
7Subject: [PATCH] meson: patch in an install prefix for building on nix
8
9Used in the nixpkgs version of libvirt so that we can install things in
10the nix store, but read them from the root filesystem.
11---
12 meson.build | 9 +++++++++
13 meson_options.txt | 2 ++
14 src/libxl/meson.build | 6 +++---
15 src/locking/meson.build | 8 ++++----
16 src/lxc/meson.build | 6 +++---
17 src/meson.build | 18 +++++++++---------
18 src/network/meson.build | 12 ++++++------
19 src/nwfilter/xml/meson.build | 2 +-
20 src/qemu/meson.build | 14 +++++++-------
21 src/remote/meson.build | 6 +++---
22 src/security/apparmor/meson.build | 8 ++++----
23 tools/meson.build | 4 ++--
24 12 files changed, 53 insertions(+), 42 deletions(-)
25
26diff --git a/meson.build b/meson.build
27index b5164f6..33719f1 100644
28--- a/meson.build
29+++ b/meson.build
30@@ -39,6 +39,8 @@ if host_machine.system() == 'windows'
31 conf.set('WINVER', '0x0600') # Win Vista / Server 2008
32 endif
33
34+# patched in for nix
35+install_prefix = get_option('install_prefix')
36
37 # set various paths
38
39@@ -57,6 +59,13 @@ else
40 sysconfdir = prefix / get_option('sysconfdir')
41 endif
42
43+# nix: don't prefix the localstatedir; some things need to write to it, so it
44+# can't be in the nix store, and that's what the prefix is.
45+# We'll prefix things ourselves where needed
46+localstatedir = get_option('localstatedir')
47+# Same for sysconfidr
48+sysconfdir = get_option('sysconfdir')
49+
50 # if --prefix is /usr, don't use /usr/var for localstatedir or /usr/etc for
51 # sysconfdir as this makes a lot of things break in testing situations
52 if prefix == '/usr'
53diff --git a/meson_options.txt b/meson_options.txt
54index e5d79c2..081cd32 100644
55--- a/meson_options.txt
56+++ b/meson_options.txt
57@@ -1,3 +1,5 @@
58+option('install_prefix', type: 'string', value: '', description: 'prefix for nix store installation')
59+
60 option('no_git', type: 'boolean', value: false, description: 'Disable git submodule update')
61 option('packager', type: 'string', value: '', description: 'Extra packager name')
62 option('packager_version', type: 'string', value: '', description: 'Extra packager version')
63diff --git a/src/libxl/meson.build b/src/libxl/meson.build
64index 3bb6cc5..78d7be0 100644
65--- a/src/libxl/meson.build
66+++ b/src/libxl/meson.build
67@@ -84,8 +84,8 @@ if conf.has('WITH_LIBXL')
68 }
69
70 virt_install_dirs += [
71- localstatedir / 'lib' / 'libvirt' / 'libxl',
72- runstatedir / 'libvirt' / 'libxl',
73- localstatedir / 'log' / 'libvirt' / 'libxl',
74+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'libxl',
75+ install_prefix + runstatedir / 'libvirt' / 'libxl',
76+ install_prefix + localstatedir / 'log' / 'libvirt' / 'libxl',
77 ]
78 endif
79diff --git a/src/locking/meson.build b/src/locking/meson.build
80index 8a28310..9da81cc 100644
81--- a/src/locking/meson.build
82+++ b/src/locking/meson.build
83@@ -243,14 +243,14 @@ if conf.has('WITH_LIBVIRTD')
84 }
85
86 virt_install_dirs += [
87- localstatedir / 'lib' / 'libvirt' / 'lockd',
88- localstatedir / 'lib' / 'libvirt' / 'lockd' / 'files',
89- runstatedir / 'libvirt' / 'lockd',
90+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'lockd',
91+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'lockd' / 'files',
92+ install_prefix + runstatedir / 'libvirt' / 'lockd',
93 ]
94
95 if conf.has('WITH_SANLOCK')
96 virt_install_dirs += [
97- localstatedir / 'lib' / 'libvirt' / 'sanlock',
98+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'sanlock',
99 ]
100 endif
101 endif
102diff --git a/src/lxc/meson.build b/src/lxc/meson.build
103index f8e2a88..96d6687 100644
104--- a/src/lxc/meson.build
105+++ b/src/lxc/meson.build
106@@ -182,8 +182,8 @@ if conf.has('WITH_LXC')
107 }
108
109 virt_install_dirs += [
110- localstatedir / 'lib' / 'libvirt' / 'lxc',
111- runstatedir / 'libvirt' / 'lxc',
112- localstatedir / 'log' / 'libvirt' / 'lxc',
113+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'lxc',
114+ install_prefix + runstatedir / 'libvirt' / 'lxc',
115+ install_prefix + localstatedir / 'log' / 'libvirt' / 'lxc',
116 ]
117 endif
118diff --git a/src/meson.build b/src/meson.build
119index 7c47821..d33d16a 100644
120--- a/src/meson.build
121+++ b/src/meson.build
122@@ -669,7 +669,7 @@ endforeach
123
124 virt_conf_files += 'libvirt.conf'
125
126-install_data(virt_conf_files, install_dir: confdir)
127+install_data(virt_conf_files, install_dir: install_prefix + confdir)
128 install_data(virt_aug_files, install_dir: virt_aug_dir)
129
130 # augeas_test_data:
131@@ -729,7 +729,7 @@ foreach data : virt_daemon_confs
132 output: '@0@.conf'.format(data['name']),
133 configuration: daemon_conf,
134 install: true,
135- install_dir: confdir,
136+ install_dir: install_prefix + confdir,
137 )
138
139 if data.get('with_ip', false)
140@@ -853,14 +853,14 @@ if conf.has('WITH_LIBVIRTD')
141
142 install_data(
143 init_file,
144- install_dir: sysconfdir / 'init.d',
145+ install_dir: install_prefix + sysconfdir / 'init.d',
146 rename: [ init['name'] ],
147 )
148
149 if init.has_key('confd')
150 install_data(
151 init['confd'],
152- install_dir: sysconfdir / 'conf.d',
153+ install_dir: install_prefix + sysconfdir / 'conf.d',
154 rename: [ init['name'] ],
155 )
156 endif
157@@ -872,7 +872,7 @@ if init_script != 'none'
158 foreach sysconf : sysconf_files
159 install_data(
160 sysconf['file'],
161- install_dir: sysconfdir / 'sysconfig',
162+ install_dir: install_prefix + sysconfdir / 'sysconfig',
163 rename: [ sysconf['name'] ],
164 )
165 endforeach
166@@ -897,10 +897,10 @@ endif
167 # Install empty directories
168
169 virt_install_dirs += [
170- localstatedir / 'cache' / 'libvirt',
171- localstatedir / 'lib' / 'libvirt' / 'images',
172- localstatedir / 'lib' / 'libvirt' / 'filesystems',
173- localstatedir / 'lib' / 'libvirt' / 'boot',
174+ install_prefix + localstatedir / 'cache' / 'libvirt',
175+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'images',
176+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'filesystems',
177+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'boot',
178 ]
179
180 meson.add_install_script(
181diff --git a/src/network/meson.build b/src/network/meson.build
182index 3ec598c..b02040b 100644
183--- a/src/network/meson.build
184+++ b/src/network/meson.build
185@@ -79,9 +79,9 @@ if conf.has('WITH_NETWORK')
186 }
187
188 virt_install_dirs += [
189- localstatedir / 'lib' / 'libvirt' / 'network',
190- localstatedir / 'lib' / 'libvirt' / 'dnsmasq',
191- runstatedir / 'libvirt' / 'network',
192+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'network',
193+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'dnsmasq',
194+ install_prefix + runstatedir / 'libvirt' / 'network',
195 ]
196
197 configure_file(
198@@ -89,12 +89,12 @@ if conf.has('WITH_NETWORK')
199 output: '@BASENAME@',
200 copy: true,
201 install: true,
202- install_dir: confdir / 'qemu' / 'networks',
203+ install_dir: install_prefix + confdir / 'qemu' / 'networks',
204 )
205
206 meson.add_install_script(
207 meson_python_prog.path(), python3_prog.path(), meson_install_symlink_prog.path(),
208- confdir / 'qemu' / 'networks' / 'autostart',
209+ install_prefix + confdir / 'qemu' / 'networks' / 'autostart',
210 '../default.xml', 'default.xml',
211 )
212
213diff --git a/src/nwfilter/xml/meson.build b/src/nwfilter/xml/meson.build
214index 0d96c54..66c92a1 100644
215--- a/src/nwfilter/xml/meson.build
216+++ b/src/nwfilter/xml/meson.build
217@@ -25,4 +25,4 @@ nwfilter_xml_files = [
218 'qemu-announce-self.xml',
219 ]
220
221-install_data(nwfilter_xml_files, install_dir: sysconfdir / 'libvirt' / 'nwfilter')
222+install_data(nwfilter_xml_files, install_dir: install_prefix + sysconfdir / 'libvirt' / 'nwfilter')
223diff --git a/src/qemu/meson.build b/src/qemu/meson.build
224index 90640b0..8802cec 100644
225--- a/src/qemu/meson.build
226+++ b/src/qemu/meson.build
227@@ -171,12 +171,12 @@ if conf.has('WITH_QEMU')
228 }
229
230 virt_install_dirs += [
231- localstatedir / 'lib' / 'libvirt' / 'qemu',
232- runstatedir / 'libvirt' / 'qemu',
233- localstatedir / 'cache' / 'libvirt' / 'qemu',
234- localstatedir / 'log' / 'libvirt' / 'qemu',
235- localstatedir / 'lib' / 'libvirt' / 'swtpm',
236- runstatedir / 'libvirt' / 'qemu' / 'swtpm',
237- localstatedir / 'log' / 'swtpm' / 'libvirt' / 'qemu',
238+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu',
239+ install_prefix + runstatedir / 'libvirt' / 'qemu',
240+ install_prefix + localstatedir / 'cache' / 'libvirt' / 'qemu',
241+ install_prefix + localstatedir / 'log' / 'libvirt' / 'qemu',
242+ install_prefix + localstatedir / 'lib' / 'libvirt' / 'swtpm',
243+ install_prefix + runstatedir / 'libvirt' / 'qemu' / 'swtpm',
244+ install_prefix + localstatedir / 'log' / 'swtpm' / 'libvirt' / 'qemu',
245 ]
246 endif
247diff --git a/src/remote/meson.build b/src/remote/meson.build
248index 9ad2f6a..429a15b 100644
249--- a/src/remote/meson.build
250+++ b/src/remote/meson.build
251@@ -245,7 +245,7 @@ if conf.has('WITH_REMOTE')
252 }
253
254 virt_install_dirs += [
255- localstatedir / 'log' / 'libvirt',
256+ install_prefix + localstatedir / 'log' / 'libvirt',
257 ]
258
259 logrotate_conf = configuration_data()
260@@ -259,7 +259,7 @@ if conf.has('WITH_REMOTE')
261 )
262 install_data(
263 log_file,
264- install_dir: sysconfdir / 'logrotate.d',
265+ install_dir: install_prefix + sysconfdir / 'logrotate.d',
266 rename: [ name ],
267 )
268 endforeach
269@@ -309,7 +309,7 @@ endif
270 if conf.has('WITH_SASL')
271 install_data(
272 'libvirtd.sasl',
273- install_dir: sysconfdir / 'sasl2',
274+ install_dir: install_prefix + sysconfdir / 'sasl2',
275 rename: [ 'libvirt.conf' ],
276 )
277 endif
278diff --git a/src/security/apparmor/meson.build b/src/security/apparmor/meson.build
279index af43780..e2d6c81 100644
280--- a/src/security/apparmor/meson.build
281+++ b/src/security/apparmor/meson.build
282@@ -17,22 +17,22 @@ foreach name : apparmor_gen_profiles
283 output: name,
284 configuration: apparmor_gen_profiles_conf,
285 install: true,
286- install_dir: apparmor_dir,
287+ install_dir: install_prefix + apparmor_dir,
288 )
289 endforeach
290
291 install_data(
292 [ 'libvirt-qemu', 'libvirt-lxc' ],
293- install_dir: apparmor_dir / 'abstractions',
294+ install_dir: install_prefix + apparmor_dir / 'abstractions',
295 )
296
297 install_data(
298 [ 'TEMPLATE.qemu', 'TEMPLATE.lxc' ],
299- install_dir: apparmor_dir / 'libvirt',
300+ install_dir: install_prefix + apparmor_dir / 'libvirt',
301 )
302
303 install_data(
304 'usr.lib.libvirt.virt-aa-helper.local',
305- install_dir: apparmor_dir / 'local',
306+ install_dir: install_prefix + apparmor_dir / 'local',
307 rename: 'usr.lib.libvirt.virt-aa-helper',
308 )
309diff --git a/tools/meson.build b/tools/meson.build
310index b8c6802..dacd0ff 100644
311--- a/tools/meson.build
312+++ b/tools/meson.build
313@@ -115,7 +115,7 @@ if conf.has('WITH_LOGIN_SHELL')
314 install_rpath: libvirt_rpath,
315 )
316
317- install_data('virt-login-shell.conf', install_dir: sysconfdir / 'libvirt')
318+ install_data('virt-login-shell.conf', install_dir: install_prefix + sysconfdir / 'libvirt')
319 endif
320
321 if host_machine.system() == 'windows'
322@@ -274,7 +274,7 @@ configure_file(
323 if init_script == 'systemd'
324 install_data(
325 'libvirt-guests.sysconf',
326- install_dir: sysconfdir / 'sysconfig',
327+ install_dir: install_prefix + sysconfdir / 'sysconfig',
328 rename: 'libvirt-guests',
329 )