From 5e9b247d260ff4e2b9a9620053e61e8a0161cdee Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 9 May 2016 12:21:28 +0200 Subject: Migrate ~/.local/share/xdg-app to ~/.local/share/flatpak --- common/flatpak-dir.c | 2 +- common/flatpak-run.c | 4 ++-- common/flatpak-utils.c | 24 ++++++++++++++++++++++++ common/flatpak-utils.h | 2 ++ 4 files changed, 29 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index c4bbfe3..bf737a2 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -167,7 +167,7 @@ flatpak_get_system_base_dir_location (void) GFile * flatpak_get_user_base_dir_location (void) { - g_autofree char *base = g_build_filename (g_get_user_data_dir (), "xdg-app", NULL); + g_autofree char *base = g_build_filename (g_get_user_data_dir (), "flatpak", NULL); return g_file_new_for_path (base); } diff --git a/common/flatpak-run.c b/common/flatpak-run.c index 388aef9..fab92fb 100644 --- a/common/flatpak-run.c +++ b/common/flatpak-run.c @@ -2440,7 +2440,7 @@ setup_seccomp (GPtrArray *argv_array, * can do, and we should support code portability between different * container tools. * - * This syscall blacklist is copied from xdg-app, which was in turn + * This syscall blacklist is copied from linux-user-chroot, which was in turn * clearly influenced by the Sandstorm.io blacklist. * * If you make any changes here, I suggest sending the changes along @@ -2454,7 +2454,7 @@ setup_seccomp (GPtrArray *argv_array, * https://github.com/sandstorm-io/sandstorm * in src/sandstorm/supervisor.c++ * http://cgit.freedesktop.org/xdg-app/xdg-app/ - * in lib/xdg-app-helper.c + * in common/flatpak-run.c * https://git.gnome.org/browse/linux-user-chroot * in src/setup-seccomp.c * diff --git a/common/flatpak-utils.c b/common/flatpak-utils.c index fca297a..b79e276 100644 --- a/common/flatpak-utils.c +++ b/common/flatpak-utils.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -252,6 +253,29 @@ flatpak_get_bwrap (void) return HELPER; } +/* We only migrate the user dir, because thats what most people used with xdg-app, + * and its where all per-user state/config are stored. + */ +void +flatpak_migrate_from_xdg_app (void) +{ + g_autofree char *source = g_build_filename (g_get_user_data_dir (), "xdg-app", NULL); + g_autofree char *dest = g_build_filename (g_get_user_data_dir (), "flatpak", NULL); + + if (!g_file_test (dest, G_FILE_TEST_EXISTS) && + g_file_test (source, G_FILE_TEST_EXISTS)) + { + g_print ("Migrating %s to %s\n", source, dest); + if (rename (source, dest) != 0) + { + if (errno != ENOENT && + errno != ENOTEMPTY && + errno != EEXIST) + g_print ("Error during migration: %s\n", strerror (errno)); + } + } +} + static gboolean is_valid_initial_name_character (gint c) { diff --git a/common/flatpak-utils.h b/common/flatpak-utils.h index 8f3ab92..5621b65 100644 --- a/common/flatpak-utils.h +++ b/common/flatpak-utils.h @@ -45,6 +45,8 @@ const char * flatpak_get_arch (void); const char * flatpak_get_bwrap (void); +void flatpak_migrate_from_xdg_app (void); + GBytes * flatpak_read_stream (GInputStream *in, gboolean null_terminate, GError **error); -- cgit v1.2.1