static void gnome_help_check_dir (const char *name, const char *description, const char *scrollkeeper_config_arg) { const char *dir; char *result; dir = jb_variable_get_string(name); if (strcmp(dir, "autodetect")) return; jb_require_program("scrollkeeper-config"); jb_message_checking("for the %s", description); if (jb_exec_expand(&result, NULL, "$scrollkeeper-config $arg", "arg", scrollkeeper_config_arg, NULL)) { jb_message_result_string(result); jb_variable_set_string(name, result); } else { jb_message_result_string("not found"); jb_error("unable to autodetect the %s", description); } g_free(result); }
/* the program must have been registered with jb_register_program() */ gboolean jb_check_program (const char *name) { static GHashTable *checked_programs = NULL; JBVariable *variable; const char *program; gboolean result = FALSE; g_return_val_if_fail(name != NULL, FALSE); /* do not check for the same program twice */ if (checked_programs != NULL) { gpointer checked_result; if (g_hash_table_lookup_extended(checked_programs, name, NULL, &checked_result)) return GPOINTER_TO_INT(checked_result); } else checked_programs = g_hash_table_new(g_str_hash, g_str_equal); jb_message_checking("for %s", name); variable = jb_variable_get_variable_or_error(name); program = g_value_get_string(&variable->value); if (variable->user_set) { char *absolute_program; absolute_program = g_find_program_in_path(program); if (absolute_program != NULL) { jb_message_result_string(absolute_program); g_value_take_string(&variable->value, absolute_program); result = TRUE; } else { jb_message_result_string_format("not found (\"%s\" was specified but was not found, is a directory or is not executable)", program); g_value_set_string(&variable->value, NULL); } } else { if (program != NULL) { jb_message_result_string(program); result = TRUE; } else jb_message_result_string("not found"); } g_hash_table_insert(checked_programs, g_strdup(name), GINT_TO_POINTER(result)); return result; }
void jb_check_host_system (void) { char *output; gboolean status = FALSE; if (jb_variable_get_variable("host-cpu") != NULL) return; /* already checked */ jb_message_checking("the host system type"); if (jb_exec(&output, NULL, "jbsrc/tools/config.sub `jbsrc/tools/config.guess`")) { char **fields; int len; fields = g_strsplit(output, "-", 0); len = g_strv_length(fields); if (len == 3) { jb_variable_set_string("host-cpu", fields[0]); jb_variable_set_string("host-manufacturer", fields[1]); jb_variable_set_string("host-kernel", NULL); jb_variable_set_string("host-os", fields[2]); status = TRUE; } else if (len == 4) { jb_variable_set_string("host-cpu", fields[0]); jb_variable_set_string("host-manufacturer", fields[1]); jb_variable_set_string("host-kernel", fields[2]); jb_variable_set_string("host-os", fields[3]); status = TRUE; } g_strfreev(fields); } if (status) jb_message_result_string(output); else jb_message_result_string("unknown"); g_free(output); if (! status) jb_error("unable to determine host system type"); }
void jb_message_result_bool (gboolean result) { g_return_if_fail(printing_action); jb_message_result_string(result ? "yes" : "no"); }
gboolean jb_evolution_plugin_check (const char *minversion) { char *packages; gboolean result; if (! minversion) minversion = "2.12"; packages = g_strdup_printf("evolution-plugin-3.0 >= %s evolution-shell-3.0 libemail-engine", minversion); result = jb_check_packages("Evolution", "evolution-plugin", packages); g_free(packages); if (! result) return FALSE; if (! strcmp(jb_variable_get_string("evolution-plugin-dir"), "autodetect")) { char *plugindir; jb_message_checking("for the Evolution plugin directory"); plugindir = jb_get_package_variable("evolution-plugin-3.0", "plugindir"); jb_message_result_string(plugindir ? plugindir : "not found"); if (! plugindir) return FALSE; jb_variable_set_string("evolution-plugin-dir", plugindir); g_free(plugindir); } return jb_check_packages("Evolution", "camel", "camel-1.2"); }
void jb_message_result_string_format (const char *format, ...) { va_list args; char *message; g_return_if_fail(format != NULL); g_return_if_fail(printing_action); va_start(args, format); message = g_strdup_vprintf(format, args); va_end(args); jb_message_result_string(message); g_free(message); }