Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/deb-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,22 @@ jobs:
rm -r /run/host${{ runner.tool_cache }}

- name: Install needed packages
run: apt update && apt install dpkg-dev build-essential debhelper libbtrfs-dev libdevmapper-dev libgpgme-dev lvm2 dh-golang golang-go gcc pkg-config make -y
run: |
dpkg --add-architecture arm64
apt update
apt install -y dh-golang golang-go libbtrfs-dev libdevmapper-dev libgpgme-dev lvm2 gcc-aarch64-linux-gnu libdevmapper-dev:arm64 pkgconf:arm64

- name: Vendor dependencies
run: go mod vendor

- name: Build debian package
run: |
make deb
mv ../*.deb ../albius.deb
rm -rf obj-x86_64-linux-gnu
apt install -y libgpgme-dev:arm64
make deb-arm64
mv ../albius_*_amd64.deb ./albius-amd64.deb
mv ../albius_*_arm64.deb ./albius-arm64.deb

- uses: softprops/action-gh-release@v1
with:
Expand All @@ -40,4 +47,4 @@ jobs:
prerelease: true
name: "Continuous Build"
files: |
/__w/Albius/albius.deb
albius*.deb
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ build:
deb:
dpkg-buildpackage --no-sign

deb-arm64:
dpkg-buildpackage --host-arch arm64 --no-check-builddeps --no-sign

test:
sudo go test -v ./...

Expand Down
11 changes: 1 addition & 10 deletions core/recipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,16 +857,7 @@ func runPostInstallOperation(chroot bool, operation string, args []interface{})
if len(args) > 5 {
efiDevice = args[5].(string)
}
var grubTarget system.FirmwareType
switch target {
case "bios":
grubTarget = system.BIOS
case "efi":
grubTarget = system.EFI
default:
return operationError(operation, "unrecognized firmware type: %s", target)
}
err := system.RunGrubInstall(targetRoot, bootDirectory, installDevice, grubTarget, entryName, removable, efiDevice)
err := system.RunGrubInstall(targetRoot, bootDirectory, installDevice, target, entryName, removable, efiDevice)
if err != nil {
return operationError(operation, err)
}
Expand Down
62 changes: 51 additions & 11 deletions core/system/grub.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,48 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"strings"

"github.com/vanilla-os/albius/core/util"
)

type GrubConfig map[string]string

const (
BIOS = "i386-pc"
EFI = "x86_64-efi"
)
func GetGrubTarget(target string) (string, error) {
var grubTarget string
switch target {
case "bios":
grubTarget = "i386-pc"
case "efi":
arch := runtime.GOARCH
switch arch {
case "amd64":
grubTarget = "x86_64-efi"
case "arm64":
grubTarget = "arm64-efi"
default:
return "", fmt.Errorf("unsupported architecture: %s", arch)
}
default:
return "", fmt.Errorf("unrecognized firmware type: %s", target)
}
return grubTarget, nil
}

type FirmwareType string
func GetEFIBootloaderFile() (string, error) {
arch := runtime.GOARCH
var bootloaderFile string
switch arch {
case "amd64":
bootloaderFile = "shimx64.efi"
case "arm64":
bootloaderFile = "shimaa64.efi"
default:
return "", fmt.Errorf("unsupported architecture: %s", arch)
}
return bootloaderFile, nil
}

func GetGrubConfig(targetRoot string) (GrubConfig, error) {
targetRootGrubFile := filepath.Join(targetRoot, "/etc/default/grub")
Expand Down Expand Up @@ -97,7 +126,7 @@ func RemoveGrubScript(targetRoot, scriptName string) error {
return nil
}

func RunGrubInstall(targetRoot, bootDirectory, diskPath string, target FirmwareType, entryName string, removable bool, efiDevice ...string) error {
func RunGrubInstall(targetRoot, bootDirectory, diskPath string, target string, entryName string, removable bool, efiDevice ...string) error {
// Mount necessary targets for chroot
if targetRoot != "" {
requiredBinds := []string{"/dev", "/dev/pts", "/proc", "/sys", "/run"}
Expand All @@ -117,9 +146,13 @@ func RunGrubInstall(targetRoot, bootDirectory, diskPath string, target FirmwareT
removableStr = "--removable"
}

command := fmt.Sprintf(grubInstallCmd, removableStr, entryName, bootDirectory, target, diskPath)
grubTarget, err := GetGrubTarget(target)
if err != nil {
return err
}

command := fmt.Sprintf(grubInstallCmd, removableStr, entryName, bootDirectory, grubTarget, diskPath)

var err error
if targetRoot != "" {
err = util.RunInChroot(targetRoot, command)
} else {
Expand All @@ -129,13 +162,20 @@ func RunGrubInstall(targetRoot, bootDirectory, diskPath string, target FirmwareT
return fmt.Errorf("failed to run grub-install: %s", err)
}

if !removable && target == EFI {
efibootmgrCmd := "efibootmgr --create --disk=%s --part=%s --label=%s --loader=\"\\EFI\\%s\\shimx64.efi\""
if !removable && target == "efi" {
efibootmgrCmd := "efibootmgr --create --disk=%s --part=%s --label=%s --loader=\"\\EFI\\%s\\%s\""
if len(efiDevice) == 0 || efiDevice[0] == "" {
return errors.New("EFI device was not specified")
}
diskName, part := util.SeparateDiskPart(efiDevice[0])
err = util.RunCommand(fmt.Sprintf(efibootmgrCmd, diskName, part, entryName, entryName))

var bootloaderFile string
bootloaderFile, err = GetEFIBootloaderFile()
if err != nil {
return err
}

err = util.RunCommand(fmt.Sprintf(efibootmgrCmd, diskName, part, entryName, entryName, bootloaderFile))
if err != nil {
return fmt.Errorf("failed to run efibootmgr for grub-install: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Vcs-Browser: https://github.com/vanilla-os/Albius
Vcs-Git: git://github.com/vanilla-os/Albius.git

Package: albius
Architecture: all
Architecture: any
Depends: ${shlibs:Depends},
${misc:Depends},
lvm2,
Expand Down