From 2e3aca0122a0c57d415ae3ea8ead9107325631ac Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Wed, 18 Sep 2019 18:17:12 +0200 Subject: [PATCH] Trim unused shared library linkages from the session helper https://github.com/flatpak/flatpak/pull/3052 --- ...-trim-unused-shared-library-linkages.patch | 729 ++++++++++++++++++ flatpak.spec | 11 +- 2 files changed, 739 insertions(+), 1 deletion(-) create mode 100644 flatpak-trim-unused-shared-library-linkages.patch diff --git a/flatpak-trim-unused-shared-library-linkages.patch b/flatpak-trim-unused-shared-library-linkages.patch new file mode 100644 index 0000000..466cf92 --- /dev/null +++ b/flatpak-trim-unused-shared-library-linkages.patch @@ -0,0 +1,729 @@ +From efe5c943a8c6c3ae842ea737908ea6a8e3ad807d Mon Sep 17 00:00:00 2001 +From: Debarshi Ray +Date: Tue, 13 Aug 2019 15:46:17 +0200 +Subject: [PATCH 1/4] build: Link against libarchive only when necessary + +The libarchive API is used in a relatively few places inside the +'common' sub-directory. It's definitely not as widespread as GLib. A +subsequent commit will leverage this to prevent unused shared +libraries from being linked to the session helper. + +Closes: #3052 +Approved by: alexlarsson +--- + common/Makefile.am.inc | 3 ++- + configure.ac | 3 ++- + 2 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/common/Makefile.am.inc b/common/Makefile.am.inc +index 5483ac4ea5ac..56dbb7cab0ba 100644 +--- a/common/Makefile.am.inc ++++ b/common/Makefile.am.inc +@@ -131,6 +131,7 @@ libflatpak_common_la_SOURCES = \ + libflatpak_common_la_CFLAGS = \ + -DFLATPAK_COMPILATION \ + $(AM_CFLAGS) \ ++ $(ARCHIVE_CFLAGS) \ + $(BASE_CFLAGS) \ + $(HIDDEN_VISIBILITY_CFLAGS) \ + $(OSTREE_CFLAGS) \ +@@ -144,7 +145,7 @@ libflatpak_common_la_CFLAGS = \ + -DLIBEXECDIR=\"$(libexecdir)\" \ + -I$(srcdir)/dbus-proxy \ + $(NULL) +-libflatpak_common_la_LIBADD = $(AM_LIBADD) libglnx.la $(BASE_LIBS) $(OSTREE_LIBS) $(SOUP_LIBS) $(JSON_LIBS) $(XAUTH_LIBS) $(LIBSECCOMP_LIBS) $(INTERNAL_GPGME_LIBS) $(SYSTEMD_LIBS) $(DCONF_LIBS) ++libflatpak_common_la_LIBADD = $(AM_LIBADD) libglnx.la $(ARCHIVE_LIBS) $(BASE_LIBS) $(OSTREE_LIBS) $(SOUP_LIBS) $(JSON_LIBS) $(XAUTH_LIBS) $(LIBSECCOMP_LIBS) $(INTERNAL_GPGME_LIBS) $(SYSTEMD_LIBS) $(DCONF_LIBS) + + + libflatpak_la_SOURCES = \ +diff --git a/configure.ac b/configure.ac +index 2cd7af6a484b..49bc0b72f037 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -210,7 +210,8 @@ AC_SUBST([GDBUS_CODEGEN], [`$PKG_CONFIG --variable gdbus_codegen gio-2.0`]) + + POLKIT_GOBJECT_REQUIRED=0.98 + +-PKG_CHECK_MODULES(BASE, [glib-2.0 >= $GLIB_REQS gio-2.0 gio-unix-2.0 libarchive >= 2.8.0 libxml-2.0 >= 2.4 ]) ++PKG_CHECK_MODULES(ARCHIVE, [libarchive >= 2.8.0]) ++PKG_CHECK_MODULES(BASE, [glib-2.0 >= $GLIB_REQS gio-2.0 gio-unix-2.0 libxml-2.0 >= 2.4 ]) + PKG_CHECK_MODULES(SOUP, [libsoup-2.4]) + PKG_CHECK_MODULES(DCONF, [dconf >= 0.26], [have_dconf=yes], [have_dconf=no]) + if test $have_dconf = yes; then +-- +2.20.1 + + +From 8ffb98e65dae539d65acdd281221d5a83f4f1acb Mon Sep 17 00:00:00 2001 +From: Debarshi Ray +Date: Tue, 13 Aug 2019 16:47:02 +0200 +Subject: [PATCH 2/4] build: Link against libxml only when necessary + +The libxml API is used in a relatively few places inside the 'common' +sub-directory. It's definitely not as widespread as GLib. A subsequent +commit will leverage this to prevent unused shared libraries from +being linked to the session helper. + +Closes: #3052 +Approved by: alexlarsson +--- + common/Makefile.am.inc | 3 ++- + configure.ac | 3 ++- + 2 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/common/Makefile.am.inc b/common/Makefile.am.inc +index 56dbb7cab0ba..3019802f2ae9 100644 +--- a/common/Makefile.am.inc ++++ b/common/Makefile.am.inc +@@ -138,6 +138,7 @@ libflatpak_common_la_CFLAGS = \ + $(SOUP_CFLAGS) \ + $(JSON_CFLAGS) \ + $(XAUTH_CFLAGS) \ ++ $(XML_CFLAGS) \ + $(LIBSECCOMP_CFLAGS) \ + $(INTERNAL_GPGME_CFLAGS) \ + $(SYSTEMD_CFLAGS) \ +@@ -145,7 +146,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) $(LIBSECCOMP_LIBS) $(INTERNAL_GPGME_LIBS) $(SYSTEMD_LIBS) $(DCONF_LIBS) ++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_la_SOURCES = \ +diff --git a/configure.ac b/configure.ac +index 49bc0b72f037..7b85258df962 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -211,8 +211,9 @@ AC_SUBST([GDBUS_CODEGEN], [`$PKG_CONFIG --variable gdbus_codegen gio-2.0`]) + POLKIT_GOBJECT_REQUIRED=0.98 + + PKG_CHECK_MODULES(ARCHIVE, [libarchive >= 2.8.0]) +-PKG_CHECK_MODULES(BASE, [glib-2.0 >= $GLIB_REQS gio-2.0 gio-unix-2.0 libxml-2.0 >= 2.4 ]) ++PKG_CHECK_MODULES(BASE, [glib-2.0 >= $GLIB_REQS gio-2.0 gio-unix-2.0]) + PKG_CHECK_MODULES(SOUP, [libsoup-2.4]) ++PKG_CHECK_MODULES(XML, [libxml-2.0 >= 2.4]) + PKG_CHECK_MODULES(DCONF, [dconf >= 0.26], [have_dconf=yes], [have_dconf=no]) + if test $have_dconf = yes; then + AC_DEFINE(HAVE_DCONF, 1, [Define if dconf is available]) +-- +2.20.1 + + +From f72ce1891ba955167a7344b67451f6e4c5c32e1c Mon Sep 17 00:00:00 2001 +From: Debarshi Ray +Date: Tue, 13 Aug 2019 18:01:30 +0200 +Subject: [PATCH 3/4] common, session-helper: Make the session helper more + self-contained + +... by moving the definition of FlatpakHostCommandFlags from the +'common' sub-directory to 'session-helper'. It hasn't been used by +anything else ever since flatpak-builder was moved to a separate +repository in commit 52bd14656151fe63. + +Closes: #3052 +Approved by: alexlarsson +--- + common/flatpak-utils-private.h | 5 ----- + session-helper/flatpak-session-helper.c | 5 +++++ + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/common/flatpak-utils-private.h b/common/flatpak-utils-private.h +index a5c03ceb5a76..0151b5253d2a 100644 +--- a/common/flatpak-utils-private.h ++++ b/common/flatpak-utils-private.h +@@ -37,11 +37,6 @@ + + #define AUTOFS_SUPER_MAGIC 0x0187 + +-typedef enum { +- FLATPAK_HOST_COMMAND_FLAGS_CLEAR_ENV = 1 << 0, +- FLATPAK_HOST_COMMAND_FLAGS_WATCH_BUS = 1 << 1, +-} FlatpakHostCommandFlags; +- + #define FLATPAK_ANSI_ALT_SCREEN_ON "\x1b[?1049h" + #define FLATPAK_ANSI_ALT_SCREEN_OFF "\x1b[?1049l" + #define FLATPAK_ANSI_HIDE_CURSOR "\x1b[?25l" +diff --git a/session-helper/flatpak-session-helper.c b/session-helper/flatpak-session-helper.c +index 5dd7629e7f88..0fbac666775c 100644 +--- a/session-helper/flatpak-session-helper.c ++++ b/session-helper/flatpak-session-helper.c +@@ -30,6 +30,11 @@ + #include "flatpak-dbus-generated.h" + #include "flatpak-utils-private.h" + ++typedef enum { ++ FLATPAK_HOST_COMMAND_FLAGS_CLEAR_ENV = 1 << 0, ++ FLATPAK_HOST_COMMAND_FLAGS_WATCH_BUS = 1 << 1, ++} FlatpakHostCommandFlags; ++ + static char *monitor_dir; + static char *p11_kit_server_socket_path; + static int p11_kit_server_pid = 0; +-- +2.20.1 + + +From dd07d16a28782c5090ae5a2d40158e8325f7b70d Mon Sep 17 00:00:00 2001 +From: Debarshi Ray +Date: Mon, 12 Aug 2019 22:19:19 +0200 +Subject: [PATCH 4/4] 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 +--- + app/Makefile.am.inc | 3 +- + app/flatpak-builtins-build-update-repo.c | 4 +- + common/Makefile.am.inc | 29 ++++++- + common/flatpak-dir.c | 4 +- + common/flatpak-exports.c | 4 +- + common/flatpak-run.c | 4 +- + common/flatpak-utils-base-private.h | 34 ++++++++ + common/flatpak-utils-base.c | 100 +++++++++++++++++++++++ + common/flatpak-utils-private.h | 8 -- + common/flatpak-utils.c | 74 +---------------- + session-helper/Makefile.am.inc | 4 +- + session-helper/flatpak-session-helper.c | 5 +- + system-helper/Makefile.am.inc | 2 +- + tests/Makefile.am.inc | 7 +- + 14 files changed, 181 insertions(+), 101 deletions(-) + create mode 100644 common/flatpak-utils-base-private.h + create mode 100644 common/flatpak-utils-base.c + +diff --git a/app/Makefile.am.inc b/app/Makefile.am.inc +index 558065343353..a561c1d056db 100644 +--- a/app/Makefile.am.inc ++++ b/app/Makefile.am.inc +@@ -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 = \ +diff --git a/app/flatpak-builtins-build-update-repo.c b/app/flatpak-builtins-build-update-repo.c +index f106436df698..6442da4e40ba 100644 +--- a/app/flatpak-builtins-build-update-repo.c ++++ b/app/flatpak-builtins-build-update-repo.c +@@ -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; +diff --git a/common/Makefile.am.inc b/common/Makefile.am.inc +index 3019802f2ae9..867c9c052935 100644 +--- a/common/Makefile.am.inc ++++ b/common/Makefile.am.inc +@@ -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) \ +diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c +index 8f9dc66cc95b..d898d6242028 100644 +--- a/common/flatpak-dir.c ++++ b/common/flatpak-dir.c +@@ -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 + + #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" +diff --git a/common/flatpak-exports.c b/common/flatpak-exports.c +index 7a5694cc37f6..8562712ba1b1 100644 +--- a/common/flatpak-exports.c ++++ b/common/flatpak-exports.c +@@ -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" +diff --git a/common/flatpak-run.c b/common/flatpak-run.c +index 8d52d3a528fa..8d0d01acba4a 100644 +--- a/common/flatpak-run.c ++++ b/common/flatpak-run.c +@@ -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" +diff --git a/common/flatpak-utils-base-private.h b/common/flatpak-utils-base-private.h +new file mode 100644 +index 000000000000..d7a55273bd6b +--- /dev/null ++++ b/common/flatpak-utils-base-private.h +@@ -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 . ++ * ++ * Authors: ++ * Alexander Larsson ++ */ ++ ++#ifndef __FLATPAK_UTILS_BASE_H__ ++#define __FLATPAK_UTILS_BASE_H__ ++ ++#include ++ ++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__ */ +diff --git a/common/flatpak-utils-base.c b/common/flatpak-utils-base.c +new file mode 100644 +index 000000000000..07d7725e1a86 +--- /dev/null ++++ b/common/flatpak-utils-base.c +@@ -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 . ++ * ++ * Authors: ++ * Alexander Larsson ++ */ ++ ++#include "config.h" ++ ++#include "flatpak-utils-base-private.h" ++ ++#include ++#include ++ ++#include ++#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); ++} +diff --git a/common/flatpak-utils-private.h b/common/flatpak-utils-private.h +index 0151b5253d2a..bedeffd1216c 100644 +--- a/common/flatpak-utils-private.h ++++ b/common/flatpak-utils-private.h +@@ -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, +diff --git a/common/flatpak-utils.c b/common/flatpak-utils.c +index d9912e85d6c5..2f59337e7547 100644 +--- a/common/flatpak-utils.c ++++ b/common/flatpak-utils.c +@@ -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 +@@ -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, +diff --git a/session-helper/Makefile.am.inc b/session-helper/Makefile.am.inc +index 7ea49bf0b652..f56c94b19274 100644 +--- a/session-helper/Makefile.am.inc ++++ b/session-helper/Makefile.am.inc +@@ -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 +diff --git a/session-helper/flatpak-session-helper.c b/session-helper/flatpak-session-helper.c +index 0fbac666775c..26e83fc64832 100644 +--- a/session-helper/flatpak-session-helper.c ++++ b/session-helper/flatpak-session-helper.c +@@ -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 + #include + #include + #include +@@ -28,7 +29,7 @@ + #include + #include + #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, +diff --git a/system-helper/Makefile.am.inc b/system-helper/Makefile.am.inc +index cce749ce325e..6152ec9951fa 100644 +--- a/system-helper/Makefile.am.inc ++++ b/system-helper/Makefile.am.inc +@@ -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 +diff --git a/tests/Makefile.am.inc b/tests/Makefile.am.inc +index 28c188377430..9039c1ed9aec 100644 +--- a/tests/Makefile.am.inc ++++ b/tests/Makefile.am.inc +@@ -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 +-- +2.20.1 + diff --git a/flatpak.spec b/flatpak.spec index 51b4a6a..1923a16 100644 --- a/flatpak.spec +++ b/flatpak.spec @@ -3,7 +3,7 @@ Name: flatpak Version: 1.4.2 -Release: 5%{?dist} +Release: 6%{?dist} Summary: Application deployment framework for desktop apps License: LGPLv2+ @@ -16,6 +16,8 @@ Source1: flatpak-add-fedora-repos.service Patch0: 0001-ref-Fix-a-memory-leak.patch # https://github.com/flatpak/flatpak/pull/3048 Patch1: OCI-correctly-handle-locally-present-icons.patch +# https://github.com/flatpak/flatpak/pull/3052 +Patch2: flatpak-trim-unused-shared-library-linkages.patch BuildRequires: pkgconfig(appstream-glib) BuildRequires: pkgconfig(dconf) @@ -43,6 +45,10 @@ BuildRequires: systemd BuildRequires: /usr/bin/xdg-dbus-proxy BuildRequires: /usr/bin/xmlto BuildRequires: /usr/bin/xsltproc +# For Patch2 +BuildRequires: automake autoconf libtool +BuildRequires: gettext-devel +BuildRequires: gtk-doc %{?systemd_requires} @@ -272,6 +278,9 @@ fi %changelog +* Wed Sep 18 2019 Debarshi Ray - 1.4.2-6 +- Trim unused shared library linkages from the session helper + * Wed Aug 7 2019 Owen Taylor - 1.4.2-5 - Add patch fixing problem with downloading icons for OCI remotes (#1683375)