Skip to content

Commit

Permalink
Add support for 'autoprune-unless' for extensions
Browse files Browse the repository at this point in the history
This is an existing flatpak feature that was never added to
flatpak-builder, so it couldn't be used in app manifests.
  • Loading branch information
chrisawi authored and TingPing committed Jan 15, 2024
1 parent 7d621d6 commit f5313c1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/flatpak-manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@
Additionally the standard flatpak extension properties
are supported, and put directly into the metadata file:
autodelete, no-autodownload, subdirectories,
add-ld-path, download-if, enable-if, merge-dirs,
add-ld-path, download-if, enable-if, autoprune-unless, merge-dirs,
subdirectory-suffix, locale-subset, version, versions.
See the flatpak metadata documentation for more information on these.
</para>
Expand Down
21 changes: 21 additions & 0 deletions src/builder-extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct BuilderExtension
char *add_ld_path;
char *download_if;
char *enable_if;
char *autoprune_unless;
char *merge_dirs;
char *subdirectory_suffix;
char *version;
Expand All @@ -71,6 +72,7 @@ enum {
PROP_ADD_LD_PATH,
PROP_DOWNLOAD_IF,
PROP_ENABLE_IF,
PROP_AUTOPRUNE_UNLESS,
PROP_MERGE_DIRS,
PROP_NO_AUTODOWNLOAD,
PROP_LOCALE_SUBSET,
Expand All @@ -92,6 +94,7 @@ builder_extension_finalize (GObject *object)
g_free (self->add_ld_path);
g_free (self->download_if);
g_free (self->enable_if);
g_free (self->autoprune_unless);
g_free (self->merge_dirs);
g_free (self->subdirectory_suffix);
g_free (self->version);
Expand Down Expand Up @@ -150,6 +153,10 @@ builder_extension_get_property (GObject *object,
g_value_set_string (value, self->enable_if);
break;

case PROP_AUTOPRUNE_UNLESS:
g_value_set_string (value, self->autoprune_unless);
break;

case PROP_MERGE_DIRS:
g_value_set_string (value, self->merge_dirs);
break;
Expand Down Expand Up @@ -225,6 +232,11 @@ builder_extension_set_property (GObject *object,
self->enable_if = g_value_dup_string (value);
break;

case PROP_AUTOPRUNE_UNLESS:
g_clear_pointer (&self->autoprune_unless, g_free);
self->autoprune_unless = g_value_dup_string (value);
break;

case PROP_MERGE_DIRS:
g_clear_pointer (&self->merge_dirs, g_free);
self->merge_dirs = g_value_dup_string (value);
Expand Down Expand Up @@ -329,6 +341,13 @@ builder_extension_class_init (BuilderExtensionClass *klass)
"",
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_AUTOPRUNE_UNLESS,
g_param_spec_string ("autoprune-unless",
"",
"",
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_MERGE_DIRS,
g_param_spec_string ("merge-dirs",
Expand Down Expand Up @@ -445,6 +464,7 @@ builder_extension_add_finish_args (BuilderExtension *self,
add_arg (self, args, FLATPAK_METADATA_KEY_ADD_LD_PATH, self->add_ld_path);
add_arg (self, args, FLATPAK_METADATA_KEY_DOWNLOAD_IF, self->download_if);
add_arg (self, args, FLATPAK_METADATA_KEY_ENABLE_IF, self->enable_if);
add_arg (self, args, FLATPAK_METADATA_KEY_AUTOPRUNE_UNLESS, self->autoprune_unless);
add_arg (self, args, FLATPAK_METADATA_KEY_MERGE_DIRS, self->merge_dirs);
add_arg (self, args, FLATPAK_METADATA_KEY_SUBDIRECTORY_SUFFIX, self->subdirectory_suffix);
add_arg (self, args, FLATPAK_METADATA_KEY_VERSION, self->version);
Expand All @@ -467,6 +487,7 @@ builder_extension_checksum (BuilderExtension *self,
builder_cache_checksum_str (cache, self->add_ld_path);
builder_cache_checksum_str (cache, self->download_if);
builder_cache_checksum_str (cache, self->enable_if);
builder_cache_checksum_str (cache, self->autoprune_unless);
builder_cache_checksum_str (cache, self->merge_dirs);
builder_cache_checksum_str (cache, self->subdirectory_suffix);
builder_cache_checksum_str (cache, self->version);
Expand Down
1 change: 1 addition & 0 deletions src/builder-flatpak-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ typedef void (*FlatpakLoadUriProgress) (guint64 downloaded_bytes,
#define FLATPAK_METADATA_KEY_DIRECTORY "directory"
#define FLATPAK_METADATA_KEY_DOWNLOAD_IF "download-if"
#define FLATPAK_METADATA_KEY_ENABLE_IF "enable-if"
#define FLATPAK_METADATA_KEY_AUTOPRUNE_UNLESS "autoprune-unless"
#define FLATPAK_METADATA_KEY_MERGE_DIRS "merge-dirs"
#define FLATPAK_METADATA_KEY_NO_AUTODOWNLOAD "no-autodownload"
#define FLATPAK_METADATA_KEY_LOCALE_SUBSET "locale-subset"
Expand Down

0 comments on commit f5313c1

Please sign in to comment.