forked from Mirrors/flatpak-builder
builder: Prefix module errors
Sprinkle g_prefix_error calls in builder-module.c, to make sure that module-specific errors get a "module foo:" prefix. This is not quite perfect, since callers tend to impose their own prefix as well, but at least it clearly identifies the module in which the error ocurred.tingping/wmclass
parent
1d8408e381
commit
5f928b30ac
|
@ -548,8 +548,11 @@ builder_module_download_sources (BuilderModule *self,
|
|||
BuilderSource *source = l->data;
|
||||
|
||||
if (!builder_source_download (source, update_vcs, context, error))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -571,8 +574,11 @@ builder_module_extract_sources (BuilderModule *self,
|
|||
BuilderSource *source = l->data;
|
||||
|
||||
if (!builder_source_extract (source, dest, context, error))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -676,7 +682,10 @@ build (GFile *app_dir,
|
|||
|
||||
if (subp == NULL ||
|
||||
!g_subprocess_wait_check (subp, NULL, error))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", module_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -723,14 +732,20 @@ builder_module_handle_debuginfo (BuilderModule *self,
|
|||
if (is_shared)
|
||||
{
|
||||
if (!strip (error, "--remove-section=.comment", "--remove-section=.note", "--strip-unneeded", path, NULL))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!strip (error, "--remove-section=.comment", "--remove-section=.note", path, NULL))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!builder_options_get_no_debuginfo (self->build_options, context))
|
||||
{
|
||||
g_autofree char *rel_path_dir = g_path_get_dirname (rel_path);
|
||||
|
@ -763,6 +778,7 @@ builder_module_handle_debuginfo (BuilderModule *self,
|
|||
if (g_mkdir_with_parents (debug_dir, 0755) != 0)
|
||||
{
|
||||
glnx_set_error_from_errno (error);
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -770,6 +786,7 @@ builder_module_handle_debuginfo (BuilderModule *self,
|
|||
if (g_mkdir_with_parents (source_dir_path, 0755) != 0)
|
||||
{
|
||||
glnx_set_error_from_errno (error);
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -802,35 +819,47 @@ builder_module_handle_debuginfo (BuilderModule *self,
|
|||
GFileType file_type;
|
||||
|
||||
if (!gs_file_ensure_directory (dst_parent, TRUE, NULL, error))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
file_type = g_file_query_file_type (src, 0, NULL);
|
||||
if (file_type == G_FILE_TYPE_DIRECTORY)
|
||||
{
|
||||
if (!gs_file_ensure_directory (dst, FALSE, NULL, error))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else if (file_type == G_FILE_TYPE_REGULAR)
|
||||
{
|
||||
if (!g_file_copy (src, dst,
|
||||
G_FILE_COPY_OVERWRITE,
|
||||
NULL, NULL, NULL, error))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_print ("stripping %s to %s\n", path, debug_path);
|
||||
if (!eu_strip (error, "--remove-comment", "--reloc-debug-sections",
|
||||
"-f", debug_path,
|
||||
"-F", real_debug_path,
|
||||
path, NULL))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -871,7 +900,10 @@ builder_module_build (BuilderModule *self,
|
|||
|
||||
if (!gs_file_ensure_directory (build_parent_dir, TRUE,
|
||||
NULL, error))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (count = 1; source_dir_path == NULL; count++)
|
||||
{
|
||||
|
@ -891,6 +923,7 @@ builder_module_build (BuilderModule *self,
|
|||
if (!g_error_matches (my_error, G_IO_ERROR, G_IO_ERROR_EXISTS))
|
||||
{
|
||||
g_propagate_error (error, g_steal_pointer (&my_error));
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
g_clear_error (&my_error);
|
||||
|
@ -906,6 +939,7 @@ builder_module_build (BuilderModule *self,
|
|||
!g_error_matches (my_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
|
||||
{
|
||||
g_propagate_error (error, g_steal_pointer (&my_error));
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
g_clear_error (&my_error);
|
||||
|
@ -913,7 +947,10 @@ builder_module_build (BuilderModule *self,
|
|||
if (!g_file_make_symbolic_link (build_link,
|
||||
buildname,
|
||||
NULL, error))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_print ("========================================================================\n");
|
||||
g_print ("Building module %s in %s\n", self->name, source_dir_path);
|
||||
|
@ -941,7 +978,7 @@ builder_module_build (BuilderModule *self,
|
|||
cmake_file = g_file_get_child (source_subdir, "CMakeLists.txt");
|
||||
if (!g_file_query_exists (cmake_file, NULL))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Can't find CMakeLists.txt");
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "module: %s: Can't find CMakeLists.txt", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
configure_file = g_object_ref (cmake_file);
|
||||
|
@ -953,9 +990,12 @@ builder_module_build (BuilderModule *self,
|
|||
if (self->rm_configure)
|
||||
{
|
||||
if (!g_file_delete (configure_file, NULL, error))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
has_configure = g_file_query_exists (configure_file, NULL);
|
||||
|
||||
|
@ -977,18 +1017,21 @@ builder_module_build (BuilderModule *self,
|
|||
|
||||
if (autogen_cmd == NULL)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Can't find autogen, autogen.sh or bootstrap");
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "module %s: Can't find autogen, autogen.sh or bootstrap", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
env_with_noconfigure = g_environ_setenv (g_strdupv (env), "NOCONFIGURE", "1", TRUE);
|
||||
if (!build (app_dir, self->name, context, source_dir, source_subdir_relative, build_args, env_with_noconfigure, error,
|
||||
autogen_cmd, NULL))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!g_file_query_exists (configure_file, NULL))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "autogen did not create configure");
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "module %s: autogen did not create configure", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1003,7 +1046,10 @@ builder_module_build (BuilderModule *self,
|
|||
g_autofree char *configure_content = NULL;
|
||||
|
||||
if (!g_file_load_contents (configure_file, NULL, &configure_content, NULL, NULL, error))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
var_require_builddir = strstr (configure_content, "buildapi-variable-require-builddir") != NULL;
|
||||
use_builddir = var_require_builddir || self->builddir;
|
||||
|
@ -1017,7 +1063,10 @@ builder_module_build (BuilderModule *self,
|
|||
build_dir = g_file_get_child (source_subdir, "_flatpak_build");
|
||||
|
||||
if (!g_file_make_directory (build_dir, NULL, error))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (self->cmake)
|
||||
{
|
||||
|
@ -1070,7 +1119,7 @@ builder_module_build (BuilderModule *self,
|
|||
|
||||
if (makefile_names[i] == NULL)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Can't find makefile");
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "module %s: Can't find makefile", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1102,8 +1151,11 @@ builder_module_build (BuilderModule *self,
|
|||
root_dir = g_file_get_child (app_dir, "files");
|
||||
|
||||
if (!builder_migrate_locale_dirs (root_dir, error))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (self->post_install)
|
||||
{
|
||||
|
@ -1123,11 +1175,17 @@ builder_module_build (BuilderModule *self,
|
|||
if (!builder_context_get_keep_build_dirs (context))
|
||||
{
|
||||
if (!g_file_delete (build_link, NULL, error))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!gs_shutil_rm_rf (source_dir, NULL, error))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1144,8 +1202,11 @@ builder_module_update (BuilderModule *self,
|
|||
BuilderSource *source = l->data;
|
||||
|
||||
if (!builder_source_update (source, context, error))
|
||||
{
|
||||
g_prefix_error (error, "module %s: ", self->name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue