diff --git a/Makefile.am b/Makefile.am index 78bd507c14..c25dfb6882 100644 --- a/Makefile.am +++ b/Makefile.am @@ -200,6 +200,24 @@ EXTRA_DIST += README.md EXTRA_DIST += flatpak.png +EXTRA_DIST += \ + completion/meson.build \ + env.d/meson.build \ + meson.build \ + meson_options.txt \ + po/meson.build \ + profile/meson.build \ + scripts/meson.build \ + subprojects/bubblewrap/meson.build \ + subprojects/bubblewrap/meson_options.txt \ + subprojects/dbus-proxy/meson.build \ + subprojects/dbus-proxy/meson_options.txt \ + subprojects/libglnx/meson.build \ + subprojects/libglnx/meson_options.txt \ + subprojects/libglnx/tests/meson.build \ + triggers/meson.build \ + $(NULL) + AM_DISTCHECK_CONFIGURE_FLAGS = \ --enable-documentation \ --disable-maintainer-mode \ diff --git a/app/Makefile.am.inc b/app/Makefile.am.inc index b3b6a281d8..8af1840a75 100644 --- a/app/Makefile.am.inc +++ b/app/Makefile.am.inc @@ -2,6 +2,7 @@ bin_PROGRAMS += \ flatpak \ $(NULL) +EXTRA_DIST += app/meson.build EXTRA_DIST += app/parse-datetime.y flatpak_dbus_built_sources = app/flatpak-permission-dbus-generated.c app/flatpak-permission-dbus-generated.h diff --git a/app/meson.build b/app/meson.build new file mode 100644 index 0000000000..14b20f6217 --- /dev/null +++ b/app/meson.build @@ -0,0 +1,142 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +sources = [ + 'flatpak-builtins-utils.c', + 'flatpak-table-printer.c', +] + +parse_datetime = custom_target( + 'parse-datetime.c', + input : [ + 'parse-datetime.y', + ], + output : [ + 'parse-datetime.c', + ], + build_by_default : true, + command : [ + bison, + '@INPUT@', + '-o', '@OUTPUT@', + ], +) + +flatpak_permission_gdbus = gnome.gdbus_codegen( + 'flatpak-permission-dbus-generated', + sources: [ + '../data/org.freedesktop.impl.portal.PermissionStore.xml', + ], + interface_prefix : 'org.freedesktop.impl.portal', + namespace : 'XdpDbus', +) + +libflatpak_app = static_library( + 'libflatpak-app', + sources : sources + [parse_datetime[0]], + dependencies : base_deps + [ + appstream_dep, + json_glib_dep, + libglnx_dep, + libostree_dep, + libsystemd_dep, + polkit_agent_dep, + ], + include_directories : [ + common_include_directories, + include_directories('.'), + ], + install : false, +) +libflatpak_app_dep = declare_dependency( + dependencies : [ + base_deps, + appstream_dep, + json_glib_dep, + libglnx_dep, + libostree_dep, + libsystemd_dep, + polkit_agent_dep, + ], + include_directories : [ + common_include_directories, + include_directories('.'), + ], + link_with : [ + libflatpak_app, + ], +) + +sources = [ + 'flatpak-builtins-build-bundle.c', + 'flatpak-builtins-build-commit-from.c', + 'flatpak-builtins-build-export.c', + 'flatpak-builtins-build-finish.c', + 'flatpak-builtins-build-import-bundle.c', + 'flatpak-builtins-build-init.c', + 'flatpak-builtins-build-sign.c', + 'flatpak-builtins-build-update-repo.c', + 'flatpak-builtins-build.c', + 'flatpak-builtins-config.c', + 'flatpak-builtins-create-usb.c', + 'flatpak-builtins-document-export.c', + 'flatpak-builtins-document-info.c', + 'flatpak-builtins-document-list.c', + 'flatpak-builtins-document-unexport.c', + 'flatpak-builtins-enter.c', + 'flatpak-builtins-history.c', + 'flatpak-builtins-info.c', + 'flatpak-builtins-install.c', + 'flatpak-builtins-kill.c', + 'flatpak-builtins-list.c', + 'flatpak-builtins-make-current.c', + 'flatpak-builtins-mask.c', + 'flatpak-builtins-override.c', + 'flatpak-builtins-permission-list.c', + 'flatpak-builtins-permission-remove.c', + 'flatpak-builtins-permission-reset.c', + 'flatpak-builtins-permission-set.c', + 'flatpak-builtins-permission-show.c', + 'flatpak-builtins-pin.c', + 'flatpak-builtins-ps.c', + 'flatpak-builtins-remote-add.c', + 'flatpak-builtins-remote-delete.c', + 'flatpak-builtins-remote-info.c', + 'flatpak-builtins-remote-list.c', + 'flatpak-builtins-remote-ls.c', + 'flatpak-builtins-remote-modify.c', + 'flatpak-builtins-repair.c', + 'flatpak-builtins-repo.c', + 'flatpak-builtins-run.c', + 'flatpak-builtins-search.c', + 'flatpak-builtins-uninstall.c', + 'flatpak-builtins-update.c', + 'flatpak-cli-transaction.c', + 'flatpak-complete.c', + 'flatpak-main.c', + 'flatpak-quiet-transaction.c', +] + +if build_system_helper + sources += [ + 'flatpak-polkit-agent-text-listener.c', + ] +endif + +flatpak_exe = executable( + 'flatpak', + dependencies : base_deps + [ + appstream_dep, + json_glib_dep, + libflatpak_app_dep, + libflatpak_common_dep, + libflatpak_common_base_dep, + libglnx_dep, + libostree_dep, + libsystemd_dep, + polkit_agent_dep, + ], + install : true, + install_dir : get_option('bindir'), + sources : sources + flatpak_gdbus + flatpak_permission_gdbus, +) diff --git a/common/Makefile.am.inc b/common/Makefile.am.inc index 7d7bf28b56..aa4dc6e242 100644 --- a/common/Makefile.am.inc +++ b/common/Makefile.am.inc @@ -36,6 +36,7 @@ common/flatpak-enum-types.c: $(flatpakinclude_HEADERS) common/flatpak-enum-types common/flatpak-enum-types.c.tmp && mv common/flatpak-enum-types.c.tmp common/flatpak-enum-types.c EXTRA_DIST += common/flatpak-enum-types.c.template common/flatpak-enum-types.h.template +EXTRA_DIST += common/meson.build common/flatpak-dbus-generated.c: data/org.freedesktop.Flatpak.xml data/org.freedesktop.Flatpak.Authenticator.xml Makefile mkdir -p $(builddir)/common diff --git a/common/meson.build b/common/meson.build new file mode 100644 index 0000000000..b87f22acfe --- /dev/null +++ b/common/meson.build @@ -0,0 +1,263 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +public_headers = [ + 'flatpak-bundle-ref.h', + 'flatpak-error.h', + 'flatpak-installation.h', + 'flatpak-installed-ref.h', + 'flatpak-instance.h', + 'flatpak-portal-error.h', + 'flatpak-ref.h', + 'flatpak-related-ref.h', + 'flatpak-remote-ref.h', + 'flatpak-remote.h', + 'flatpak-transaction.h', + 'flatpak.h', +] + +install_headers( + public_headers, + subdir : 'flatpak', +) + +flatpak_version_macros = configure_file( + input : 'flatpak-version-macros.h.in', + output : 'flatpak-version-macros.h', + configuration : { + 'FLATPAK_MAJOR_VERSION' : flatpak_major_version, + 'FLATPAK_MINOR_VERSION' : flatpak_minor_version, + 'FLATPAK_MICRO_VERSION' : flatpak_micro_version, + }, + install_dir : get_option('includedir') / 'flatpak', +) + +# TODO: After the Autotools build system is removed, we can probably +# switch this to gnome.mkenums_simple, but it's easier to keep them +# consistent if we use the same templates +enums = gnome.mkenums( + 'flatpak-enum-types', + c_template : 'flatpak-enum-types.c.template', + h_template : 'flatpak-enum-types.h.template', + install_dir : get_option('includedir') / 'flatpak', + install_header : true, + sources : public_headers, +) + +flatpak_gdbus = gnome.gdbus_codegen( + 'flatpak-dbus-generated', + sources : [ + '../data/org.freedesktop.Flatpak.xml', + '../data/org.freedesktop.Flatpak.Authenticator.xml', + ], + interface_prefix : 'org.freedesktop.Flatpak.', + namespace : 'Flatpak', +) + +flatpak_document_gdbus = gnome.gdbus_codegen( + 'flatpak-document-dbus-generated', + sources: [ + '../data/org.freedesktop.portal.Documents.xml', + ], + interface_prefix : 'org.freedesktop.portal.', + namespace : 'XdpDbus', +) + +systemd_gdbus = gnome.gdbus_codegen( + 'flatpak-systemd-dbus-generated', + sources: [ + '../data/org.freedesktop.systemd1.xml', + ], + interface_prefix : 'org.freedesktop.systemd1.', + namespace : 'Systemd', +) + +variant_schema_compiler_command = [ + global_source_root / 'subprojects' / 'variant-schema-compiler' / 'variant-schema-compiler', +] + +if get_option('internal_checks') + variant_schema_compiler_command += ['--internal-validation'] +endif + +variant_schema_compiler_command += [ + '--outfile', '@OUTPUT0@', + '--outfile-header', '@OUTPUT1@', + '--prefix', 'var', + '@INPUT@', +] + +flatpak_variant = custom_target( + 'flatpak-variant-private.h', + input : [ + '../data/flatpak-variants.gv', + ], + output : [ + 'flatpak-variant-impl-private.h', + 'flatpak-variant-private.h', + ], + build_by_default : true, + command : variant_schema_compiler_command, +) + +built_headers = [ + enums[1], + flatpak_version_macros, + flatpak_gdbus[1], + flatpak_document_gdbus[1], + systemd_gdbus[1], + flatpak_variant[1], +] + +libflatpak_common_base = static_library( + 'flatpak-common-base', + dependencies : base_deps + [libglnx_dep], + gnu_symbol_visibility : 'hidden', + include_directories : [common_include_directories], + install : false, + sources : [ + 'flatpak-utils-base.c', + 'flatpak-utils-base-private.h', + ] + flatpak_gdbus + flatpak_document_gdbus, +) +libflatpak_common_base_dep = declare_dependency( + dependencies : base_deps + [libglnx_dep], + include_directories : [common_include_directories], + link_with : [ + libflatpak_common_base, + ], + sources : built_headers, +) + +sources = [ + 'flatpak-appdata.c', + 'flatpak-auth.c', + 'flatpak-bundle-ref.c', + 'flatpak-bwrap.c', + 'flatpak-chain-input-stream.c', + 'flatpak-context.c', + 'flatpak-dir.c', + 'flatpak-error.c', + 'flatpak-exports.c', + 'flatpak-installation.c', + 'flatpak-installed-ref.c', + 'flatpak-instance.c', + 'flatpak-json-oci.c', + 'flatpak-json.c', + 'flatpak-oci-registry.c', + 'flatpak-portal-error.c', + 'flatpak-progress.c', + 'flatpak-prune.c', + 'flatpak-ref-utils.c', + 'flatpak-ref.c', + 'flatpak-related-ref.c', + 'flatpak-remote-ref.c', + 'flatpak-remote.c', + 'flatpak-run.c', + 'flatpak-transaction.c', + 'flatpak-utils-http.c', + 'flatpak-utils.c', + 'flatpak-uri.c', + 'flatpak-zstd-decompressor.c', +] + +if malcontent_dep.found() + sources += ['flatpak-parental-controls.c'] +endif + +libflatpak_common = static_library( + 'flatpak-common', + dependencies : [ + base_deps, + dconf_dep, + gpgme_dep, + json_glib_dep, + libarchive_dep, + libcurl_dep, + libflatpak_common_base_dep, + libglnx_dep, + libostree_dep, + libseccomp_dep, + libsoup_dep, + libsystemd_dep, + libxml_dep, + libzstd_dep, + malcontent_dep, + polkit_agent_dep, + xau_dep, + ], + gnu_symbol_visibility : 'hidden', + include_directories : [common_include_directories], + install : false, + sources : enums + public_headers + sources + systemd_gdbus + [ + flatpak_variant[0], + flatpak_variant[1], + ], +) +libflatpak_common_dep = declare_dependency( + dependencies : [ + base_deps, + libflatpak_common_base_dep, + libglnx_dep, + ], + include_directories : [common_include_directories], + link_with : [ + libflatpak_common, + ], + sources : built_headers, +) + +libflatpak = library( + 'flatpak', + 'flatpak.c', + gnu_symbol_visibility : 'hidden', + include_directories : [common_include_directories], + install : true, + link_args : ['-export-dynamic'], + link_whole : [ + libflatpak_common_base, + libflatpak_common, + ], + soversion : '0', + version : '0.@0@.0'.format(flatpak_binary_age), +) +libflatpak_dep = declare_dependency( + dependencies : base_deps, + include_directories : [common_include_directories], + link_with : [ + libflatpak, + ], + sources : built_headers, +) + +test_libflatpak = executable( + 'test-libflatpak', + 'test-lib.c', + dependencies : base_deps + [libglnx_dep, libflatpak_dep], + install : false, +) + +if gir_dep.found() + gnome.generate_gir( + libflatpak, + export_packages : 'flatpak', + extra_args : [ + '-DFLATPAK_EXTERN=__attribute__((visibility("default"))) extern', + '-DFLATPAK_COMPILATION=1', + '--warn-all', + ], + header : 'flatpak.h', + identifier_prefix : 'Flatpak', + includes : ['GObject-2.0', 'Gio-2.0'], + install : true, + namespace : 'Flatpak', + nsversion : '1.0', + sources : [ + enums, + flatpak_version_macros, + public_headers, + sources, + ], + symbol_prefix : 'flatpak', + ) +endif diff --git a/completion/meson.build b/completion/meson.build new file mode 100644 index 0000000000..05ae43fa62 --- /dev/null +++ b/completion/meson.build @@ -0,0 +1,15 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +install_data( + 'flatpak', + install_dir : get_option('datadir') / 'bash-completion' / 'completions', +) +install_data( + '_flatpak', + install_dir : get_option('datadir') / 'zsh' / 'site-functions', +) +install_data( + 'flatpak.fish', + install_dir : get_option('datadir') / 'fish' / 'vendor_completions.d', +) diff --git a/data/Makefile.am.inc b/data/Makefile.am.inc index 3e8643b85d..8d206cd07a 100644 --- a/data/Makefile.am.inc +++ b/data/Makefile.am.inc @@ -6,6 +6,7 @@ introspection_DATA = \ $(NULL) EXTRA_DIST += \ + data/meson.build \ data/org.freedesktop.portal.Documents.xml \ data/org.freedesktop.impl.portal.PermissionStore.xml \ data/org.freedesktop.systemd1.xml \ diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 0000000000..b08e147040 --- /dev/null +++ b/data/meson.build @@ -0,0 +1,9 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +install_data( + 'org.freedesktop.Flatpak.xml', + 'org.freedesktop.Flatpak.Authenticator.xml', + 'org.freedesktop.portal.Flatpak.xml', + install_dir : get_option('datadir') / 'dbus-1' / 'interfaces', +) diff --git a/doc/Makefile.am b/doc/Makefile.am index aa3d186b7c..7ef61bdfe7 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -87,6 +87,7 @@ EXTRA_DIST = \ $(xml_files) \ docbook.css \ flatpak-docs.xml.in \ + meson.build \ xmlto-config.xsl \ $(NULL) diff --git a/doc/meson.build b/doc/meson.build new file mode 100644 index 0000000000..5a935758e2 --- /dev/null +++ b/doc/meson.build @@ -0,0 +1,133 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +if build_gtk_doc + subdir('reference') +endif + +xsltproc_flags = [ + '--nonet', + '--stringparam', 'man.output.quietly', '1', + '--stringparam', 'funcsynopsis.style', 'ansi', + '--stringparam', 'man.th.extra1.suppress', '1', + '--stringparam', 'man.authors.section.enabled', '0', + '--stringparam', 'man.copyright.section.enabled', '0', +] + +man1 = [ + 'flatpak', + 'flatpak-remotes', + 'flatpak-remote-add', + 'flatpak-remote-delete', + 'flatpak-remote-modify', + 'flatpak-remote-ls', + 'flatpak-remote-info', + 'flatpak-install', + 'flatpak-config', + 'flatpak-update', + 'flatpak-uninstall', + 'flatpak-mask', + 'flatpak-pin', + 'flatpak-list', + 'flatpak-info', + 'flatpak-make-current', + 'flatpak-run', + 'flatpak-override', + 'flatpak-enter', + 'flatpak-ps', + 'flatpak-document-export', + 'flatpak-document-unexport', + 'flatpak-document-info', + 'flatpak-documents', + 'flatpak-permission-remove', + 'flatpak-permissions', + 'flatpak-permission-show', + 'flatpak-permission-reset', + 'flatpak-permission-set', + 'flatpak-build-init', + 'flatpak-build', + 'flatpak-build-bundle', + 'flatpak-build-import-bundle', + 'flatpak-build-finish', + 'flatpak-build-export', + 'flatpak-build-update-repo', + 'flatpak-build-sign', + 'flatpak-build-commit-from', + 'flatpak-repo', + 'flatpak-search', + 'flatpak-create-usb', + 'flatpak-repair', + 'flatpak-kill', + 'flatpak-history', + 'flatpak-spawn', +] + +man5 = [ + 'flatpak-metadata', + 'flatpak-flatpakrepo', + 'flatpak-flatpakref', + 'flatpak-remote', + 'flatpak-installation', +] + +xml_files = [] + +foreach pair : [[man1, '1'], [man5, '5']] + pages = pair[0] + section = pair[1] + + foreach man : pages + xml_files += [man + '.xml'] + + if build_man_pages + custom_target( + man + '.' + section, + input : [man + '.xml'], + output : [man + '.' + section], + command : [ + xsltproc, + '-o', '@OUTPUT@', + ] + xsltproc_flags + [ + manpages_xsl, + '@INPUT@', + ], + build_by_default : true, + install : true, + install_dir : get_option('mandir') / ('man' + section), + ) + endif + endforeach +endforeach + +if xmlto.found() + cdata = configuration_data() + cdata.set('VERSION', meson.project_version()) + cdata.set('srcdir', meson.current_source_dir()) + flatpak_docs_xml = configure_file( + input : 'flatpak-docs.xml.in', + output : 'flatpak-docs.xml', + configuration : cdata, + ) + custom_target( + 'flatpak-docs.html', + input : [ + flatpak_docs_xml, + 'xmlto-config.xsl', + ], + output : ['flatpak-docs.html'], + depend_files : xml_files, + command : [ + xmlto, + '-o', meson.current_build_dir(), + ] + get_option('xmlto_flags') + [ + '--skip-validation', + 'xhtml-nochunks', + '-m', '@INPUT1@', + '@INPUT0@', + ], + build_by_default : true, + install : true, + install_dir : docdir, + ) + install_data('docbook.css', install_dir : docdir) +endif diff --git a/doc/reference/Makefile.am b/doc/reference/Makefile.am index 6aaa345123..e8f5b30f58 100644 --- a/doc/reference/Makefile.am +++ b/doc/reference/Makefile.am @@ -78,6 +78,7 @@ include $(top_srcdir)/gtk-doc.make CLEANFILES += $(xml_files) +EXTRA_DIST += meson.build EXTRA_DIST += version.xml.in if ENABLE_GTK_DOC_CHECK diff --git a/doc/reference/meson.build b/doc/reference/meson.build new file mode 100644 index 0000000000..a881b0cb6b --- /dev/null +++ b/doc/reference/meson.build @@ -0,0 +1,74 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +cdata = configuration_data() +cdata.set('FLATPAK_MAJOR_VERSION', flatpak_major_version) +cdata.set('FLATPAK_MINOR_VERSION', flatpak_minor_version) +cdata.set('FLATPAK_MICRO_VERSION', flatpak_micro_version) +configure_file( + configuration : cdata, + input : 'version.xml.in', + output : 'version.xml', +) + +# We're really only doing this to generate the Docbook XML. +doc_gdbus = gnome.gdbus_codegen( + 'doc-dbus-generated', + sources : [ + project_source_root / 'data/org.freedesktop.Flatpak.Authenticator.xml', + project_source_root / 'data/org.freedesktop.Flatpak.xml', + project_source_root / 'data/org.freedesktop.impl.portal.PermissionStore.xml', + project_source_root / 'data/org.freedesktop.portal.Documents.xml', + project_source_root / 'data/org.freedesktop.portal.Flatpak.xml', + ], + namespace : 'doc', + docbook : 'dbus', +) + +gnome.gtkdoc( + 'flatpak', + main_xml : 'libflatpak-docs.xml', + namespace : 'flatpak', + src_dir : [ + project_build_root / 'common', + project_source_root / 'common', + ], + content_files : doc_gdbus[2], + dependencies : base_deps + [libflatpak_dep], + ignore_headers : [ + 'valgrind-private.h', + 'flatpak-bwrap-private.h', + 'flatpak-chain-input-stream-private.h', + 'flatpak-common-types-private.h', + 'flatpak-context-private.h', + 'flatpak-dbus-generated.h', + 'flatpak-dir-private.h', + 'flatpak-document-dbus-generated.h', + 'flatpak-enum-types.h', + 'flatpak-exports-private.h', + 'flatpak-installed-ref-private.h', + 'flatpak-json-oci-private.h', + 'flatpak-json-private.h', + 'flatpak-oci-registry-private.h', + 'flatpak-progress-private.h', + 'flatpak-remote-private.h', + 'flatpak-remote-ref-private.h', + 'flatpak-run-private.h', + 'flatpak-systemd-dbus-generated.h', + 'flatpak-installation-private.h', + 'flatpak-transaction-private.h', + 'flatpak-utils-private.h', + 'flatpak-utils-base-private.h', + 'flatpak-utils-http-private.h', + 'flatpak-instance-private.h', + 'flatpak-auth-private.h', + 'flatpak-parental-controls-private.h', + 'flatpak-appdata-private.h', + 'flatpak-zstd-decompressor-private.h', + ], + install : true, + scan_args : [ + '--ignore-decorators=FLATPAK_EXTERN', + '--rebuild-types', + ], +) diff --git a/env.d/meson.build b/env.d/meson.build new file mode 100644 index 0000000000..0ecf17a8cf --- /dev/null +++ b/env.d/meson.build @@ -0,0 +1,23 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +install_data( + '60-flatpak', + install_dir : get_option('systemduserenvgendir'), +) +install_data( + '60-flatpak-system-only', + install_dir : get_option('systemdsystemenvgendir'), +) + +if get_option('gdm_env_file') + conf_data = configuration_data() + conf_data.set('localstatedir', get_option('prefix') / get_option('localstatedir')) + conf_data.set('sysconfdir', get_option('prefix') / get_option('sysconfdir')) + configure_file( + input : 'flatpak.env.in', + output : 'flatpak.env', + configuration : conf_data, + install_dir : get_option('datadir') / 'gdm' / 'env.d', + ) +endif diff --git a/icon-validator/Makefile.am.inc b/icon-validator/Makefile.am.inc index a0f5b5e827..3282e42c48 100644 --- a/icon-validator/Makefile.am.inc +++ b/icon-validator/Makefile.am.inc @@ -1,3 +1,5 @@ +EXTRA_DIST += icon-validator/meson.build + libexec_PROGRAMS += \ flatpak-validate-icon \ $(NULL) diff --git a/icon-validator/meson.build b/icon-validator/meson.build new file mode 100644 index 0000000000..0745d17ed1 --- /dev/null +++ b/icon-validator/meson.build @@ -0,0 +1,12 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +executable( + 'flatpak-validate-icon', + install : true, + install_dir : get_option('libexecdir'), + dependencies : [ + gdk_pixbuf_dep, + ], + sources : ['validate-icon.c'], +) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000000..8b94682ac0 --- /dev/null +++ b/meson.build @@ -0,0 +1,587 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +project( + 'Flatpak', + 'c', + version : '1.14.99', + default_options: [ + 'warning_level=2', + ], + meson_version : '>=0.49.0', +) + +flatpak_major_version = 1 +flatpak_minor_version = 14 +flatpak_micro_version = 99 +flatpak_extra_version = '' + +flatpak_interface_age = 0 +flatpak_binary_age = ( + 10000 * flatpak_major_version + + 100 * flatpak_minor_version + + flatpak_micro_version +) + +if '@0@.@1@.@2@@3@'.format( + flatpak_major_version, + flatpak_minor_version, + flatpak_micro_version, + flatpak_extra_version, +) != meson.project_version() + error('Project version does not match parts') +endif + +required_glib = '2.46' +required_bwrap = '0.5.0' +required_dbus_proxy = '0.1.0' +required_libostree = '2020.8' + +gnome = import('gnome') +i18n = import('i18n') +pkgconfig = import('pkgconfig') + +# TODO: We can replace these with meson.project_foo_root() +# when we depend on meson 0.56 +project_build_root = meson.current_build_dir() +project_source_root = meson.current_source_dir() + +if meson.version().version_compare('>=0.58') + global_source_root = meson.global_source_root() +else + global_source_root = meson.source_root() +endif + +if meson.version().version_compare('>=0.55.0') + can_run_host_binaries = meson.can_run_host_binaries() +else + can_run_host_binaries = meson.has_exe_wrapper() or not meson.is_cross_build() +endif + +if meson.version().version_compare('>=0.53') + fs = import('fs') +endif + +cc = meson.get_compiler('c') +add_project_arguments('-include', 'config.h', language : 'c') +common_include_directories = include_directories( + '.', + 'common', +) + +# Keep this in sync with ostree, except remove -Wall (part of Meson +# warning_level 2) and -Werror=declaration-after-statement +add_project_arguments( + cc.get_supported_arguments([ + '-Werror=shadow', + '-Werror=empty-body', + '-Werror=strict-prototypes', + '-Werror=missing-prototypes', + '-Werror=implicit-function-declaration', + '-Werror=pointer-arith', + '-Werror=init-self', + '-Werror=missing-declarations', + '-Werror=return-type', + '-Werror=overflow', + '-Werror=int-conversion', + '-Werror=parenthesis', + '-Werror=incompatible-pointer-types', + '-Werror=misleading-indentation', + '-Werror=missing-include-dirs', + + # Meson warning_level=2 would do this, but we are not fully + # signedness-safe yet + '-Wno-sign-compare', + '-Wno-error=sign-compare', + + # Meson warning_level=2 would do this + '-Wno-cast-function-type', + '-Wno-error=cast-function-type', + + # Deliberately not warning about these, ability to zero-initialize + # a struct is a feature + '-Wno-missing-field-initializers', + '-Wno-error=missing-field-initializers', + + # Deliberately not warning about these + '-Wno-unused-parameter', + '-Wno-error=unused-parameter', + ]), + language : 'c', +) +# Flatpak is Linux-specific, so for now we assume that -fvisibility=hidden +# is always supported +add_project_arguments('-fvisibility=hidden', language : 'c') + +if ( + cc.has_argument('-Werror=format=2') + and cc.has_argument('-Werror=format-security') + and cc.has_argument('-Werror=format-nonliteral') +) + add_project_arguments([ + '-Werror=format=2', + '-Werror=format-security', + '-Werror=format-nonliteral', + ], language : 'c') +endif + +dbus_config_dir = get_option('dbus_config_dir') +if dbus_config_dir == '' + dbus_config_dir = get_option('sysconfdir') / 'dbus-1' / 'system.d' +endif + +dbus_service_dir = get_option('dbus_service_dir') +if dbus_service_dir == '' + dbus_service_dir = get_option('datadir') / 'dbus-1' / 'services' +endif + +profile_dir = get_option('profile_dir') +if profile_dir == '' + profile_dir = get_option('sysconfdir') / 'profile.d' +endif + +system_install_dir = get_option('system_install_dir') +if system_install_dir == '' + system_install_dir = get_option('localstatedir') / 'lib' / 'flatpak' +endif + +docdir = get_option('docdir') +if docdir == '' + docdir = get_option('datadir') / 'doc' / 'flatpak' +endif + +if not cc.check_header('sys/xattr.h') + error('You must have sys/xattr.h from glibc') +endif + +libglnx = subproject( + 'libglnx', + default_options : [ + 'warning_level=1', + 'tests=false', + ], +) + +not_found = dependency('', required : false) +threads_dep = dependency('threads') +bison = find_program('bison') +libcap_dep = dependency('libcap') +libglnx_dep = libglnx.get_variable('libglnx_dep') +libglnx_testlib_dep = libglnx.get_variable('libglnx_testlib_dep') +libarchive_dep = dependency('libarchive', version : '>=2.8.0') +glib_dep = dependency('glib-2.0', version : '>=' + required_glib) +gio_dep = dependency('gio-2.0', version : '>=' + required_glib) +gio_unix_dep = dependency('gio-unix-2.0', version : '>=' + required_glib) + +libcurl_dep = not_found +libsoup_dep = not_found + +if get_option('http_backend') == 'soup' + libsoup_dep = dependency('libsoup-2.4') +else + libcurl_dep = dependency('libcurl', version : '>=7.29.0') +endif + +libxml_dep = dependency('libxml-2.0', version : '>=2.4') +libzstd_dep = dependency('libzstd', version : '>=0.8.1', required : get_option('libzstd')) +dconf_dep = dependency('dconf', version : '>=0.26', required : get_option('dconf')) +libsystemd_dep = dependency('libsystemd', required : get_option('systemd')) +malcontent_dep = dependency('malcontent-0', required : get_option('malcontent')) +polkit_agent_dep = dependency('polkit-agent-1', version : '>=0.98', required : get_option('system_helper')) +build_system_helper = polkit_agent_dep.found() + +fuse_dep = dependency('fuse3', version : '>=3.1.1', required : false) + +if fuse_dep.found() + fuse_api = 31 +else + fuse_dep = dependency('fuse', version : '>=2.9.2') + fuse_api = 26 +endif + +xau_dep = dependency('xau', required : get_option('xauth')) +libostree_dep = dependency('ostree-1', version : '>=' + required_libostree) +json_glib_dep = dependency('json-glib-1.0') +appstream_dep = dependency('appstream', version : '>=0.12.0') +gdk_pixbuf_dep = dependency('gdk-pixbuf-2.0') +libseccomp_dep = dependency('libseccomp', required : get_option('seccomp')) +gir_dep = dependency('gobject-introspection-1.0', version : '>=1.40.0', required : get_option('gir')) +gtkdoc_dep = dependency('gtk-doc', required : get_option('gtkdoc')) +build_gtk_doc = gtkdoc_dep.found() + +base_deps = [glib_dep, gio_dep, gio_unix_dep] + +if meson.version().version_compare('>=0.60.0') + gpgme_dep = dependency('gpgme-pthread', 'gpgme', version : '>=1.1.8') +elif meson.version().version_compare('>=0.51.0') + gpgme_dep = dependency('gpgme-pthread', version : '>=1.1.8', required : false) + if not gpgme_dep.found() + gpgme_dep = dependency('gpgme', version : '>=1.1.8') + endif +else + # Meson < 0.51.0 couldn't detect older versions of libgpgme that didn't + # have a .pc file, so detect it the hard way + gpgme_config = find_program('gpgme-config') + result = run_command( + gpgme_config, '--version', + capture : true, + check : true, + ) + if result.stdout().version_compare('<1.1.8') + error('gpgme >= 1.1.8 is required') + endif + ldflags = [] + libs = [] + cflags = run_command( + gpgme_config, '--cflags', + capture : true, + check : true, + ).stdout().split() + foreach word : run_command( + gpgme_config, '--libs', + capture : true, + check : true, + ).stdout().split() + if word.startswith('-l') + # No string.substring() in these Meson versions either + word = run_command( + 'sh', '-c', 'echo ${1#-l}', 'sh', word, + check : true, + ).stdout().strip() + libs += cc.find_library(word) + else + ldflags += word + endif + endforeach + gpgme_dep = declare_dependency( + compile_args : cflags, + dependencies : libs, + link_args : ldflags, + ) +endif + +if get_option('selinux_module').disabled() + build_selinux_module = false +else + if meson.version().version_compare('>=0.53') + build_selinux_module = fs.is_file('/usr/share/selinux/devel/Makefile') + else + build_selinux_module = run_command( + 'test', '-f', '/usr/share/selinux/devel/Makefile', + check : false, + ).returncode() == 0 + endif + + if get_option('selinux_module').enabled() and not build_selinux_module + error('selinux-policy-devel needed to build selinux module') + endif +endif + +manpages_xsl = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl' +xsltproc = find_program('xsltproc', required : get_option('man')) +build_man_pages = false + +if xsltproc.found() + if run_command([ + xsltproc, '--nonet', manpages_xsl, + ], check : false).returncode() == 0 + message('Docbook XSL found') + build_man_pages = true + elif get_option('man').enabled() + error('Man page requested, but Docbook XSL stylesheets not found') + else + message('Docbook XSL not found, man page disabled automatically') + endif +endif + +xmlto = find_program('xmlto', required : get_option('docbook_docs')) + +if run_command( + 'python3', '-c', 'import pyparsing', + check : false +).returncode() != 0 + error('python3 "pyparsing" module is required') +endif + +foreach system_executable : [ + ['bubblewrap', required_bwrap, 'system_bubblewrap'], + ['xdg-dbus-proxy', required_dbus_proxy, 'system_dbus_proxy'], +] + name = system_executable[0] + required = system_executable[1] + option_name = system_executable[2] + value = get_option(option_name) + + if value != '' + version = '' + + if can_run_host_binaries + result = run_command( + value, '--version', + capture : true, + check : true, + ) + output = result.stdout() + + if output.startswith(name + ' ') + version = output.split()[1] + endif + endif + + if version == '' + # Cross-compiling, or unable to parse --version output + warning( + 'Unable to determine version of @0@ (@1@), please ensure it is >= @2@'.format( + name, value, required, + ) + ) + elif version.version_compare('<' + required) + error( + '@0@ must be version >= @1@ (found: @2@)'.format( + option_name, required, version, + ) + ) + endif + endif +endforeach + +# We don't actually need this, but we do need the polkit daemon itself, +# and they're generally packaged together. +find_program('pkcheck', required : get_option('tests')) + +find_program('socat', required : get_option('tests')) + +if get_option('installed_tests') and not get_option('tests') + error('-Dinstalled_tests=true is incompatible with -Dtests=false') +endif + +cdata = configuration_data() +cdata.set('_GNU_SOURCE', 1) +cdata.set('FLATPAK_COMPILATION', 1) +cdata.set('PACKAGE_MAJOR_VERSION', flatpak_major_version) +cdata.set('PACKAGE_MINOR_VERSION', flatpak_minor_version) +cdata.set('PACKAGE_MICRO_VERSION', flatpak_micro_version) +cdata.set('PACKAGE_EXTRA_VERSION', flatpak_extra_version) +cdata.set_quoted( + 'PACKAGE_STRING', + '@0@ @1@'.format(meson.project_name(), meson.project_version()), +) +cdata.set_quoted('PACKAGE_VERSION', meson.project_version()) +cdata.set_quoted( + 'FLATPAK_BINDIR', + get_option('prefix') / get_option('bindir'), +) +cdata.set_quoted( + 'FLATPAK_SYSTEMDIR', + get_option('prefix') / system_install_dir, +) +cdata.set_quoted( + 'FLATPAK_CONFIGDIR', + get_option('prefix') / get_option('sysconfdir') / 'flatpak', +) +cdata.set_quoted( + 'FLATPAK_BASEDIR', + get_option('prefix') / get_option('datadir') / 'flatpak', +) +cdata.set_quoted( + 'FLATPAK_TRIGGERDIR', + get_option('prefix') / get_option('datadir') / 'flatpak' / 'triggers', +) +cdata.set_quoted('LIBEXECDIR', get_option('prefix') / get_option('libexecdir')) +cdata.set_quoted('DATADIR', get_option('prefix') / get_option('datadir')) +cdata.set_quoted('LOCALEDIR', get_option('prefix') / get_option('localedir')) +cdata.set_quoted('SYSTEM_FONTS_DIR', get_option('system_fonts_dir')) +cdata.set_quoted('SYSTEM_HELPER_USER', get_option('system_helper_user')) +cdata.set_quoted( + 'SYSTEM_FONT_CACHE_DIRS', + ':'.join(get_option('system_font_cache_dirs')), +) +cdata.set_quoted('G_LOG_DOMAIN', 'flatpak') +cdata.set_quoted('GETTEXT_PACKAGE', 'flatpak') +cdata.set('FUSE_USE_VERSION', fuse_api) + +if get_option('system_bubblewrap') == '' + cdata.set_quoted('HELPER', get_option('prefix') / get_option('libexecdir') / 'flatpak-bwrap') +else + cdata.set_quoted('HELPER', get_option('system_bubblewrap')) +endif + +if get_option('system_dbus_proxy') == '' + cdata.set_quoted('DBUSPROXY', get_option('prefix') / get_option('libexecdir') / 'flatpak-dbus-proxy') +else + cdata.set_quoted('DBUSPROXY', get_option('system_dbus_proxy')) +endif + +# Flatpak is Linux-specific, so we assume this is always supported +cdata.set('FLATPAK_EXTERN', '__attribute__((visibility("default"))) extern') + +if glib_dep.version().version_compare('>=2.60') + # Ignore massive GTimeVal deprecation warnings in 2.62 + cdata.set('GLIB_VERSION_MIN_REQUIRED', 'GLIB_VERSION_2_60') +endif + +if appstream_dep.version().version_compare('>=0.14.0') + cdata.set('HAVE_APPSTREAM_0_14_0', 1) +endif + +if dconf_dep.found() + cdata.set('HAVE_DCONF', 1) +endif + +if libcurl_dep.found() + cdata.set('HAVE_CURL', 1) +endif + +if libseccomp_dep.found() + cdata.set('ENABLE_SECCOMP', 1) +endif + +if libsoup_dep.found() + cdata.set('HAVE_SOUP', 1) +endif + +if libsystemd_dep.found() + cdata.set('HAVE_LIBSYSTEMD', 1) +endif + +if libzstd_dep.found() + cdata.set('HAVE_ZSTD', 1) +endif + +if malcontent_dep.found() + cdata.set('HAVE_LIBMALCONTENT', 1) +endif + +if xau_dep.found() + cdata.set('ENABLE_XAUTH', 1) +endif + +if not get_option('sandboxed_triggers') + cdata.set('DISABLE_SANDBOXED_TRIGGERS', 1) +endif + +if cc.has_function( + 'archive_read_support_filter_all', + dependencies : libarchive_dep, + prefix : '#include ', +) + cdata.set('HAVE_ARCHIVE_READ_SUPPORT_FILTER_ALL', 1) +endif + +if build_system_helper + cdata.set('USE_SYSTEM_HELPER', '1') +endif + +configure_file( + output : 'config.h', + configuration : cdata, +) + +if meson.version().version_compare('>=0.53.0') + # TODO: When we depend on Meson >= 0.57.0, we can print dependencies + # as themselves rather than as booleans if we want to. + summary( + { + 'Build system helper' : build_system_helper, + 'Build selinux module' : build_selinux_module, + 'Build bubblewrap' : (get_option('system_bubblewrap') == ''), + 'Build dbus-proxy' : (get_option('system_dbus_proxy') == ''), + 'Use sandboxed triggers' : get_option('sandboxed_triggers'), + 'Use seccomp' : libseccomp_dep.found(), + 'Privileged group' : get_option('privileged_group'), + 'Use dconf' : dconf_dep.found(), + 'Use libsystemd' : libsystemd_dep.found(), + 'Use libmalcontent' : malcontent_dep.found(), + 'Use libzstd' : libzstd_dep.found(), + 'Use auto sideloading' : get_option('auto_sideloading'), + }, + bool_yn : true, + ) +endif + +if get_option('system_bubblewrap') == '' + subproject( + 'bubblewrap', + default_options : [ + 'program_prefix=flatpak-', + 'tests=false', + ], + ) +endif + +if get_option('system_dbus_proxy') == '' + subproject( + 'dbus-proxy', + default_options : [ + 'warning_level=1', + 'program_prefix=flatpak-', + 'tests=false', + ], + ) +endif + +# Used for .service files in multiple subdirectories +service_conf_data = configuration_data() +service_conf_data.set('libexecdir', get_option('prefix') / get_option('libexecdir')) +service_conf_data.set('localstatedir', get_option('prefix') / get_option('localstatedir')) +service_conf_data.set('media_dir', get_option('prefix') / get_option('run_media_dir')) +service_conf_data.set('extraargs', '') + +subdir('common') +subdir('data') + +subdir('app') +subdir('env.d') +subdir('profile') +subdir('icon-validator') +subdir('oci-authenticator') +subdir('portal') +subdir('revokefs') +subdir('session-helper') +subdir('scripts') + +subdir('completion') +subdir('doc') +subdir('po') +subdir('triggers') + +if get_option('auto_sideloading') + subdir('sideload-repos-systemd') +endif + +if build_selinux_module + subdir('selinux') +endif + +if build_system_helper + subdir('system-helper') +endif + +if get_option('tests') + subdir('tests') +endif + +pkgconfig_variables = [] + +# TODO: These can be dropped when we require Meson >= 0.62.0 +pkgconfig_variables += 'exec_prefix=${prefix}' +pkgconfig_variables += 'datadir=' + ('${prefix}' / get_option('datadir')) + +pkgconfig_variables += 'datarootdir=' + ('${prefix}' / get_option('datadir')) +pkgconfig_variables += 'interfaces_dir=${datadir}/dbus-1/interfaces/' +pkgconfig_variables += 'httpbackend=' + get_option('http_backend') + +pkgconfig.generate( + libflatpak, + description : 'Application sandboxing framework', + subdirs : 'flatpak', + requires : [ + 'glib-2.0', + 'gio-2.0', + 'ostree-1', + ], + requires_private : [ + 'gio-unix-2.0', + ], + variables : pkgconfig_variables, +) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000000..11b19f9871 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,228 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +option( + 'auto_sideloading', + type : 'boolean', + description : 'enable systemd units which make Flatpak sideload from inserted USB drives', + value : false, +) +option( + 'dconf', + type : 'feature', + description : 'Use dconf?', + value : 'auto', +) +option( + 'dbus_config_dir', + type : 'string', + description : 'directory for D-Bus system configuration [$sysconfdir/dbus-1/system.d]', + value : '', +) +option( + 'dbus_service_dir', + type : 'string', + description : 'directory for D-Bus session service files [$datadir/dbus-1/services]', + value : '', +) +option( + 'docbook_docs', + type : 'feature', + description : 'build documentation with xmlto', + value : 'auto', +) +option( + 'docdir', + type : 'string', + description : 'documentation directory [$datadir/doc/flatpak]', + value : '', +) +option( + 'gdm_env_file', + type : 'boolean', + description : 'install gdm env.d file (not needed if systemd generators work', + value : false, +) +option( + 'gir', + type : 'feature', + description : 'build GObject-Introspection metadata', + value : 'auto', +) +option( + 'gtkdoc', + type : 'feature', + description : 'build API reference documentation with gtk-doc', + value : 'auto', +) +option( + 'http_backend', + type : 'combo', + description : 'library used to implement HTTP', + choices : ['curl', 'soup'], + value : 'curl', +) +option( + 'installed_tests', + type : 'boolean', + description : 'install automated tests', + value : false, +) +option( + 'internal_checks', + type : 'boolean', + description : 'enable internal checking', + value : false, +) +option( + 'libzstd', + type : 'feature', + description : 'use libzstd?', + value : 'auto', +) +option( + 'malcontent', + type : 'feature', + description : 'use libmalcontent for parental controls?', + value : 'auto', +) +option( + 'man', + type : 'feature', + description : 'build man pages', + value : 'auto', +) +option( + 'privileged_group', + type : 'string', + description : 'name of root-equivalent group', + value : 'wheel', +) +option( + 'profile_dir', + type : 'string', + description : 'directory for profile.d files', + value : '', +) +option( + 'run_media_dir', + type : 'string', + description : 'location of auto-mounted USB drives]', + value : '/run/media', +) +option( + 'sandboxed_triggers', + type : 'boolean', + description : 'enable sandboxed triggers', + value : true, +) +option( + 'seccomp', + type : 'feature', + description : 'enable seccomp', + value : 'enabled', +) +option( + 'selinux_module', + type : 'feature', + description : 'enable selinux module for system-helper', + value : 'auto', +) +option( + 'system_bubblewrap', + type : 'string', + description : 'system bwrap executable, or empty string to build subproject', + value : '', +) +option( + 'system_dbus_proxy', + type : 'string', + description : 'system xdg-dbus-proxy executable, or empty string to build subproject', + value : '', +) +option( + 'system_font_cache_dirs', + type : 'array', + description : 'directory where the system font cache is', + value : ['/var/cache/fontconfig', '/usr/lib/fontconfig/cache'], +) +option( + 'system_fonts_dir', + type : 'string', + description : 'Directory where system fonts are', + value : '/usr/share/fonts', +) +option( + 'system_helper', + type : 'feature', + description : 'enable system helper', + value : 'enabled', +) +option( + 'system_helper_user', + type : 'string', + description : 'name of the system helper user', + value : 'flatpak', +) +option( + 'system_install_dir', + type : 'string', + description : 'location of system installation [$localstatedir/lib/flatpak]', + value : '', +) +option( + 'systemdsystemenvgendir', + type : 'string', + description : 'directory for systemd system environment generators', + value : 'lib/systemd/system-environment-generators', +) +option( + 'systemd', + type : 'feature', + description : 'build with systemd support', + value : 'auto', +) +option( + 'systemdsystemunitdir', + type : 'string', + description : 'directory for systemd system service files', + # deliberately lib and not based on get_option('libdir'): + # this should not be lib64 or lib/x86_64-linux-gnu + value : 'lib/systemd/system', +) +option( + 'systemduserenvgendir', + type : 'string', + description : 'directory for systemd user environment generators', + value : 'lib/systemd/user-environment-generators', +) +option( + 'systemduserunitdir', + type : 'string', + description : 'directory for systemd user service files', + value : 'lib/systemd/user', +) +option( + 'sysusersdir', + type : 'string', + description : 'directory for systemd sysusers.d configuration files', + value : 'lib/sysusers.d' +) +option( + 'tests', + type : 'boolean', + description : 'build tests', + value : true, +) +option( + 'xauth', + type : 'feature', + description : 'enable Xauth use', + value : 'enabled', +) +option( + 'xmlto_flags', + type : 'array', + description : 'options to pass to xmlto', + value : [], +) diff --git a/oci-authenticator/Makefile.am.inc b/oci-authenticator/Makefile.am.inc index 3510e25c17..75d60ded40 100644 --- a/oci-authenticator/Makefile.am.inc +++ b/oci-authenticator/Makefile.am.inc @@ -1,3 +1,5 @@ +EXTRA_DIST += oci-authenticator/meson.build + libexec_PROGRAMS += \ flatpak-oci-authenticator \ $(NULL) diff --git a/oci-authenticator/meson.build b/oci-authenticator/meson.build new file mode 100644 index 0000000000..9229f039ef --- /dev/null +++ b/oci-authenticator/meson.build @@ -0,0 +1,35 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +executable( + 'flatpak-oci-authenticator', + 'flatpak-oci-authenticator.c', + dependencies : [ + base_deps, + json_glib_dep, + libflatpak_common_base_dep, + libflatpak_common_dep, + libglnx_dep, + libostree_dep, + libsoup_dep, + ], + include_directories : [ + include_directories('.'), + ], + install : true, + install_dir : get_option('libexecdir'), +) + +configure_file( + input : 'flatpak-oci-authenticator.service.in', + output : 'flatpak-oci-authenticator.service', + configuration : service_conf_data, + install_dir : get_option('systemduserunitdir'), +) + +configure_file( + input : 'org.flatpak.Authenticator.Oci.service.in', + output : 'org.flatpak.Authenticator.Oci.service', + configuration : service_conf_data, + install_dir : dbus_service_dir, +) diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 0000000000..7364cc9647 --- /dev/null +++ b/po/meson.build @@ -0,0 +1,4 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +i18n.gettext('flatpak', preset: 'glib') diff --git a/portal/Makefile.am.inc b/portal/Makefile.am.inc index dc45969575..5fa0abb922 100644 --- a/portal/Makefile.am.inc +++ b/portal/Makefile.am.inc @@ -1,3 +1,5 @@ +EXTRA_DIST += portal/meson.build + libexec_PROGRAMS += \ flatpak-portal \ $(NULL) diff --git a/portal/meson.build b/portal/meson.build new file mode 100644 index 0000000000..a3ebf71f7a --- /dev/null +++ b/portal/meson.build @@ -0,0 +1,59 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +permission_gdbus = gnome.gdbus_codegen( + 'flatpak-permission-dbus', + sources: [ + '../data/org.freedesktop.impl.portal.PermissionStore.xml', + ], + interface_prefix : 'org.freedesktop.impl.portal', + namespace : 'XdpDbus', +) + +portal_gdbus = gnome.gdbus_codegen( + 'flatpak-portal-dbus', + sources: [ + '../data/org.freedesktop.portal.Flatpak.xml', + ], + interface_prefix : 'org.freedesktop.portal', + namespace : 'Portal', +) + +executable( + 'flatpak-portal', + dependencies : [ + threads_dep, + base_deps, + json_glib_dep, + libflatpak_common_base_dep, + libflatpak_common_dep, + libglnx_dep, + libostree_dep, + libsoup_dep, + ], + include_directories : [ + include_directories('.'), + ], + install : true, + install_dir : get_option('libexecdir'), + sources : [ + 'flatpak-portal.c', + 'flatpak-portal-app-info.c', + 'portal-impl.c', + '../common/flatpak-portal-error.c', + ] + permission_gdbus + portal_gdbus, +) + +configure_file( + input : 'flatpak-portal.service.in', + output : 'flatpak-portal.service', + configuration : service_conf_data, + install_dir : get_option('systemduserunitdir'), +) + +configure_file( + input : 'org.freedesktop.portal.Flatpak.service.in', + output : 'org.freedesktop.portal.Flatpak.service', + configuration : service_conf_data, + install_dir : dbus_service_dir, +) diff --git a/profile/meson.build b/profile/meson.build new file mode 100644 index 0000000000..18483e8b37 --- /dev/null +++ b/profile/meson.build @@ -0,0 +1,11 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +install_data( + 'flatpak.sh', + install_dir : profile_dir, +) +install_data( + 'flatpak.fish', + install_dir : get_option('datadir') / 'fish' / 'vendor_conf.d', +) diff --git a/revokefs/Makefile.am.inc b/revokefs/Makefile.am.inc index 77cb53983f..e971a80f83 100644 --- a/revokefs/Makefile.am.inc +++ b/revokefs/Makefile.am.inc @@ -18,6 +18,8 @@ # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. +EXTRA_DIST += revokefs/meson.build + libexec_PROGRAMS += revokefs-fuse noinst_PROGRAMS += revokefs-demo diff --git a/revokefs/meson.build b/revokefs/meson.build new file mode 100644 index 0000000000..9f7511275f --- /dev/null +++ b/revokefs/meson.build @@ -0,0 +1,24 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +executable( + 'revokefs-fuse', + dependencies : [ + base_deps, + fuse_dep, + libglnx_dep, + ], + install : true, + install_dir : get_option('libexecdir'), + sources : [ + 'main.c', + 'writer.c', + ], +) + +executable( + 'revokefs-demo', + install : false, + sources : ['demo.c'], + dependencies : base_deps, +) diff --git a/scripts/meson.build b/scripts/meson.build new file mode 100644 index 0000000000..211acbed46 --- /dev/null +++ b/scripts/meson.build @@ -0,0 +1,9 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +install_data( + 'flatpak-bisect', + 'flatpak-coredumpctl', + install_dir : get_option('bindir'), + install_mode : 'rwxr-xr-x', +) diff --git a/selinux/Makefile.am.inc b/selinux/Makefile.am.inc index fab55558ad..c5e72425b6 100644 --- a/selinux/Makefile.am.inc +++ b/selinux/Makefile.am.inc @@ -17,6 +17,7 @@ EXTRA_DIST += \ selinux/flatpak.te \ selinux/flatpak.fc \ selinux/flatpak.if \ + selinux/meson.build \ $(NULL) DISTCLEANFILES += flatpak.pp.bz2 diff --git a/selinux/meson.build b/selinux/meson.build new file mode 100644 index 0000000000..0c3174bf2c --- /dev/null +++ b/selinux/meson.build @@ -0,0 +1,20 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +custom_target( + 'flatpak.pp.bz2', + input : ['flatpak.te', 'flatpak.fc'], + output : ['flatpak.pp.bz2'], + build_by_default : true, + command : [ + files('build-selinux.sh'), + '@OUTPUT0@', + '@INPUT@', + ], + install_dir : get_option('datadir') / 'selinux' / 'packages', +) + +install_data( + 'flatpak.if', + install_dir : get_option('datadir') / 'selinux' / 'include' / 'contrib', +) diff --git a/session-helper/Makefile.am.inc b/session-helper/Makefile.am.inc index 7da3fda8ed..e7bb402ce8 100644 --- a/session-helper/Makefile.am.inc +++ b/session-helper/Makefile.am.inc @@ -1,3 +1,5 @@ +EXTRA_DIST += session-helper/meson.build + libexec_PROGRAMS += \ flatpak-session-helper \ $(NULL) diff --git a/session-helper/meson.build b/session-helper/meson.build new file mode 100644 index 0000000000..14fc47b47d --- /dev/null +++ b/session-helper/meson.build @@ -0,0 +1,29 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +executable( + 'flatpak-session-helper', + dependencies : [ + base_deps, + threads_dep, + libglnx_dep, + libflatpak_common_base_dep, + ], + install : true, + install_dir : get_option('libexecdir'), + sources : ['flatpak-session-helper.c'], +) + +configure_file( + input : 'flatpak-session-helper.service.in', + output : 'flatpak-session-helper.service', + configuration : service_conf_data, + install_dir : get_option('systemduserunitdir'), +) + +configure_file( + input : 'org.freedesktop.Flatpak.service.in', + output : 'org.freedesktop.Flatpak.service', + configuration : service_conf_data, + install_dir : dbus_service_dir, +) diff --git a/sideload-repos-systemd/Makefile.am.inc b/sideload-repos-systemd/Makefile.am.inc index b1bbc3858d..7a1b1b1125 100644 --- a/sideload-repos-systemd/Makefile.am.inc +++ b/sideload-repos-systemd/Makefile.am.inc @@ -17,4 +17,4 @@ dist_tmpfiles_DATA = sideload-repos-systemd/tmpfiles.d/flatpak-sideload-repos.co endif EXTRA_DIST += sideload-repos-systemd/flatpak-sideload-usb-repo.path.in sideload-repos-systemd/flatpak-sideload-usb-repo.service.in - +EXTRA_DIST += sideload-repos-systemd/meson.build diff --git a/sideload-repos-systemd/meson.build b/sideload-repos-systemd/meson.build new file mode 100644 index 0000000000..d97cb7a089 --- /dev/null +++ b/sideload-repos-systemd/meson.build @@ -0,0 +1,27 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +install_data( + 'flatpak-create-sideload-symlinks.sh', + install_dir : get_option('libexecdir'), + install_mode : 'rwxr-xr-x', +) + +configure_file( + input : 'flatpak-sideload-usb-repo.service.in', + output : 'flatpak-sideload-usb-repo.service', + configuration : service_conf_data, + install_dir : get_option('systemduserunitdir'), +) + +configure_file( + input : 'flatpak-sideload-usb-repo.path.in', + output : 'flatpak-sideload-usb-repo.path', + configuration : service_conf_data, + install_dir : get_option('systemduserunitdir'), +) + +install_data( + 'flatpak-sideload-repos.conf', + install_dir : 'lib/tmpfiles.d', +) diff --git a/system-helper/Makefile.am.inc b/system-helper/Makefile.am.inc index 09ea63e511..4ae5d801d9 100644 --- a/system-helper/Makefile.am.inc +++ b/system-helper/Makefile.am.inc @@ -48,3 +48,4 @@ DISTCLEANFILES += system-helper/org.freedesktop.Flatpak.policy system-helper/org endif EXTRA_DIST += system-helper/org.freedesktop.Flatpak.policy.in system-helper/org.freedesktop.Flatpak.SystemHelper.conf system-helper/org.freedesktop.Flatpak.rules.in system-helper/org.freedesktop.Flatpak.SystemHelper.service.in system-helper/flatpak-system-helper.service.in system-helper/flatpak.conf.in +EXTRA_DIST += system-helper/meson.build diff --git a/system-helper/meson.build b/system-helper/meson.build new file mode 100644 index 0000000000..c4da8671af --- /dev/null +++ b/system-helper/meson.build @@ -0,0 +1,64 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +executable( + 'flatpak-system-helper', + dependencies : base_deps + [ + appstream_dep, + json_glib_dep, + libflatpak_common_base_dep, + libflatpak_common_dep, + libglnx_dep, + libostree_dep, + libsoup_dep, + polkit_agent_dep, + ], + install : true, + install_dir : get_option('libexecdir'), + sources : ['flatpak-system-helper.c'], +) + +configure_file( + input : 'flatpak-system-helper.service.in', + output : 'flatpak-system-helper.service', + configuration : service_conf_data, + install_dir : get_option('systemdsystemunitdir'), +) + +configure_file( + input : 'org.freedesktop.Flatpak.SystemHelper.service.in', + output : 'org.freedesktop.Flatpak.SystemHelper.service', + configuration : service_conf_data, + install_dir : get_option('datadir') / 'dbus-1' / 'system-services', +) + +install_data( + 'org.freedesktop.Flatpak.SystemHelper.conf', + install_dir : dbus_config_dir, +) + +conf_data = configuration_data() +conf_data.set('privileged_group', get_option('privileged_group')) +configure_file( + input : 'org.freedesktop.Flatpak.rules.in', + output : 'org.freedesktop.Flatpak.rules', + configuration : conf_data, + install_dir : get_option('datadir') / 'polkit-1' / 'rules.d', +) + +i18n.merge_file( + input : 'org.freedesktop.Flatpak.policy.in', + output : 'org.freedesktop.Flatpak.policy', + po_dir : '../po', + install : true, + install_dir : get_option('datadir') / 'polkit-1' / 'actions', +) + +conf_data = configuration_data() +conf_data.set('SYSTEM_HELPER_USER', get_option('system_helper_user')) +configure_file( + input : 'flatpak.conf.in', + output : 'flatpak.conf', + configuration : conf_data, + install_dir : get_option('sysusersdir'), +) diff --git a/tests/Makefile.am.inc b/tests/Makefile.am.inc index ebc9d390a8..9018e27517 100644 --- a/tests/Makefile.am.inc +++ b/tests/Makefile.am.inc @@ -302,7 +302,16 @@ EXTRA_DIST += \ tests/expand-test-matrix.sh \ tests/flatpak.supp \ tests/glib.supp \ + tests/installed-services/meson.build \ tests/make-runtime-repos \ + tests/meson.build \ + tests/package_version.txt.in \ + tests/services/meson.build \ + tests/share/xdg-desktop-portal/portals/meson.build \ + tests/tap.test.in \ + tests/test-keyring/meson.build \ + tests/test-keyring2/meson.build \ + tests/test-matrix/meson.build \ tests/test-wrapper.sh \ tests/update-test-matrix \ $(NULL) diff --git a/tests/expand-test-matrix.sh b/tests/expand-test-matrix.sh index 6c39ee94cb..4965fa6a02 100755 --- a/tests/expand-test-matrix.sh +++ b/tests/expand-test-matrix.sh @@ -125,4 +125,18 @@ if [ "$1" = "--automake" ]; then echo " ${f} \\" done echo " \$(NULL)" +elif [ "$1" = "--meson" ]; then + echo "# This file is autogenerated by ./tests/update-test-matrix, don't edit" + for f in $tests $dist_tests; do + f="${f#tests/}" + case "$f" in + (*@*) + s="${f%%@*}.sh" + ;; + (*) + s="$f" + ;; + esac + echo "wrapped_tests += {'name' : '$f', 'script' : '$s'}" + done fi diff --git a/tests/installed-services/meson.build b/tests/installed-services/meson.build new file mode 100644 index 0000000000..ad20f4da30 --- /dev/null +++ b/tests/installed-services/meson.build @@ -0,0 +1,47 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +foreach triple : [ + ['oci-authenticator', 'org.flatpak.Authenticator.Oci', {}], + ['portal', 'org.freedesktop.portal.Flatpak', { + 'extraargs' : ' --poll-timeout=1', + }], + ['session-helper', 'org.freedesktop.Flatpak', {}], + ['system-helper', 'org.freedesktop.Flatpak.SystemHelper', { + 'extraargs' : ' --session --no-idle-exit', + }], +] + directory = triple[0] + service = triple[1] + options = triple[2] + + configure_file( + input : project_source_root / directory / (service + '.service.in'), + output : service + '.service', + configuration : { + 'extraargs' : options.get('extraargs', ''), + 'libexecdir' : get_option('prefix') / get_option('libexecdir'), + }, + install_dir : installed_testdir / 'services', + ) +endforeach + +foreach service : [ + 'org.flatpak.Authenticator.test', + 'org.freedesktop.impl.portal.desktop.test', +] + configure_file( + input : project_source_root / 'tests' / (service + '.service.in'), + output : service + '.service', + configuration : { + 'libexecdir' : installed_testdir, + }, + install_dir : installed_testdir / 'services', + ) +endforeach + +install_data( + project_source_root / 'tests/test.portal.in', + install_dir : installed_testdir / 'share/xdg-desktop-portal/portals', + rename : 'test.portal', +) diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 0000000000..044cb03eb2 --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,415 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +installed_testdir = get_option('prefix') / get_option('libexecdir') / 'installed-tests' / 'Flatpak' +installed_tests_metadir = get_option('prefix') / get_option('datadir') / 'installed-tests' / 'Flatpak' + +tests_environment = environment() +tests_environment.set('FLATPAK_CONFIG_DIR', '/dev/null') +tests_environment.set( + 'FLATPAK_PORTAL', + project_build_root / 'portal' / 'flatpak-portal', +) +tests_environment.set( + 'FLATPAK_REVOKEFS_FUSE', + project_build_root / 'revokefs' / 'revokefs-fuse', +) +tests_environment.set('FLATPAK_TESTS_DEBUG', '1') +tests_environment.set('FLATPAK_TESTS_STRICT_TAP', '1') +tests_environment.set('FLATPAK_TRIGGERSDIR', project_source_root / 'triggers') +tests_environment.set( + 'FLATPAK_VALIDATE_ICON', + project_build_root / 'icon-validator' / 'flatpak-validate-icon', +) +tests_environment.set('G_TEST_BUILDDIR', meson.current_build_dir()) +tests_environment.set('G_TEST_SRCDIR', meson.current_source_dir()) +tests_environment.prepend('GI_TYPELIB_PATH', project_build_root / 'common') +tests_environment.prepend('LD_LIBRARY_PATH', project_build_root / 'common') +tests_environment.prepend('PATH', project_build_root / 'app') + +if get_option('system_bubblewrap') == '' + tests_environment.set('FLATPAK_BWRAP', project_build_root / 'subprojects' / 'bubblewrap' / 'flatpak-bwrap') +else + tests_environment.set('FLATPAK_BWRAP', get_option('system_bubblewrap')) +endif + +if get_option('system_dbus_proxy') == '' + tests_environment.set('FLATPAK_DBUSPROXY', project_build_root / 'subprojects' / 'dbus-proxy' / 'flatpak-dbus-proxy') +else + tests_environment.set('FLATPAK_DBUSPROXY', get_option('system_dbus_proxy')) +endif + +# Explicitly doing a find_program() for this avoids lots of output with +# older Meson versions +tap_test = find_program( + files(project_source_root / 'buildutil/tap-test'), +) + +# TODO: When we depend on Meson 0.50.0, we can use +# install : get_option('installed_tests') +# install_dir : installed_testdir +# instead of +# install_dir : maybe_installed_testdir +if get_option('installed_tests') + maybe_installed_testdir = installed_testdir +else + maybe_installed_testdir = false +endif + +if can_run_host_binaries + runtime_repo = custom_target( + 'runtime-repo', + build_by_default : false, + command : [ + files('make-runtime-repos'), + project_build_root / 'app', + files('make-test-runtime.sh'), + project_build_root / 'tests/runtime-repo', + '@OUTPUT@', + ], + depends : [flatpak_exe], + output : 'runtime-repo.stamp', + ) +endif + +libtestlib = static_library( + 'testlib', + 'testlib.c', + include_directories : [common_include_directories], + dependencies : [ + base_deps, + libglnx_dep, + ], + install : false, +) +libtestlib_dep = declare_dependency( + dependencies : [ + base_deps, + libglnx_dep, + ], + include_directories : [common_include_directories], + link_with : libtestlib, +) + +c_tests = [ + ['testcommon', {}], + ['testlibrary', { + 'dependencies' : [ + base_deps, + fuse_dep, + libflatpak_dep, + libglnx_dep, + libostree_dep, + ], + 'extra_sources' : [ + 'can-use-fuse.c', + 'testlib.c', + ], + 'timeout' : 150, + }], + ['test-context', {}], + ['test-exports', {}], + ['test-instance', { + 'extra_dependencies' : [ + libglnx_testlib_dep, + ], + }], + ['test-portal', { + 'extra_sources' : [ + portal_gdbus[0], + portal_gdbus[1], + ], + }], +] + +foreach testcase : c_tests + name = testcase[0] + options = testcase[1] + + exe = executable( + name, + dependencies : options.get('dependencies', [ + base_deps, + appstream_dep, + json_glib_dep, + libflatpak_app_dep, + libflatpak_common_dep, + libflatpak_common_base_dep, + libglnx_dep, + libostree_dep, + libsoup_dep, + libtestlib_dep, + ] + options.get('extra_dependencies', [])), + sources : [name + '.c'] + options.get('extra_sources', []), + install : get_option('installed_tests'), + install_dir : installed_testdir, + ) + + if get_option('installed_tests') + configure_file( + input : 'tap.test.in', + output : name + '.test', + configuration : { + 'basename' : name, + 'installed_testdir' : installed_testdir, + 'wrapper' : '', + }, + install_dir : installed_tests_metadir, + ) + endif + + if can_run_host_binaries + if meson.version().version_compare('>=0.50.0') + test( + name, + tap_test, + args : [exe], + depends : runtime_repo, + env : tests_environment, + protocol : 'tap', + timeout : options.get('timeout', 30), + ) + else + # Fall back to using exit status rather than TAP + test( + name, + tap_test, + args : [exe], + depends : runtime_repo, + env : tests_environment, + timeout : options.get('timeout', 30), + ) + endif + endif +endforeach + +executable( + 'hold-lock', + 'hold-lock.c', + dependencies : [ + base_deps, + libglnx_dep, + ], + include_directories : [common_include_directories], + install : get_option('installed_tests'), + install_dir : installed_testdir, +) + +executable( + 'httpcache', + 'httpcache.c', + dependencies : [ + base_deps, + json_glib_dep, + libflatpak_common_dep, + libflatpak_common_base_dep, + libglnx_dep, + libostree_dep, + libsoup_dep, + ], + include_directories : [common_include_directories], + install : get_option('installed_tests'), + install_dir : installed_testdir, +) + +executable( + 'mock-flatpak', + 'mock-flatpak.c', + dependencies : [ + base_deps, + appstream_dep, + json_glib_dep, + libflatpak_app_dep, + libflatpak_common_dep, + libflatpak_common_base_dep, + libtestlib_dep, + libglnx_dep, + libostree_dep, + libsoup_dep, + ], + install : get_option('installed_tests'), + install_dir : installed_testdir, +) + +executable( + 'test-update-portal', + sources : [ + 'test-update-portal.c', + ] + portal_gdbus, + dependencies : base_deps, + include_directories : [common_include_directories], + install : get_option('installed_tests'), + install_dir : installed_testdir, +) + +executable( + 'test-portal-impl', + 'test-portal-impl.c', + dependencies : base_deps, + include_directories : [common_include_directories], + install : get_option('installed_tests'), + install_dir : installed_testdir, +) + +executable( + 'test-authenticator', + 'test-authenticator.c', + dependencies : [ + base_deps, + libflatpak_common_dep, + libflatpak_common_base_dep, + libglnx_dep, + ], + install : get_option('installed_tests'), + install_dir : installed_testdir, +) + +executable( + 'try-syscall', + 'try-syscall.c', + include_directories : [common_include_directories], + install : get_option('installed_tests'), + install_dir : installed_testdir, + override_options: ['b_sanitize=none'], +) + +executable( + 'list-unused', + 'list-unused.c', + dependencies : [ + base_deps, + libflatpak_common_dep, + libflatpak_common_base_dep, + libglnx_dep, + libostree_dep, + ], + include_directories : [common_include_directories], + install : get_option('installed_tests'), + install_dir : installed_testdir, +) + +subdir('share/xdg-desktop-portal/portals') +subdir('services') +subdir('test-keyring') +subdir('test-keyring2') + +configure_file( + input : 'package_version.txt.in', + output : 'package_version.txt', + configuration : { + 'PACKAGE_VERSION' : meson.project_version(), + }, + install_dir : maybe_installed_testdir, +) + +if get_option('installed_tests') + subdir('installed-services') + + install_data( + 'http-utils-test-server.py', + 'make-multi-collection-id-repo.sh', + 'make-test-app.sh', + 'make-test-runtime.sh', + 'oci-registry-client.py', + 'oci-registry-server.py', + 'test-webserver.sh', + 'test-wrapper.sh', + 'web-server.py', + + install_dir : installed_testdir, + install_mode : 'rwxr-xr-x', + ) + + install_data( + 'libtest.sh', + 'org.flatpak.Authenticator.test.service.in', + 'org.freedesktop.impl.portal.desktop.test.service.in', + 'org.test.Hello.png', + 'session.conf.in', + 'test.filter', + 'test.portal.in', + + install_dir : installed_testdir, + install_mode : 'rw-r--r--', + ) +endif + +shared_module( + 'preload', + 'libpreload.c', + install : get_option('installed_tests'), + install_dir : installed_testdir, + override_options: ['b_sanitize=none'], +) + +wrapped_tests = [] +subdir('test-matrix') + +foreach testcase : wrapped_tests + name = testcase['name'] + script = testcase.get('script', name) + + timeout = { + 'test-bundle.sh' : 60, + 'test-oci-registry.sh' : 60, + 'test-repo.sh' : 300, + 'test-run.sh' : 90, + 'test-summaries.sh' : 60, + 'test-unused.sh' : 90, + 'test-update-portal.sh' : 90, + }.get(script, 30) + + is_parallel = { + 'test-history.sh' : false, + }.get(script, true) + + if get_option('installed_tests') + if name == script + wrapper = '' + else + wrapper = installed_testdir / 'test-wrapper.sh' + endif + + install_data( + script, + install_dir : installed_testdir, + install_mode : 'rwxr-xr-x', + ) + configure_file( + input : 'tap.test.in', + output : name + '.test', + configuration : { + 'basename' : name, + 'installed_testdir' : installed_testdir, + 'wrapper' : wrapper, + }, + install_dir : installed_tests_metadir, + ) + endif + + if can_run_host_binaries + if meson.version().version_compare('>=0.50.0') + test( + name, + tap_test, + args : [meson.current_source_dir() / name], + depends : runtime_repo, + env : tests_environment, + is_parallel : is_parallel, + protocol : 'tap', + timeout : timeout, + ) + else + # Fall back to using exit status rather than TAP + test( + name, + tap_test, + args : [meson.current_source_dir() / name], + depends : runtime_repo, + env : tests_environment, + is_parallel : is_parallel, + timeout : timeout, + ) + endif + endif +endforeach diff --git a/tests/package_version.txt.in b/tests/package_version.txt.in new file mode 100644 index 0000000000..a24f9877ac --- /dev/null +++ b/tests/package_version.txt.in @@ -0,0 +1 @@ +@PACKAGE_VERSION@ diff --git a/tests/services/meson.build b/tests/services/meson.build new file mode 100644 index 0000000000..27eb641c96 --- /dev/null +++ b/tests/services/meson.build @@ -0,0 +1,28 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +foreach triple : [ + ['oci-authenticator', 'org.flatpak.Authenticator.Oci', {}], + ['portal', 'org.freedesktop.portal.Flatpak', { + 'extraargs' : ' --poll-timeout=1', + }], + ['session-helper', 'org.freedesktop.Flatpak', {}], + ['system-helper', 'org.freedesktop.Flatpak.SystemHelper', { + 'extraargs' : ' --session --no-idle-exit', + }], + ['tests', 'org.flatpak.Authenticator.test', {}], + ['tests', 'org.freedesktop.impl.portal.desktop.test', {}], +] + directory = triple[0] + service = triple[1] + options = triple[2] + + configure_file( + input : project_source_root / directory / (service + '.service.in'), + output : service + '.service', + configuration : { + 'extraargs' : options.get('extraargs', ''), + 'libexecdir' : project_build_root / directory, + } + ) +endforeach diff --git a/tests/share/xdg-desktop-portal/portals/meson.build b/tests/share/xdg-desktop-portal/portals/meson.build new file mode 100644 index 0000000000..7364014507 --- /dev/null +++ b/tests/share/xdg-desktop-portal/portals/meson.build @@ -0,0 +1,6 @@ +configure_file( + input : project_source_root / 'tests/test.portal.in', + output : 'test.portal', + copy : true, +) + diff --git a/tests/tap.test.in b/tests/tap.test.in new file mode 100644 index 0000000000..5289490207 --- /dev/null +++ b/tests/tap.test.in @@ -0,0 +1,4 @@ +[Test] +Type=session +Exec=env G_TEST_SRCDIR=@installed_testdir@ G_TEST_BUILDDIR=@installed_testdir@ @wrapper@ @installed_testdir@/@basename@ --tap +Output=TAP diff --git a/tests/test-keyring/meson.build b/tests/test-keyring/meson.build new file mode 100644 index 0000000000..fb1c47a3ea --- /dev/null +++ b/tests/test-keyring/meson.build @@ -0,0 +1,26 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +if get_option('installed_tests') + install_sub = installed_testdir / 'test-keyring' +else + install_sub = false +endif + +foreach file : [ + 'README', + 'pubring.gpg', + 'secring.gpg', +] + # TODO: When we depend on Meson 0.50.0, we can use + # install : get_option('installed_tests') + # instead of + # install_dir : false + configure_file( + input : file, + output : file, + copy : true, + install_dir : install_sub, + install_mode : 'rw-r--r--', + ) +endforeach diff --git a/tests/test-keyring2/meson.build b/tests/test-keyring2/meson.build new file mode 100644 index 0000000000..9715c4ccac --- /dev/null +++ b/tests/test-keyring2/meson.build @@ -0,0 +1,26 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +if get_option('installed_tests') + install_sub = installed_testdir / 'test-keyring2' +else + install_sub = false +endif + +foreach file : [ + 'README', + 'pubring.gpg', + 'secring.gpg', +] + # TODO: When we depend on Meson 0.50.0, we can use + # install : get_option('installed_tests') + # instead of + # install_dir : false + configure_file( + input : file, + output : file, + copy : true, + install_dir : install_sub, + install_mode : 'rw-r--r--', + ) +endforeach diff --git a/tests/test-matrix/meson.build b/tests/test-matrix/meson.build new file mode 100644 index 0000000000..151760484d --- /dev/null +++ b/tests/test-matrix/meson.build @@ -0,0 +1,45 @@ +# This file is autogenerated by ./tests/update-test-matrix, don't edit +wrapped_tests += {'name' : 'test-run@user,nodeltas.wrap', 'script' : 'test-run.sh'} +wrapped_tests += {'name' : 'test-run@user,deltas.wrap', 'script' : 'test-run.sh'} +wrapped_tests += {'name' : 'test-run@system,nodeltas.wrap', 'script' : 'test-run.sh'} +wrapped_tests += {'name' : 'test-run@system,deltas.wrap', 'script' : 'test-run.sh'} +wrapped_tests += {'name' : 'test-run@system-norevokefs,nodeltas.wrap', 'script' : 'test-run.sh'} +wrapped_tests += {'name' : 'test-run@system-norevokefs,deltas.wrap', 'script' : 'test-run.sh'} +wrapped_tests += {'name' : 'test-info@user.wrap', 'script' : 'test-info.sh'} +wrapped_tests += {'name' : 'test-info@system.wrap', 'script' : 'test-info.sh'} +wrapped_tests += {'name' : 'test-repo@user.wrap', 'script' : 'test-repo.sh'} +wrapped_tests += {'name' : 'test-repo@system.wrap', 'script' : 'test-repo.sh'} +wrapped_tests += {'name' : 'test-repo@system-norevokefs.wrap', 'script' : 'test-repo.sh'} +wrapped_tests += {'name' : 'test-repo@user,oldsummary.wrap', 'script' : 'test-repo.sh'} +wrapped_tests += {'name' : 'test-repo@system,oldsummary.wrap', 'script' : 'test-repo.sh'} +wrapped_tests += {'name' : 'test-sideload@user.wrap', 'script' : 'test-sideload.sh'} +wrapped_tests += {'name' : 'test-sideload@system.wrap', 'script' : 'test-sideload.sh'} +wrapped_tests += {'name' : 'test-bundle@user.wrap', 'script' : 'test-bundle.sh'} +wrapped_tests += {'name' : 'test-bundle@system.wrap', 'script' : 'test-bundle.sh'} +wrapped_tests += {'name' : 'test-bundle@system-norevokefs.wrap', 'script' : 'test-bundle.sh'} +wrapped_tests += {'name' : 'test-oci-registry@user.wrap', 'script' : 'test-oci-registry.sh'} +wrapped_tests += {'name' : 'test-oci-registry@system.wrap', 'script' : 'test-oci-registry.sh'} +wrapped_tests += {'name' : 'test-update-remote-configuration@newsummary.wrap', 'script' : 'test-update-remote-configuration.sh'} +wrapped_tests += {'name' : 'test-update-remote-configuration@oldsummary.wrap', 'script' : 'test-update-remote-configuration.sh'} +wrapped_tests += {'name' : 'test-update-portal@user.wrap', 'script' : 'test-update-portal.sh'} +wrapped_tests += {'name' : 'test-update-portal@system.wrap', 'script' : 'test-update-portal.sh'} +wrapped_tests += {'name' : 'test-summaries@user.wrap', 'script' : 'test-summaries.sh'} +wrapped_tests += {'name' : 'test-summaries@system.wrap', 'script' : 'test-summaries.sh'} +wrapped_tests += {'name' : 'test-subset@user.wrap', 'script' : 'test-subset.sh'} +wrapped_tests += {'name' : 'test-subset@system.wrap', 'script' : 'test-subset.sh'} +wrapped_tests += {'name' : 'test-basic.sh', 'script' : 'test-basic.sh'} +wrapped_tests += {'name' : 'test-completion.sh', 'script' : 'test-completion.sh'} +wrapped_tests += {'name' : 'test-config.sh', 'script' : 'test-config.sh'} +wrapped_tests += {'name' : 'test-build-update-repo.sh', 'script' : 'test-build-update-repo.sh'} +wrapped_tests += {'name' : 'test-http-utils.sh', 'script' : 'test-http-utils.sh'} +wrapped_tests += {'name' : 'test-history.sh', 'script' : 'test-history.sh'} +wrapped_tests += {'name' : 'test-default-remotes.sh', 'script' : 'test-default-remotes.sh'} +wrapped_tests += {'name' : 'test-metadata-validation.sh', 'script' : 'test-metadata-validation.sh'} +wrapped_tests += {'name' : 'test-extensions.sh', 'script' : 'test-extensions.sh'} +wrapped_tests += {'name' : 'test-oci.sh', 'script' : 'test-oci.sh'} +wrapped_tests += {'name' : 'test-override.sh', 'script' : 'test-override.sh'} +wrapped_tests += {'name' : 'test-auth.sh', 'script' : 'test-auth.sh'} +wrapped_tests += {'name' : 'test-unused.sh', 'script' : 'test-unused.sh'} +wrapped_tests += {'name' : 'test-prune.sh', 'script' : 'test-prune.sh'} +wrapped_tests += {'name' : 'test-seccomp.sh', 'script' : 'test-seccomp.sh'} +wrapped_tests += {'name' : 'test-repair.sh', 'script' : 'test-repair.sh'} diff --git a/tests/update-test-matrix b/tests/update-test-matrix index 04e6531641..4449cc50af 100755 --- a/tests/update-test-matrix +++ b/tests/update-test-matrix @@ -37,3 +37,4 @@ TEST_MATRIX_SOURCE=( ) "${tests_srcdir}/expand-test-matrix.sh" --automake "${TEST_MATRIX_SOURCE[*]}" > "${tests_srcdir}/Makefile-test-matrix.am.inc" +"${tests_srcdir}/expand-test-matrix.sh" --meson "${TEST_MATRIX_SOURCE[*]}" > "${tests_srcdir}/test-matrix/meson.build" diff --git a/triggers/meson.build b/triggers/meson.build new file mode 100644 index 0000000000..f9f81a3681 --- /dev/null +++ b/triggers/meson.build @@ -0,0 +1,9 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.1-or-later + +install_data( + 'desktop-database.trigger', + 'gtk-icon-cache.trigger', + 'mime-database.trigger', + install_dir : get_option('datadir') / 'flatpak' / 'triggers', +)