Migrate ~/.local/share/xdg-app to ~/.local/share/flatpak

tingping/wmclass
Alexander Larsson 2016-05-09 12:21:28 +02:00
parent 8abbc0186e
commit 5e9b247d26
14 changed files with 48 additions and 11 deletions

View File

@ -35,7 +35,7 @@ FLATPAK_BINDIR=$(bindir)
AM_CPPFLAGS = \
-DFLATPAK_BINDIR=\"$(FLATPAK_BINDIR)\" \
-DFLATPAK_SYSTEMDIR=\"$(localstatedir)/lib/xdg-app\"\
-DFLATPAK_SYSTEMDIR=\"$(localstatedir)/lib/flatpak\"\
-DFLATPAK_CONFIGDIR=\"$(sysconfdir)/flatpak\"\
-DFLATPAK_BASEDIR=\"$(pkgdatadir)\" \
-DFLATPAK_TRIGGERDIR=\"$(pkgdatadir)/triggers\" \

View File

@ -345,6 +345,8 @@ main (int argc,
else
g_unsetenv ("GIO_USE_VFS");
flatpak_migrate_from_xdg_app ();
ret = flatpak_run (argc, argv, &error);
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
flatpak_usage (commands, TRUE);

View File

@ -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);
}

View File

@ -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
*

View File

@ -26,6 +26,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
@ -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)
{

View File

@ -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);

View File

@ -773,6 +773,8 @@ main (int argc,
/* Avoid even loading gvfs to avoid accidental confusion */
g_setenv ("GIO_USE_VFS", "local", TRUE);
flatpak_migrate_from_xdg_app ();
context = g_option_context_new ("- document portal");
g_option_context_add_main_entries (context, entries, NULL);
if (!g_option_context_parse (context, &argc, &argv, &error))
@ -806,7 +808,7 @@ main (int argc,
loop = g_main_loop_new (NULL, FALSE);
path = g_build_filename (g_get_user_data_dir (), "xdg-app/db", TABLE_NAME, NULL);
path = g_build_filename (g_get_user_data_dir (), "flatpak/db", TABLE_NAME, NULL);
db = flatpak_db_new (path, FALSE, &error);
if (db == NULL)
{

View File

@ -1 +1 @@
XDG_DATA_DIRS=$HOME/.local/share/xdg-app/exports/share/:@localstatedir@/xdg-app/exports/share/:/usr/local/share/:/usr/share/
XDG_DATA_DIRS=$HOME/.local/share/flatpak/exports/share/:@localstatedir@/flatpak/exports/share/:/usr/local/share/:/usr/share/

View File

@ -43,7 +43,7 @@
*
* An FlatpakInstallation object provides information about an installation
* location for flatpak applications. Typical installation locations are either
* system-wide (in /var/lib/xdg-app) or per-user (in ~/.local/share/xdg-app).
* system-wide (in /var/lib/flatpak) or per-user (in ~/.local/share/flatpak).
*
* FlatpakInstallation can list configured remotes as well as installed application
* and runtime references (in short: refs). It can also run, install, update and
@ -184,6 +184,8 @@ FlatpakInstallation *
flatpak_installation_new_user (GCancellable *cancellable,
GError **error)
{
flatpak_migrate_from_xdg_app ();
return flatpak_installation_new_for_dir (flatpak_dir_get_user (), cancellable, error);
}
@ -203,6 +205,8 @@ flatpak_installation_new_for_path (GFile *path, gboolean user,
GCancellable *cancellable,
GError **error)
{
flatpak_migrate_from_xdg_app ();
return flatpak_installation_new_for_dir (flatpak_dir_new (path, user), cancellable, error);
}

View File

@ -1,4 +1,4 @@
# @sysconfdir@/profile.d/flatpak.sh - set XDG_DATA_DIRS
XDG_DATA_DIRS="${XDG_DATA_DIRS:-$HOME/.local/share/xdg-app/exports/share:@localstatedir@/xdg-app/exports/share/:/usr/local/share/:/usr/share/}"
XDG_DATA_DIRS="${XDG_DATA_DIRS:-$HOME/.local/share/flatpak/exports/share:@localstatedir@/flatpak/exports/share/:/usr/local/share/:/usr/share/}"
export XDG_DATA_DIRS

View File

@ -15,4 +15,4 @@ flatpak_session_helper_SOURCES = \
$(NULL)
flatpak_session_helper_LDADD = $(BASE_LIBS) libflatpak-common.la
flatpak_session_helper_CFLAGS = $(BASE_CFLAGS)
flatpak_session_helper_CFLAGS = $(BASE_CFLAGS) $(SOUP_CFLAGS) $(OSTREE_CFLAGS) $(GSYSTEM_CFLAGS)

View File

@ -64,7 +64,7 @@ lookup_table (const char *name,
if (table != NULL)
return table;
dir = g_build_filename (g_get_user_data_dir (), "xdg-app/db", NULL);
dir = g_build_filename (g_get_user_data_dir (), "flatpak/db", NULL);
g_mkdir_with_parents (dir, 0755);
path = g_build_filename (dir, name, NULL);

View File

@ -26,6 +26,7 @@
#include <gio/gio.h>
#include "flatpak-dbus.h"
#include "flatpak-permission-store.h"
#include "flatpak-utils.h"
static char *monitor_dir;
@ -134,6 +135,8 @@ main (int argc,
g_set_prgname (argv[0]);
flatpak_migrate_from_xdg_app ();
monitor_dir = g_build_filename (g_get_user_runtime_dir (), "flatpak-monitor", NULL);
if (g_mkdir_with_parents (monitor_dir, 0755) != 0)
{

View File

@ -72,7 +72,7 @@ TEST_DATA_DIR=`mktemp -d /var/tmp/test-flatpak-XXXXXX`
export XDG_DATA_HOME=${TEST_DATA_DIR}/share
export USERDIR=${TEST_DATA_DIR}/share/xdg-app
export USERDIR=${TEST_DATA_DIR}/share/flatpak
export ARCH=`flatpak --default-arch`
export FLATPAK="${CMD_PREFIX} flatpak"