Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be nicer to non-amd64 hosts #452

Merged
merged 2 commits into from
Dec 30, 2023
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
5 changes: 3 additions & 2 deletions actions/debootstrap_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import (
"os"
"path"
"strings"
"runtime"

"github.com/go-debos/debos"
"github.com/go-debos/fakemachine"
Expand Down Expand Up @@ -212,8 +213,8 @@ func (d *DebootstrapAction) Run(context *debos.DebosContext) error {
cmdline = append(cmdline, fmt.Sprintf("--components=%s", s))
}

/* FIXME drop the hardcoded amd64 assumption" */
foreign := context.Architecture != "amd64"
/* Only works for amd64, arm64 and riscv64 hosts, which should be enough */
foreign := context.Architecture != runtime.GOARCH

if foreign {
cmdline = append(cmdline, "--foreign")
Expand Down
31 changes: 24 additions & 7 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"os/exec"
"path"
"runtime"
)

type ChrootEnterMethod int
Expand Down Expand Up @@ -292,19 +293,35 @@ func newQemuHelper(c Command) qemuHelper {

switch c.Architecture {
case "armhf", "armel", "arm":
q.qemusrc = "/usr/bin/qemu-arm-static"
if runtime.GOARCH != "arm64" && runtime.GOARCH != "arm" {
q.qemusrc = "/usr/bin/qemu-arm-static"
}
case "arm64":
q.qemusrc = "/usr/bin/qemu-aarch64-static"
if runtime.GOARCH != "arm64" {
q.qemusrc = "/usr/bin/qemu-aarch64-static"
}
case "mips":
q.qemusrc = "/usr/bin/qemu-mips-static"
case "mipsel":
q.qemusrc = "/usr/bin/qemu-mipsel-static"
if runtime.GOARCH != "mips64le" && runtime.GOARCH != "mipsle" {
q.qemusrc = "/usr/bin/qemu-mipsel-static"
}
case "mips64el":
q.qemusrc = "/usr/bin/qemu-mips64el-static"
if runtime.GOARCH != "mips64le" {
q.qemusrc = "/usr/bin/qemu-mips64el-static"
}
case "riscv64":
q.qemusrc = "/usr/bin/qemu-riscv64-static"
case "amd64", "i386":
/* Dummy, no qemu */
if runtime.GOARCH != "riscv64" {
q.qemusrc = "/usr/bin/qemu-riscv64-static"
}
case "i386":
if runtime.GOARCH != "amd64" && runtime.GOARCH != "386" {
q.qemusrc = "/usr/bin/qemu-i386-static"
}
case "amd64":
if runtime.GOARCH != "amd64" {
q.qemusrc = "/usr/bin/qemu-x86_64-static"
}
default:
log.Panicf("Don't know qemu for Architecture %s", c.Architecture)
}
Expand Down