Add support for multiple installations in the system helper

Allow passing an extra string parameter specifying the ID of a
system installation to refer to it, or an empty string for the
default one.
tingping/wmclass
Mario Sanchez Prada 2016-12-16 19:17:44 +00:00
parent 3e295085b7
commit 719616f086
3 changed files with 90 additions and 17 deletions

View File

@ -1412,11 +1412,14 @@ flatpak_dir_update_appstream (FlatpakDir *self,
}
else
{
const char *installation = flatpak_dir_get_id (self);
g_debug ("Calling system helper: DeployAppstream");
if (!flatpak_system_helper_call_deploy_appstream_sync (system_helper,
flatpak_file_get_path_cached (ostree_repo_get_path (child_repo)),
remote,
arch,
installation ? installation : "",
cancellable,
error))
return FALSE;
@ -3973,6 +3976,7 @@ flatpak_dir_install (FlatpakDir *self,
{
g_autoptr(OstreeRepo) child_repo = NULL;
g_auto(GLnxLockFile) child_repo_lock = GLNX_LOCK_FILE_INIT;
const char *installation = flatpak_dir_get_id (self);
const char *empty_subpaths[] = {NULL};
const char **subpaths;
g_autofree char *child_repo_path = NULL;
@ -4052,6 +4056,7 @@ flatpak_dir_install (FlatpakDir *self,
child_repo_path ? child_repo_path : "",
helper_flags, ref, remote_name,
(const char * const *) subpaths,
installation ? installation : "",
cancellable,
error))
return FALSE;
@ -4105,6 +4110,7 @@ flatpak_dir_install_bundle (FlatpakDir *self,
{
FlatpakSystemHelper *system_helper;
g_autoptr(GVariant) gpg_data_v = NULL;
const char *installation = flatpak_dir_get_id (self);
system_helper = flatpak_dir_get_system_helper (self);
g_assert (system_helper != NULL);
@ -4118,6 +4124,7 @@ flatpak_dir_install_bundle (FlatpakDir *self,
if (!flatpak_system_helper_call_install_bundle_sync (system_helper,
flatpak_file_get_path_cached (file),
0, gpg_data_v,
installation ? installation : "",
&ref,
cancellable,
error))
@ -4448,11 +4455,14 @@ flatpak_dir_update (FlatpakDir *self,
active_checksum = flatpak_dir_read_active (self, ref, NULL);
if (g_strcmp0 (active_checksum, latest_checksum) != 0)
{
const char *installation = flatpak_dir_get_id (self);
g_debug ("Calling system helper: Deploy");
if (!flatpak_system_helper_call_deploy_sync (system_helper,
child_repo_path ? child_repo_path : "",
helper_flags, ref, remote_name,
subpaths,
installation ? installation : "",
cancellable,
error))
return FALSE;
@ -4545,6 +4555,7 @@ flatpak_dir_uninstall (FlatpakDir *self,
if (flatpak_dir_use_system_helper (self))
{
FlatpakSystemHelper *system_helper;
const char *installation = flatpak_dir_get_id (self);
system_helper = flatpak_dir_get_system_helper (self);
g_assert (system_helper != NULL);
@ -4552,6 +4563,7 @@ flatpak_dir_uninstall (FlatpakDir *self,
g_debug ("Calling system helper: Uninstall");
if (!flatpak_system_helper_call_uninstall_sync (system_helper,
flags, ref,
installation ? installation : "",
cancellable, error))
return FALSE;
@ -6516,6 +6528,7 @@ flatpak_dir_remove_remote (FlatpakDir *self,
FlatpakSystemHelper *system_helper;
g_autoptr(GVariant) gpg_data_v = NULL;
FlatpakHelperConfigureRemoteFlags flags = 0;
const char *installation = flatpak_dir_get_id (self);
gpg_data_v = g_variant_ref_sink (g_variant_new_from_data (G_VARIANT_TYPE ("ay"), "", 0, TRUE, NULL, NULL));
@ -6530,6 +6543,7 @@ flatpak_dir_remove_remote (FlatpakDir *self,
flags, remote_name,
"",
gpg_data_v,
installation ? installation : "",
cancellable, error))
return FALSE;
@ -6625,6 +6639,7 @@ flatpak_dir_modify_remote (FlatpakDir *self,
FlatpakSystemHelper *system_helper;
g_autofree char *config_data = g_key_file_to_data (config, NULL, NULL);
g_autoptr(GVariant) gpg_data_v = NULL;
const char *installation = flatpak_dir_get_id (self);
if (gpg_data != NULL)
gpg_data_v = variant_new_ay_bytes (gpg_data);
@ -6639,6 +6654,7 @@ flatpak_dir_modify_remote (FlatpakDir *self,
0, remote_name,
config_data,
gpg_data_v,
installation ? installation : "",
cancellable, error))
return FALSE;
@ -6934,6 +6950,7 @@ flatpak_dir_update_remote_configuration (FlatpakDir *self,
FlatpakSystemHelper *system_helper;
g_autofree char *config_data = g_key_file_to_data (config, NULL, NULL);
g_autoptr(GVariant) gpg_data_v = NULL;
const char *installation = flatpak_dir_get_id (self);
gpg_data_v = g_variant_ref_sink (g_variant_new_from_data (G_VARIANT_TYPE ("ay"), "", 0, TRUE, NULL, NULL));
@ -6945,6 +6962,7 @@ flatpak_dir_update_remote_configuration (FlatpakDir *self,
0, remote,
config_data,
gpg_data_v,
installation ? installation : "",
cancellable, error))
return FALSE;

View File

@ -65,17 +65,20 @@
<arg type='s' name='ref' direction='in'/>
<arg type='s' name='origin' direction='in'/>
<arg type='as' name='subpaths' direction='in'/>
<arg type='s' name='installation' direction='in'/>
</method>
<method name="DeployAppstream">
<arg type='ay' name='repo_path' direction='in'/>
<arg type='s' name='origin' direction='in'/>
<arg type='s' name='arch' direction='in'/>
<arg type='s' name='installation' direction='in'/>
</method>
<method name="Uninstall">
<arg type='u' name='flags' direction='in'/>
<arg type='s' name='ref' direction='in'/>
<arg type='s' name='installation' direction='in'/>
</method>
<method name="InstallBundle">
@ -84,6 +87,7 @@
<arg type='ay' name='gpg_key' direction='in'>
<annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
</arg>
<arg type='s' name='installation' direction='in'/>
<arg type='s' name='ref' direction='out'/>
</method>
@ -94,6 +98,7 @@
<arg type='ay' name='gpg_key' direction='in'>
<annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
</arg>
<arg type='s' name='installation' direction='in'/>
</method>
</interface>

View File

@ -117,9 +117,19 @@ schedule_idle_callback (void)
}
static FlatpakDir *
dir_get_system (void)
dir_get_system (const char *installation, GError **error)
{
FlatpakDir *system = flatpak_dir_get_system_default ();
FlatpakDir *system = NULL;
if (installation != NULL && *installation != '\0')
system = flatpak_dir_get_system_by_id (installation, NULL, error);
else
system = flatpak_dir_get_system_default ();
/* This can happen in case of error with flatpak_dir_get_system_by_id(). */
if (system == NULL)
return NULL;
flatpak_dir_set_no_system_helper (system, TRUE);
return system;
}
@ -131,9 +141,10 @@ handle_deploy (FlatpakSystemHelper *object,
guint32 arg_flags,
const gchar *arg_ref,
const gchar *arg_origin,
const gchar *const *arg_subpaths)
const gchar *const *arg_subpaths,
const gchar *arg_installation)
{
g_autoptr(FlatpakDir) system = dir_get_system ();
g_autoptr(FlatpakDir) system = NULL;
g_autoptr(GFile) path = g_file_new_for_path (arg_repo_path);
g_autoptr(GError) error = NULL;
g_autoptr(GFile) deploy_dir = NULL;
@ -143,7 +154,14 @@ handle_deploy (FlatpakSystemHelper *object,
g_autoptr(GMainContext) main_context = NULL;
g_autofree char *url = NULL;
g_debug ("Deploy %s %u %s %s", arg_repo_path, arg_flags, arg_ref, arg_origin);
g_debug ("Deploy %s %u %s %s %s", arg_repo_path, arg_flags, arg_ref, arg_origin, arg_installation);
system = dir_get_system (arg_installation, &error);
if (system == NULL)
{
g_dbus_method_invocation_return_gerror (invocation, error);
return TRUE;
}
if ((arg_flags & ~FLATPAK_HELPER_DEPLOY_FLAGS_ALL) != 0)
{
@ -293,15 +311,23 @@ handle_deploy_appstream (FlatpakSystemHelper *object,
GDBusMethodInvocation *invocation,
const gchar *arg_repo_path,
const gchar *arg_origin,
const gchar *arg_arch)
const gchar *arg_arch,
const gchar *arg_installation)
{
g_autoptr(FlatpakDir) system = dir_get_system ();
g_autoptr(FlatpakDir) system = NULL;
g_autoptr(GFile) path = g_file_new_for_path (arg_repo_path);
g_autoptr(GError) error = NULL;
g_autoptr(GMainContext) main_context = NULL;
g_autofree char *branch = NULL;
g_debug ("DeployAppstream %s %s %s", arg_repo_path, arg_origin, arg_arch);
g_debug ("DeployAppstream %s %s %s %s", arg_repo_path, arg_origin, arg_arch, arg_installation);
system = dir_get_system (arg_installation, &error);
if (system == NULL)
{
g_dbus_method_invocation_return_gerror (invocation, error);
return TRUE;
}
if (!g_file_query_exists (path, NULL))
{
@ -358,12 +384,20 @@ static gboolean
handle_uninstall (FlatpakSystemHelper *object,
GDBusMethodInvocation *invocation,
guint arg_flags,
const gchar *arg_ref)
const gchar *arg_ref,
const gchar *arg_installation)
{
g_autoptr(FlatpakDir) system = dir_get_system ();
g_autoptr(FlatpakDir) system = NULL;
g_autoptr(GError) error = NULL;
g_debug ("Uninstall %u %s", arg_flags, arg_ref);
g_debug ("Uninstall %u %s %s", arg_flags, arg_ref, arg_installation);
system = dir_get_system (arg_installation, &error);
if (system == NULL)
{
g_dbus_method_invocation_return_gerror (invocation, error);
return TRUE;
}
if ((arg_flags & ~FLATPAK_HELPER_UNINSTALL_FLAGS_ALL) != 0)
{
@ -394,15 +428,23 @@ handle_install_bundle (FlatpakSystemHelper *object,
GDBusMethodInvocation *invocation,
const gchar *arg_bundle_path,
guint32 arg_flags,
GVariant *arg_gpg_key)
GVariant *arg_gpg_key,
const gchar *arg_installation)
{
g_autoptr(FlatpakDir) system = dir_get_system ();
g_autoptr(FlatpakDir) system = NULL;
g_autoptr(GFile) path = g_file_new_for_path (arg_bundle_path);
g_autoptr(GError) error = NULL;
g_autoptr(GBytes) gpg_data = NULL;
g_autofree char *ref = NULL;
g_debug ("InstallBundle %s %u %p", arg_bundle_path, arg_flags, arg_gpg_key);
g_debug ("InstallBundle %s %u %p %s", arg_bundle_path, arg_flags, arg_gpg_key, arg_installation);
system = dir_get_system (arg_installation, &error);
if (system == NULL)
{
g_dbus_method_invocation_return_gerror (invocation, error);
return TRUE;
}
if (arg_flags != 0)
{
@ -439,16 +481,24 @@ handle_configure_remote (FlatpakSystemHelper *object,
guint arg_flags,
const gchar *arg_remote,
const gchar *arg_config,
GVariant *arg_gpg_key)
GVariant *arg_gpg_key,
const gchar *arg_installation)
{
g_autoptr(FlatpakDir) system = dir_get_system ();
g_autoptr(FlatpakDir) system = NULL;
g_autoptr(GError) error = NULL;
g_autoptr(GKeyFile) config = g_key_file_new ();
g_autofree char *group = g_strdup_printf ("remote \"%s\"", arg_remote);
g_autoptr(GBytes) gpg_data = NULL;
gboolean force_remove;
g_debug ("ConfigureRemote %u %s", arg_flags, arg_remote);
g_debug ("ConfigureRemote %u %s %s", arg_flags, arg_remote, arg_installation);
system = dir_get_system (arg_installation, &error);
if (system == NULL)
{
g_dbus_method_invocation_return_gerror (invocation, error);
return TRUE;
}
if (*arg_remote == 0 || strchr (arg_remote, '/') != NULL)
{