Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/bz-entry-group.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,9 @@ bz_entry_group_new_for_single_entry (BzEntry *entry)
if (unique_id != NULL)
gtk_string_list_append (group->unique_ids, unique_id);

group->installable = 1;
group->installable_available = 1;

future = dex_future_new_for_object (entry);
group->standalone_ui_entry = bz_result_new (future);
dex_unref (future);
Expand Down Expand Up @@ -1312,6 +1315,35 @@ dup_all_into_store_fiber (BzEntryGroup *self)
g_autoptr (GListStore) store = NULL;
guint n_resolved = 0;

if (self->standalone_ui_entry != NULL)
{
g_autoptr (GError) error = NULL;
BzEntry *entry = NULL;
DexFuture *future = NULL;

store = g_list_store_new (BZ_TYPE_ENTRY);
future = bz_result_dup_future (self->standalone_ui_entry);

if (dex_await (dex_ref (future), &error))
{
entry = g_value_get_object (dex_future_get_value (future, NULL));
if (entry != NULL)
{
bz_entry_group_connect_living (self, entry);
g_list_store_append (store, entry);
return dex_future_new_for_object (store);
}
}

g_warning ("Standalone entry for %s failed to resolve: %s",
self->id, error ? error->message : "unknown error");
return dex_future_new_reject (
G_IO_ERROR,
G_IO_ERROR_UNKNOWN,
"Standalone entry for %s failed to resolve",
self->id);
}

futures = g_ptr_array_new_with_free_func (dex_unref);

n_items = g_list_model_get_n_items (G_LIST_MODEL (self->unique_ids));
Expand Down
103 changes: 77 additions & 26 deletions src/bz-flatpak-instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,19 +845,17 @@ ensure_flathub_fiber (EnsureFlathubData *data)
static DexFuture *
load_local_ref_fiber (LoadLocalRefData *data)
{
GFile *file = data->file;
g_autoptr (GError) local_error = NULL;
g_autofree char *uri = NULL;
g_autofree char *path = NULL;
g_autoptr (FlatpakBundleRef) bref = NULL;
g_autoptr (BzFlatpakEntry) entry = NULL;
g_autoptr (GBytes) appstream_gz = NULL;
gboolean result = FALSE;
g_autoptr (AsComponent) component = NULL;
g_autoptr (GBytes) appstream = NULL;
g_autoptr (GInputStream) stream_gz = NULL;
g_autoptr (GInputStream) stream_data = NULL;
g_autoptr (GZlibDecompressor) decompressor = NULL;
GFile *file = data->file;
g_autoptr (GError) local_error = NULL;
g_autofree char *uri = NULL;
g_autofree char *path = NULL;
g_autoptr (FlatpakBundleRef) bref = NULL;
g_autoptr (BzFlatpakEntry) entry = NULL;
g_autoptr (GBytes) appstream_gz = NULL;
gboolean result = FALSE;
g_autoptr (AsComponent) component = NULL;
g_autoptr (GBytes) appstream = NULL;
g_autoptr (GFile) working_file = NULL;

uri = g_file_get_uri (file);
path = g_file_get_path (file);
Expand All @@ -866,9 +864,9 @@ load_local_ref_fiber (LoadLocalRefData *data)

if (g_str_has_suffix (uri, ".flatpakref"))
{
const char *resolved_uri = NULL;
g_autoptr (GKeyFile) key_file = g_key_file_new ();
g_autofree char *name = NULL;
const char *resolved_uri = NULL;
g_autoptr (GKeyFile) key_file = g_key_file_new ();
g_autofree char *name = NULL;

if (g_str_has_prefix (uri, "flatpak+https"))
resolved_uri = uri + strlen ("flatpak+");
Expand All @@ -879,9 +877,9 @@ load_local_ref_fiber (LoadLocalRefData *data)

if (g_str_has_prefix (resolved_uri, "http"))
{
g_autoptr (SoupMessage) message = NULL;
g_autoptr (GOutputStream) output = NULL;
g_autoptr (GBytes) bytes = NULL;
g_autoptr (SoupMessage) message = NULL;
g_autoptr (GOutputStream) output = NULL;
g_autoptr (GBytes) bytes = NULL;

message = soup_message_new (SOUP_METHOD_GET, resolved_uri);
output = g_memory_output_stream_new_resizable ();
Expand Down Expand Up @@ -924,6 +922,41 @@ load_local_ref_fiber (LoadLocalRefData *data)
return dex_future_new_take_string (g_steal_pointer (&name));
}

if (path != NULL &&
strstr (path, "/run/user/") != NULL)
{
g_autofree char *basename = NULL;
g_autofree char *bundles_dir = NULL;
g_autofree char *tmp_path = NULL;

basename = g_file_get_basename (file);
bundles_dir = g_build_filename (g_get_user_cache_dir (), "bundles", NULL);
tmp_path = g_build_filename (bundles_dir, basename, NULL);

if (g_mkdir_with_parents (bundles_dir, 0755) != 0)
return dex_future_new_reject (
BZ_FLATPAK_ERROR,
BZ_FLATPAK_ERROR_IO_MISBEHAVIOR,
"Failed to create bundle cache directory '%s'",
bundles_dir);

working_file = g_file_new_for_path (tmp_path);
if (!g_file_copy (file, working_file,
G_FILE_COPY_OVERWRITE,
data->cancellable,
NULL, NULL,
&local_error))
return dex_future_new_reject (
BZ_FLATPAK_ERROR,
BZ_FLATPAK_ERROR_IO_MISBEHAVIOR,
"Failed to copy bundle out of portal path '%s': %s",
path, local_error->message);

g_free (path);
path = g_steal_pointer (&tmp_path);
file = working_file;
}

bref = flatpak_bundle_ref_new (file, &local_error);
if (bref == NULL)
return dex_future_new_reject (
Expand All @@ -937,7 +970,7 @@ load_local_ref_fiber (LoadLocalRefData *data)
if (appstream_gz != NULL)
{
g_autoptr (XbBuilderSource) source = NULL;
g_autoptr (XbSilo) silo = NULL;
g_autoptr (XbSilo) silo = NULL;

appstream = decompress_appstream_gz (appstream_gz, NULL, &local_error);
if (appstream == NULL)
Expand Down Expand Up @@ -1769,12 +1802,14 @@ transaction_fiber (TransactionData *data)
BzFlatpakEntry *entry = NULL;
FlatpakRef *ref = NULL;
gboolean is_user = FALSE;
gboolean is_bundle = FALSE;
g_autofree char *ref_fmt = NULL;
g_autoptr (FlatpakTransaction) transaction = NULL;

entry = g_ptr_array_index (installations, i);
ref = bz_flatpak_entry_get_ref (entry);
is_user = bz_flatpak_entry_is_user (BZ_FLATPAK_ENTRY (entry));
is_bundle = FLATPAK_IS_BUNDLE_REF (ref);
ref_fmt = flatpak_ref_format_ref (ref);

if ((is_user && self->user == NULL) ||
Expand Down Expand Up @@ -1804,12 +1839,28 @@ transaction_fiber (TransactionData *data)
local_error->message);
}

result = flatpak_transaction_add_install (
transaction,
bz_entry_get_remote_repo_name (BZ_ENTRY (entry)),
ref_fmt,
NULL,
&local_error);
if (is_bundle)
{
GFile *bundle_file = NULL;

bundle_file = flatpak_bundle_ref_get_file (FLATPAK_BUNDLE_REF (ref));

result = flatpak_transaction_add_install_bundle (
transaction,
bundle_file,
NULL, // gpg_data
&local_error);
}
else
{
result = flatpak_transaction_add_install (
transaction,
bz_entry_get_remote_repo_name (BZ_ENTRY (entry)),
ref_fmt,
NULL,
&local_error);
}

if (!result)
{
dex_channel_close_send (channel);
Expand Down
5 changes: 0 additions & 5 deletions src/bz-full-view.blp
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,6 @@ template $BzFullView: Adw.Bin {
margin-bottom: 15;
spacing: 20;

Adw.Banner {
title: _("Installing .flatpak bundles is not yet supported");
revealed: bind template.ui-entry as <$BzResult>.object as <$BzFlatpakEntry>.is-bundle as <bool>;
}

Adw.Clamp {
maximum-size: 860;
tightening-threshold: 1000;
Expand Down