File: meson.build

package info (click to toggle)
fwupd 2.0.20-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 32,504 kB
  • sloc: ansic: 277,388; python: 11,485; xml: 9,493; sh: 1,625; makefile: 167; cpp: 19; asm: 11; javascript: 9
file content (220 lines) | stat: -rw-r--r-- 5,774 bytes parent folder | download | duplicates (2)
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
subdir('bios-settings.d')
subdir('pki')
subdir('remotes.d')
subdir('icons')

if get_option('bash_completion')
  subdir('bash-completion')
endif

if get_option('fish_completion')
  subdir('fish-completion')
endif

if get_option('tests')
  subdir('device-tests')
endif

if build_daemon
  subdir('motd')
endif

if get_option('tests')
  if build_daemon
    subdir('tests')
  endif
endif

if build_standalone
  install_data(
    ['fwupd.conf'],
    install_tag: 'runtime',
    install_dir: join_paths(sysconfdir, 'fwupd'),
    install_mode: 'rw-r-----',
  )
  plugin_quirks += files('cfi.quirk', 'ds20.quirk', 'power.quirk', 'vendors.quirk')
endif

if get_option('metainfo')
  custom_target(
    'metainfo',
    input: 'org.freedesktop.fwupd.metainfo.xml',
    output: 'org.freedesktop.fwupd.metainfo.xml',
    command: [generate_metainfo, '@INPUT@', '@OUTPUT@'],
    install: true,
    install_tag: 'doc',
    install_dir: join_paths(datadir, 'metainfo'),
  )
  install_data(
    ['org.freedesktop.fwupd.svg'],
    install_tag: 'doc',
    install_dir: join_paths(datadir, 'icons', 'hicolor', 'scalable', 'apps'),
  )
endif

if build_daemon
  install_data(
    ['org.freedesktop.fwupd.conf'],
    install_tag: 'runtime',
    install_dir: join_paths(datadir, 'dbus-1', 'system.d'),
  )

  build_conf = configuration_data()
  build_conf.set('libexecdir', libexecdir)

  if libsystemd.found()
    build_conf.set('bindir', bindir)
    build_conf.set('datadir', datadir)
    build_conf.set('localstatedir', localstatedir)
    build_conf.set('systemd_service', 'SystemdService=fwupd.service')
    rw_directories = []
    if allow_uefi
      rw_directories += [
        '-/boot/efi',
        '-/boot/EFI',
        '-/boot/grub',
        '-/efi/EFI',
        '-/sys/firmware/efi/efivars',
      ]
    endif

    # not using ConfigurationDirectory further down
    if get_option('prefix') != '/usr'
      rw_directories += join_paths(sysconfdir, 'fwupd')
    endif

    dynamic_options = []
    dynamic_options += ['ReadWritePaths=' + ' '.join(rw_directories)]
    #pull configuration/cache/state from /etc and /var only if prefix is /usr
    if get_option('prefix') == '/usr'
      dynamic_options += 'ConfigurationDirectory=fwupd'
      dynamic_options += 'StateDirectory=fwupd'
      dynamic_options += 'CacheDirectory=fwupd'
    endif

    device_allows = [
      'block-sd',
      'char-aux',
      'char-cpu/*',
      'char-drm',
      'char-gpiochip',
      'char-hidraw',
      'char-mei',
      'char-mtd',
      'char-tpm',
      'char-usb',
      'char-usb_device',
    ]
    if allow_flashrom
      device_allows += ['char-mem']
    endif
    if cc.has_header(
      'linux/nvme_ioctl.h',
      required: false,
    )
      device_allows += ['char-nvme']
    endif
    if allow_uefi
      # for BLKSSZGET
      device_allows += ['block-blkext']
    endif
    if get_option('plugin_modem_manager').allowed()
      device_allows += ['char-wwan_port']
    endif
    foreach device_allow : device_allows
      dynamic_options += ['DeviceAllow=' + device_allow + ' rw']
    endforeach

    # allow-list, see `systemd-analyze syscall-filter` for what each group adds
    syscall_filter = [
      '@basic-io',
      '@file-system',
      '@io-event',
      '@ipc',
      '@network-io',
      '@process',
      '@sync',
      '@signal', # for g_local_file_monitor_new
      '@timer', # for usbi_create_timer
      '@chown', # for sqlite3Step
      'ioctl',
      'uname',
      'fadvise64',
      'sysinfo', # for sysconf
      'madvise', # for mtrim
      'mremap', # for g_realloc
      'splice',
      'vmsplice',
      'copy_file_range', # for g_file_copy
    ]
    if allow_flashrom
      syscall_filter += ['@raw-io']
    endif
    dynamic_options += ['SystemCallFilter=' + ' '.join(syscall_filter)]
    if supported_build
      dynamic_options += ['Environment="FWUPD_SYSCALL_FILTER=systemd"']
      dynamic_options += ['SystemCallErrorNumber=EPERM']
    else
      # to debug what additional syscalls are required, we set SystemCallErrorNumber=SIGSYS
      # and then can do `coredumpctl debug` and get the syscall number with `(gdb) p $rax`
      dynamic_options += ['SystemCallErrorNumber=SIGSYS']
    endif
    if not supported_build
      dynamic_options += ['Environment="G_DEBUG=fatal-criticals"']
    endif
    build_conf.set('dynamic_options', '\n'.join(dynamic_options))
    build_conf.set('motd_dir', motd_dir)

    # replace @dynamic_options@
    configure_file(
      input: 'fwupd.service.in',
      output: 'fwupd.service',
      configuration: build_conf,
      install: true,
      install_tag: 'runtime',
      install_dir: systemdunitdir,
    )

    # for various plugins
    install_data(
      ['fwupd-i2c.conf'],
      install_tag: 'runtime',
      install_dir: systemd_modules_load_dir,
    )

    # for activation
    configure_file(
      input: 'fwupd.shutdown.in',
      output: 'fwupd.shutdown',
      configuration: build_conf,
      install: true,
      install_tag: 'runtime',
      install_dir: systemd_shutdown_dir,
    )
  else
    build_conf.set('systemd_service', '')
  endif

  configure_file(
    input: 'org.freedesktop.fwupd.service.in',
    output: 'org.freedesktop.fwupd.service',
    configuration: build_conf,
    install: true,
    install_tag: 'runtime',
    install_dir: join_paths(datadir, 'dbus-1', 'system-services'),
  )

  if launchctl.found()
    con2 = configuration_data()
    con2.set('libexecdir', libexecdir)
    con2.set('dbus_socket_address', get_option('dbus_socket_address'))
    configure_file(
      input: 'org.freedesktop.fwupd.plist',
      output: 'org.freedesktop.fwupd.plist',
      configuration: con2,
      install_tag: 'runtime',
      install_dir: get_option('launchd_agent_dir'),
    )
  endif

endif