diff options
Diffstat (limited to 'src/libostree/ostree-bootloader-aboot.c')
-rw-r--r-- | src/libostree/ostree-bootloader-aboot.c | 122 |
1 files changed, 59 insertions, 63 deletions
diff --git a/src/libostree/ostree-bootloader-aboot.c b/src/libostree/ostree-bootloader-aboot.c index 9370aa6e..c21bd67c 100644 --- a/src/libostree/ostree-bootloader-aboot.c +++ b/src/libostree/ostree-bootloader-aboot.c @@ -17,10 +17,10 @@ #include "config.h" -#include "ostree-sysroot-private.h" #include "ostree-bootloader-aboot.h" #include "ostree-deployment-private.h" #include "ostree-libarchive-private.h" +#include "ostree-sysroot-private.h" #include "otutil.h" #include <sys/mount.h> @@ -33,21 +33,20 @@ static const char aboot_requires_execute_path[] = "boot/ostree-bootloader-update struct _OstreeBootloaderAboot { - GObject parent_instance; + GObject parent_instance; - OstreeSysroot *sysroot; + OstreeSysroot *sysroot; }; typedef GObjectClass OstreeBootloaderAbootClass; static void _ostree_bootloader_aboot_bootloader_iface_init (OstreeBootloaderInterface *iface); G_DEFINE_TYPE_WITH_CODE (OstreeBootloaderAboot, _ostree_bootloader_aboot, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (OSTREE_TYPE_BOOTLOADER, _ostree_bootloader_aboot_bootloader_iface_init)); + G_IMPLEMENT_INTERFACE (OSTREE_TYPE_BOOTLOADER, + _ostree_bootloader_aboot_bootloader_iface_init)); static gboolean -_ostree_bootloader_aboot_query (OstreeBootloader *bootloader, - gboolean *out_is_active, - GCancellable *cancellable, - GError **error) +_ostree_bootloader_aboot_query (OstreeBootloader *bootloader, gboolean *out_is_active, + GCancellable *cancellable, GError **error) { /* We don't auto-detect this one; should be explicitly chosen right now. * see also https://github.com/coreos/coreos-assembler/pull/849 @@ -63,61 +62,55 @@ _ostree_bootloader_aboot_get_name (OstreeBootloader *bootloader) } static gboolean -_ostree_bootloader_aboot_write_config (OstreeBootloader *bootloader, - int bootversion, - GPtrArray *new_deployments, - GCancellable *cancellable, - GError **error) +_ostree_bootloader_aboot_write_config (OstreeBootloader *bootloader, int bootversion, + GPtrArray *new_deployments, GCancellable *cancellable, + GError **error) { OstreeBootloaderAboot *self = OSTREE_BOOTLOADER_ABOOT (bootloader); /* Write our stamp file */ if (!glnx_file_replace_contents_at (self->sysroot->sysroot_fd, aboot_requires_execute_path, - (guint8*)"", 0, GLNX_FILE_REPLACE_NODATASYNC, - cancellable, error)) + (guint8 *)"", 0, GLNX_FILE_REPLACE_NODATASYNC, cancellable, + error)) return FALSE; return TRUE; } static gboolean -_ostree_aboot_get_bls_config (OstreeBootloaderAboot *self, - int bootversion, - gchar **aboot, - gchar **abootcfg, - gchar **version, - gchar **vmlinuz, - gchar **initramfs, - gchar **options, - GCancellable *cancellable, - GError **error) +_ostree_aboot_get_bls_config (OstreeBootloaderAboot *self, int bootversion, gchar **aboot, + gchar **abootcfg, gchar **version, gchar **vmlinuz, gchar **initramfs, + gchar **options, GCancellable *cancellable, GError **error) { g_autoptr (GPtrArray) configs = NULL; - if ( !_ostree_sysroot_read_boot_loader_configs (self->sysroot, bootversion, &configs, cancellable, error)) + if (!_ostree_sysroot_read_boot_loader_configs (self->sysroot, bootversion, &configs, cancellable, + error)) return glnx_prefix_error (error, "aboot: loading bls configs"); if (!configs || configs->len == 0) return glnx_throw (error, "aboot: no bls config"); - OstreeBootconfigParser *parser = (OstreeBootconfigParser *) g_ptr_array_index (configs, 0); + OstreeBootconfigParser *parser = (OstreeBootconfigParser *)g_ptr_array_index (configs, 0); const gchar *val = NULL; val = ostree_bootconfig_parser_get (parser, "aboot"); - if (!val) { - return glnx_throw (error, "aboot: no \"aboot\" key in bootloader config"); - } - *aboot = g_strdup(val); + if (!val) + { + return glnx_throw (error, "aboot: no \"aboot\" key in bootloader config"); + } + *aboot = g_strdup (val); val = ostree_bootconfig_parser_get (parser, "abootcfg"); - if (!val) { - return glnx_throw (error, "aboot: no \"abootcfg\" key in bootloader config"); - } - *abootcfg = g_strdup(val); + if (!val) + { + return glnx_throw (error, "aboot: no \"abootcfg\" key in bootloader config"); + } + *abootcfg = g_strdup (val); val = ostree_bootconfig_parser_get (parser, "version"); if (!val) return glnx_throw (error, "aboot: no \"version\" key in bootloader config"); - *version = g_strdup(val); + *version = g_strdup (val); val = ostree_bootconfig_parser_get (parser, "linux"); if (!val) @@ -132,16 +125,14 @@ _ostree_aboot_get_bls_config (OstreeBootloaderAboot *self, val = ostree_bootconfig_parser_get (parser, "options"); if (!val) return glnx_throw (error, "aboot: no \"options\" key in bootloader config"); - *options = g_strdup(val); + *options = g_strdup (val); return TRUE; } static gboolean -_ostree_bootloader_aboot_post_bls_sync (OstreeBootloader *bootloader, - int bootversion, - GCancellable *cancellable, - GError **error) +_ostree_bootloader_aboot_post_bls_sync (OstreeBootloader *bootloader, int bootversion, + GCancellable *cancellable, GError **error) { OstreeBootloaderAboot *self = OSTREE_BOOTLOADER_ABOOT (bootloader); @@ -150,38 +141,43 @@ _ostree_bootloader_aboot_post_bls_sync (OstreeBootloader *bootloader, */ // g_assert (self->sysroot->booted_deployment); - if (!glnx_fstatat_allow_noent (self->sysroot->sysroot_fd, aboot_requires_execute_path, NULL, 0, error)) + if (!glnx_fstatat_allow_noent (self->sysroot->sysroot_fd, aboot_requires_execute_path, NULL, 0, + error)) return FALSE; /* If there's no stamp file, nothing to do */ if (errno == ENOENT) return TRUE; - g_autofree gchar* aboot = NULL; - g_autofree gchar* abootcfg = NULL; - g_autofree gchar* version = NULL; - g_autofree gchar* vmlinuz = NULL; - g_autofree gchar* initramfs = NULL; - g_autofree gchar* options = NULL; - if (!_ostree_aboot_get_bls_config (self, bootversion, &aboot, &abootcfg, &version, &vmlinuz, &initramfs, &options, cancellable, error)) + g_autofree gchar *aboot = NULL; + g_autofree gchar *abootcfg = NULL; + g_autofree gchar *version = NULL; + g_autofree gchar *vmlinuz = NULL; + g_autofree gchar *initramfs = NULL; + g_autofree gchar *options = NULL; + if (!_ostree_aboot_get_bls_config (self, bootversion, &aboot, &abootcfg, &version, &vmlinuz, + &initramfs, &options, cancellable, error)) return FALSE; - g_autofree char *path_str = g_file_get_path(self->sysroot->path); + g_autofree char *path_str = g_file_get_path (self->sysroot->path); - const char *const aboot_argv[] = {"aboot-deploy", "-r", path_str, "-c", abootcfg, aboot, NULL}; + const char *const aboot_argv[] = { "aboot-deploy", "-r", path_str, "-c", abootcfg, aboot, NULL }; int estatus; - if (!g_spawn_sync (NULL, (char**)aboot_argv, NULL, G_SPAWN_SEARCH_PATH, - NULL, NULL, NULL, NULL, &estatus, error)) { - return FALSE; - } - - if (!g_spawn_check_exit_status (estatus, error)) { - return FALSE; - } - - if (!glnx_unlinkat (self->sysroot->sysroot_fd, aboot_requires_execute_path, 0, error)) { - return FALSE; - } + if (!g_spawn_sync (NULL, (char **)aboot_argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL, + &estatus, error)) + { + return FALSE; + } + + if (!g_spawn_check_exit_status (estatus, error)) + { + return FALSE; + } + + if (!glnx_unlinkat (self->sysroot->sysroot_fd, aboot_requires_execute_path, 0, error)) + { + return FALSE; + } return TRUE; } |