diff --git a/NEWS b/NEWS index 3c2be3ccc..d0ea75c21 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ Major changes in 0.6.11 * HostCommand now returns the real PID rather than a fake one. * Fix regression in flatpak update --appstream * Fix regression installing bundles without origin urls + * New flatpak-builder option --show-deps lists all the files + the manifest depends on. Major changes in 0.6.10 ======================= diff --git a/builder/builder-main.c b/builder/builder-main.c index a7e32d48e..f89cee754 100644 --- a/builder/builder-main.c +++ b/builder/builder-main.c @@ -37,6 +37,7 @@ static gboolean opt_run; static gboolean opt_disable_cache; static gboolean opt_download_only; static gboolean opt_build_only; +static gboolean opt_show_deps; static gboolean opt_disable_download; static gboolean opt_disable_updates; static gboolean opt_ccache; @@ -63,6 +64,7 @@ static GOptionEntry entries[] = { { "disable-updates", 0, 0, G_OPTION_ARG_NONE, &opt_disable_updates, "Only download missing sources, never update to latest vcs version", NULL }, { "download-only", 0, 0, G_OPTION_ARG_NONE, &opt_download_only, "Only download sources, don't build", NULL }, { "build-only", 0, 0, G_OPTION_ARG_NONE, &opt_build_only, "Stop after build, don't run clean and finish phases", NULL }, + { "show-deps", 0, 0, G_OPTION_ARG_NONE, &opt_show_deps, "List the dependencies of the json file (see --show-deps --help)", NULL }, { "require-changes", 0, 0, G_OPTION_ARG_NONE, &opt_require_changes, "Don't create app dir or export if no changes", NULL }, { "keep-build-dirs", 0, 0, G_OPTION_ARG_NONE, &opt_keep_build_dirs, "Don't remove build directories after install", NULL }, { "repo", 0, 0, G_OPTION_ARG_STRING, &opt_repo, "Repo to export into", "DIR"}, @@ -84,6 +86,12 @@ static GOptionEntry run_entries[] = { { NULL } }; +static GOptionEntry show_deps_entries[] = { + { "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, "Print debug information during command processing", NULL }, + { "show-deps", 0, 0, G_OPTION_ARG_NONE, &opt_show_deps, "List the dependencies of the json file (see --show-deps --help)", NULL }, + { NULL } +}; + static void message_handler (const gchar *log_domain, @@ -174,7 +182,7 @@ main (int argc, g_autoptr(GError) error = NULL; g_autoptr(BuilderManifest) manifest = NULL; g_autoptr(GOptionContext) context = NULL; - const char *app_dir_path, *manifest_path; + const char *app_dir_path = NULL, *manifest_path; g_autofree gchar *json = NULL; g_autoptr(BuilderContext) build_context = NULL; g_autoptr(GFile) base_dir = NULL; @@ -188,8 +196,10 @@ main (int argc, const char *platform_id = NULL; g_autofree char **orig_argv; gboolean is_run = FALSE; + gboolean is_show_deps = FALSE; g_autoptr(FlatpakContext) arg_context = NULL; int i, first_non_arg, orig_argc; + int argnr; setlocale (LC_ALL, ""); @@ -217,6 +227,8 @@ main (int argc, first_non_arg = i + 1; if (strcmp (argv[i], "--run") == 0) is_run = TRUE; + if (strcmp (argv[i], "--show-deps") == 0) + is_show_deps = TRUE; } if (is_run) @@ -229,6 +241,11 @@ main (int argc, /* We drop the post-command part from the args, these go with the command in the sandbox */ argc = MIN (first_non_arg + 3, argc); } + else if (is_show_deps) + { + context = g_option_context_new ("MANIFEST - Show manifest dependencies"); + g_option_context_add_main_entries (context, show_deps_entries, NULL); + } else { context = g_option_context_new ("DIRECTORY MANIFEST - Build manifest"); @@ -250,15 +267,18 @@ main (int argc, if (opt_verbose) g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, message_handler, NULL); - if (argc == 1) - return usage (context, "DIRECTORY must be specified"); + argnr = 1; - app_dir_path = argv[1]; + if (!is_show_deps) + { + if (argc == argnr) + return usage (context, "DIRECTORY must be specified"); + app_dir_path = argv[argnr++]; + } - if (argc == 2) + if (argc == argnr) return usage (context, "MANIFEST must be specified"); - - manifest_path = argv[2]; + manifest_path = argv[argnr++]; if (!g_file_get_contents (manifest_path, &json, NULL, &error)) { @@ -277,6 +297,17 @@ main (int argc, if (is_run && argc == 3) return usage (context, "Program to run must be specified"); + if (is_show_deps) + { + if (!builder_manifest_show_deps (manifest, &error)) + { + g_printerr ("Error running %s: %s\n", argv[3], error->message); + return 1; + } + + return 0; + } + manifest_file = g_file_new_for_path (manifest_path); base_dir = g_file_get_parent (manifest_file); app_dir = g_file_new_for_path (app_dir_path); @@ -325,6 +356,7 @@ main (int argc, } g_assert (!opt_run); + g_assert (!opt_show_deps); if (g_file_query_exists (app_dir, NULL) && !directory_is_empty (app_dir_path)) { diff --git a/builder/builder-manifest.c b/builder/builder-manifest.c index 523b09909..e408984af 100644 --- a/builder/builder-manifest.c +++ b/builder/builder-manifest.c @@ -815,8 +815,12 @@ builder_manifest_deserialize_property (JsonSerializable *serializable, g_autofree char *json = NULL; if (g_file_get_contents (module_path, &json, NULL, NULL)) - module = json_gobject_from_data (BUILDER_TYPE_MODULE, - json, -1, NULL); + { + module = json_gobject_from_data (BUILDER_TYPE_MODULE, + json, -1, NULL); + if (module) + builder_module_set_json_path (BUILDER_MODULE (module), module_path); + } } else if (JSON_NODE_HOLDS_OBJECT (element_node)) module = json_gobject_deserialize (BUILDER_TYPE_MODULE, element_node); @@ -2103,6 +2107,27 @@ builder_manifest_create_platform (BuilderManifest *self, } +gboolean +builder_manifest_show_deps (BuilderManifest *self, + GError **error) +{ + g_autoptr(GHashTable) names = g_hash_table_new (g_str_hash, g_str_equal); + GList *l; + + if (!expand_modules (self->modules, &self->expanded_modules, names, error)) + return FALSE; + + for (l = self->expanded_modules; l != NULL; l = l->next) + { + BuilderModule *module = l->data; + + if (!builder_module_show_deps (module, error)) + return FALSE; + } + + return TRUE; +} + gboolean builder_manifest_run (BuilderManifest *self, BuilderContext *context, diff --git a/builder/builder-manifest.h b/builder/builder-manifest.h index 4dc3a959f..91bdee709 100644 --- a/builder/builder-manifest.h +++ b/builder/builder-manifest.h @@ -70,6 +70,8 @@ gboolean builder_manifest_run (BuilderManifest *self, char **argv, int argc, GError **error); +gboolean builder_manifest_show_deps (BuilderManifest *self, + GError **error); void builder_manifest_checksum (BuilderManifest *self, BuilderCache *cache, BuilderContext *context); diff --git a/builder/builder-module.c b/builder/builder-module.c index 750ca62b3..83abc1d0b 100644 --- a/builder/builder-module.c +++ b/builder/builder-module.c @@ -38,6 +38,7 @@ struct BuilderModule { GObject parent; + char *json_path; char *name; char *subdir; char **post_install; @@ -98,6 +99,7 @@ builder_module_finalize (GObject *object) { BuilderModule *self = (BuilderModule *) object; + g_free (self->json_path); g_free (self->name); g_free (self->subdir); g_strfreev (self->post_install); @@ -653,6 +655,25 @@ builder_module_get_modules (BuilderModule *self) return self->modules; } +gboolean +builder_module_show_deps (BuilderModule *self, + GError **error) +{ + GList *l; + if (self->json_path) + g_print ("%s\n", self->json_path); + + for (l = self->sources; l != NULL; l = l->next) + { + BuilderSource *source = l->data; + + if (!builder_source_show_deps (source, error)) + return FALSE; + } + + return TRUE; +} + gboolean builder_module_download_sources (BuilderModule *self, gboolean update_vcs, @@ -1525,6 +1546,13 @@ builder_module_checksum_for_cleanup (BuilderModule *self, builder_cache_checksum_strv (cache, self->cleanup); } +void +builder_module_set_json_path (BuilderModule *self, + const char *json_path) +{ + self->json_path = g_strdup (json_path); +} + GPtrArray * builder_module_get_changes (BuilderModule *self) { diff --git a/builder/builder-module.h b/builder/builder-module.h index e0b825a1b..f6c8cd5be 100644 --- a/builder/builder-module.h +++ b/builder/builder-module.h @@ -43,10 +43,14 @@ const char * builder_module_get_name (BuilderModule *self); gboolean builder_module_get_disabled (BuilderModule *self); GList * builder_module_get_sources (BuilderModule *self); GList * builder_module_get_modules (BuilderModule *self); +void builder_module_set_json_path (BuilderModule *self, + const char *json_path); GPtrArray * builder_module_get_changes (BuilderModule *self); void builder_module_set_changes (BuilderModule *self, GPtrArray *changes); +gboolean builder_module_show_deps (BuilderModule *self, + GError **error); gboolean builder_module_download_sources (BuilderModule *self, gboolean update_vcs, BuilderContext *context, diff --git a/builder/builder-source-archive.c b/builder/builder-source-archive.c index 2d066e86d..cc44da553 100644 --- a/builder/builder-source-archive.c +++ b/builder/builder-source-archive.c @@ -297,6 +297,19 @@ download_uri (const char *url, return g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (out)); } +static gboolean +builder_source_archive_show_deps (BuilderSource *source, + GError **error) +{ + BuilderSourceArchive *self = BUILDER_SOURCE_ARCHIVE (source); + + if (self->path && self->path[0] != 0) + g_print ("%s\n", self->path); + + return TRUE; +} + + static gboolean builder_source_archive_download (BuilderSource *source, gboolean update_vcs, @@ -649,6 +662,7 @@ builder_source_archive_class_init (BuilderSourceArchiveClass *klass) object_class->get_property = builder_source_archive_get_property; object_class->set_property = builder_source_archive_set_property; + source_class->show_deps = builder_source_archive_show_deps; source_class->download = builder_source_archive_download; source_class->extract = builder_source_archive_extract; source_class->checksum = builder_source_archive_checksum; diff --git a/builder/builder-source-file.c b/builder/builder-source-file.c index 7888d5348..d7d9b1de8 100644 --- a/builder/builder-source-file.c +++ b/builder/builder-source-file.c @@ -257,6 +257,18 @@ download_uri (const char *url, return g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (out)); } +static gboolean +builder_source_file_show_deps (BuilderSource *source, + GError **error) +{ + BuilderSourceFile *self = BUILDER_SOURCE_FILE (source); + + if (self->path && self->path[0] != 0) + g_print ("%s\n", self->path); + + return TRUE; +} + static gboolean builder_source_file_download (BuilderSource *source, gboolean update_vcs, @@ -501,6 +513,7 @@ builder_source_file_class_init (BuilderSourceFileClass *klass) object_class->get_property = builder_source_file_get_property; object_class->set_property = builder_source_file_set_property; + source_class->show_deps = builder_source_file_show_deps; source_class->download = builder_source_file_download; source_class->extract = builder_source_file_extract; source_class->update = builder_source_file_update; diff --git a/builder/builder-source-patch.c b/builder/builder-source-patch.c index 614365fa9..d021ee1c4 100644 --- a/builder/builder-source-patch.c +++ b/builder/builder-source-patch.c @@ -135,6 +135,18 @@ get_source_file (BuilderSourcePatch *self, return g_file_resolve_relative_path (builder_context_get_base_dir (context), self->path); } +static gboolean +builder_source_patch_show_deps (BuilderSource *source, + GError **error) +{ + BuilderSourcePatch *self = BUILDER_SOURCE_PATCH (source); + + if (self->path && self->path[0] != 0) + g_print ("%s\n", self->path); + + return TRUE; +} + static gboolean builder_source_patch_download (BuilderSource *source, gboolean update_vcs, @@ -255,6 +267,7 @@ builder_source_patch_class_init (BuilderSourcePatchClass *klass) object_class->get_property = builder_source_patch_get_property; object_class->set_property = builder_source_patch_set_property; + source_class->show_deps = builder_source_patch_show_deps; source_class->download = builder_source_patch_download; source_class->extract = builder_source_patch_extract; source_class->checksum = builder_source_patch_checksum; diff --git a/builder/builder-source.c b/builder/builder-source.c index 2e6c58d7a..44bee53cc 100644 --- a/builder/builder-source.c +++ b/builder/builder-source.c @@ -97,6 +97,12 @@ builder_source_set_property (GObject *object, G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } } +static gboolean +builder_source_real_show_deps (BuilderSource *self, + GError **error) +{ + return TRUE; +} static gboolean builder_source_real_download (BuilderSource *self, @@ -138,6 +144,7 @@ builder_source_class_init (BuilderSourceClass *klass) object_class->get_property = builder_source_get_property; object_class->set_property = builder_source_set_property; + klass->show_deps = builder_source_real_show_deps; klass->download = builder_source_real_download; klass->extract = builder_source_real_extract; klass->update = builder_source_real_update; @@ -224,6 +231,17 @@ builder_source_from_json (JsonNode *node) return NULL; } +gboolean +builder_source_show_deps (BuilderSource *self, + GError **error) +{ + BuilderSourceClass *class; + + class = BUILDER_SOURCE_GET_CLASS (self); + + return class->show_deps (self, error); +} + gboolean builder_source_download (BuilderSource *self, gboolean update_vcs, diff --git a/builder/builder-source.h b/builder/builder-source.h index ff5301aa9..ecee25e05 100644 --- a/builder/builder-source.h +++ b/builder/builder-source.h @@ -48,6 +48,8 @@ typedef struct { GObjectClass parent_class; + gboolean (* show_deps)(BuilderSource *self, + GError **error); gboolean (* download)(BuilderSource *self, gboolean update_vcs, BuilderContext *context, @@ -70,6 +72,8 @@ GType builder_source_get_type (void); BuilderSource * builder_source_from_json (JsonNode *node); JsonNode * builder_source_to_json (BuilderSource *self); +gboolean builder_source_show_deps (BuilderSource *self, + GError **error); gboolean builder_source_download (BuilderSource *self, gboolean update_vcs, BuilderContext *context, diff --git a/doc/flatpak-builder.xml b/doc/flatpak-builder.xml index 029ec6951..28ec02834 100644 --- a/doc/flatpak-builder.xml +++ b/doc/flatpak-builder.xml @@ -43,6 +43,12 @@ MANIFEST COMMAND + + flatpak-builder + --show-deps + OPTION + MANIFEST + @@ -627,6 +633,14 @@ + + + + + List all the (local) files that the manifest depends on. + + +