diff options
author | Alexander Larsson <alexl@redhat.com> | 2016-02-08 11:30:48 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2016-02-08 11:30:48 +0100 |
commit | 1cc94f4f046b156fce83c588f2d6cf898bc8b44d (patch) | |
tree | f8ff23cf0f6ffed38c182ce7861f7868be646e46 /builder | |
parent | dd1e967b60aa94ef10465c51d35986995ec53f94 (diff) | |
download | xdg-app-1cc94f4f046b156fce83c588f2d6cf898bc8b44d.tar.gz |
builder: Use predictable names for build dirs
Instead of random hex, we use a pure counter
Diffstat (limited to 'builder')
-rw-r--r-- | builder/builder-module.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/builder/builder-module.c b/builder/builder-module.c index 9d8c019..a768809 100644 --- a/builder/builder-module.c +++ b/builder/builder-module.c @@ -757,23 +757,33 @@ builder_module_build (BuilderModule *self, g_auto(GStrv) env = NULL; g_auto(GStrv) build_args = NULL; const char *cflags, *cxxflags; - g_autofree char *buildname = NULL; g_autoptr(GFile) source_dir = NULL; g_autoptr(GFile) source_subdir = NULL; const char *source_subdir_relative = NULL; - g_autoptr(GFile) source_dir_template = NULL; g_autofree char *source_dir_path = NULL; + int count; - buildname = g_strdup_printf ("build-%s-XXXXXX", self->name); + for (count = 1; source_dir_path == NULL; count++) + { + g_autofree char *buildname = NULL; + g_autoptr(GFile) source_dir_count = NULL; + g_autoptr(GError) my_error = NULL; - source_dir_template = g_file_get_child (builder_context_get_state_dir (context), - buildname); - source_dir_path = g_file_get_path (source_dir_template); + buildname = g_strdup_printf ("build-%s-%d", self->name, count); - if (g_mkdtemp (source_dir_path) == NULL) - { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Can't create build directory"); - return FALSE; + source_dir_count = g_file_get_child (builder_context_get_state_dir (context), buildname); + + if (g_file_make_directory (source_dir_count, NULL, &my_error)) + source_dir_path = g_file_get_path (source_dir_count); + else + { + if (!g_error_matches (my_error, G_IO_ERROR, G_IO_ERROR_EXISTS)) + { + g_propagate_error (error, g_steal_pointer (&my_error)); + return FALSE; + } + /* Already exists, try again */ + } } source_dir = g_file_new_for_path (source_dir_path); |