|
| 1 | +/* |
| 2 | + * This file is part of usysconf. |
| 3 | + * |
| 4 | + * Copyright © 2017-2019 Solus Project |
| 5 | + * |
| 6 | + * This program is free software; you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU General Public License as published by |
| 8 | + * the Free Software Foundation; either version 2 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + */ |
| 11 | + |
| 12 | +#define _GNU_SOURCE |
| 13 | + |
| 14 | +#include "context.h" |
| 15 | +#include "files.h" |
| 16 | +#include "util.h" |
| 17 | + |
| 18 | +static const char *gio_modules_paths[] = { |
| 19 | + "/usr/lib64/gio/modules/", |
| 20 | +}; |
| 21 | + |
| 22 | +/** |
| 23 | + * Create a module cache with metadata from gio modules. Without this gio has to open each module which can cause bugs. |
| 24 | + */ |
| 25 | +static UscHandlerStatus usc_handler_glib2_gio_exec(__usc_unused__ UscContext *ctx, const char *path) |
| 26 | +{ |
| 27 | + autofree(char) *fp = NULL; |
| 28 | + char *command[] = { |
| 29 | + "/usr/bin/gio-querymodules", |
| 30 | + NULL, /* /usr/lib64/gio/modules */ |
| 31 | + NULL, /* Terminator */ |
| 32 | + }; |
| 33 | + |
| 34 | + if (!usc_file_is_dir(path)) { |
| 35 | + return USC_HANDLER_SKIP; |
| 36 | + } |
| 37 | + |
| 38 | + command[1] = (char *)path, |
| 39 | + |
| 40 | + usc_context_emit_task_start(ctx, "Creating GIO modules cache"); |
| 41 | + int ret = usc_exec_command(command); |
| 42 | + if (ret != 0) { |
| 43 | + usc_context_emit_task_finish(ctx, USC_HANDLER_FAIL); |
| 44 | + return USC_HANDLER_FAIL | USC_HANDLER_BREAK; |
| 45 | + } |
| 46 | + usc_context_emit_task_finish(ctx, USC_HANDLER_SUCCESS); |
| 47 | + /* Only want to run once for all of our globs */ |
| 48 | + return USC_HANDLER_SUCCESS | USC_HANDLER_BREAK; |
| 49 | +} |
| 50 | + |
| 51 | +const UscHandler usc_handler_glib2_gio = { |
| 52 | + .name = "glib2-gio", |
| 53 | + .description = "Create glib2 GIO modules cache", |
| 54 | + .required_bin = "/usr/bin/gio-querymodules", |
| 55 | + .exec = usc_handler_glib2_gio_exec, |
| 56 | + .paths = gio_modules_paths, |
| 57 | + .n_paths = ARRAY_SIZE(gio_modules_paths), |
| 58 | +}; |
| 59 | + |
| 60 | +/* |
| 61 | + * Editor modelines - https://www.wireshark.org/tools/modelines.html |
| 62 | + * |
| 63 | + * Local variables: |
| 64 | + * c-basic-offset: 8 |
| 65 | + * tab-width: 8 |
| 66 | + * indent-tabs-mode: nil |
| 67 | + * End: |
| 68 | + * |
| 69 | + * vi: set shiftwidth=8 tabstop=8 expandtab: |
| 70 | + * :indentSize=8:tabSize=8:noTabs=true: |
| 71 | + */ |
0 commit comments