Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 0.20240321.x
  • main
  • v0.20231013.x
  • wip/case_insensitive_fs
  • wip/denittis/line_based
  • wip/denittis/portal_helper
  • wip/denittis/t17372
  • wip/denittis/t20052
  • wip/denittis/t20177
  • wip/denittis/t7017
  • wip/denittis/tasks239
  • wip/denittis/up_libcapsule
  • wip/diagnose-task724
  • wip/fix_archlinux_ci
  • wip/flatpak_exports_for_run_host
  • wip/gameoverlayrenderer
  • wip/input-device-diagnostic
  • wip/input-portal
  • wip/issue18
  • wip/luigipiucco/nixos
  • wip/protected/ci
  • wip/protected/scout-on-soldier
  • wip/protected/smcv-ci
  • wip/protected/smcv-merge-slr
  • wip/protected/task679
  • wip/refi64/check-steam-running
  • wip/refi64/ci-coverage-demo
  • wip/refi64/mr_template_test
  • wip/refi64/openxr
  • wip/refi64/openxr-rt-pv
  • wip/refi64/openxr-sysinfo
  • wip/refi64/vk-layers
  • wip/regenerate-ldso-cache
  • wip/shorten_socket
  • wip/smcv/always-copy-runtime
  • wip/smcv/ci
  • wip/smcv/clang
  • wip/smcv/delete-in-background
  • wip/smcv/dev-lib-symlinks
  • wip/smcv/diagnose-sfl10602
  • wip/smcv/diffable
  • wip/smcv/doc
  • wip/smcv/docs
  • wip/smcv/fex-3
  • wip/smcv/gcc11
  • wip/smcv/guessed-library-arch
  • wip/smcv/inspect-library
  • wip/smcv/into-library
  • wip/smcv/ld-so-wrapper
  • wip/smcv/lxc
  • wip/smcv/no-nvidia-pkcs11
  • wip/smcv/pv-wrap-to-journal
  • wip/smcv/refcount-locks
  • wip/smcv/relocatable-bin
  • wip/smcv/spawn-really-async
  • wip/smcv/staging
  • wip/smcv/steam-portal
  • wip/smcv/task149-nonfhs
  • wip/smcv/task212-basename
  • wip/smcv/task370-debug
  • wip/smcv/test-diagnostics
  • wip/smcv/variant-init-statically
  • wip/smcv/vulkan-1-1
  • wip/sr640
  • wip/sr684
  • wip/task293-v1
  • wip/task342-3
  • wip/task466
  • wip/task466-more
  • wip/task481-test
  • wip/task488-test
  • wip/task595
  • wip/task634
  • wip/task647
  • wip/task88
  • wip/task88-pre
  • wip/vulkan_shaders
  • wip/xytovl/openxr
  • pressure-vessel-v0.20180430.0
  • pressure-vessel-v0.20180517.0
  • pressure-vessel-v0.20180517.1
  • pressure-vessel-v0.20180518.0
  • pressure-vessel-v0.20180518.1
  • pressure-vessel-v0.20190510.0
  • pressure-vessel-v0.20190815.0
  • pressure-vessel-v0.20190819.0
  • pressure-vessel-v0.20190820.0
  • pressure-vessel-v0.20190822.0
  • pressure-vessel-v0.20190823.0
  • pressure-vessel-v0.20190912.0
  • pressure-vessel-v0.20190926.0
  • pressure-vessel-v0.20190927.0
  • pressure-vessel-v0.20191112.0
  • pressure-vessel-v0.20191112.1
  • pressure-vessel-v0.20191115.0
  • pressure-vessel-v0.20191216.0
  • pressure-vessel-v0.20200108.0
  • pressure-vessel-v0.20200331.0
  • pressure-vessel-v0.20200624.0
  • pressure-vessel-v0.20200708.0
  • pressure-vessel-v0.20200709.0
  • pressure-vessel-v0.20200805.0
  • pressure-vessel-v0.20200819.0
  • pressure-vessel-v0.20200908.0
  • pressure-vessel-v0.20200909.0
  • steamrt/0.20190926.0-0+steamrt1.2
  • v0.20190717.0
  • v0.20190801.0
  • v0.20190802.0
  • v0.20190806.0
  • v0.20190816.0
  • v0.20190820.0
  • v0.20190820.1
  • v0.20190822.0
  • v0.20190909.0
  • v0.20190926.0
  • v0.20190926.1
  • v0.20191024.0
  • v0.20191120.0
  • v0.20191205.0
  • v0.20191209.0
  • v0.20200108.0
  • v0.20200109.0
  • v0.20200306.0
  • v0.20200331.0
  • v0.20200331.1
  • v0.20200415.0
  • v0.20200624.0
  • v0.20200908.0
  • v0.20200908.1
  • v0.20200914.0
  • v0.20201002.0
  • v0.20201007.0
  • v0.20201022.0
  • v0.20201124.0
  • v0.20201203.0
  • v0.20210105.0
  • v0.20210114.0
  • v0.20210126.0
  • v0.20210201.0
  • v0.20210203.0
  • v0.20210305.0
  • v0.20210312.0
  • v0.20210317.0
  • v0.20210331.0
  • v0.20210415.0
  • v0.20210430.0
  • v0.20210518.0
  • v0.20210608.0
  • v0.20210608.1
  • v0.20210608.2
  • v0.20210608.3
  • v0.20210617.0
  • v0.20210617.1
  • v0.20210630.0
  • v0.20210722.0
  • v0.20210806.0
  • v0.20210809.0
  • v0.20210809.1
  • v0.20210820.0
  • v0.20210906.0
  • v0.20210906.1
  • v0.20210906.2
  • v0.20211027.0
  • v0.20211207.0
  • v0.20220107.0
  • v0.20220111.0
  • v0.20220119.0
  • v0.20220131.0
  • v0.20220311.0
  • v0.20220315.0
  • v0.20220420.0
  • v0.20220601.0
  • v0.20220620.0
  • v0.20220624.0
  • v0.20220725.0
  • v0.20220725.1
  • v0.20220726.0
178 results

Target

Select target project
  • steamrt/steam-runtime-tools
1 result
Select Git revision
  • 0.20240321.x
  • main
  • v0.20231013.x
  • wip/case_insensitive_fs
  • wip/denittis/line_based
  • wip/denittis/portal_helper
  • wip/denittis/t17372
  • wip/denittis/t20052
  • wip/denittis/t20177
  • wip/denittis/t7017
  • wip/denittis/tasks239
  • wip/denittis/up_libcapsule
  • wip/diagnose-task724
  • wip/fix_archlinux_ci
  • wip/flatpak_exports_for_run_host
  • wip/gameoverlayrenderer
  • wip/input-device-diagnostic
  • wip/input-portal
  • wip/issue18
  • wip/luigipiucco/nixos
  • wip/protected/ci
  • wip/protected/scout-on-soldier
  • wip/protected/smcv-ci
  • wip/protected/smcv-merge-slr
  • wip/protected/task679
  • wip/refi64/check-steam-running
  • wip/refi64/ci-coverage-demo
  • wip/refi64/mr_template_test
  • wip/refi64/openxr
  • wip/refi64/openxr-rt-pv
  • wip/refi64/openxr-sysinfo
  • wip/refi64/vk-layers
  • wip/regenerate-ldso-cache
  • wip/shorten_socket
  • wip/smcv/always-copy-runtime
  • wip/smcv/ci
  • wip/smcv/clang
  • wip/smcv/delete-in-background
  • wip/smcv/dev-lib-symlinks
  • wip/smcv/diagnose-sfl10602
  • wip/smcv/diffable
  • wip/smcv/doc
  • wip/smcv/docs
  • wip/smcv/fex-3
  • wip/smcv/gcc11
  • wip/smcv/guessed-library-arch
  • wip/smcv/inspect-library
  • wip/smcv/into-library
  • wip/smcv/ld-so-wrapper
  • wip/smcv/lxc
  • wip/smcv/no-nvidia-pkcs11
  • wip/smcv/pv-wrap-to-journal
  • wip/smcv/refcount-locks
  • wip/smcv/relocatable-bin
  • wip/smcv/spawn-really-async
  • wip/smcv/staging
  • wip/smcv/steam-portal
  • wip/smcv/task149-nonfhs
  • wip/smcv/task212-basename
  • wip/smcv/task370-debug
  • wip/smcv/test-diagnostics
  • wip/smcv/variant-init-statically
  • wip/smcv/vulkan-1-1
  • wip/sr640
  • wip/sr684
  • wip/task293-v1
  • wip/task342-3
  • wip/task466
  • wip/task466-more
  • wip/task481-test
  • wip/task488-test
  • wip/task595
  • wip/task634
  • wip/task647
  • wip/task88
  • wip/task88-pre
  • wip/vulkan_shaders
  • wip/xytovl/openxr
  • pressure-vessel-v0.20180430.0
  • pressure-vessel-v0.20180517.0
  • pressure-vessel-v0.20180517.1
  • pressure-vessel-v0.20180518.0
  • pressure-vessel-v0.20180518.1
  • pressure-vessel-v0.20190510.0
  • pressure-vessel-v0.20190815.0
  • pressure-vessel-v0.20190819.0
  • pressure-vessel-v0.20190820.0
  • pressure-vessel-v0.20190822.0
  • pressure-vessel-v0.20190823.0
  • pressure-vessel-v0.20190912.0
  • pressure-vessel-v0.20190926.0
  • pressure-vessel-v0.20190927.0
  • pressure-vessel-v0.20191112.0
  • pressure-vessel-v0.20191112.1
  • pressure-vessel-v0.20191115.0
  • pressure-vessel-v0.20191216.0
  • pressure-vessel-v0.20200108.0
  • pressure-vessel-v0.20200331.0
  • pressure-vessel-v0.20200624.0
  • pressure-vessel-v0.20200708.0
  • pressure-vessel-v0.20200709.0
  • pressure-vessel-v0.20200805.0
  • pressure-vessel-v0.20200819.0
  • pressure-vessel-v0.20200908.0
  • pressure-vessel-v0.20200909.0
  • steamrt/0.20190926.0-0+steamrt1.2
  • v0.20190717.0
  • v0.20190801.0
  • v0.20190802.0
  • v0.20190806.0
  • v0.20190816.0
  • v0.20190820.0
  • v0.20190820.1
  • v0.20190822.0
  • v0.20190909.0
  • v0.20190926.0
  • v0.20190926.1
  • v0.20191024.0
  • v0.20191120.0
  • v0.20191205.0
  • v0.20191209.0
  • v0.20200108.0
  • v0.20200109.0
  • v0.20200306.0
  • v0.20200331.0
  • v0.20200331.1
  • v0.20200415.0
  • v0.20200624.0
  • v0.20200908.0
  • v0.20200908.1
  • v0.20200914.0
  • v0.20201002.0
  • v0.20201007.0
  • v0.20201022.0
  • v0.20201124.0
  • v0.20201203.0
  • v0.20210105.0
  • v0.20210114.0
  • v0.20210126.0
  • v0.20210201.0
  • v0.20210203.0
  • v0.20210305.0
  • v0.20210312.0
  • v0.20210317.0
  • v0.20210331.0
  • v0.20210415.0
  • v0.20210430.0
  • v0.20210518.0
  • v0.20210608.0
  • v0.20210608.1
  • v0.20210608.2
  • v0.20210608.3
  • v0.20210617.0
  • v0.20210617.1
  • v0.20210630.0
  • v0.20210722.0
  • v0.20210806.0
  • v0.20210809.0
  • v0.20210809.1
  • v0.20210820.0
  • v0.20210906.0
  • v0.20210906.1
  • v0.20210906.2
  • v0.20211027.0
  • v0.20211207.0
  • v0.20220107.0
  • v0.20220111.0
  • v0.20220119.0
  • v0.20220131.0
  • v0.20220311.0
  • v0.20220315.0
  • v0.20220420.0
  • v0.20220601.0
  • v0.20220620.0
  • v0.20220624.0
  • v0.20220725.0
  • v0.20220725.1
  • v0.20220726.0
178 results
Show changes
Showing
with 2413 additions and 332 deletions
/*
* Copyright © 2021 Collabora Ltd.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "mtree.h"
#include "steam-runtime-tools/profiling-internal.h"
#include "steam-runtime-tools/resolve-in-sysroot-internal.h"
#include "steam-runtime-tools/utils-internal.h"
#include <gio/gunixinputstream.h>
#include "enumtypes.h"
/* Enabling debug logging for this is rather too verbose, so only
* enable it when actively debugging this module */
#if 0
#define trace(...) g_debug (__VA_ARGS__)
#else
#define trace(...) do { } while (0)
#endif
gboolean
pv_mtree_entry_parse (const char *line,
PvMtreeEntry *entry,
const char *filename,
guint line_number,
GError **error)
{
PvMtreeEntry blank = PV_MTREE_ENTRY_BLANK;
g_auto(GStrv) tokens = NULL;
gsize i;
*entry = blank;
if (line[0] == '\0' || line[0] == '#')
return TRUE;
if (line[0] == '/')
return glnx_throw (error,
"%s:%u: Special commands not supported",
filename, line_number);
if (line[0] != '.' || (line[1] != ' ' && line[1] != '/' && line[1] != '\0'))
return glnx_throw (error,
"%s:%u: Filenames not relative to top level not supported",
filename, line_number);
if (g_str_has_suffix (line, "\\"))
return glnx_throw (error,
"%s:%u: Continuation lines not supported",
filename, line_number);
for (i = 0; line[i] != '\0'; i++)
{
if (line[i] == '\\')
{
if (line[i + 1] >= '0' && line[i + 1] <= '9')
continue;
switch (line[i + 1])
{
/* g_strcompress() documents these to work */
case 'b':
case 'f':
case 'n':
case 'r':
case 't':
case 'v':
case '"':
case '\\':
i += 1;
continue;
/* \M, \^, \a, \s, \E, \x, \$, escaped whitespace and escaped
* newline are not supported here */
default:
return glnx_throw (error,
"%s:%u: Unsupported backslash escape: \"\\%c\"",
filename, line_number, line[i + 1]);
}
}
}
tokens = g_strsplit_set (line, " \t", -1);
if (tokens == NULL)
return glnx_throw (error, "%s:%u: Line is empty", filename, line_number);
entry->name = g_strcompress (tokens[0]);
for (i = 1; tokens[i] != NULL; i++)
{
const char *equals;
char *endptr;
equals = strchr (tokens[i], '=');
if (equals == NULL)
return glnx_throw (error,
"%s:%u: No value for keyword '%s'",
filename, line_number, tokens[i]);
if (g_str_has_prefix (tokens[i], "cksum=")
|| g_str_has_prefix (tokens[i], "device=")
|| g_str_has_prefix (tokens[i], "flags=")
|| g_str_has_prefix (tokens[i], "gid=")
|| g_str_has_prefix (tokens[i], "gname=")
|| g_str_has_prefix (tokens[i], "ignore=")
|| g_str_has_prefix (tokens[i], "inode=")
|| g_str_has_prefix (tokens[i], "md5=")
|| g_str_has_prefix (tokens[i], "md5digest=")
|| g_str_has_prefix (tokens[i], "nlink=")
|| g_str_has_prefix (tokens[i], "nochange=")
|| g_str_has_prefix (tokens[i], "optional=")
|| g_str_has_prefix (tokens[i], "resdevice=")
|| g_str_has_prefix (tokens[i], "ripemd160digest=")
|| g_str_has_prefix (tokens[i], "rmd160=")
|| g_str_has_prefix (tokens[i], "rmd160digest=")
|| g_str_has_prefix (tokens[i], "sha1=")
|| g_str_has_prefix (tokens[i], "sha1digest=")
|| g_str_has_prefix (tokens[i], "sha384=")
|| g_str_has_prefix (tokens[i], "sha384digest=")
|| g_str_has_prefix (tokens[i], "sha512=")
|| g_str_has_prefix (tokens[i], "sha512digest=")
|| g_str_has_prefix (tokens[i], "uid=")
|| g_str_has_prefix (tokens[i], "uname="))
continue;
if (g_str_has_prefix (tokens[i], "link="))
{
entry->link = g_strcompress (equals + 1);
continue;
}
if (g_str_has_prefix (tokens[i], "contents="))
{
entry->contents = g_strcompress (equals + 1);
continue;
}
if (g_str_has_prefix (tokens[i], "sha256=")
|| g_str_has_prefix (tokens[i], "sha256digest="))
{
if (entry->sha256 == NULL)
entry->sha256 = g_strdup (equals + 1);
else if (strcmp (entry->sha256, equals + 1) != 0)
return glnx_throw (error,
"%s:%u: sha256 and sha256digest not consistent",
filename, line_number);
continue;
}
if (g_str_has_prefix (tokens[i], "mode="))
{
gint64 value = g_ascii_strtoll (equals + 1, &endptr, 8);
if (equals[1] == '\0' || *endptr != '\0')
return glnx_throw (error,
"%s:%u: Invalid mode %s",
filename, line_number, equals + 1);
entry->mode = value & 07777;
continue;
}
if (g_str_has_prefix (tokens[i], "size="))
{
gint64 value = g_ascii_strtoll (equals + 1, &endptr, 10);
if (equals[1] == '\0' || *endptr != '\0')
return glnx_throw (error,
"%s:%u: Invalid size %s",
filename, line_number, equals + 1);
entry->size = value;
continue;
}
if (g_str_has_prefix (tokens[i], "time="))
{
gdouble value = g_ascii_strtod (equals + 1, &endptr);
if (equals[1] == '\0' || *endptr != '\0')
return glnx_throw (error,
"%s:%u: Invalid time %s",
filename, line_number, equals + 1);
entry->mtime_usec = (value * G_TIME_SPAN_SECOND);
continue;
}
if (g_str_has_prefix (tokens[i], "type="))
{
int value;
if (srt_enum_from_nick (PV_TYPE_MTREE_ENTRY_KIND, equals + 1,
&value, NULL))
entry->kind = value;
else
entry->kind = PV_MTREE_ENTRY_KIND_UNKNOWN;
continue;
}
g_warning ("%s:%u: Unknown mtree keyword %s",
filename, line_number, tokens[i]);
}
if (entry->kind == PV_MTREE_ENTRY_KIND_UNKNOWN)
return glnx_throw (error,
"%s:%u: Unknown mtree entry type",
filename, line_number);
if (entry->link != NULL && entry->kind != PV_MTREE_ENTRY_KIND_LINK)
return glnx_throw (error,
"%s:%u: Non-symlink cannot have a symlink target",
filename, line_number);
if (entry->link == NULL && entry->kind == PV_MTREE_ENTRY_KIND_LINK)
return glnx_throw (error,
"%s:%u: Symlink must have a symlink target",
filename, line_number);
return TRUE;
}
/*
* pv_mtree_apply:
* @mtree: (type filename): Path to a mtree(5) manifest
* @sysroot: (type filename): A directory
* @sysroot_fd: A fd opened on @sysroot
* @source_files: (optional): A directory from which files will be
* hard-linked or copied when populating @sysroot. The `content`
* or filename in @mtree is taken to be relative to @source_files.
* @flags: Flags affecting how this is done
*
* Make the container root filesystem @sysroot conform to @mtree.
*
* @mtree must contain a subset of BSD mtree(5) syntax:
*
* - one entry per line
* - no device nodes, fifos, sockets or other special devices
* - strings are escaped using octal (for example \040 for space)
* - filenames other than "." start with "./"
*
* For regular files, we assert that the file exists, set its mtime,
* and set its permissions to either 0644 or 0755.
*
* For directories, we create the directory with 0755 permissions.
*
* For symbolic links, we create the symbolic link if it does not
* already exist.
*
* A suitable mtree file can be created from a tarball or the filesystem
* with `bsdtar(1)` from the `libarchive-tools` Debian package:
*
* |[
* bsdtar -cf - \
* --format=mtree \
* --options "!all,type,link,mode,size,time" \
* @- < foo.tar.gz
* bsdtar -cf - \
* --format=mtree \
* --options "!all,type,link,mode,size,time" \
* -C files/ .
* ]|
*
* A suitable mtree file can also be created by `mtree(8)` from the
* `netbsd-mtree` Debian package if the filenames happen to be ASCII
* (although this implementation does not support all escaped non-ASCII
* filenames produced by `netbsd-mtree`):
*
* |[
* mtree -p files -c | mtree -C
* ]|
*
* Because hard links are used whenever possible, the permissions or
* modification time of a source file in @source_files might be modified
* to conform to the @mtree.
*
* Returns: %TRUE on success
*/
gboolean
pv_mtree_apply (const char *mtree,
const char *sysroot,
int sysroot_fd,
const char *source_files,
PvMtreeApplyFlags flags,
GError **error)
{
glnx_autofd int mtree_fd = -1;
g_autoptr(GInputStream) istream = NULL;
g_autoptr(GDataInputStream) reader = NULL;
g_autoptr(SrtProfilingTimer) timer = NULL;
glnx_autofd int source_files_fd = -1;
guint line_number = 0;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
g_return_val_if_fail (mtree != NULL, FALSE);
g_return_val_if_fail (sysroot != NULL, FALSE);
g_return_val_if_fail (sysroot_fd >= 0, FALSE);
timer = _srt_profiling_start ("Apply %s to %s", mtree, sysroot);
if (!glnx_openat_rdonly (AT_FDCWD, mtree, TRUE, &mtree_fd, error))
return FALSE;
istream = g_unix_input_stream_new (glnx_steal_fd (&mtree_fd), TRUE);
if (flags & PV_MTREE_APPLY_FLAGS_GZIP)
{
g_autoptr(GInputStream) filter = NULL;
g_autoptr(GZlibDecompressor) decompressor = NULL;
decompressor = g_zlib_decompressor_new (G_ZLIB_COMPRESSOR_FORMAT_GZIP);
filter = g_converter_input_stream_new (istream, G_CONVERTER (decompressor));
g_clear_object (&istream);
istream = g_object_ref (filter);
}
reader = g_data_input_stream_new (istream);
g_data_input_stream_set_newline_type (reader, G_DATA_STREAM_NEWLINE_TYPE_LF);
if (source_files != NULL)
{
if (!glnx_opendirat (AT_FDCWD, source_files, FALSE, &source_files_fd,
error))
return FALSE;
}
g_info ("Applying \"%s\" to \"%s\"...", mtree, sysroot);
while (TRUE)
{
g_autofree gchar *line = NULL;
g_autofree gchar *parent = NULL;
const char *base;
g_autoptr(GError) local_error = NULL;
g_auto(PvMtreeEntry) entry = PV_MTREE_ENTRY_BLANK;
glnx_autofd int parent_fd = -1;
glnx_autofd int fd = -1;
int adjusted_mode;
line = g_data_input_stream_read_line (reader, NULL, NULL, &local_error);
if (line == NULL)
{
if (local_error != NULL)
{
g_propagate_prefixed_error (error, g_steal_pointer (&local_error),
"While reading a line from %s: ",
mtree);
return FALSE;
}
else
{
/* End of file, not an error */
break;
}
}
g_strstrip (line);
line_number++;
trace ("line %u: %s", line_number, line);
if (!pv_mtree_entry_parse (line, &entry, mtree, line_number, error))
return FALSE;
if (entry.name == NULL || strcmp (entry.name, ".") == 0)
continue;
trace ("mtree entry: %s", entry.name);
parent = g_path_get_dirname (entry.name);
base = glnx_basename (entry.name);
trace ("Creating %s in %s", parent, sysroot);
parent_fd = _srt_resolve_in_sysroot (sysroot_fd, parent,
SRT_RESOLVE_FLAGS_MKDIR_P,
NULL, error);
if (parent_fd < 0)
return glnx_prefix_error (error,
"Unable to create parent directory for \"%s\" in \"%s\"",
entry.name, sysroot);
switch (entry.kind)
{
case PV_MTREE_ENTRY_KIND_FILE:
if (entry.size == 0)
{
/* For empty files, we can create it from nothing. */
fd = TEMP_FAILURE_RETRY (openat (parent_fd, base,
(O_RDWR | O_CLOEXEC | O_NOCTTY
| O_NOFOLLOW | O_CREAT
| O_TRUNC),
0644));
if (fd < 0)
return glnx_throw_errno_prefix (error,
"Unable to open \"%s\" in \"%s\"",
entry.name, sysroot);
}
else if (source_files_fd >= 0)
{
const char *source = entry.contents;
if (source == NULL)
source = entry.name;
/* If it already exists, assume it's correct */
if (glnx_openat_rdonly (parent_fd, base, FALSE, &fd, NULL))
{
trace ("\"%s\" already exists in \"%s\"",
entry.name, sysroot);
}
/* If we can create a hard link, that's also fine */
else if (TEMP_FAILURE_RETRY (linkat (source_files_fd, source,
parent_fd, base, 0)) == 0)
{
trace ("Created hard link \"%s\" in \"%s\"",
entry.name, sysroot);
}
/* Or if we can copy it, that's fine too */
else
{
g_debug ("Could not create hard link \"%s\" from \"%s/%s\" into \"%s\": %s",
entry.name, source_files, source, sysroot,
g_strerror (errno));
if (!glnx_file_copy_at (source_files_fd, source, NULL,
parent_fd, base,
GLNX_FILE_COPY_OVERWRITE | GLNX_FILE_COPY_NOCHOWN,
NULL, error))
return glnx_prefix_error (error,
"Could not create copy \"%s\" from \"%s/%s\" into \"%s\"",
entry.name, source_files,
source, sysroot);
}
}
/* For other regular files we just assert that it already exists
* (and is not a symlink). */
if (fd < 0
&& !glnx_openat_rdonly (parent_fd, base, FALSE, &fd, error))
return glnx_prefix_error (error,
"Unable to open \"%s\" in \"%s\"",
entry.name, sysroot);
break;
case PV_MTREE_ENTRY_KIND_DIR:
/* Create directories on-demand */
if (!glnx_ensure_dir (parent_fd, base, 0755, error))
return glnx_prefix_error (error,
"Unable to create directory \"%s\" in \"%s\"",
entry.name, sysroot);
/* Assert that it is in fact a directory */
if (!glnx_opendirat (parent_fd, base, FALSE, &fd, error))
return glnx_prefix_error (error,
"Unable to open directory \"%s\" in \"%s\"",
entry.name, sysroot);
break;
case PV_MTREE_ENTRY_KIND_LINK:
{
g_autofree char *target = NULL;
/* Create symlinks on-demand. To be idempotent, don't delete
* an existing symlink. */
target = glnx_readlinkat_malloc (parent_fd, base,
NULL, NULL);
if (target == NULL && symlinkat (entry.link, parent_fd, base) != 0)
return glnx_throw_errno_prefix (error,
"Unable to create symlink \"%s\" in \"%s\"",
entry.name, sysroot);
}
break;
case PV_MTREE_ENTRY_KIND_BLOCK:
case PV_MTREE_ENTRY_KIND_CHAR:
case PV_MTREE_ENTRY_KIND_FIFO:
case PV_MTREE_ENTRY_KIND_SOCKET:
case PV_MTREE_ENTRY_KIND_UNKNOWN:
default:
return glnx_throw (error,
"%s:%u: Special file not supported",
mtree, line_number);
}
if (entry.kind == PV_MTREE_ENTRY_KIND_DIR
|| (entry.mode >= 0 && entry.mode & 0111))
adjusted_mode = 0755;
else
adjusted_mode = 0644;
if (fd >= 0 && !glnx_fchmod (fd, adjusted_mode, error))
{
g_prefix_error (error,
"Unable to set mode of \"%s\" in \"%s\": ",
entry.name, sysroot);
return FALSE;
}
if (entry.mtime_usec >= 0 && fd >= 0 && entry.kind == PV_MTREE_ENTRY_KIND_FILE)
{
struct timespec times[2] =
{
{ .tv_sec = 0, .tv_nsec = UTIME_OMIT }, /* atime */
{
.tv_sec = entry.mtime_usec / G_TIME_SPAN_SECOND,
.tv_nsec = (entry.mtime_usec % G_TIME_SPAN_SECOND) * 1000
} /* mtime */
};
if (futimens (fd, times) != 0)
g_warning ("Unable to set mtime of \"%s\" in \"%s\": %s",
entry.name, sysroot, g_strerror (errno));
}
}
return TRUE;
}
/*
* Free the contents of @entry, but not @entry itself.
*/
void
pv_mtree_entry_clear (PvMtreeEntry *entry)
{
g_clear_pointer (&entry->name, g_free);
g_clear_pointer (&entry->contents, g_free);
g_clear_pointer (&entry->link, g_free);
g_clear_pointer (&entry->sha256, g_free);
}
/*
* Copyright © 2021 Collabora Ltd.
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <glib.h>
#include "steam-runtime-tools/glib-backports-internal.h"
#include "libglnx/libglnx.h"
typedef enum
{
PV_MTREE_APPLY_FLAGS_GZIP = (1 << 0),
PV_MTREE_APPLY_FLAGS_NONE = 0
} PvMtreeApplyFlags;
typedef enum
{
PV_MTREE_ENTRY_KIND_UNKNOWN = '\0',
PV_MTREE_ENTRY_KIND_BLOCK = 'b',
PV_MTREE_ENTRY_KIND_CHAR = 'c',
PV_MTREE_ENTRY_KIND_DIR = 'd',
PV_MTREE_ENTRY_KIND_FIFO = 'p',
PV_MTREE_ENTRY_KIND_FILE = '-',
PV_MTREE_ENTRY_KIND_LINK = 'l',
PV_MTREE_ENTRY_KIND_SOCKET = 's',
} PvMtreeEntryKind;
typedef struct _PvMtreeEntry PvMtreeEntry;
struct _PvMtreeEntry
{
gchar *name;
gchar *contents;
gchar *link;
gchar *sha256;
goffset size;
GTimeSpan mtime_usec;
int mode;
PvMtreeEntryKind kind;
};
#define PV_MTREE_ENTRY_BLANK \
{ \
.size = -1, \
.mtime_usec = -1, \
.mode = -1, \
}
gboolean pv_mtree_entry_parse (const char *line,
PvMtreeEntry *entry,
const char *filename,
guint line_number,
GError **error);
void pv_mtree_entry_clear (PvMtreeEntry *entry);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (PvMtreeEntry, pv_mtree_entry_clear)
gboolean pv_mtree_apply (const char *mtree,
const char *sysroot,
int sysroot_fd,
const char *source_files,
PvMtreeApplyFlags flags,
GError **error);
......@@ -42,6 +42,7 @@
#include "enumtypes.h"
#include "exports.h"
#include "flatpak-run-private.h"
#include "mtree.h"
#include "tree-copy.h"
#include "utils.h"
......@@ -67,7 +68,8 @@ struct _PvRuntime
gchar *id;
gchar *deployment;
gchar *source_files; /* either deployment or that + "/files" */
gchar *tools_dir;
const gchar *pv_prefix;
const gchar *helpers_path;
PvBwrapLock *runtime_lock;
GStrv original_environ;
......@@ -115,7 +117,6 @@ enum {
PROP_FLAGS,
PROP_ID,
PROP_VARIABLE_DIR,
PROP_TOOLS_DIRECTORY,
N_PROPERTIES
};
......@@ -329,7 +330,7 @@ runtime_architecture_init (RuntimeArchitecture *self,
self->capsule_capture_libs_basename = g_strdup_printf ("%s-capsule-capture-libs",
self->details->tuple);
self->capsule_capture_libs = g_build_filename (runtime->tools_dir,
self->capsule_capture_libs = g_build_filename (runtime->helpers_path,
self->capsule_capture_libs_basename,
NULL);
self->libdir_in_current_namespace = g_build_filename (runtime->overrides, "lib",
......@@ -442,10 +443,6 @@ pv_runtime_get_property (GObject *object,
g_value_set_string (value, self->source);
break;
case PROP_TOOLS_DIRECTORY:
g_value_set_string (value, self->tools_dir);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
......@@ -529,12 +526,6 @@ pv_runtime_set_property (GObject *object,
break;
case PROP_TOOLS_DIRECTORY:
/* Construct-only */
g_return_if_fail (self->tools_dir == NULL);
self->tools_dir = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
......@@ -549,7 +540,6 @@ pv_runtime_constructed (GObject *object)
g_return_if_fail (self->original_environ != NULL);
g_return_if_fail (self->source != NULL);
g_return_if_fail (self->tools_dir != NULL);
}
static void
......@@ -820,17 +810,10 @@ pv_runtime_garbage_collect (PvRuntime *self,
if (g_str_has_prefix (dent->d_name, "deploy-"))
{
/* Don't GC old deployments unless we know which one is current
* and therefore should not be deleted */
if (self->id == NULL)
{
g_debug ("Ignoring %s/deploy-*: current ID not known",
self->variable_dir);
continue;
}
/* Don't GC the current deployment */
if (strcmp (dent->d_name + strlen ("deploy-"), self->id) == 0)
if (_srt_fstatat_is_same_file (self->variable_dir_fd,
dent->d_name,
AT_FDCWD,
self->deployment))
{
g_debug ("Ignoring %s/%s: is the current version",
self->variable_dir, dent->d_name);
......@@ -875,17 +858,17 @@ pv_runtime_init_variable_dir (PvRuntime *self,
static gboolean
pv_runtime_create_copy (PvRuntime *self,
PvBwrapLock *variable_dir_lock,
const char *usr_mtree,
PvMtreeApplyFlags mtree_flags,
GError **error)
{
g_autofree gchar *dest_usr = NULL;
g_autofree gchar *source_usr_subdir = NULL;
g_autofree gchar *temp_dir = NULL;
g_autoptr(GDir) dir = NULL;
g_autoptr(PvBwrapLock) copy_lock = NULL;
g_autoptr(PvBwrapLock) source_lock = NULL;
g_autoptr(SrtProfilingTimer) timer = NULL;
const char *member;
const char *source_usr;
glnx_autofd int temp_dir_fd = -1;
gboolean is_just_usr;
......@@ -906,28 +889,62 @@ pv_runtime_create_copy (PvRuntime *self,
"Cannot create temporary directory \"%s\"",
temp_dir);
source_usr_subdir = g_build_filename (self->source_files, "usr", NULL);
dest_usr = g_build_filename (temp_dir, "usr", NULL);
is_just_usr = !g_file_test (source_usr_subdir, G_FILE_TEST_IS_DIR);
if (usr_mtree != NULL)
{
is_just_usr = TRUE;
}
else
{
g_autofree gchar *source_usr_subdir = g_build_filename (self->source_files,
"usr", NULL);
is_just_usr = !g_file_test (source_usr_subdir, G_FILE_TEST_IS_DIR);
}
if (is_just_usr)
{
/* ${source_files}/usr does not exist, so assume it's a merged /usr,
* for example ./scout/files. Copy ${source_files}/bin to
* ${temp_dir}/usr/bin, etc. */
source_usr = self->source_files;
if (usr_mtree != NULL)
{
/* If there's a manifest available, it's actually quicker to iterate
* through the manifest and use that to populate a new copy of the
* runtime that it would be to do the equivalent of `cp -al` -
* presumably because the mtree is probably contiguous on disk,
* and the nested directories are probably not. */
glnx_autofd int dest_usr_fd = -1;
if (!glnx_ensure_dir (AT_FDCWD, dest_usr, 0755, error))
return FALSE;
if (!pv_cheap_tree_copy (self->source_files, dest_usr,
PV_COPY_FLAGS_NONE, error))
return FALSE;
if (!glnx_opendirat (AT_FDCWD, dest_usr, FALSE, &dest_usr_fd, error))
{
g_prefix_error (error, "Unable to open \"%s\": ", dest_usr);
return FALSE;
}
if (!pv_mtree_apply (usr_mtree, dest_usr, dest_usr_fd,
self->source_files, mtree_flags,
error))
return FALSE;
}
else
{
/* Fall back to assuming that what's on-disk is correct. */
if (!pv_cheap_tree_copy (self->source_files, dest_usr,
PV_COPY_FLAGS_NONE, error))
return FALSE;
}
}
else
{
/* ${source_files}/usr exists, so assume it's a complete sysroot.
* Merge ${source_files}/bin and ${source_files}/usr/bin into
* ${temp_dir}/usr/bin, etc. */
source_usr = source_usr_subdir;
g_assert (usr_mtree == NULL);
if (!pv_cheap_tree_copy (self->source_files, temp_dir,
PV_COPY_FLAGS_USRMERGE, error))
......@@ -982,7 +999,7 @@ pv_runtime_create_copy (PvRuntime *self,
temp_dir);
}
dir = g_dir_open (source_usr, 0, error);
dir = g_dir_open (dest_usr, 0, error);
if (dir == NULL)
return FALSE;
......@@ -1471,11 +1488,18 @@ pv_runtime_initable_init (GInitable *initable,
g_autoptr(PvBwrapLock) mutable_lock = NULL;
g_autofree gchar *contents = NULL;
g_autofree gchar *os_release = NULL;
g_autofree gchar *usr_mtree = NULL;
gsize len;
PvMtreeApplyFlags mtree_flags = PV_MTREE_APPLY_FLAGS_NONE;
g_return_val_if_fail (PV_IS_RUNTIME (self), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
self->pv_prefix = _srt_find_myself (&self->helpers_path, error);
if (self->pv_prefix == NULL)
return FALSE;
/* Enumerating the graphics provider's drivers only requires things
* we already know, so start this first, and let it run in parallel
* with other setup. The results go in the SrtSystemInfo's cache
......@@ -1533,11 +1557,40 @@ pv_runtime_initable_init (GInitable *initable,
self->deployment);
}
/* If it contains ./files/, assume it's a Flatpak-style runtime where
* ./files is a merged /usr and ./metadata is an optional GKeyFile */
/* If the deployment contains usr-mtree.txt, assume that it's a
* Flatpak-style merged-/usr runtime, and usr-mtree.txt describes
* what's in the runtime. The content is taken from the files/
* directory, but files not listed in the mtree are not included.
*
* The manifest compresses well (about 3:1 if sha256sums are included)
* so try to read a compressed version first, falling back to
* uncompressed. */
usr_mtree = g_build_filename (self->deployment, "usr-mtree.txt.gz", NULL);
if (g_file_test (usr_mtree, G_FILE_TEST_IS_REGULAR))
{
mtree_flags |= PV_MTREE_APPLY_FLAGS_GZIP;
}
else
{
g_clear_pointer (&usr_mtree, g_free);
usr_mtree = g_build_filename (self->deployment, "usr-mtree.txt", NULL);
}
if (!g_file_test (usr_mtree, G_FILE_TEST_IS_REGULAR))
g_clear_pointer (&usr_mtree, g_free);
/* Or, if it contains ./files/, assume it's a Flatpak-style runtime where
* ./files is a merged /usr and ./metadata is an optional GKeyFile. */
self->source_files = g_build_filename (self->deployment, "files", NULL);
if (g_file_test (self->source_files, G_FILE_TEST_IS_DIR))
if (usr_mtree != NULL)
{
g_debug ("Assuming %s is a merged-/usr runtime because it has "
"a /usr mtree",
self->deployment);
}
else if (g_file_test (self->source_files, G_FILE_TEST_IS_DIR))
{
g_debug ("Assuming %s is a Flatpak-style runtime", self->deployment);
}
......@@ -1550,12 +1603,6 @@ pv_runtime_initable_init (GInitable *initable,
g_debug ("Taking runtime files from: %s", self->source_files);
if (!g_file_test (self->tools_dir, G_FILE_TEST_IS_DIR))
{
return glnx_throw (error, "\"%s\" is not a directory",
self->tools_dir);
}
/* Take a lock on the runtime until we're finished with setup,
* to make sure it doesn't get deleted.
*
......@@ -1601,6 +1648,10 @@ pv_runtime_initable_init (GInitable *initable,
return FALSE;
}
/* Always copy the runtime into var/ before applying a manifest. */
if (usr_mtree != NULL)
self->flags |= PV_RUNTIME_FLAGS_COPY_RUNTIME;
if (self->flags & PV_RUNTIME_FLAGS_COPY_RUNTIME)
{
if (self->variable_dir_fd < 0)
......@@ -1620,7 +1671,8 @@ pv_runtime_initable_init (GInitable *initable,
if (mutable_lock == NULL)
return FALSE;
if (!pv_runtime_create_copy (self, mutable_lock, error))
if (!pv_runtime_create_copy (self, mutable_lock, usr_mtree,
mtree_flags, error))
return FALSE;
}
......@@ -1785,7 +1837,6 @@ pv_runtime_finalize (GObject *object)
g_free (self->source);
g_free (self->source_files);
g_free (self->deployment);
g_free (self->tools_dir);
if (self->runtime_lock != NULL)
pv_bwrap_lock_free (self->runtime_lock);
......@@ -1855,13 +1906,6 @@ pv_runtime_class_init (PvRuntimeClass *cls)
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
properties[PROP_TOOLS_DIRECTORY] =
g_param_spec_string ("tools-directory", "Tools directory",
"Path to pressure-vessel/bin in current namespace",
NULL,
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
}
......@@ -1870,14 +1914,12 @@ pv_runtime_new (const char *source,
const char *id,
const char *variable_dir,
const char *bubblewrap,
const char *tools_dir,
PvGraphicsProvider *provider,
const GStrv original_environ,
PvRuntimeFlags flags,
GError **error)
{
g_return_val_if_fail (source != NULL, NULL);
g_return_val_if_fail (tools_dir != NULL, NULL);
g_return_val_if_fail ((flags & ~(PV_RUNTIME_FLAGS_MASK)) == 0, NULL);
return g_initable_new (PV_TYPE_RUNTIME,
......@@ -1889,7 +1931,6 @@ pv_runtime_new (const char *source,
"variable-dir", variable_dir,
"source", source,
"id", id,
"tools-directory", tools_dir,
"flags", flags,
NULL);
}
......@@ -5236,8 +5277,6 @@ pv_runtime_bind (PvRuntime *self,
PvEnviron *container_env,
GError **error)
{
g_autofree gchar *pressure_vessel_prefix = NULL;
g_return_val_if_fail (PV_IS_RUNTIME (self), FALSE);
g_return_val_if_fail ((exports == NULL) == (bwrap == NULL), FALSE);
g_return_val_if_fail (bwrap == NULL || !pv_bwrap_was_finished (bwrap), FALSE);
......@@ -5271,8 +5310,6 @@ pv_runtime_bind (PvRuntime *self,
if (bwrap != NULL)
bind_runtime_finish (self, exports, bwrap);
pressure_vessel_prefix = g_path_get_dirname (self->tools_dir);
/* Make sure pressure-vessel itself is visible there. */
if (self->mutable_sysroot != NULL)
{
......@@ -5292,7 +5329,7 @@ pv_runtime_bind (PvRuntime *self,
dest = glnx_fdrel_abspath (parent_dirfd, "from-host");
if (!pv_cheap_tree_copy (pressure_vessel_prefix, dest,
if (!pv_cheap_tree_copy (self->pv_prefix, dest,
PV_COPY_FLAGS_NONE, error))
return FALSE;
......@@ -5308,7 +5345,7 @@ pv_runtime_bind (PvRuntime *self,
else
{
g_autofree gchar *pressure_vessel_prefix_in_host_namespace =
pv_current_namespace_path_to_host_path (pressure_vessel_prefix);
pv_current_namespace_path_to_host_path (self->pv_prefix);
g_assert (bwrap != NULL);
......
......@@ -90,7 +90,6 @@ PvRuntime *pv_runtime_new (const char *source,
const char *id,
const char *variable_dir,
const char *bubblewrap,
const char *tools_dir,
PvGraphicsProvider *provider,
const GStrv original_environ,
PvRuntimeFlags flags,
......
......@@ -46,75 +46,6 @@
static int my_pid = -1;
static const gchar *my_prgname = NULL;
/**
* pv_envp_cmp:
* @p1: a `const char * const *`
* @p2: a `const char * const *`
*
* Compare two environment variables, given as pointers to pointers
* to the actual `KEY=value` string.
*
* In particular this is suitable for sorting a #GStrv using `qsort`.
*
* Returns: negative, 0 or positive if `*p1` compares before, equal to
* or after `*p2`
*/
int
pv_envp_cmp (const void *p1,
const void *p2)
{
const char * const * s1 = p1;
const char * const * s2 = p2;
size_t l1 = strlen (*s1);
size_t l2 = strlen (*s2);
size_t min;
const char *tmp;
int ret;
tmp = strchr (*s1, '=');
if (tmp != NULL)
l1 = tmp - *s1;
tmp = strchr (*s2, '=');
if (tmp != NULL)
l2 = tmp - *s2;
min = MIN (l1, l2);
ret = strncmp (*s1, *s2, min);
/* If they differ before the first '=' (if any) in either s1 or s2,
* then they are certainly different */
if (ret != 0)
return ret;
ret = strcmp (*s1, *s2);
/* If they do not differ at all, then they are equal */
if (ret == 0)
return ret;
/* FOO < FOO=..., and FOO < FOOBAR */
if ((*s1)[min] == '\0')
return -1;
/* FOO=... > FOO, and FOOBAR > FOO */
if ((*s2)[min] == '\0')
return 1;
/* FOO= < FOOBAR */
if ((*s1)[min] == '=' && (*s2)[min] != '=')
return -1;
/* FOOBAR > FOO= */
if ((*s2)[min] == '=' && (*s1)[min] != '=')
return 1;
/* Fall back to plain string comparison */
return ret;
}
/**
* pv_get_current_dirs:
* @cwd_p: (out) (transfer full) (optional): Used to return the
......@@ -812,50 +743,6 @@ pv_terminate_all_child_processes (GTimeSpan wait_period,
return TRUE;
}
/*
* @str: A path
* @prefix: A possible prefix
*
* The same as flatpak_has_path_prefix(), but instead of a boolean,
* return the part of @str after @prefix (non-%NULL but possibly empty)
* if @str has prefix @prefix, or %NULL if it does not.
*
* Returns: (nullable) (transfer none): the part of @str after @prefix,
* or %NULL if @str is not below @prefix
*/
const char *
pv_get_path_after (const char *str,
const char *prefix)
{
while (TRUE)
{
/* Skip consecutive slashes to reach next path
element */
while (*str == '/')
str++;
while (*prefix == '/')
prefix++;
/* No more prefix path elements? Done! */
if (*prefix == 0)
return str;
/* Compare path element */
while (*prefix != 0 && *prefix != '/')
{
if (*str != *prefix)
return NULL;
str++;
prefix++;
}
/* Matched prefix path element,
must be entire str path element */
if (*str != '/' && *str != 0)
return NULL;
}
}
/**
* pv_current_namespace_path_to_host_path:
* @current_env_path: a path in the current environment
......@@ -883,7 +770,7 @@ pv_current_namespace_path_to_host_path (const gchar *current_env_path)
home = g_get_home_dir ();
if (home != NULL)
after = pv_get_path_after (current_env_path, home);
after = _srt_get_path_after (current_env_path, home);
/* If we are inside a Flatpak container, usually, the home
* folder is '${HOME}/.var/app/${FLATPAK_ID}' on the host system */
......@@ -913,7 +800,7 @@ pv_current_namespace_path_to_host_path (const gchar *current_env_path)
}
}
after = pv_get_path_after (current_env_path, "/run/host");
after = _srt_get_path_after (current_env_path, "/run/host");
/* In a Flatpak container, usually, '/run/host' is the root of the
* host system */
......
......@@ -44,9 +44,6 @@
#define pv_log_failure(...) \
g_log (G_LOG_DOMAIN, PV_LOG_LEVEL_FAILURE, __VA_ARGS__)
int pv_envp_cmp (const void *p1,
const void *p2);
void pv_get_current_dirs (gchar **cwd_p,
gchar **cwd_l);
......@@ -79,9 +76,6 @@ gboolean pv_terminate_all_child_processes (GTimeSpan wait_period,
gchar *pv_current_namespace_path_to_host_path (const gchar *current_env_path);
const char *pv_get_path_after (const char *str,
const char *prefix);
void pv_set_up_logging (gboolean opt_verbose);
void pv_delete_dangling_symlink (int dirfd,
......
/*
* Copyright 2018-2021 Wim Taymans
* Copyright 2021 Collabora Ltd.
*
* SPDX-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include "wrap-pipewire.h"
/* From Pipewire 0.3.27 */
#define PW_DEFAULT_REMOTE "pipewire-0"
#define DEFAULT_SYSTEM_RUNTIME_DIR "/run/pipewire"
/* Adapted from Pipewire 0.3.27 */
static const char *
get_remote (void)
{
const char *name = NULL;
name = getenv("PIPEWIRE_REMOTE");
if (name == NULL || name[0] == '\0')
name = PW_DEFAULT_REMOTE;
return name;
}
/* Adapted from Pipewire 0.3.27 */
static const char *
get_runtime_dir (void)
{
const char *runtime_dir;
runtime_dir = g_getenv ("PIPEWIRE_RUNTIME_DIR");
if (runtime_dir == NULL)
runtime_dir = g_getenv ("XDG_RUNTIME_DIR");
if (runtime_dir == NULL)
runtime_dir = g_getenv ("HOME");
if (runtime_dir == NULL)
runtime_dir = g_getenv ("USERPROFILE");
if (runtime_dir == NULL)
runtime_dir = g_get_home_dir ();
return runtime_dir;
}
void
pv_wrap_add_pipewire_args (FlatpakBwrap *sharing_bwrap,
PvEnviron *container_env)
{
g_autoptr(GDir) dir = NULL;
const char *remote = get_remote ();
const char *runtime_dir = get_runtime_dir ();
const char *member;
/* Make Pipewire look in the container's XDG_RUNTIME_DIR */
pv_environ_lock_env (container_env, "PIPEWIRE_RUNTIME_DIR", NULL);
if (g_file_test (DEFAULT_SYSTEM_RUNTIME_DIR, G_FILE_TEST_IS_DIR))
flatpak_bwrap_add_args (sharing_bwrap,
"--ro-bind",
DEFAULT_SYSTEM_RUNTIME_DIR,
DEFAULT_SYSTEM_RUNTIME_DIR,
NULL);
dir = g_dir_open (runtime_dir, 0, NULL);
if (dir == NULL)
return;
for (member = g_dir_read_name (dir);
member != NULL;
member = g_dir_read_name (dir))
{
/* Assume that anything starting with pipewire- is a (default or
* extra) Pipewire socket */
if (g_str_has_prefix (member, "pipewire-"))
{
g_autofree gchar *host_socket =
g_build_filename (runtime_dir, member, NULL);
g_autofree gchar *container_socket =
g_strdup_printf ("/run/user/%d/%s", getuid (), member);
flatpak_bwrap_add_args (sharing_bwrap,
"--ro-bind",
host_socket,
container_socket,
NULL);
}
}
if (!g_str_has_prefix (remote, "pipewire-"))
{
/* If the configured Pipewire socket is something weird, remap it
* to be named pv-pipewire to avoid colliding with anything else */
g_autofree gchar *host_socket =
g_build_filename (runtime_dir, remote, NULL);
if (g_file_test (host_socket, G_FILE_TEST_EXISTS))
{
g_autofree gchar *container_socket =
g_strdup_printf ("/run/user/%d/pv-pipewire", getuid ());
pv_environ_lock_env (container_env, "PIPEWIRE_REMOTE", "pv-pipewire");
flatpak_bwrap_add_args (sharing_bwrap,
"--ro-bind",
host_socket,
container_socket,
NULL);
}
else
{
pv_environ_lock_env (container_env, "PIPEWIRE_REMOTE", NULL);
}
}
}
/*
* Copyright 2021 Collabora Ltd.
*
* SPDX-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include "environ.h"
#include "flatpak-bwrap-private.h"
void pv_wrap_add_pipewire_args (FlatpakBwrap *sharing_bwrap,
PvEnviron *container_env);
......@@ -86,6 +86,7 @@ pv_wrap_share_sockets (FlatpakBwrap *bwrap,
flatpak_run_add_session_dbus_args (sharing_bwrap);
flatpak_run_add_system_dbus_args (sharing_bwrap);
flatpak_run_add_resolved_args (sharing_bwrap);
pv_wrap_add_pipewire_args (sharing_bwrap, container_env);
}
envp = pv_bwrap_steal_envp (sharing_bwrap);
......
......@@ -26,6 +26,7 @@
#include "flatpak-bwrap-private.h"
#include "flatpak-exports-private.h"
#include "wrap-pipewire.h"
void pv_wrap_share_sockets (FlatpakBwrap *bwrap,
PvEnviron *container_env,
......
......@@ -1725,7 +1725,7 @@ main (int argc,
g_debug ("Environment variables:");
qsort (env, g_strv_length (env), sizeof (char *), pv_envp_cmp);
qsort (env, g_strv_length (env), sizeof (char *), flatpak_envp_cmp);
for (i = 0; env[i] != NULL; i++)
{
......@@ -1971,7 +1971,6 @@ main (int argc,
opt_runtime_id,
opt_variable_dir,
bwrap_executable,
tools_dir,
graphics_provider,
original_environ,
flags,
......@@ -2749,9 +2748,7 @@ main (int argc,
/* We'll have permuted the order anyway, so we might as well sort it,
* to make debugging a bit easier. */
if (final_argv->envp != NULL)
qsort (final_argv->envp, g_strv_length (final_argv->envp),
sizeof (char *), pv_envp_cmp);
flatpak_bwrap_sort_envp (final_argv);
if (opt_verbose)
{
......
......@@ -281,17 +281,18 @@ _srt_resolve_in_sysroot (int sysroot,
if (!glnx_fstatat (fd, "", &stat_buf, AT_EMPTY_PATH, error))
{
g_prefix_error (error,
"Unable to determine whether \"%s\" "
"Unable to determine whether \"%s/%s\" "
"is a directory",
current_path->str);
current_path->str, next);
return -1;
}
if (!S_ISDIR (stat_buf.st_mode))
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_DIRECTORY,
"\"%s\" is not a directory",
current_path->str);
"\"%s/%s\" is not a directory",
current_path->str, next);
return -1;
}
}
......
......@@ -1231,15 +1231,10 @@ ensure_overrides_cached (SrtSystemInfo *self)
if (!self->overrides.have_data)
{
static const char * const paths[] = {
"overrides",
"usr/lib/pressure-vessel/overrides",
"overrides/",
"usr/lib/pressure-vessel/overrides/",
};
g_autoptr(GError) error = NULL;
g_autofree gchar *output = NULL;
g_autofree gchar *messages = NULL;
g_autofree gchar *runtime = NULL;
const gchar *argv[] = {"find", NULL, "-ls", NULL};
int exit_status = -1;
gsize i;
self->overrides.have_data = TRUE;
......@@ -1255,46 +1250,14 @@ ensure_overrides_cached (SrtSystemInfo *self)
if (_srt_file_test_in_sysroot (self->sysroot, self->sysroot_fd,
paths[i], G_FILE_TEST_EXISTS))
{
argv[1] = paths[i];
self->overrides.values = _srt_recursive_list_content (self->sysroot,
self->sysroot_fd,
paths[i],
self->env,
&self->overrides.messages);
break;
}
}
if (argv[1] == NULL)
return;
if (!g_spawn_sync (self->sysroot, /* working directory */
(gchar **) argv,
self->env,
G_SPAWN_SEARCH_PATH,
_srt_child_setup_unblock_signals,
NULL, /* user data */
&output, /* stdout */
&messages, /* stderr */
&exit_status,
&error))
{
g_debug ("An error occurred calling the \"find\" binary: %s", error->message);
self->overrides.messages = g_new0 (gchar *, 2);
self->overrides.messages[0] = g_strdup_printf ("%s %d: %s", g_quark_to_string (error->domain), error->code, error->message);
self->overrides.messages[1] = NULL;
return;
}
if (exit_status != 0)
g_debug ("... wait status %d", exit_status);
if (output != NULL)
{
g_strchomp (output);
self->overrides.values = g_strsplit (output, "\n", -1);
}
if (messages != NULL)
{
g_strchomp (messages);
self->overrides.messages = g_strsplit (messages, "\n", -1);
}
}
}
......@@ -1311,11 +1274,10 @@ ensure_overrides_cached (SrtSystemInfo *self)
*
* The output is intended to be human-readable debugging information,
* rather than something to use programmatically, and its format is
* not guaranteed. It is currently in `find -ls` format.
* not guaranteed.
*
* Similarly, @messages is intended to be human-readable debugging
* information. It is currently whatever was output on standard error
* by `find -ls`.
* information.
*
* Returns: (array zero-terminated=1) (transfer full) (nullable): A
* %NULL-terminated array of libraries that have been overridden,
......@@ -1340,11 +1302,7 @@ srt_system_info_list_pressure_vessel_overrides (SrtSystemInfo *self,
static void
ensure_pinned_libs_cached (SrtSystemInfo *self)
{
gchar *output = NULL;
gchar *messages = NULL;
gchar *runtime = NULL;
int exit_status = -1;
GError *error = NULL;
g_autofree gchar *runtime = NULL;
g_return_if_fail (_srt_check_not_setuid ());
......@@ -1357,86 +1315,18 @@ ensure_pinned_libs_cached (SrtSystemInfo *self)
if (runtime == NULL || g_strcmp0 (runtime, "/") == 0)
return;
const gchar *argv[] = {"find", "pinned_libs_32", "-ls", NULL};
if (!g_spawn_sync (runtime, /* working directory */
(gchar **) argv,
self->env,
G_SPAWN_SEARCH_PATH,
_srt_child_setup_unblock_signals,
NULL, /* user data */
&output, /* stdout */
&messages, /* stderr */
&exit_status,
&error))
{
g_debug ("An error occurred calling the \"find\" binary: %s", error->message);
self->pinned_libs.messages_32 = g_new0 (gchar *, 2);
self->pinned_libs.messages_32[0] = g_strdup_printf ("%s %d: %s", g_quark_to_string (error->domain), error->code, error->message);
self->pinned_libs.messages_32[1] = NULL;
goto out;
}
if (exit_status != 0)
g_debug ("... wait status %d", exit_status);
if (output != NULL)
{
g_strchomp (output);
self->pinned_libs.values_32 = g_strsplit (output, "\n", -1);
}
if (messages != NULL)
{
g_strchomp (messages);
self->pinned_libs.messages_32 = g_strsplit (messages, "\n", -1);
}
g_free (output);
g_free (messages);
/* Do the same check for `pinned_libs_64` */
argv[1] = "pinned_libs_64";
if (!g_spawn_sync (runtime, /* working directory */
(gchar **) argv,
self->env,
G_SPAWN_SEARCH_PATH,
_srt_child_setup_unblock_signals,
NULL, /* user data */
&output, /* stdout */
&messages, /* stderr */
&exit_status,
&error))
{
g_debug ("An error occurred calling the \"find\" binary: %s", error->message);
self->pinned_libs.messages_64 = g_new0 (gchar *, 2);
self->pinned_libs.messages_64[0] = g_strdup_printf ("%s %d: %s", g_quark_to_string (error->domain), error->code, error->message);
self->pinned_libs.messages_64[1] = NULL;
goto out;
}
if (exit_status != 0)
g_debug ("... wait status %d", exit_status);
if (output != NULL)
{
g_strchomp (output);
self->pinned_libs.values_64 = g_strsplit (output, "\n", -1);
}
if (messages != NULL)
{
g_strchomp (messages);
self->pinned_libs.messages_64 = g_strsplit (messages, "\n", -1);
}
self->pinned_libs.values_32 = _srt_recursive_list_content (runtime,
-1,
"pinned_libs_32",
self->env,
&self->pinned_libs.messages_32);
self->pinned_libs.values_64 = _srt_recursive_list_content (runtime,
-1,
"pinned_libs_64",
self->env,
&self->pinned_libs.messages_64);
}
out:
g_clear_error (&error);
g_free (output);
g_free (messages);
g_free (runtime);
}
/**
......@@ -1461,14 +1351,14 @@ ensure_pinned_libs_cached (SrtSystemInfo *self)
*
* The output is intended to be human-readable debugging information,
* rather than something to use programmatically, and its format is
* not guaranteed. It is currently in `find -ls` format.
* not guaranteed.
*
* Similarly, @messages is intended to be human-readable debugging
* information. It is currently whatever was output on standard error
* by `find -ls`.
* information.
*
* Returns: (array zero-terminated=1) (transfer full) (element-type utf8) (nullable):
* An array of strings, or %NULL if we were unable to call "find".
* An array of strings, or %NULL if not in an `LD_LIBRARY_PATH`-based Steam
* Runtime or if it was not possible to list the pinned libs.
* Free with g_strfreev().
*/
gchar **
......@@ -1507,14 +1397,14 @@ srt_system_info_list_pinned_libs_32 (SrtSystemInfo *self,
*
* The output is intended to be human-readable debugging information,
* rather than something to use programmatically, and its format is
* not guaranteed. It is currently in `find -ls` format.
* not guaranteed.
*
* Similarly, @messages is intended to be human-readable debugging
* information. It is currently whatever was output on standard error
* by `find -ls`.
* information.
*
* Returns: (array zero-terminated=1) (transfer full) (element-type utf8) (nullable):
* An array of strings, or %NULL if we were unable to call "find".
* An array of strings, or %NULL if not in an `LD_LIBRARY_PATH`-based Steam
* Runtime or if it was not possible to list the pinned libs.
* Free with g_strfreev().
*/
gchar **
......
......@@ -114,6 +114,15 @@ G_GNUC_INTERNAL gboolean _srt_steam_command_via_pipe (const char * const *argume
gssize n_arguments,
GError **error);
G_GNUC_INTERNAL gchar **_srt_recursive_list_content (const gchar *sysroot,
int sysroot_fd,
const gchar *directory,
gchar **envp,
gchar ***messages_out);
G_GNUC_INTERNAL const char *_srt_get_path_after (const char *str,
const char *prefix);
/*
* _srt_is_same_stat:
* @a: a stat buffer
......
......@@ -1129,3 +1129,290 @@ _srt_steam_command_via_pipe (const char * const *arguments,
return TRUE;
}
typedef struct
{
const char *from;
const char *to;
} CommonReplacements;
/*
* _srt_list_directory_content:
* @working_dir_fd: File descriptor to the current working directory
* @working_dir_path: (not nullable) (type filename): Working directory in
* the sysroot
* @sub_directory: (nullable) (type filename): If %NULL, the @working_dir_path
* itself will be opened
* @common_replacements: (nullable): If not %NULL, perform these replacements
* to the beginning of the targets paths for symlinks that have been found
* @level: Current level of recursion
* @result: (not nullable): The elements that @directory contains are appended
* to this array
* @messages: (not nullable): Human-readable debug information are appended
* to this array
*/
static void
_srt_list_directory_content (int working_dir_fd,
const gchar *working_dir_path,
const gchar *sub_directory,
const CommonReplacements *common_replacements,
int level,
GPtrArray *result,
GPtrArray *messages)
{
g_autofree gchar *full_working_path = NULL;
g_auto(GLnxDirFdIterator) iter = { FALSE };
g_autoptr(GError) error = NULL;
gsize i;
g_return_if_fail (working_dir_path != NULL);
g_return_if_fail (result != NULL);
g_return_if_fail (messages != NULL);
if (sub_directory != NULL)
full_working_path = g_build_filename (working_dir_path, sub_directory, NULL);
else
full_working_path = g_strdup (working_dir_path);
/* Arbitrary limit. If we reach this level of recursion it's a sign that
* something went wrong and it's better to bail out. */
if (level > 9)
{
g_ptr_array_add (messages, g_strdup_printf ("%s/... (too much recursion, not shown)",
full_working_path));
return;
}
if (!glnx_dirfd_iterator_init_at (working_dir_fd,
sub_directory != NULL ? sub_directory : ".",
FALSE,
&iter,
&error))
{
glnx_prefix_error (&error,
"An error occurred trying to initialize an iterator for \"%s\"",
full_working_path);
g_debug ("%s", error->message);
g_ptr_array_add (messages, g_strdup_printf ("%s %d: %s",
g_quark_to_string (error->domain),
error->code, error->message));
return;
}
while (error == NULL)
{
struct dirent *dent;
g_autofree gchar *full_name = NULL;
if (!glnx_dirfd_iterator_next_dent_ensure_dtype (&iter, &dent, NULL, &error))
{
glnx_prefix_error (&error, "An error occurred trying to initerate through \"%s\"",
full_working_path);
g_debug ("%s", error->message);
g_ptr_array_add (messages, g_strdup_printf ("%s %d: %s",
g_quark_to_string (error->domain),
error->code, error->message));
return;
}
if (dent == NULL)
break;
full_name = g_build_filename (full_working_path, dent->d_name, NULL);
if (dent->d_type == DT_LNK)
{
g_autofree gchar *target = NULL;
target = glnx_readlinkat_malloc (iter.fd, dent->d_name, NULL, &error);
if (target == NULL)
{
glnx_prefix_error (&error, "An error occurred trying to read the symlink \"%s\"",
full_name);
g_debug ("%s", error->message);
g_ptr_array_add (messages, g_strdup_printf ("%s %d: %s",
g_quark_to_string (error->domain),
error->code, error->message));
g_clear_error (&error);
target = g_strdup ("(unknown)");
}
for (i = 0; common_replacements != NULL && common_replacements[i].to != NULL; i++)
{
if (common_replacements[i].from == NULL)
continue;
const gchar *after = _srt_get_path_after (target, common_replacements[i].from);
if (after != NULL)
{
g_autofree gchar *new_target = NULL;
new_target = g_build_filename (common_replacements[i].to, after, NULL);
g_clear_pointer (&target, g_free);
target = g_steal_pointer (&new_target);
break;
}
}
g_ptr_array_add (result, g_strdup_printf ("%s -> %s", full_name, target));
}
else if (dent->d_type == DT_DIR)
{
g_ptr_array_add (result, g_strdup_printf ("%s/", full_name));
_srt_list_directory_content (iter.fd, full_working_path, dent->d_name,
common_replacements, level + 1, result, messages);
}
else
{
g_ptr_array_add (result, g_steal_pointer (&full_name));
}
}
}
/*
* _srt_recursive_list_content:
* @sysroot: (not nullable) (type filename): A path used as the root
* @sysroot_fd: A file descriptor opened on @sysroot, or negative to
* reopen it
* @directory: (not nullable) (type filename): A path below the root directory,
* either absolute or relative (to the root)
* @envp: (array zero-terminated=1) (not nullable): Behave as though `environ`
* was this array
* @messages_out: (optional) (out) (array zero-terminated=1) (transfer full):
* If not %NULL, used to return a %NULL-terminated array of diagnostic
* messages. Free with g_strfreev().
*
* Returns: (array zero-terminated=1) (transfer full) (nullable): A
* %NULL-terminated array of files, symbolic links and directories, that
* are present in the provided @directory. Free with g_strfreev().
*/
gchar **
_srt_recursive_list_content (const gchar *sysroot,
int sysroot_fd,
const gchar *directory,
gchar **envp,
gchar ***messages_out)
{
g_autoptr(GPtrArray) content = NULL;
g_autoptr(GPtrArray) messages = NULL;
glnx_autofd int local_sysroot_fd = -1;
glnx_autofd int top_fd = -1;
g_autoptr(GError) error = NULL;
const gchar *steam_runtime = NULL;
g_return_val_if_fail (sysroot != NULL, NULL);
g_return_val_if_fail (directory != NULL, NULL);
g_return_val_if_fail (envp != NULL, NULL);
g_return_val_if_fail (messages_out == NULL || *messages_out == NULL, NULL);
steam_runtime = g_environ_getenv (envp, "STEAM_RUNTIME");
/* If STEAM_RUNTIME is just the root directory we don't want to replace
* every leading '/' with $STEAM_RUNTIME */
if (g_strcmp0 (steam_runtime, "/") == 0)
steam_runtime = NULL;
const CommonReplacements common_replacements[] =
{
{ steam_runtime, "$STEAM_RUNTIME" },
{ g_environ_getenv (envp, "HOME"), "$HOME" },
{ NULL, NULL },
};
content = g_ptr_array_new_with_free_func (g_free);
messages = g_ptr_array_new_with_free_func (g_free);
if (sysroot_fd < 0)
{
if (!glnx_opendirat (-1, sysroot, FALSE, &local_sysroot_fd, &error))
{
glnx_prefix_error (&error, "An error occurred trying to open sysroot \"%s\"",
sysroot);
g_debug ("%s", error->message);
g_ptr_array_add (messages, g_strdup_printf ("%s %d: %s",
g_quark_to_string (error->domain),
error->code, error->message));
goto out;
}
sysroot_fd = local_sysroot_fd;
}
top_fd = _srt_resolve_in_sysroot (sysroot_fd,
directory,
SRT_RESOLVE_FLAGS_DIRECTORY,
NULL,
&error);
if (top_fd < 0)
{
glnx_prefix_error (&error, "An error occurred trying to resolve \"%s\" in sysroot",
directory);
g_debug ("%s", error->message);
g_ptr_array_add (messages, g_strdup_printf ("%s %d: %s",
g_quark_to_string (error->domain),
error->code, error->message));
goto out;
}
_srt_list_directory_content (top_fd, directory, NULL, common_replacements, 0,
content, messages);
g_ptr_array_sort (content, _srt_indirect_strcmp0);
out:
if (content->len > 0)
g_ptr_array_add (content, NULL);
if (messages_out != NULL && messages->len > 0)
{
g_ptr_array_add (messages, NULL);
*messages_out = (GStrv) g_ptr_array_free (g_steal_pointer (&messages), FALSE);
}
return (GStrv) g_ptr_array_free (g_steal_pointer (&content), FALSE);
}
/*
* @str: A path
* @prefix: A possible prefix
*
* The same as flatpak_has_path_prefix(), but instead of a boolean,
* return the part of @str after @prefix (non-%NULL but possibly empty)
* if @str has prefix @prefix, or %NULL if it does not.
*
* Returns: (nullable) (transfer none): the part of @str after @prefix,
* or %NULL if @str is not below @prefix
*/
const char *
_srt_get_path_after (const char *str,
const char *prefix)
{
while (TRUE)
{
/* Skip consecutive slashes to reach next path
element */
while (*str == '/')
str++;
while (*prefix == '/')
prefix++;
/* No more prefix path elements? Done! */
if (*prefix == 0)
return str;
/* Compare path element */
while (*prefix != 0 && *prefix != '/')
{
if (*str != *prefix)
return NULL;
str++;
prefix++;
}
/* Matched prefix path element,
must be entire str path element */
if (*str != '/' && *str != 0)
return NULL;
}
}
.deps
/.version
/INSTALL
/build-aux/*
/data/*-linux-gnu*-capsule-mkstublib
/m4/*
/test-suite.log
/tests/*.log
/tests/*.t
/tests/*.test
/tests/*.trs
/tests/notgl-dlopener
/tests/notgl-helper-user
/tests/notgl-user
/tests/shim/libnotgl.so.0.c
/tests/shim/libnotgles.so.1.c
Makefile.in
aclocal.m4
autom4te.cache
config.status
config.log
configure
libtool
update
Makefile
.*stamp
.libs
*.la
*.lo
*.o
shim/*.so.c
shim/*.so.symbols
shim/*.so.map
/capsule-capture-libs
/capsule-elf-dump
print-libstubs
capsule-symbols
capsule-version
TAGS
tags
*~
data/*.pc
data/dirconf.txt
*.swp
*.tmp
install.log
*.1
*.3
*-docs.xml
*.types
gtk-doc.make
*.tar.*
*.tgz
*.tar
tmpl/
*.stamp
html/
xml/
libcapsule-*.txt
*.args
*.hierarchy
*.interfaces
*.prerequisites
*.signals
!/build-aux/git-version-gen
!/m4/ax_is_release.m4
!/m4/capsule_*.m4
Vivek Das Mohapatra <vivek@collabora.com>; <vivek@etla.org>
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
# Copyright © 2017 Collabora Ltd
# This file is part of libcapsule.
# libcapsule is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of the
# License, or (at your option) any later version.
# libcapsule is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with libcapsule. If not, see <http://www.gnu.org/licenses/>.
AUTOMAKE_OPTIONS = subdir-objects
ACLOCAL_AMFLAGS = -I m4 --install
AM_CPPFLAGS = -DHOST_PREFIX=\"$(HOST_PREFIX)\"
common_cflags = -fvisibility=hidden \
--std=c99 \
$(WARN_CFLAGS) \
$(LIBELF_CFLAGS) \
$(GLIB_CFLAGS)
# Used for production code and tests, but not for test fixtures
AM_CFLAGS = $(common_cflags) $(SANITIZE_CFLAGS)
# Used for test fixtures only
test_fixture_cflags = $(common_cflags)
AM_LDFLAGS = $(WARN_LDFLAGS)
static_docs = Building Debugging Limitations Quick-Start Capsules
# installable items:
bin_PROGRAMS = capsule-capture-libs capsule-symbols capsule-version
if ENABLE_LIBRARY
dist_bin_SCRIPTS = data/capsule-init-project
lib_LTLIBRARIES = libcapsule.la
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = data/libcapsule.pc data/libcapsule-tools.pc
nobase_include_HEADERS = capsule/capsule.h
dist_doc_DATA = $(foreach doc,$(static_docs),doc/$(doc).txt)
endif
if ENABLE_TOOLS_RPATH
# Use -Wl to hide it from libtool
tools_ldflags = -Wl,-rpath,$(enable_tools_rpath)
endif
if ENABLE_HOST_PREFIX
if ENABLE_LIBRARY
bin_SCRIPTS = data/$(HOST_PREFIX)capsule-mkstublib
# Write out a version of capsule-mkstublib with different defaults
# for each architecture
data/$(HOST_PREFIX)capsule-mkstublib: data/capsule-mkstublib Makefile
$(AM_V_GEN)set -e; \
( \
sed -e 1q $<; \
echo '# Inserted by Makefile to make this architecture-specific'; \
echo ': "$${CAPSULE_SYMBOLS_TOOL:="$(bindir)/$(HOST_PREFIX)capsule-symbols"}"';\
sed -e 1d $<; \
) > $@.tmp; chmod +x $@.tmp; mv $@.tmp $@
endif
install-exec-hook: install-exec-hook-host-prefix
install-exec-hook-host-prefix:
cd $(DESTDIR)$(bindir) && ln -f capsule-symbols $(HOST_PREFIX)capsule-symbols
cd $(DESTDIR)$(bindir) && ln -f capsule-version $(HOST_PREFIX)capsule-version
cd $(DESTDIR)$(bindir) && ln -f capsule-elf-dump $(HOST_PREFIX)capsule-elf-dump
cd $(DESTDIR)$(bindir) && ln -f capsule-capture-libs $(HOST_PREFIX)capsule-capture-libs
uninstall-hook: uninstall-hook-host-prefix
uninstall-hook-host-prefix:
cd $(DESTDIR)$(bindir) && rm -f $(HOST_PREFIX)capsule-capture-libs
cd $(DESTDIR)$(bindir) && rm -f $(HOST_PREFIX)capsule-elf-dump
cd $(DESTDIR)$(bindir) && rm -f $(HOST_PREFIX)capsule-symbols
cd $(DESTDIR)$(bindir) && rm -f $(HOST_PREFIX)capsule-version
else
if ENABLE_LIBRARY
dist_bin_SCRIPTS += data/capsule-mkstublib
endif
endif
if ENABLE_LIBRARY
# Headers to be included by shim libraries
nobase_include_HEADERS += capsule/capsule-shim.h \
capsule/_int_dlopen.h
endif
noinst_LTLIBRARIES = utils/libutils.la \
utils/libld.la
utils_libutils_la_SOURCES = utils/utils.c utils/utils.h
utils_libld_la_SOURCES = utils/ld-cache.c utils/ld-cache.h
utils_libld_la_SOURCES += utils/ld-libs.c utils/ld-libs.h
utils_libld_la_LIBADD = utils/libutils.la -ldl $(LIBELF_LIBS)
# Mostly just a demo program, but keep this hanging around as it's a useful PoC
bin_PROGRAMS += capsule-elf-dump
capsule_elf_dump_SOURCES = utils/elf-dump.c utils/dump.c
capsule_elf_dump_SOURCES += utils/tools.c utils/tools.h
capsule_elf_dump_LDADD = utils/libutils.la -ldl
# This looks redundant, but it forces Automake to build separate
# instantiations of dump.o for elf-dump and libcapsule
capsule_elf_dump_CFLAGS = $(AM_CFLAGS)
capsule_elf_dump_LDFLAGS = $(AM_LDFLAGS) $(tools_ldflags)
capsule_capture_libs_SOURCES = utils/capture-libs.c \
utils/library-cmp.c \
utils/library-cmp.h \
utils/tools.c \
utils/tools.h
capsule_capture_libs_LDADD = utils/libld.la
capsule_capture_libs_LDFLAGS = $(AM_LDFLAGS) $(tools_ldflags)
# now the rules for building our installables:
capsule_symbols_SOURCES = utils/print-libstubs.c utils/tools.c utils/tools.h
capsule_symbols_LDADD = utils/libld.la
capsule_symbols_LDFLAGS = $(AM_LDFLAGS) $(tools_ldflags)
capsule_version_SOURCES = utils/print-version.c utils/tools.c utils/tools.h
capsule_version_LDADD = utils/libld.la
capsule_version_LDFLAGS = $(AM_LDFLAGS) $(tools_ldflags)
if ENABLE_LIBRARY
libcapsule_la_SOURCES = capsule/capsule-dlmopen.c \
capsule/capsule-relocate.c \
capsule/capsule-init.c \
capsule/capsule-private.h \
capsule/capsule-malloc.h \
capsule/capsule-wrappers.c \
utils/dump.c \
utils/process-pt-dynamic.c \
utils/mmap-info.c
libcapsule_la_LDFLAGS = -version-number 0:1 -Wl,-z,nodelete
libcapsule_la_LIBADD = utils/libld.la
libcapsule_la_SOURCES += utils/debug.h \
utils/dump.h \
utils/process-pt-dynamic.h \
utils/mmap-info.h
dist_pkgdata_DATA = data/capsule-shim.mk \
data/disabled.mk \
data/shim-.gitignore \
data/shim-Makefile.am \
data/shim-README.in \
data/shim-configure.ac.in \
data/shim-target-Makefile.am
endif
BUILT_SOURCES = $(top_srcdir)/.version
$(top_srcdir)/.version:
$(AM_V_GEN)echo $(VERSION) > $@-t && mv $@-t $@
include $(top_srcdir)/data/disabled.mk
# ============================================================================
# GNOME-style installed-tests
insttestsdir = $(libexecdir)/installed-tests/$(PACKAGE_TARNAME)
nobase_insttests_LTLIBRARIES =
if ENABLE_LIBRARY
# /!\ Order is important here: the helper library must come first
nobase_insttests_LTLIBRARIES += tests/red/libhelper.la \
tests/green/libhelper.la \
tests/helper/libhelper.la \
tests/red/libnotgl.la \
tests/red/libnotgles.la \
tests/green/libnotgl.la \
tests/green/libnotgles.la \
tests/lib/libnotgl.la \
tests/lib/libnotgles.la \
tests/shim/libnotgl.la \
tests/shim/libnotgles.la
nobase_dist_insttests_DATA = tests/CapsuleTest.pm \
tests/CapsuleTestDpkg.pm \
tests/notgl.h \
tests/notgl-green.c \
tests/notgl-red.c \
tests/notgl-ref.c \
tests/notgl-helper.h \
tests/notgl-helper-green.c \
tests/notgl-helper-red.c \
tests/notgl-helper-ref.c \
tests/notgles.h \
tests/notgles-green.c \
tests/notgles-red.c \
tests/notgles-ref.c \
tests/shim/libnotgl.so.0.excluded \
tests/shim/libnotgl.so.0.shared \
tests/shim/libnotgl.so.0.symbols \
tests/shim/libnotgles.so.1.excluded \
tests/shim/libnotgles.so.1.shared \
tests/shim/libnotgles.so.1.symbols
# Install the source code so we can rebuild it inside a container if we want to
gl_shims = libEGL.so.1 \
libGL.so.1 \
libGLESv2.so.2 \
libGLX.so.0 \
libOpenGL.so.0 \
libX11.so.6 \
libXext.so.6 \
libXi.so.6 \
libgbm.so.1 \
libxcb-dri2.so.0 \
libxcb-glx.so.0 \
libxcb-present.so.0 \
libxcb-sync.so.1 \
libxcb.so.1
# We don't do this via nobase_dist_insttests_DATA because patsubst doesn't
# work for make dist, so we would have to write it out longhand
install-data-local-shim-sources:
$(AM_V_GEN)set -e; \
$(mkinstalldirs) $(DESTDIR)$(insttestsdir)/examples/shim; \
for lib in ${gl_shims}; do \
$(INSTALL_DATA) \
$(srcdir)/examples/shim/$$lib.excluded \
$(srcdir)/examples/shim/$$lib.shared \
$(srcdir)/examples/shim/$$lib.symbols \
$(srcdir)/examples/shim/$$lib.symbols.updated-for \
$(DESTDIR)$(insttestsdir)/examples/shim; \
done
uninstall-hook: uninstall-hook-shim-sources
uninstall-hook-shim-sources:
$(AM_V_GEN)set -e; \
for lib in ${gl_shims}; do \
rm -fr \
$(DESTDIR)$(insttestsdir)/examples/shim/$$lib.excluded \
$(DESTDIR)$(insttestsdir)/examples/shim/$$lib.shared \
$(DESTDIR)$(insttestsdir)/examples/shim/$$lib.symbols \
$(DESTDIR)$(insttestsdir)/examples/shim/$$lib.symbols.updated-for \
; \
done
dist-hook-shim-sources:
$(AM_V_GEN)set -e; \
$(MKDIR_P) $(distdir)/examples/shim; \
for lib in ${gl_shims}; do \
cp \
$(srcdir)/examples/shim/$$lib.excluded \
$(srcdir)/examples/shim/$$lib.shared \
$(srcdir)/examples/shim/$$lib.symbols \
$(srcdir)/examples/shim/$$lib.symbols.updated-for \
$(distdir)/examples/shim; \
done
endif
maintainer-update-gl-shims:
@if test -z "${GL_SHIMS_SOURCE_MACHINE}"; then \
echo "usage: make -C $(CURDIR) maintainer-update-gl-shims GL_SHIMS_SOURCE_MACHINE=some-machine">&2; \
exit 2; \
fi
set -e; for lib in ${gl_shims}; do \
ssh "${GL_SHIMS_SOURCE_MACHINE}" \
x86_64-linux-gnu-capsule-symbols "$$lib" \
> $(abs_top_srcdir)/examples/shim/"$$lib.symbols.tmp"; \
LC_ALL=C sort -u \
< $(abs_top_srcdir)/examples/shim/"$$lib.symbols.tmp" \
> $(abs_top_srcdir)/examples/shim/"$$lib.symbols"; \
rm -f $(abs_top_srcdir)/examples/shim/"$$lib.symbols.tmp"; \
: > $(abs_top_srcdir)/examples/shim/"$$lib.excluded"; \
: > $(abs_top_srcdir)/examples/shim/"$$lib.shared"; \
: > $(abs_top_srcdir)/examples/shim/"$$lib.symbols.updated-for"; \
done
if ENABLE_LIBRARY
tests_lib_libnotgl_la_SOURCES = tests/notgl-ref.c \
tests/notgl.h \
tests/notgl-helper.h
tests_lib_libnotgl_la_CFLAGS = $(test_fixture_cflags)
tests_lib_libnotgl_la_LDFLAGS = -shared -version-number 0:42:23
tests_lib_libnotgl_la_LIBADD = tests/helper/libhelper.la
tests_lib_libnotgles_la_SOURCES = tests/notgles-ref.c \
tests/notgles.h \
tests/notgl-helper.h
tests_lib_libnotgles_la_CFLAGS = $(test_fixture_cflags)
tests_lib_libnotgles_la_LDFLAGS = -shared -version-number 1:42:23
tests_lib_libnotgles_la_LIBADD = tests/helper/libhelper.la
tests_red_libnotgl_la_SOURCES = tests/notgl-red.c \
tests/notgl.h \
tests/notgl-helper.h
tests_red_libnotgl_la_CFLAGS = $(test_fixture_cflags)
# Give it a gratuitously higher version number
tests_red_libnotgl_la_LDFLAGS = -shared -version-number 0:123:456
# We want the RUNPATH or RPATH to point to tests/helper here, so we can
# demonstrate the functionality of loading two different libraries from the
# same path on host and container
tests_red_libnotgl_la_LIBADD = tests/helper/libhelper.la
tests_red_libnotgles_la_SOURCES = tests/notgles-red.c \
tests/notgles.h \
tests/notgl-helper.h
tests_red_libnotgles_la_CFLAGS = $(test_fixture_cflags)
tests_red_libnotgles_la_LDFLAGS = -shared -version-number 1:123:456
tests_red_libnotgles_la_LIBADD = tests/helper/libhelper.la
tests_green_libnotgl_la_SOURCES = tests/notgl-green.c \
tests/notgl.h \
tests/notgl-helper.h
tests_green_libnotgl_la_CFLAGS = $(test_fixture_cflags)
# Give this one a gratuitously *lower* version number
tests_green_libnotgl_la_LDFLAGS = -shared -version-number 0:23:42
# Again, we want the RUNPATH or RPATH to point to tests/helper here
tests_green_libnotgl_la_LIBADD = tests/helper/libhelper.la
tests_green_libnotgles_la_SOURCES = tests/notgles-green.c \
tests/notgles.h \
tests/notgl-helper.h
tests_green_libnotgles_la_CFLAGS = $(test_fixture_cflags)
tests_green_libnotgles_la_LDFLAGS = -shared -version-number 1:23:42
tests_green_libnotgles_la_LIBADD = tests/helper/libhelper.la
tests_helper_libhelper_la_SOURCES = tests/notgl-helper-ref.c \
tests/notgl-helper.h
tests_helper_libhelper_la_CFLAGS = $(test_fixture_cflags)
tests_helper_libhelper_la_LDFLAGS = -shared -version-number 0:42:23
tests_red_libhelper_la_SOURCES = tests/notgl-helper-red.c \
tests/notgl-helper.h
tests_red_libhelper_la_CFLAGS = $(test_fixture_cflags)
tests_red_libhelper_la_LDFLAGS = -shared -version-number 0:123:456
tests_green_libhelper_la_SOURCES = tests/notgl-helper-green.c \
tests/notgl-helper.h
tests_green_libhelper_la_CFLAGS = $(test_fixture_cflags)
tests_green_libhelper_la_LDFLAGS = -shared -version-number 0:23:42
nodist_tests_shim_libnotgl_la_SOURCES = tests/shim/libnotgl.so.0.c
tests_shim_libnotgl_la_LIBADD = libcapsule.la
tests_shim_libnotgl_la_CFLAGS = $(test_fixture_cflags)
tests_shim_libnotgl_la_LDFLAGS = -shared -version-number 0:0:0
nodist_tests_shim_libnotgles_la_SOURCES = tests/shim/libnotgles.so.1.c
tests_shim_libnotgles_la_LIBADD = libcapsule.la
tests_shim_libnotgles_la_CFLAGS = $(test_fixture_cflags)
tests_shim_libnotgles_la_LDFLAGS = -shared -version-number 1:0:0
tests/shim/%.c: tests/shim/%.excluded tests/shim/%.shared tests/shim/%.symbols data/capsule-mkstublib Makefile
$(AM_V_GEN)\
PKG_CONFIG_PATH=$(abs_builddir)/data \
V=$V \
$(top_srcdir)/data/capsule-mkstublib \
--symbols-from=$(srcdir)/tests/shim/$*.symbols \
--no-update-symbols \
--runtime-tree=/host \
$* \
$(srcdir)/tests/shim/$*.excluded \
$(srcdir)/tests/shim/$*.shared \
$@
endif
if ENABLE_SHARED
AM_CPPFLAGS += -DENABLE_SHARED
nobase_insttests_LTLIBRARIES += tests/version1/libunversionedabibreak.la \
tests/version2/libunversionedabibreak.la \
tests/version1/libunversionednumber.la \
tests/version2/libunversionednumber.la \
tests/version1/libunversionedsymbols.la \
tests/version2/libunversionedsymbols.la \
tests/version1/libversionedabibreak.la \
tests/version2/libversionedabibreak.la \
tests/version1/libversionedlikedbus.la \
tests/version2/libversionedlikedbus.la \
tests/version1/libversionedlikeglibc.la \
tests/version2/libversionedlikeglibc.la \
tests/version1/libversionednumber.la \
tests/version2/libversionednumber.la \
tests/version1/libversionedprivatenothidden.la \
tests/version2/libversionedprivatenothidden.la \
tests/version1/libversionedsymbols.la \
tests/version2/libversionedsymbols.la \
tests/version1/libversionedupgrade.la \
tests/version2/libversionedupgrade.la
tests_version1_libunversionedabibreak_la_CFLAGS = $(test_fixture_cflags)
tests_version1_libunversionedabibreak_la_LDFLAGS = -shared -version-number 1:0:0
tests_version2_libunversionedabibreak_la_CFLAGS = $(test_fixture_cflags)
tests_version2_libunversionedabibreak_la_LDFLAGS = -shared -version-number 1:0:0
tests_version1_libunversionednumber_la_CFLAGS = $(test_fixture_cflags)
tests_version1_libunversionednumber_la_LDFLAGS = -shared -version-number 1:0:0
tests_version2_libunversionednumber_la_CFLAGS = $(test_fixture_cflags)
tests_version2_libunversionednumber_la_LDFLAGS = -shared -version-number 1:2:3
tests_version1_libunversionedsymbols_la_CFLAGS = $(test_fixture_cflags)
tests_version1_libunversionedsymbols_la_LDFLAGS = -shared -version-number 1:0:0
tests_version2_libunversionedsymbols_la_CFLAGS = $(test_fixture_cflags)
tests_version2_libunversionedsymbols_la_LDFLAGS = -shared -version-number 1:0:0
tests_version1_libversionedabibreak_la_CFLAGS = $(test_fixture_cflags)
tests_version1_libversionedabibreak_la_LDFLAGS = -shared -version-number 1:0:0 \
-Wl,--version-script=$(srcdir)/tests/version1/libversionedabibreak.map
tests_version2_libversionedabibreak_la_CFLAGS = $(test_fixture_cflags)
tests_version2_libversionedabibreak_la_LDFLAGS = -shared -version-number 1:0:0 \
-Wl,--version-script=$(srcdir)/tests/version2/libversionedabibreak.map
tests_version1_libversionedlikedbus_la_CFLAGS = $(test_fixture_cflags)
tests_version1_libversionedlikedbus_la_LDFLAGS = -shared -version-number 1:0:0 \
-Wl,--version-script=$(srcdir)/tests/version1/libversionedlikedbus.map
tests_version2_libversionedlikedbus_la_CFLAGS = $(test_fixture_cflags)
tests_version2_libversionedlikedbus_la_LDFLAGS = -shared -version-number 1:2:0 \
-Wl,--version-script=$(srcdir)/tests/version2/libversionedlikedbus.map
tests_version1_libversionedlikeglibc_la_CFLAGS = $(test_fixture_cflags)
tests_version1_libversionedlikeglibc_la_LDFLAGS = -shared -version-number 1:0:0 \
-Wl,--version-script=$(srcdir)/tests/version1/libversionedlikeglibc.map
tests_version2_libversionedlikeglibc_la_CFLAGS = $(test_fixture_cflags)
tests_version2_libversionedlikeglibc_la_LDFLAGS = -shared -version-number 1:0:0 \
-Wl,--version-script=$(srcdir)/tests/version2/libversionedlikeglibc.map
tests_version1_libversionednumber_la_CFLAGS = $(test_fixture_cflags)
tests_version1_libversionednumber_la_LDFLAGS = -shared -version-number 1:0:0 \
-Wl,--version-script=$(srcdir)/tests/libversioned.map
tests_version2_libversionednumber_la_CFLAGS = $(test_fixture_cflags)
tests_version2_libversionednumber_la_LDFLAGS = -shared -version-number 1:2:3 \
-Wl,--version-script=$(srcdir)/tests/libversioned.map
tests_version1_libversionedprivatenothidden_la_CFLAGS = $(test_fixture_cflags)
tests_version1_libversionedprivatenothidden_la_LDFLAGS = -shared -version-number 1:1:1 \
-Wl,--version-script=$(srcdir)/tests/version1/libversionedprivatenothidden.map
tests_version2_libversionedprivatenothidden_la_CFLAGS = $(test_fixture_cflags)
tests_version2_libversionedprivatenothidden_la_LDFLAGS = -shared -version-number 1:1:1 \
-Wl,--version-script=$(srcdir)/tests/version2/libversionedprivatenothidden.map
tests_version1_libversionedsymbols_la_CFLAGS = $(test_fixture_cflags)
tests_version1_libversionedsymbols_la_LDFLAGS = -shared -version-number 1:0:0 \
-Wl,--version-script=$(srcdir)/tests/libversioned.map
tests_version2_libversionedsymbols_la_CFLAGS = $(test_fixture_cflags)
tests_version2_libversionedsymbols_la_LDFLAGS = -shared -version-number 1:0:0 \
-Wl,--version-script=$(srcdir)/tests/libversioned.map
tests_version1_libversionedupgrade_la_CFLAGS = $(test_fixture_cflags)
tests_version1_libversionedupgrade_la_LDFLAGS = -shared -version-number 1:0:0 \
-Wl,--version-script=$(srcdir)/tests/version1/libversionedupgrade.map
tests_version2_libversionedupgrade_la_CFLAGS = $(test_fixture_cflags)
tests_version2_libversionedupgrade_la_LDFLAGS = -shared -version-number 1:0:0 \
-Wl,--version-script=$(srcdir)/tests/version2/libversionedupgrade.map
endif
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' \
$(SHELL) $(top_srcdir)/build-aux/tap-driver.sh
LOG_COMPILER =
TEST_EXTENSIONS = .pl .t
PL_LOG_DRIVER = $(LOG_DRIVER)
PL_LOG_COMPILER = $(PERL)
T_LOG_DRIVER = $(LOG_DRIVER)
T_LOG_COMPILER = $(SHELL) $(top_srcdir)/tests/glib-tap.sh
AM_TESTS_ENVIRONMENT = export CAPSULE_CAPTURE_LIBS_TOOL="$(abs_builddir)/capsule-capture-libs"; \
export CAPSULE_CFLAGS="-I$(abs_top_srcdir) -I$(abs_top_builddir)"; \
export CAPSULE_LIBS="$(abs_top_builddir)/libcapsule.la"; \
export CAPSULE_SYMBOLS_TOOL="$(abs_builddir)/capsule-symbols";\
export CAPSULE_TESTS_GNU_BUILD="${build}"; \
export CAPSULE_TESTS_GNU_HOST="${host}"; \
export CAPSULE_TESTS_UNINSTALLED=1; \
export CAPSULE_VERSION_TOOL="$(abs_builddir)/capsule-version";\
export CC="${CC}"; \
export G_TEST_SRCDIR="$(abs_srcdir)"; \
export G_TEST_BUILDDIR="$(abs_builddir)";\
export G_DEBUG=gc-friendly; \
export MALLOC_CHECK_=2; \
export NM="$(NM)"; \
export PKG_CONFIG_PATH="$(abs_builddir)/data";
if ENABLE_LIBRARY
test_extra_programs = tests/notgl-user \
tests/notgl-helper-user \
tests/notgl-dlopener
tests_notgl_user_LDADD = tests/lib/libnotgl.la
tests_notgl_helper_user_LDADD = tests/lib/libnotgl.la \
tests/lib/libnotgles.la \
tests/helper/libhelper.la
tests_notgl_dlopener_LDADD = -ldl
endif
test_extra_scripts = tests/manual/gl.pl
test_programs =
if HAVE_GLIB
test_programs += tests/utils.t
endif
tests_utils_t_SOURCES = tests/utils.c \
tests/test-helpers.c \
tests/test-helpers.h \
utils/library-cmp.c \
utils/library-cmp.h
tests_utils_t_LDADD = utils/libutils.la $(GLIB_LIBS) $(LIBELF_LIBS)
test_scripts = tests/capture-libs.pl \
tests/symbols.pl \
tests/version.pl
if ENABLE_LIBRARY
test_scripts += tests/gl-shim.pl \
tests/init-project.pl \
tests/notgl.pl
endif
nobase_insttests_PROGRAMS = $(test_programs) \
$(test_extra_programs)
nobase_dist_insttests_SCRIPTS = $(test_scripts) \
$(test_extra_scripts)
TESTS = $(test_programs) \
$(test_scripts)
testmetadir = $(datadir)/installed-tests/$(PACKAGE_TARNAME)
testmeta_DATA = $(patsubst %,%.test,$(test_programs) $(test_scripts))
$(testmeta_DATA): tests/%.test: tests/% Makefile
@$(MKDIR_P) $(dir $@)
$(AM_V_GEN)set -e; \
maybe_tap=; \
case "$*" in \
(*.t) \
maybe_tap=" --tap"; \
;; \
esac; \
(\
echo "[Test]"; \
echo "Type=session"; \
echo "Output=TAP"; \
echo "Exec=env CAPSULE_TESTS_GNU_HOST=$(host) $(insttestsdir)/tests/$*$$maybe_tap"; \
) > $@.tmp && mv $@.tmp $@
if ENABLE_LIBRARY
# ============================================================================
# gtk-doc configuration: see /usr/share/doc/gtk-doc-tools/examples/Makefile.am
DOC_MODULE = libcapsule
DOC_MAIN_SGML_FILE = $(DOC_MODULE)-docs.xml
DOC_SOURCE_DIR = $(top_srcdir)/capsule
SCAN_OPTIONS = --rebuild-sections --rebuild-types
MKDB_OPTIONS = --xml-mode --output-format=xml
MKTMPL_OPTIONS =
MKHTML_OPTIONS =
FIXXREF_OPTIONS =
HFILE_GLOB = $(top_srcdir)/capsule/capsule.h
CFILE_GLOB = $(top_srcdir)/capsule/*.c
EXTRA_HFILES =
IGNORE_HFILES =
HTML_IMAGES =
content_files =
expand_content_files =
GTKDOC_CFLAGS =
GTKDOC_LIBS =
include $(top_srcdir)/gtk-doc.make
# standalone man pages
include $(top_srcdir)/documentation.mk
# Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=786174
$(DOC_MAIN_SGML_FILE): sgml-build.stamp
@true
else
CLEANFILES =
EXTRA_DIST =
endif
# These need to come after we include gtk-doc.make, which unconditionally
# defines these variables and targets
dist-hook: dist-hook-git-version-gen
.PHONY: dist-hook-git-version-gen
dist-hook-git-version-gen:
$(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version
dist-hook: dist-hook-shim-sources
.PHONY: dist-hook-shim-sources
install-data-local: install-data-local-shim-sources
.PHONY: install-data-local-shim-sources
CLEANFILES += $(testmeta_DATA)
if ENABLE_HOST_PREFIX
CLEANFILES += data/$(HOST_PREFIX)capsule-mkstublib
endif
CLEANFILES += $(nodist_tests_shim_libnotgl_la_SOURCES)
CLEANFILES += $(nodist_tests_shim_libnotgles_la_SOURCES)
EXTRA_DIST += $(top_srcdir)/.version
EXTRA_DIST += autogen.sh
EXTRA_DIST += build-aux/git-version-gen
EXTRA_DIST += ci/Jenkinsfile
EXTRA_DIST += ci/gitlab-ci.yml
EXTRA_DIST += data/capsule-mkstublib
EXTRA_DIST += doc/Building-libcapsule.txt
EXTRA_DIST += doc/Strategy.txt
EXTRA_DIST += doc/capsule-init-project.xml
EXTRA_DIST += doc/capsule-mkstublib.xml
EXTRA_DIST += doc/devhelp2man.xslt
EXTRA_DIST += tests/glib-tap.sh
EXTRA_DIST += tests/libversioned.map
EXTRA_DIST += tests/version1/libversionedabibreak.map
EXTRA_DIST += tests/version1/libversionedlikedbus.map
EXTRA_DIST += tests/version1/libversionedlikeglibc.map
EXTRA_DIST += tests/version1/libversionedprivatenothidden.map
EXTRA_DIST += tests/version1/libversionedupgrade.map
EXTRA_DIST += tests/version2/libversionedabibreak.map
EXTRA_DIST += tests/version2/libversionedlikedbus.map
EXTRA_DIST += tests/version2/libversionedlikeglibc.map
EXTRA_DIST += tests/version2/libversionedprivatenothidden.map
EXTRA_DIST += tests/version2/libversionedupgrade.map