From 63244019745afd810bb8faf30b315388c018c172 Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Wed, 1 Feb 2017 18:16:55 +0000 Subject: [PATCH] scripts: Port to the modern clr-boot-manager usage model In the current system we depend on the legacy boot infrastructure, which has been provided by clr-boot-manager in the way of compatibility scripts. These scripts all do the same thing, which is to invoke clr-boot-manager with the "update" subcommand. Given that clr-boot-manager doesn't need to know the context of the operation, i.e. it is able to deduce whether kernel or bootloaders need updating, regardless, it makes little sense to use any of these scripts, and we should begin to deprecate them. In clr-boot-manager 2.0, we will look to remove these compat scripts completely, however they will continue to exist until then to facilitate necessary format bumps, etc. Signed-off-by: Ikey Doherty --- src/scripts.c | 44 ++++++++----------------------------- src/verify.c | 2 +- test/functional/ignore-list | 8 ++----- 3 files changed, 12 insertions(+), 42 deletions(-) diff --git a/src/scripts.c b/src/scripts.c index baf7a799..1bb436bb 100644 --- a/src/scripts.c +++ b/src/scripts.c @@ -32,41 +32,19 @@ #include "swupd.h" -static void update_kernel(void) +static void update_boot(void) { - char *kernel_update_cmd = NULL; + char *boot_update_cmd = NULL; + __attribute__((unused)) int ret = 0; if (strcmp("/", path_prefix) == 0) { - string_or_die(&kernel_update_cmd, "/usr/bin/kernel_updater.sh"); + string_or_die(&boot_update_cmd, "/usr/bin/clr-boot-manager update"); } else { - string_or_die(&kernel_update_cmd, "%s/usr/bin/kernel_updater.sh --path %s", path_prefix, path_prefix); + string_or_die(&boot_update_cmd, "%s/usr/bin/clr-boot-manager update --path %s", path_prefix, path_prefix); } - system(kernel_update_cmd); - free(kernel_update_cmd); -} - -static void update_bootloader(void) -{ - char *bootloader_update_cmd = NULL; - - if (strcmp("/", path_prefix) == 0) { - string_or_die(&bootloader_update_cmd, "/usr/bin/gummiboot_updaters.sh"); - } else { - string_or_die(&bootloader_update_cmd, "%s/usr/bin/gummiboot_updaters.sh --path %s", path_prefix, path_prefix); - } - - system(bootloader_update_cmd); - free(bootloader_update_cmd); - - if (strcmp("/", path_prefix) == 0) { - string_or_die(&bootloader_update_cmd, "/usr/bin/systemdboot_updater.sh"); - } else { - string_or_die(&bootloader_update_cmd, "%s/usr/bin/systemdboot_updater.sh --path %s", path_prefix, path_prefix); - } - - system(bootloader_update_cmd); - free(bootloader_update_cmd); + ret = system(boot_update_cmd); + free(boot_update_cmd); } static void update_triggers(void) @@ -80,12 +58,8 @@ void run_scripts(void) printf("Calling post-update helper scripts.\n"); /* path_prefix aware helper */ - if (need_update_boot) { - update_kernel(); - } - - if (need_update_bootloader) { - update_bootloader(); + if (need_update_boot || need_update_bootloader) { + update_boot(); } /* helpers which don't run when path_prefix is set */ diff --git a/src/verify.c b/src/verify.c index 8937c682..bfe3c1cb 100644 --- a/src/verify.c +++ b/src/verify.c @@ -525,7 +525,7 @@ static void remove_orphaned_files(struct manifest *official_manifest) /* Note: boot files marked as deleted should not be deleted by * verify/fix; this task is delegated to an external program - * (currently /usr/bin/kernel_updater.sh). + * (currently /usr/bin/clr-boot-manager). */ if (ignore(file)) { continue; diff --git a/test/functional/ignore-list b/test/functional/ignore-list index 7c099cd1..39118fb2 100644 --- a/test/functional/ignore-list +++ b/test/functional/ignore-list @@ -9,10 +9,6 @@ ^No kernel update needed, skipping helper call out.$ ^No bootloader update needed, skipping helper call out.$ ^Update took .* seconds$ -^sh: .*/usr/bin/kernel_updater.sh: No such file or directory$ -^sh: .*/usr/bin/gummiboot_updaters.sh: No such file or directory$ -^sh: .*/usr/bin/systemdboot_updater.sh: No such file or directory$ -^sh: .*/usr/bin/kernel_updater.sh: not found$ -^sh: .*/usr/bin/gummiboot_updaters.sh: not found$ -^sh: .*/usr/bin/systemdboot_updater.sh: not found$ +^sh: .*/usr/bin/clr-boot-manager: No such file or directory$ +^sh: .*/usr/bin/clr-boot-manager: not found$ ^Possible filedescriptor leak: .*$