diff options
author | Alexander Larsson <alexl@redhat.com> | 2016-01-11 15:35:17 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2016-01-11 15:35:17 +0100 |
commit | 13d07d6a6f149c9c5004745e7338c18809fe0745 (patch) | |
tree | 8362517acb4419f5e411b75bae7da6e1a61250f3 /builder | |
parent | e2b347ba7601fa10118a76836a04994738f20bab (diff) | |
download | xdg-app-13d07d6a6f149c9c5004745e7338c18809fe0745.tar.gz |
builder: Add support for exporting with --repo=foo
Diffstat (limited to 'builder')
-rw-r--r-- | builder/builder-cache.c | 10 | ||||
-rw-r--r-- | builder/builder-cache.h | 1 | ||||
-rw-r--r-- | builder/builder-manifest.c | 22 | ||||
-rw-r--r-- | builder/xdg-app-builder-main.c | 63 |
4 files changed, 91 insertions, 5 deletions
diff --git a/builder/builder-cache.c b/builder/builder-cache.c index 62624dc..8dd1624 100644 --- a/builder/builder-cache.c +++ b/builder/builder-cache.c @@ -250,10 +250,16 @@ builder_cache_checkout (BuilderCache *self, const char *commit) return TRUE; } +gboolean +builder_cache_has_checkout (BuilderCache *self) +{ + return self->disabled; +} + void builder_cache_ensure_checkout (BuilderCache *self) { - if (self->disabled) + if (builder_cache_has_checkout (self)) return; if (self->last_parent) @@ -263,6 +269,8 @@ builder_cache_ensure_checkout (BuilderCache *self) if (!builder_cache_checkout (self, self->last_parent)) g_error ("Failed to check out cache"); } + + self->disabled = TRUE; } gboolean diff --git a/builder/builder-cache.h b/builder/builder-cache.h index 42f04e7..6f2863a 100644 --- a/builder/builder-cache.h +++ b/builder/builder-cache.h @@ -43,6 +43,7 @@ gboolean builder_cache_open (BuilderCache *self, GChecksum * builder_cache_get_checksum (BuilderCache *self); gboolean builder_cache_lookup (BuilderCache *self); void builder_cache_ensure_checkout (BuilderCache *self); +gboolean builder_cache_has_checkout (BuilderCache *self); gboolean builder_cache_commit (BuilderCache *self, const char *body, GError **error); diff --git a/builder/builder-manifest.c b/builder/builder-manifest.c index b9075ab..d5db8f9 100644 --- a/builder/builder-manifest.c +++ b/builder/builder-manifest.c @@ -1119,12 +1119,30 @@ builder_manifest_finish (BuilderManifest *self, if (g_file_query_exists (debuginfo_dir, NULL)) { g_autoptr(GFile) metadata_file = NULL; + g_autoptr(GFile) metadata_debuginfo_file = NULL; g_autofree char *metadata_contents = NULL; + g_autofree char *extension_contents = NULL; + g_autoptr(GFileOutputStream) output = NULL; + + metadata_file = g_file_get_child (app_dir, "metadata"); + metadata_debuginfo_file = g_file_get_child (app_dir, "metadata.debuginfo"); + + extension_contents = g_strdup_printf("\n" + "[Extension %s.Debug]\n" + "directory=lib/debug\n", + self->app_id); + + output = g_file_append_to (metadata_file, G_FILE_CREATE_NONE, NULL, error); + if (output == NULL) + return FALSE; + + if (!g_output_stream_write_all (G_OUTPUT_STREAM (output), extension_contents, strlen (extension_contents), + NULL, NULL, error)) + return FALSE; - metadata_file = g_file_get_child (app_dir, "metadata.debuginfo"); metadata_contents = g_strdup_printf("[Runtime]\n" "name=%s.Debug\n", self->app_id); - if (!g_file_replace_contents (metadata_file, + if (!g_file_replace_contents (metadata_debuginfo_file, metadata_contents, strlen (metadata_contents), NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, NULL, NULL, error)) diff --git a/builder/xdg-app-builder-main.c b/builder/xdg-app-builder-main.c index f75e31d..a6b97c3 100644 --- a/builder/xdg-app-builder-main.c +++ b/builder/xdg-app-builder-main.c @@ -40,6 +40,7 @@ static gboolean opt_disable_download; static gboolean opt_disable_updates; static gboolean opt_require_changes; static gboolean opt_keep_build_dirs; +static char *opt_repo; static GOptionEntry entries[] = { { "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, "Print debug information during command processing", NULL }, @@ -49,8 +50,9 @@ 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 }, - { "require-changes", 0, 0, G_OPTION_ARG_NONE, &opt_require_changes, "Don't create app dir if no changes", 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"}, { NULL } }; @@ -76,6 +78,40 @@ usage (GOptionContext *context, const char *message) return 1; } +static gboolean +do_export (GError **error, + ...) +{ + va_list ap; + const char *arg; + + g_autoptr(GPtrArray) args = NULL; + g_autoptr(GSubprocess) subp = NULL; + + args = g_ptr_array_new_with_free_func (g_free); + g_ptr_array_add (args, g_strdup ("xdg-app")); + g_ptr_array_add (args, g_strdup ("build-export")); + + va_start (ap, error); + while ((arg = va_arg (ap, const gchar *))) + g_ptr_array_add (args, g_strdup ((gchar *) arg)); + va_end (ap); + + g_ptr_array_add (args, NULL); + + subp = + g_subprocess_newv ((const gchar * const *) args->pdata, + G_SUBPROCESS_FLAGS_NONE, + error); + + if (subp == NULL || + !g_subprocess_wait_check (subp, NULL, error)) + return FALSE; + + return TRUE; +} + + int main (int argc, char **argv) @@ -227,7 +263,30 @@ main (int argc, } if (!opt_require_changes) - builder_cache_ensure_checkout (cache); + { + builder_cache_ensure_checkout (cache); + } + + if (opt_repo && builder_cache_has_checkout (cache)) + { + g_autoptr(GFile) debuginfo_metadata = NULL; + + if (!do_export (&error,"--exclude=/lib/debug/*", opt_repo, app_dir_path, NULL)) + { + g_print ("Export failed: %s\n", error->message); + return 1; + } + + debuginfo_metadata = g_file_get_child (app_dir, "metadata.debuginfo"); + if (g_file_query_exists (debuginfo_metadata, NULL)) + { + if (!do_export (&error, "--runtime", "--metadata=metadata.debuginfo", "--files=files/lib/debug", opt_repo, app_dir_path, NULL)) + { + g_print ("Export failed: %s\n", error->message); + return 1; + } + } + } if (!builder_gc (cache, &error)) { |