From e427741ecf542257232840d1b3fb7ecca54cbd07 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Sat, 13 Jun 2020 19:08:26 -0500 Subject: hscript: maybe implement bootloader key --- hscript/meta.cc | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/hscript/meta.cc b/hscript/meta.cc index e42925e..164e55c 100644 --- a/hscript/meta.cc +++ b/hscript/meta.cc @@ -774,5 +774,82 @@ bool Bootloader::execute() const { method = _value; } + if(method == "grub-efi") { + if(script->options().test(Simulate)) { + std::cout << "apk --root " << script->targetDirectory() + << " --keys-dir etc/apk/keys add grub-efi" + << std::endl + << "chroot " << script->targetDirectory() + << " grub-install" << std::endl; + return true; + } +#ifdef HAS_INSTALL_ENV + if(run_command("/sbin/apk", + {"--root", script->targetDirectory(), "--keys-dir", + "etc/apk/keys", "add", "grub-efi"}) != 0) { + output_error(pos, "bootloader: couldn't add package"); + return false; + } + if(run_command("chroot", {script->targetDirectory(), "grub-install"}) + != 0) { + output_error(pos, "bootloader: failed to install GRUB"); + return false; + } +#endif + return true; + } + else if(method == "grub-bios") { + if(script->options().test(Simulate)) { + std::cout << "apk --root " << script->targetDirectory() + << " --keys-dir etc/apk/keys add grub-bios" + << std::endl + << "chroot " << script->targetDirectory() + << " grub-install" << std::endl; + return true; + } +#ifdef HAS_INSTALL_ENV + if(run_command("/sbin/apk", + {"--root", script->targetDirectory(), "--keys-dir", + "etc/apk/keys", "add", "grub-bios"}) != 0) { + output_error(pos, "bootloader: couldn't add package"); + return false; + } + if(run_command("chroot", {script->targetDirectory(), "grub-install"}) + != 0) { + output_error(pos, "bootloader: failed to install GRUB"); + return false; + } +#endif + return true; + } + else if(method == "iquik") { + output_error(pos, "bootloader: iQUIK is not yet supported"); + return false; + } + else if(method == "grub-ieee1275") { + if(script->options().test(Simulate)) { + std::cout << "apk --root " << script->targetDirectory() + << " --keys-dir etc/apk/keys add grub-ieee1275" + << std::endl + << "chroot " << script->targetDirectory() + << " grub-install" << std::endl; + return true; + } +#ifdef HAS_INSTALL_ENV + if(run_command("/sbin/apk", + {"--root", script->targetDirectory(), "--keys-dir", + "etc/apk/keys", "add", "grub-ieee1275"}) != 0) { + output_error(pos, "bootloader: couldn't add package"); + return false; + } + if(run_command("chroot", {script->targetDirectory(), "grub-install"}) + != 0) { + output_error(pos, "bootloader: failed to install GRUB"); + return false; + } +#endif + return true; + } + return false; } -- cgit v1.2.3-70-g09d2