diff --git a/.github/workflows/deb-build.yml b/.github/workflows/deb-build.yml index 6a601f3..4c7b3cf 100644 --- a/.github/workflows/deb-build.yml +++ b/.github/workflows/deb-build.yml @@ -23,7 +23,10 @@ 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 @@ -31,7 +34,11 @@ jobs: - 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: @@ -40,4 +47,4 @@ jobs: prerelease: true name: "Continuous Build" files: | - /__w/Albius/albius.deb + albius*.deb diff --git a/Makefile b/Makefile index 465b669..69d9038 100644 --- a/Makefile +++ b/Makefile @@ -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 ./... diff --git a/core/recipe.go b/core/recipe.go index 3724439..739f89b 100644 --- a/core/recipe.go +++ b/core/recipe.go @@ -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) } diff --git a/core/system/grub.go b/core/system/grub.go index 2f54db0..c411232 100644 --- a/core/system/grub.go +++ b/core/system/grub.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "path/filepath" + "runtime" "strings" "github.com/vanilla-os/albius/core/util" @@ -12,12 +13,40 @@ import ( 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") @@ -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"} @@ -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 { @@ -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) } diff --git a/debian/control b/debian/control index d5a44f0..780ebf5 100644 --- a/debian/control +++ b/debian/control @@ -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,