From e42fef0a31d70a5d6023a99a1bb5c57947b6df8b Mon Sep 17 00:00:00 2001 From: Olli Janatuinen Date: Sat, 13 Mar 2021 13:55:32 +0000 Subject: [PATCH] UEFI install, include needed tools, correct grup-install parameters --- cmd/control/install/grub.go | 15 +++++++-------- cmd/control/install/syslinux.go | 6 +++--- cmd/power/shutdown.go | 1 + scripts/installer/BaseDockerfile.amd64 | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cmd/control/install/grub.go b/cmd/control/install/grub.go index 6196bb1ae..e019d4eaa 100644 --- a/cmd/control/install/grub.go +++ b/cmd/control/install/grub.go @@ -12,8 +12,7 @@ import ( func RunGrub(baseName, device string) error { log.Debugf("installGrub") - //grub-install --boot-directory=${baseName}/boot ${device} - cmd := exec.Command("grub-install", "--boot-directory="+baseName+"/boot", device) + cmd := exec.Command("grub-install", "--root-directory="+baseName+"/boot", "--boot-directory="+baseName+"/boot", device) if err := cmd.Run(); err != nil { log.Errorf("%s", err) return err @@ -26,8 +25,8 @@ func GrubConfig(menu BootVars) error { filetmpl, err := template.New("grub2config").Parse(`{{define "grub2menu"}}menuentry "{{.Name}}" { set root=(hd0,msdos1) - linux /{{.bootDir}}vmlinuz-{{.Version}}-rancheros {{.KernelArgs}} {{.Append}} - initrd /{{.bootDir}}initrd-{{.Version}}-rancheros + linux /{{.BootDir}}vmlinuz-{{.Version}}-rancheros {{.KernelArgs}} {{.Append}} + initrd /{{.BootDir}}initrd-{{.Version}}-rancheros } {{end}} @@ -45,7 +44,7 @@ set timeout="{{.Timeout}}" return err } - cfgFile := filepath.Join(menu.BaseName, menu.BootDir+"grub/grub.cfg") + cfgFile := filepath.Join(menu.BaseName, menu.BootDir+"/grub/grub.cfg") log.Debugf("GrubConfig written to %s", cfgFile) f, err := os.Create(cfgFile) @@ -65,8 +64,8 @@ func PvGrubConfig(menu BootVars) error { filetmpl, err := template.New("grublst").Parse(`{{define "grubmenu"}} title BurmillaOS {{.Version}}-({{.Name}}) root (hd0) -kernel /${bootDir}vmlinuz-{{.Version}}-rancheros {{.KernelArgs}} {{.Append}} -initrd /${bootDir}initrd-{{.Version}}-rancheros +kernel /${BootDir}vmlinuz-{{.Version}}-rancheros {{.KernelArgs}} {{.Append}} +initrd /${BootDir}initrd-{{.Version}}-rancheros {{end}} default 0 @@ -85,7 +84,7 @@ hiddenmenu return err } - cfgFile := filepath.Join(menu.BaseName, menu.BootDir+"grub/menu.lst") + cfgFile := filepath.Join(menu.BaseName, menu.BootDir+"/grub/menu.lst") log.Debugf("grubMenu written to %s", cfgFile) f, err := os.Create(cfgFile) if err != nil { diff --git a/cmd/control/install/syslinux.go b/cmd/control/install/syslinux.go index aa1af550b..3ab465f23 100644 --- a/cmd/control/install/syslinux.go +++ b/cmd/control/install/syslinux.go @@ -69,7 +69,7 @@ func ReadSyslinuxCfg(currentCfg string) (string, string, error) { vmlinuzFile := "" initrdFile := "" // Need to parse currentCfg for the lines: - // LINUX ../vmlinuz-4.9.18-rancher^M + // KERNEL ../vmlinuz-4.9.18-rancher^M // INITRD ../initrd-41e02e6-dirty^M buf, err := ioutil.ReadFile(currentCfg) if err != nil { @@ -81,8 +81,8 @@ func ReadSyslinuxCfg(currentCfg string) (string, string, error) { s := bufio.NewScanner(bytes.NewReader(buf)) for s.Scan() { line := strings.TrimSpace(s.Text()) - if strings.HasPrefix(line, "LINUX") { - vmlinuzFile = strings.TrimSpace(strings.TrimPrefix(line, "LINUX")) + if strings.HasPrefix(line, "KERNEL") { + vmlinuzFile = strings.TrimSpace(strings.TrimPrefix(line, "KERNEL")) vmlinuzFile = filepath.Join(DIST, filepath.Base(vmlinuzFile)) } if strings.HasPrefix(line, "INITRD") { diff --git a/cmd/power/shutdown.go b/cmd/power/shutdown.go index 320ba2107..c357b19d7 100644 --- a/cmd/power/shutdown.go +++ b/cmd/power/shutdown.go @@ -151,6 +151,7 @@ func Shutdown() { app.Run(os.Args) } +// Kexec - FixMe: Update this one using GRUB instead of SYSLINUX func Kexec(previous bool, bootDir, append string) error { cfg := "linux-current.cfg" if previous { diff --git a/scripts/installer/BaseDockerfile.amd64 b/scripts/installer/BaseDockerfile.amd64 index 31c5c4193..297a6d02c 100644 --- a/scripts/installer/BaseDockerfile.amd64 +++ b/scripts/installer/BaseDockerfile.amd64 @@ -9,7 +9,7 @@ ENV KERNEL_VERSION=${KERNEL_VERSION} # not installed atm udev, kexe-tools # parted: partprobe, e2fsprogs: mkfs.ext4, syslinux: extlinux&syslinux # e2fsprogs-extra: chattr -RUN apk --no-cache add grub syslinux parted e2fsprogs e2fsprogs-extra util-linux +RUN apk --no-cache add efibootmgr grub grub-efi parted e2fsprogs e2fsprogs-extra util-linux COPY conf /scripts/ COPY ./build/ros /bin/