summary refs log tree commit diff
path: root/gnu/packages/patches/libvirt-add-install-prefix.patch
blob: 9ad339d82f7984ee5fc7c13eebff0928d462159f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
Patch from NixOS:

  https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/libvirt/0001-meson-patch-in-an-install-prefix-for-building-on-nix.patch

From ad42041cfedcf25716429d2aad16641e0e2a012f Mon Sep 17 00:00:00 2001
From: Euan Kemp <euank@euank.com>
Date: Thu, 14 Jan 2021 00:32:00 -0800
Subject: [PATCH] meson: patch in an install prefix for building on nix

Used in the nixpkgs version of libvirt so that we can install things in
the nix store, but read them from the root filesystem.
---

diff --git a/meson.build b/meson.build
index 9016c0458a..b26e690194 100644
--- a/meson.build
+++ b/meson.build
@@ -39,6 +39,8 @@ if host_machine.system() == 'windows'
   conf.set('WINVER', '0x0600') # Win Vista / Server 2008
 endif
 
+# patched in for nix
+install_prefix = get_option('install_prefix')
 
 # set various paths
 
@@ -57,6 +59,13 @@ else
   sysconfdir = prefix / get_option('sysconfdir')
 endif
 
+# nix: don't prefix the localstatedir; some things need to write to it, so it
+# can't be in the nix store, and that's what the prefix is.
+# We'll prefix things ourselves where needed
+localstatedir = get_option('localstatedir')
+# Same for sysconfidr
+sysconfdir = get_option('sysconfdir')
+
 # if --prefix is /usr, don't use /usr/var for localstatedir or /usr/etc for
 # sysconfdir as this makes a lot of things break in testing situations
 if prefix == '/usr'
diff --git a/meson_options.txt b/meson_options.txt
index 5b43cdbd6b..e9dff18441 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,3 +1,5 @@
+option('install_prefix', type: 'string', value: '', description: 'prefix for nix store installation')
+
 option('no_git', type: 'boolean', value: false, description: 'Disable git submodule update')
 option('packager', type: 'string', value: '', description: 'Extra packager name')
 option('packager_version', type: 'string', value: '', description: 'Extra packager version')
diff --git a/src/ch/meson.build b/src/ch/meson.build
index 66b77907b0..6aa9bbc548 100644
--- a/src/ch/meson.build
+++ b/src/ch/meson.build
@@ -64,8 +64,8 @@ if conf.has('WITH_CH')
   }
 
   virt_install_dirs += [
-    localstatedir / 'lib' / 'libvirt' / 'ch',
-    localstatedir / 'log' / 'libvirt' / 'ch',
-    runstatedir / 'libvirt' / 'ch',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'ch',
+    install_prefix + localstatedir / 'log' / 'libvirt' / 'ch',
+    install_prefix + runstatedir / 'libvirt' / 'ch',
   ]
 endif
diff --git a/src/interface/meson.build b/src/interface/meson.build
index 828f274422..2a6b1f8c5e 100644
--- a/src/interface/meson.build
+++ b/src/interface/meson.build
@@ -56,6 +56,6 @@ if conf.has('WITH_INTERFACE')
   }
 
   virt_install_dirs += [
-    runstatedir / 'libvirt' / 'interface',
+    install_prefix + runstatedir / 'libvirt' / 'interface',
   ]
 endif
diff --git a/src/libxl/meson.build b/src/libxl/meson.build
index 0cc277db82..48d8c5b962 100644
--- a/src/libxl/meson.build
+++ b/src/libxl/meson.build
@@ -79,14 +79,14 @@ if conf.has('WITH_LIBXL')
   }
 
   virt_install_dirs += [
-    confdir / 'libxl',
-    confdir / 'libxl' / 'autostart',
-    localstatedir / 'lib' / 'libvirt' / 'libxl',
-    localstatedir / 'lib' / 'libvirt' / 'libxl' / 'channel',
-    localstatedir / 'lib' / 'libvirt' / 'libxl' / 'channel' / 'target',
-    localstatedir / 'lib' / 'libvirt' / 'libxl' / 'dump',
-    localstatedir / 'lib' / 'libvirt' / 'libxl' / 'save',
-    localstatedir / 'log' / 'libvirt' / 'libxl',
-    runstatedir / 'libvirt' / 'libxl',
+    install_prefix + confdir / 'libxl',
+    install_prefix + confdir / 'libxl' / 'autostart',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'libxl',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'libxl' / 'channel',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'libxl' / 'channel' / 'target',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'libxl' / 'dump',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'libxl' / 'save',
+    install_prefix + localstatedir / 'log' / 'libvirt' / 'libxl',
+    install_prefix + runstatedir / 'libvirt' / 'libxl',
   ]
 endif
diff --git a/src/locking/meson.build b/src/locking/meson.build
index 72f7780438..abe70d20d5 100644
--- a/src/locking/meson.build
+++ b/src/locking/meson.build
@@ -238,14 +238,14 @@ if conf.has('WITH_LIBVIRTD')
   }
 
   virt_install_dirs += [
-    localstatedir / 'lib' / 'libvirt' / 'lockd',
-    localstatedir / 'lib' / 'libvirt' / 'lockd' / 'files',
-    runstatedir / 'libvirt' / 'lockd',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'lockd',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'lockd' / 'files',
+    install_prefix + runstatedir / 'libvirt' / 'lockd',
   ]
 
   if conf.has('WITH_SANLOCK')
     virt_install_dirs += [
-      localstatedir / 'lib' / 'libvirt' / 'sanlock',
+      install_prefix + localstatedir / 'lib' / 'libvirt' / 'sanlock',
     ]
   endif
 endif
diff --git a/src/lxc/meson.build b/src/lxc/meson.build
index 99d4a34213..aae477c1ee 100644
--- a/src/lxc/meson.build
+++ b/src/lxc/meson.build
@@ -176,10 +176,10 @@ if conf.has('WITH_LXC')
   }
 
   virt_install_dirs += [
-    confdir / 'lxc',
-    confdir / 'lxc' / 'autostart',
-    localstatedir / 'lib' / 'libvirt' / 'lxc',
-    localstatedir / 'log' / 'libvirt' / 'lxc',
-    runstatedir / 'libvirt' / 'lxc',
+    install_prefix + confdir / 'lxc',
+    install_prefix + confdir / 'lxc' / 'autostart',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'lxc',
+    install_prefix + localstatedir / 'log' / 'libvirt' / 'lxc',
+    install_prefix + runstatedir / 'libvirt' / 'lxc',
   ]
 endif
diff --git a/src/meson.build b/src/meson.build
index b2d951d36c..305716010f 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -210,7 +210,7 @@ openrc_init_files = []
 
 # virt_install_dirs:
 #   list of directories to create during installation
-virt_install_dirs = [ confdir ]
+virt_install_dirs = [ install_prefix + confdir ]
 
 # driver_source_files:
 #   driver source files to check
@@ -663,7 +663,7 @@ endforeach
 
 virt_conf_files += 'libvirt.conf'
 
-install_data(virt_conf_files, install_dir: confdir)
+install_data(virt_conf_files, install_dir: install_prefix + confdir)
 install_data(virt_aug_files, install_dir: virt_aug_dir)
 
 # augeas_test_data:
@@ -723,7 +723,7 @@ foreach data : virt_daemon_confs
     output: '@0@.conf'.format(data['name']),
     configuration: daemon_conf,
     install: true,
-    install_dir: confdir,
+    install_dir: install_prefix + confdir,
   )
 
   if data.get('with_ip', false)
@@ -847,7 +847,7 @@ if conf.has('WITH_LIBVIRTD')
 
       install_data(
         init_file,
-        install_dir: sysconfdir / 'init.d',
+        install_dir: install_prefix + sysconfdir / 'init.d',
         install_mode: 'rwxr-xr-x',
         rename: [ init['name'] ],
       )
@@ -855,7 +855,7 @@ if conf.has('WITH_LIBVIRTD')
       if init.has_key('confd')
         install_data(
           init['confd'],
-          install_dir: sysconfdir / 'conf.d',
+          install_dir: install_prefix + sysconfdir / 'conf.d',
           rename: [ init['name'] ],
         )
       endif
@@ -882,10 +882,10 @@ endif
 # Install empty directories
 
 virt_install_dirs += [
-  localstatedir / 'cache' / 'libvirt',
-  localstatedir / 'lib' / 'libvirt' / 'images',
-  localstatedir / 'lib' / 'libvirt' / 'filesystems',
-  localstatedir / 'lib' / 'libvirt' / 'boot',
+  install_prefix + localstatedir / 'cache' / 'libvirt',
+  install_prefix + localstatedir / 'lib' / 'libvirt' / 'images',
+  install_prefix + localstatedir / 'lib' / 'libvirt' / 'filesystems',
+  install_prefix + localstatedir / 'lib' / 'libvirt' / 'boot',
 ]
 
 meson.add_install_script(
diff --git a/src/network/meson.build b/src/network/meson.build
index b5eff0c3ab..a0f26d624e 100644
--- a/src/network/meson.build
+++ b/src/network/meson.build
@@ -73,11 +73,11 @@ if conf.has('WITH_NETWORK')
   }
 
   virt_install_dirs += [
-    confdir / 'qemu' / 'networks',
-    confdir / 'qemu' / 'networks' / 'autostart',
-    localstatedir / 'lib' / 'libvirt' / 'network',
-    localstatedir / 'lib' / 'libvirt' / 'dnsmasq',
-    runstatedir / 'libvirt' / 'network',
+    install_prefix + confdir / 'qemu' / 'networks',
+    install_prefix + confdir / 'qemu' / 'networks' / 'autostart',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'network',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'dnsmasq',
+    install_prefix + runstatedir / 'libvirt' / 'network',
   ]
 
   configure_file(
@@ -85,12 +85,12 @@ if conf.has('WITH_NETWORK')
     output: '@BASENAME@',
     copy: true,
     install: true,
-    install_dir: confdir / 'qemu' / 'networks',
+    install_dir: install_prefix + confdir / 'qemu' / 'networks',
   )
 
   meson.add_install_script(
     meson_python_prog.path(), python3_prog.path(), meson_install_symlink_prog.path(),
-    confdir / 'qemu' / 'networks' / 'autostart',
+    install_prefix + confdir / 'qemu' / 'networks' / 'autostart',
     '../default.xml', 'default.xml',
   )
 
diff --git a/src/node_device/meson.build b/src/node_device/meson.build
index 1c95975c37..a7831242db 100644
--- a/src/node_device/meson.build
+++ b/src/node_device/meson.build
@@ -64,6 +64,6 @@ if conf.has('WITH_NODE_DEVICES')
   }
 
   virt_install_dirs += [
-    runstatedir / 'libvirt' / 'nodedev',
+    install_prefix + runstatedir / 'libvirt' / 'nodedev',
   ]
 endif
diff --git a/src/nwfilter/meson.build b/src/nwfilter/meson.build
index 55cf8fcce4..d331086f2e 100644
--- a/src/nwfilter/meson.build
+++ b/src/nwfilter/meson.build
@@ -62,9 +62,9 @@ if conf.has('WITH_NWFILTER')
   }
 
   virt_install_dirs += [
-    confdir / 'nwfilter',
-    runstatedir / 'libvirt' / 'nwfilter-binding',
-    runstatedir / 'libvirt' / 'nwfilter',
+    install_prefix + confdir / 'nwfilter',
+    install_prefix + runstatedir / 'libvirt' / 'nwfilter-binding',
+    install_prefix + runstatedir / 'libvirt' / 'nwfilter',
   ]
 
   subdir('xml')
diff --git a/src/nwfilter/xml/meson.build b/src/nwfilter/xml/meson.build
index 0d96c54ebe..66c92a1016 100644
--- a/src/nwfilter/xml/meson.build
+++ b/src/nwfilter/xml/meson.build
@@ -25,4 +25,4 @@ nwfilter_xml_files = [
   'qemu-announce-self.xml',
 ]
 
-install_data(nwfilter_xml_files, install_dir: sysconfdir / 'libvirt' / 'nwfilter')
+install_data(nwfilter_xml_files, install_dir: install_prefix + sysconfdir / 'libvirt' / 'nwfilter')
diff --git a/src/qemu/meson.build b/src/qemu/meson.build
index 39f0f615cc..5f6f30f82b 100644
--- a/src/qemu/meson.build
+++ b/src/qemu/meson.build
@@ -175,24 +175,24 @@ if conf.has('WITH_QEMU')
   endif
 
   virt_install_dirs += [
-    confdir / 'qemu',
-    confdir / 'qemu' / 'autostart',
-    localstatedir / 'cache' / 'libvirt' / 'qemu',
-    localstatedir / 'lib' / 'libvirt' / 'qemu',
-    localstatedir / 'lib' / 'libvirt' / 'qemu' / 'channel',
-    localstatedir / 'lib' / 'libvirt' / 'qemu' / 'channel' / 'target',
-    localstatedir / 'lib' / 'libvirt' / 'qemu' / 'checkpoint',
-    localstatedir / 'lib' / 'libvirt' / 'qemu' / 'dump',
-    localstatedir / 'lib' / 'libvirt' / 'qemu' / 'nvram',
-    localstatedir / 'lib' / 'libvirt' / 'qemu' / 'ram',
-    localstatedir / 'lib' / 'libvirt' / 'qemu' / 'save',
-    localstatedir / 'lib' / 'libvirt' / 'qemu' / 'snapshot',
-    localstatedir / 'lib' / 'libvirt' / 'swtpm',
-    localstatedir / 'log' / 'libvirt' / 'qemu',
-    localstatedir / 'log' / 'swtpm' / 'libvirt' / 'qemu',
-    runstatedir / 'libvirt' / 'qemu',
-    runstatedir / 'libvirt' / 'qemu' / 'dbus',
-    runstatedir / 'libvirt' / 'qemu' / 'slirp',
-    runstatedir / 'libvirt' / 'qemu' / 'swtpm',
+    install_prefix + confdir / 'qemu',
+    install_prefix + confdir / 'qemu' / 'autostart',
+    install_prefix + localstatedir / 'cache' / 'libvirt' / 'qemu',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'channel',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'channel' / 'target',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'checkpoint',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'dump',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'nvram',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'ram',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'save',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'qemu' / 'snapshot',
+    install_prefix + localstatedir / 'lib' / 'libvirt' / 'swtpm',
+    install_prefix + localstatedir / 'log' / 'libvirt' / 'qemu',
+    install_prefix + localstatedir / 'log' / 'swtpm' / 'libvirt' / 'qemu',
+    install_prefix + runstatedir / 'libvirt' / 'qemu',
+    install_prefix + runstatedir / 'libvirt' / 'qemu' / 'dbus',
+    install_prefix + runstatedir / 'libvirt' / 'qemu' / 'slirp',
+    install_prefix + runstatedir / 'libvirt' / 'qemu' / 'swtpm',
   ]
 endif
diff --git a/src/remote/meson.build b/src/remote/meson.build
index b2aafe6320..6972d254ca 100644
--- a/src/remote/meson.build
+++ b/src/remote/meson.build
@@ -235,9 +235,9 @@ if conf.has('WITH_REMOTE')
     }
 
     virt_install_dirs += [
-      localstatedir / 'log' / 'libvirt',
-      runstatedir / 'libvirt',
-      runstatedir / 'libvirt' / 'common',
+      install_prefix + localstatedir / 'log' / 'libvirt',
+      install_prefix + runstatedir / 'libvirt',
+      install_prefix + runstatedir / 'libvirt' / 'common',
     ]
 
     logrotate_conf = configuration_data()
@@ -251,7 +251,7 @@ if conf.has('WITH_REMOTE')
       )
       install_data(
         log_file,
-        install_dir: sysconfdir / 'logrotate.d',
+        install_dir: install_prefix + sysconfdir / 'logrotate.d',
         rename: [ name ],
       )
     endforeach
@@ -301,7 +301,7 @@ endif
 if conf.has('WITH_SASL')
   install_data(
     'libvirtd.sasl',
-    install_dir: sysconfdir / 'sasl2',
+    install_dir: install_prefix + sysconfdir / 'sasl2',
     rename: [ 'libvirt.conf' ],
   )
 endif
diff --git a/src/secret/meson.build b/src/secret/meson.build
index 1bda59849b..392bc2cb2e 100644
--- a/src/secret/meson.build
+++ b/src/secret/meson.build
@@ -45,7 +45,7 @@ if conf.has('WITH_SECRETS')
   }
 
   virt_install_dirs += [
-    confdir / 'secrets',
-    runstatedir / 'libvirt' / 'secrets',
+    install_prefix + confdir / 'secrets',
+    install_prefix + runstatedir / 'libvirt' / 'secrets',
   ]
 endif
diff --git a/src/security/apparmor/meson.build b/src/security/apparmor/meson.build
index 990f00b4f3..e5a7a14e1d 100644
--- a/src/security/apparmor/meson.build
+++ b/src/security/apparmor/meson.build
@@ -19,22 +19,22 @@ foreach name : apparmor_gen_profiles
     output: name,
     configuration: apparmor_gen_profiles_conf,
     install: true,
-    install_dir: apparmor_dir,
+    install_dir: install_prefix + apparmor_dir,
   )
 endforeach
 
 install_data(
   [ 'libvirt-qemu', 'libvirt-lxc' ],
-  install_dir: apparmor_dir / 'abstractions',
+  install_dir: install_prefix + apparmor_dir / 'abstractions',
 )
 
 install_data(
   [ 'TEMPLATE.qemu', 'TEMPLATE.lxc' ],
-  install_dir: apparmor_dir / 'libvirt',
+  install_dir: install_prefix + apparmor_dir / 'libvirt',
 )
 
 install_data(
   'usr.lib.libvirt.virt-aa-helper.local',
-  install_dir: apparmor_dir / 'local',
+  install_dir: install_prefix + apparmor_dir / 'local',
   rename: 'usr.lib.libvirt.virt-aa-helper',
 )
diff --git a/src/storage/meson.build b/src/storage/meson.build
index 26e7ff1a1a..ad5c6eddc3 100644
--- a/src/storage/meson.build
+++ b/src/storage/meson.build
@@ -127,9 +127,9 @@ if conf.has('WITH_STORAGE')
   }
 
   virt_install_dirs += [
-    confdir / 'storage',
-    confdir / 'storage' / 'autostart',
-    runstatedir / 'libvirt' / 'storage',
+    install_prefix + confdir / 'storage',
+    install_prefix + confdir / 'storage' / 'autostart',
+    install_prefix + runstatedir / 'libvirt' / 'storage',
   ]
 endif
 
diff --git a/tools/meson.build b/tools/meson.build
index f4b4a16c29..059c73a955 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -120,7 +120,7 @@ if conf.has('WITH_LOGIN_SHELL')
     install_rpath: libvirt_rpath,
   )
 
-  install_data('virt-login-shell.conf', install_dir: sysconfdir / 'libvirt')
+  install_data('virt-login-shell.conf', install_dir: install_prefix + sysconfdir / 'libvirt')
 endif
 
 if host_machine.system() == 'windows'
-- 
2.35.1