Skip to content

Commit

Permalink
UEFI install, include needed tools, correct grup-install parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
olljanat committed Mar 13, 2021
1 parent 731a15e commit e42fef0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
15 changes: 7 additions & 8 deletions cmd/control/install/grub.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}}
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions cmd/control/install/syslinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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") {
Expand Down
1 change: 1 addition & 0 deletions cmd/power/shutdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion scripts/installer/BaseDockerfile.amd64
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down

0 comments on commit e42fef0

Please sign in to comment.