mirror of
https://github.com/flatpak/flatpak.git
synced 2026-05-24 16:57:42 -04:00
Trim unused shared library linkages from the session helper
The org.freedesktop.Flatpak user D-Bus service isn't just used by flatpak(1) or applications running as Flatpaks. It's also used by toolbox(1) for similar reasons: * To keep various configuration files inside the container synchronized with the host * To let the container request certain commands to be run on the host The org.freedesktop.Flatpak D-Bus service itself doesn't need much in the way of dependencies, but inherits a lot of unused shared library linkages through the libflatpak-common.la convenience library. Removing these unused shared libraries reduces the footprint of toolbox(1) for those who care about such things. eg., Fedora CoreOS. This commit brings down the number of shared libraries to 19 from 62. Closes: #3052 Approved by: alexlarsson
This commit is contained in:
@@ -49,8 +49,6 @@ libflatpak_app_la_LIBADD = \
|
||||
$(APPSTREAM_GLIB_LIBS) \
|
||||
$(SYSTEMD_LIBS) \
|
||||
$(POLKIT_LIBS) \
|
||||
libglnx.la \
|
||||
libflatpak-common.la \
|
||||
$(NULL)
|
||||
|
||||
libflatpak_app_la_CFLAGS = \
|
||||
@@ -143,6 +141,7 @@ flatpak_LDADD = \
|
||||
libglnx.la \
|
||||
libflatpak-app.la \
|
||||
libflatpak-common.la \
|
||||
libflatpak-common-base.la \
|
||||
$(NULL)
|
||||
|
||||
flatpak_CFLAGS = \
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2014 Red Hat, Inc
|
||||
* Copyright © 2014-2019 Red Hat, Inc
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "libglnx/libglnx.h"
|
||||
|
||||
#include "flatpak-builtins.h"
|
||||
#include "flatpak-utils-private.h"
|
||||
#include "flatpak-utils-base-private.h"
|
||||
#include "flatpak-builtins-utils.h"
|
||||
|
||||
static char *opt_title;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
lib_LTLIBRARIES += libflatpak.la
|
||||
noinst_LTLIBRARIES += libflatpak-common.la
|
||||
noinst_LTLIBRARIES += libflatpak-common-base.la libflatpak-common.la
|
||||
noinst_PROGRAMS += test-libflatpak
|
||||
|
||||
flatpakincludedir = $(includedir)/flatpak
|
||||
@@ -67,9 +67,30 @@ common/flatpak-systemd-dbus-generated.c: data/org.freedesktop.systemd1.xml Makef
|
||||
common/%-dbus-generated.h: common/%-dbus-generated.c
|
||||
@true # Built as a side-effect of the rules for the .c
|
||||
|
||||
nodist_libflatpak_common_base_la_SOURCES = \
|
||||
$(dbus_built_sources) \
|
||||
$(NULL)
|
||||
|
||||
BUILT_SOURCES += $(nodist_libflatpak_common_base_la_SOURCES)
|
||||
CLEANFILES += $(nodist_libflatpak_common_base_la_SOURCES)
|
||||
|
||||
libflatpak_common_base_la_SOURCES = \
|
||||
common/flatpak-utils-base.c \
|
||||
common/flatpak-utils-base-private.h \
|
||||
$(NULL)
|
||||
|
||||
libflatpak_common_base_la_CFLAGS = \
|
||||
-DFLATPAK_COMPILATION \
|
||||
$(AM_CFLAGS) \
|
||||
$(BASE_CFLAGS) \
|
||||
$(HIDDEN_VISIBILITY_CFLAGS) \
|
||||
-DLIBEXECDIR=\"$(libexecdir)\" \
|
||||
$(NULL)
|
||||
|
||||
libflatpak_common_base_la_LIBADD = $(AM_LIBADD) $(BASE_LIBS)
|
||||
|
||||
nodist_libflatpak_common_la_SOURCES = \
|
||||
$(nodist_flatpakinclude_HEADERS) \
|
||||
$(dbus_built_sources) \
|
||||
$(systemd_dbus_built_sources) \
|
||||
$(xdp_dbus_built_sources) \
|
||||
common/flatpak-enum-types.c \
|
||||
@@ -146,7 +167,7 @@ libflatpak_common_la_CFLAGS = \
|
||||
-DLIBEXECDIR=\"$(libexecdir)\" \
|
||||
-I$(srcdir)/dbus-proxy \
|
||||
$(NULL)
|
||||
libflatpak_common_la_LIBADD = $(AM_LIBADD) libglnx.la $(ARCHIVE_LIBS) $(BASE_LIBS) $(OSTREE_LIBS) $(SOUP_LIBS) $(JSON_LIBS) $(XAUTH_LIBS) $(XML_LIBS) $(LIBSECCOMP_LIBS) $(INTERNAL_GPGME_LIBS) $(SYSTEMD_LIBS) $(DCONF_LIBS)
|
||||
libflatpak_common_la_LIBADD = $(AM_LIBADD) $(ARCHIVE_LIBS) $(BASE_LIBS) $(OSTREE_LIBS) $(SOUP_LIBS) $(JSON_LIBS) $(XAUTH_LIBS) $(XML_LIBS) $(LIBSECCOMP_LIBS) $(INTERNAL_GPGME_LIBS) $(SYSTEMD_LIBS) $(DCONF_LIBS)
|
||||
|
||||
|
||||
libflatpak_la_SOURCES = \
|
||||
@@ -175,6 +196,8 @@ libflatpak_la_LDFLAGS = \
|
||||
libflatpak_la_LIBADD = \
|
||||
$(AM_LIBADD) \
|
||||
libflatpak-common.la \
|
||||
libflatpak-common-base.la \
|
||||
libglnx.la \
|
||||
$(BASE_LIBS) \
|
||||
$(OSTREE_LIBS) \
|
||||
$(SOUP_LIBS) \
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2014 Red Hat, Inc
|
||||
* Copyright © 2014-2019 Red Hat, Inc
|
||||
* Copyright © 2017 Endless Mobile, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -43,7 +43,7 @@
|
||||
#include <ostree.h>
|
||||
|
||||
#include "flatpak-dir-private.h"
|
||||
#include "flatpak-utils-private.h"
|
||||
#include "flatpak-utils-base-private.h"
|
||||
#include "flatpak-oci-registry-private.h"
|
||||
#include "flatpak-run-private.h"
|
||||
#include "flatpak-appdata-private.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2014-2018 Red Hat, Inc
|
||||
* Copyright © 2014-2019 Red Hat, Inc
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -43,7 +43,7 @@
|
||||
#include "flatpak-exports-private.h"
|
||||
#include "flatpak-run-private.h"
|
||||
#include "flatpak-proxy.h"
|
||||
#include "flatpak-utils-private.h"
|
||||
#include "flatpak-utils-base-private.h"
|
||||
#include "flatpak-dir-private.h"
|
||||
#include "flatpak-systemd-dbus-generated.h"
|
||||
#include "flatpak-error.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2014 Red Hat, Inc
|
||||
* Copyright © 2014-2019 Red Hat, Inc
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
#include "flatpak-run-private.h"
|
||||
#include "flatpak-proxy.h"
|
||||
#include "flatpak-utils-private.h"
|
||||
#include "flatpak-utils-base-private.h"
|
||||
#include "flatpak-dir-private.h"
|
||||
#include "flatpak-systemd-dbus-generated.h"
|
||||
#include "flatpak-document-dbus-generated.h"
|
||||
|
||||
34
common/flatpak-utils-base-private.h
Normal file
34
common/flatpak-utils-base-private.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright © 2019 Red Hat, Inc
|
||||
*
|
||||
* This program 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors:
|
||||
* Alexander Larsson <alexl@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef __FLATPAK_UTILS_BASE_H__
|
||||
#define __FLATPAK_UTILS_BASE_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
char *flatpak_get_timezone (void);
|
||||
|
||||
char * flatpak_readlink (const char *path,
|
||||
GError **error);
|
||||
char * flatpak_resolve_link (const char *path,
|
||||
GError **error);
|
||||
char * flatpak_canonicalize_filename (const char *path);
|
||||
|
||||
#endif /* __FLATPAK_UTILS_BASE_H__ */
|
||||
100
common/flatpak-utils-base.c
Normal file
100
common/flatpak-utils-base.c
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright © 2019 Red Hat, Inc
|
||||
*
|
||||
* This program 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors:
|
||||
* Alexander Larsson <alexl@redhat.com>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "flatpak-utils-base-private.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include "libglnx/libglnx.h"
|
||||
|
||||
char *
|
||||
flatpak_get_timezone (void)
|
||||
{
|
||||
g_autofree gchar *symlink = NULL;
|
||||
gchar *etc_timezone = NULL;
|
||||
const gchar *tzdir;
|
||||
|
||||
tzdir = getenv ("TZDIR");
|
||||
if (tzdir == NULL)
|
||||
tzdir = "/usr/share/zoneinfo";
|
||||
|
||||
symlink = flatpak_resolve_link ("/etc/localtime", NULL);
|
||||
if (symlink != NULL)
|
||||
{
|
||||
/* Resolve relative path */
|
||||
g_autofree gchar *canonical = flatpak_canonicalize_filename (symlink);
|
||||
char *canonical_suffix;
|
||||
|
||||
/* Strip the prefix and slashes if possible. */
|
||||
if (g_str_has_prefix (canonical, tzdir))
|
||||
{
|
||||
canonical_suffix = canonical + strlen (tzdir);
|
||||
while (*canonical_suffix == '/')
|
||||
canonical_suffix++;
|
||||
|
||||
return g_strdup (canonical_suffix);
|
||||
}
|
||||
}
|
||||
|
||||
if (g_file_get_contents ("/etc/timezeone", &etc_timezone,
|
||||
NULL, NULL))
|
||||
{
|
||||
g_strchomp (etc_timezone);
|
||||
return etc_timezone;
|
||||
}
|
||||
|
||||
/* Final fall-back is UTC */
|
||||
return g_strdup ("UTC");
|
||||
}
|
||||
|
||||
char *
|
||||
flatpak_readlink (const char *path,
|
||||
GError **error)
|
||||
{
|
||||
return glnx_readlinkat_malloc (-1, path, NULL, error);
|
||||
}
|
||||
|
||||
char *
|
||||
flatpak_resolve_link (const char *path,
|
||||
GError **error)
|
||||
{
|
||||
g_autofree char *link = flatpak_readlink (path, error);
|
||||
g_autofree char *dirname = NULL;
|
||||
|
||||
if (link == NULL)
|
||||
return NULL;
|
||||
|
||||
if (g_path_is_absolute (link))
|
||||
return g_steal_pointer (&link);
|
||||
|
||||
dirname = g_path_get_dirname (path);
|
||||
return g_build_filename (dirname, link, NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
flatpak_canonicalize_filename (const char *path)
|
||||
{
|
||||
g_autoptr(GFile) file = g_file_new_for_path (path);
|
||||
return g_file_get_path (file);
|
||||
}
|
||||
@@ -113,8 +113,6 @@ gboolean flatpak_extension_matches_reason (const char *extension_id,
|
||||
|
||||
const char * flatpak_get_bwrap (void);
|
||||
|
||||
char *flatpak_get_timezone (void);
|
||||
|
||||
char **flatpak_strv_merge (char **strv1,
|
||||
char **strv2);
|
||||
char **flatpak_subpaths_merge (char **subpaths1,
|
||||
@@ -603,12 +601,6 @@ gboolean flatpak_canonicalize_permissions (int parent_dfd,
|
||||
int gid,
|
||||
GError **error);
|
||||
|
||||
char * flatpak_readlink (const char *path,
|
||||
GError **error);
|
||||
char * flatpak_resolve_link (const char *path,
|
||||
GError **error);
|
||||
char * flatpak_canonicalize_filename (const char *path);
|
||||
|
||||
gboolean flatpak_file_rename (GFile *from,
|
||||
GFile *to,
|
||||
GCancellable *cancellable,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2014 Red Hat, Inc
|
||||
* Copyright © 2014-2019 Red Hat, Inc
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "flatpak-dir-private.h"
|
||||
#include "flatpak-oci-registry-private.h"
|
||||
#include "flatpak-run-private.h"
|
||||
#include "flatpak-utils-base-private.h"
|
||||
#include "valgrind-private.h"
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
@@ -638,46 +639,6 @@ flatpak_get_bwrap (void)
|
||||
return HELPER;
|
||||
}
|
||||
|
||||
char *
|
||||
flatpak_get_timezone (void)
|
||||
{
|
||||
g_autofree gchar *symlink = NULL;
|
||||
gchar *etc_timezone = NULL;
|
||||
const gchar *tzdir;
|
||||
|
||||
tzdir = getenv ("TZDIR");
|
||||
if (tzdir == NULL)
|
||||
tzdir = "/usr/share/zoneinfo";
|
||||
|
||||
symlink = flatpak_resolve_link ("/etc/localtime", NULL);
|
||||
if (symlink != NULL)
|
||||
{
|
||||
/* Resolve relative path */
|
||||
g_autofree gchar *canonical = flatpak_canonicalize_filename (symlink);
|
||||
char *canonical_suffix;
|
||||
|
||||
/* Strip the prefix and slashes if possible. */
|
||||
if (g_str_has_prefix (canonical, tzdir))
|
||||
{
|
||||
canonical_suffix = canonical + strlen (tzdir);
|
||||
while (*canonical_suffix == '/')
|
||||
canonical_suffix++;
|
||||
|
||||
return g_strdup (canonical_suffix);
|
||||
}
|
||||
}
|
||||
|
||||
if (g_file_get_contents ("/etc/timezeone", &etc_timezone,
|
||||
NULL, NULL))
|
||||
{
|
||||
g_strchomp (etc_timezone);
|
||||
return etc_timezone;
|
||||
}
|
||||
|
||||
/* Final fall-back is UTC */
|
||||
return g_strdup ("UTC");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_valid_initial_name_character (gint c, gboolean allow_dash)
|
||||
{
|
||||
@@ -2441,37 +2402,6 @@ flatpak_rm_rf (GFile *dir,
|
||||
cancellable, error);
|
||||
}
|
||||
|
||||
char *
|
||||
flatpak_readlink (const char *path,
|
||||
GError **error)
|
||||
{
|
||||
return glnx_readlinkat_malloc (-1, path, NULL, error);
|
||||
}
|
||||
|
||||
char *
|
||||
flatpak_resolve_link (const char *path,
|
||||
GError **error)
|
||||
{
|
||||
g_autofree char *link = flatpak_readlink (path, error);
|
||||
g_autofree char *dirname = NULL;
|
||||
|
||||
if (link == NULL)
|
||||
return NULL;
|
||||
|
||||
if (g_path_is_absolute (link))
|
||||
return g_steal_pointer (&link);
|
||||
|
||||
dirname = g_path_get_dirname (path);
|
||||
return g_build_filename (dirname, link, NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
flatpak_canonicalize_filename (const char *path)
|
||||
{
|
||||
g_autoptr(GFile) file = g_file_new_for_path (path);
|
||||
return g_file_get_path (file);
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_file_rename (GFile *from,
|
||||
GFile *to,
|
||||
|
||||
@@ -12,5 +12,5 @@ flatpak_session_helper_SOURCES = \
|
||||
session-helper/flatpak-session-helper.c \
|
||||
$(NULL)
|
||||
|
||||
flatpak_session_helper_LDADD = $(AM_LDADD) $(BASE_LIBS) libflatpak-common.la
|
||||
flatpak_session_helper_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS) $(SOUP_CFLAGS) $(OSTREE_CFLAGS) $(GSYSTEM_CFLAGS) $(JSON_CFLAGS) -DFLATPAK_COMPILATION
|
||||
flatpak_session_helper_LDADD = $(AM_LDADD) $(BASE_LIBS) libflatpak-common-base.la libglnx.la
|
||||
flatpak_session_helper_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS) -DFLATPAK_COMPILATION
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2014 Red Hat, Inc
|
||||
* Copyright © 2014-2019 Red Hat, Inc
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -28,7 +29,7 @@
|
||||
#include <gio/gio.h>
|
||||
#include <gio/gunixfdlist.h>
|
||||
#include "flatpak-dbus-generated.h"
|
||||
#include "flatpak-utils-private.h"
|
||||
#include "flatpak-utils-base-private.h"
|
||||
|
||||
typedef enum {
|
||||
FLATPAK_HOST_COMMAND_FLAGS_CLEAR_ENV = 1 << 0,
|
||||
|
||||
@@ -18,7 +18,7 @@ flatpak_system_helper_SOURCES = \
|
||||
system-helper/flatpak-system-helper.c \
|
||||
$(NULL)
|
||||
|
||||
flatpak_system_helper_LDADD = $(BASE_LIBS) $(OSTREE_LIBS) $(JSON_LIBS) $(POLKIT_LIBS) libflatpak-common.la
|
||||
flatpak_system_helper_LDADD = $(BASE_LIBS) $(OSTREE_LIBS) $(JSON_LIBS) $(POLKIT_LIBS) libflatpak-common.la libflatpak-common-base.la libglnx.la
|
||||
flatpak_system_helper_CFLAGS = $(BASE_CFLAGS) $(OSTREE_CFLAGS) $(APPSTREAM_GLIB_CFLAGS) $(SOUP_CFLAGS) $(JSON_CFLAGS) $(POLKIT_CFLAGS) -DFLATPAK_COMPILATION -DLIBEXECDIR=\"$(libexecdir)\"
|
||||
|
||||
system-helper/org.freedesktop.Flatpak.rules: system-helper/org.freedesktop.Flatpak.rules.in
|
||||
|
||||
@@ -53,9 +53,10 @@ testcommon_LDADD = \
|
||||
$(SOUP_LIBS) \
|
||||
$(JSON_LIBS) \
|
||||
$(APPSTREAM_GLIB_LIBS) \
|
||||
libglnx.la \
|
||||
libflatpak-common.la \
|
||||
libflatpak-app.la \
|
||||
libflatpak-common.la \
|
||||
libflatpak-common-base.la \
|
||||
libglnx.la \
|
||||
$(NULL)
|
||||
testcommon_SOURCES = tests/testcommon.c
|
||||
|
||||
@@ -63,7 +64,7 @@ tests_httpcache_CFLAGS = $(AM_CFLAGS) $(BASE_CFLAGS) $(OSTREE_CFLAGS) $(SOUP_CFL
|
||||
-DFLATPAK_COMPILATION \
|
||||
-DLOCALEDIR=\"$(localedir)\"
|
||||
tests_httpcache_LDADD = $(AM_LDADD) $(BASE_LIBS) $(OSTREE_LIBS) $(SOUP_LIBS) $(JSON_LIBS) $(APPSTREAM_GLIB_LIBS) \
|
||||
libglnx.la libflatpak-common.la
|
||||
libflatpak-common.la libflatpak-common-base.la libglnx.la
|
||||
|
||||
tests/services/org.freedesktop.Flatpak.service: session-helper/org.freedesktop.Flatpak.service.in
|
||||
mkdir -p tests/services
|
||||
|
||||
Reference in New Issue
Block a user