diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5ea2acb..3e7a97d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -56,6 +56,7 @@ jobs: - kalilinux - alpine - centos + - quay.io/centos/centos:stream9 steps: - name: Checkout @@ -104,6 +105,7 @@ jobs: - debian:10 - debian:11 - centos:8 + - quay.io/centos/centos:stream9 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/config_test.go b/config_test.go index 6c4e642..5f2eb6b 100644 --- a/config_test.go +++ b/config_test.go @@ -120,6 +120,10 @@ func TestConfig(t *testing.T) { image: "centos:latest", config: configCentOS, }, + { + image: "quay.io/centos/centos:stream9", + config: configCentOS, + }, } exec.SetDebug(true) diff --git a/dockerfile.go b/dockerfile.go index 7657168..cf8f3f3 100644 --- a/dockerfile.go +++ b/dockerfile.go @@ -18,6 +18,7 @@ import ( _ "embed" "fmt" "io" + "strconv" "text/template" "github.com/sirupsen/logrus" @@ -36,10 +37,10 @@ var alpineDockerfile string var centOSDockerfile string var ( - ubuntuDockerfileTemplate = template.Must(template.New("ubuntu.Dockerfile").Parse(ubuntuDockerfile)) - debianDockerfileTemplate = template.Must(template.New("debian.Dockerfile").Parse(debianDockerfile)) - alpineDockerfileTemplate = template.Must(template.New("alpine.Dockerfile").Parse(alpineDockerfile)) - centOSDockerfileTemplate = template.Must(template.New("centos.Dockerfile").Parse(centOSDockerfile)) + ubuntuDockerfileTemplate = template.Must(template.New("ubuntu.Dockerfile").Funcs(tplFuncs).Parse(ubuntuDockerfile)) + debianDockerfileTemplate = template.Must(template.New("debian.Dockerfile").Funcs(tplFuncs).Parse(debianDockerfile)) + alpineDockerfileTemplate = template.Must(template.New("alpine.Dockerfile").Funcs(tplFuncs).Parse(alpineDockerfile)) + centOSDockerfileTemplate = template.Must(template.New("centos.Dockerfile").Funcs(tplFuncs).Parse(centOSDockerfile)) ) type NetworkManager string @@ -117,3 +118,7 @@ func NewDockerfile(release OSRelease, img, password string, networkManager Netwo } return d, nil } + +var tplFuncs = template.FuncMap{ + "atoi": strconv.Atoi, +} diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index 67d37f5..77b5497 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -53,6 +53,7 @@ var ( {name: "debian:10", luks: "Please unlock disk root:"}, {name: "debian:11", luks: "Please unlock disk root:"}, {name: "centos:8", luks: "Please enter passphrase for disk"}, + {name: "quay.io/centos/centos:stream9", luks: "Please enter passphrase for disk"}, } imgNames = func() []string { var imgs []string @@ -126,7 +127,7 @@ imgs: require := require2.New(t) - out := filepath.Join(dir, strings.NewReplacer(":", "-", ".", "-").Replace(img.name)+".qcow2") + out := filepath.Join(dir, strings.NewReplacer(":", "-", ".", "-", "/", "-").Replace(img.name)+".qcow2") if _, err := os.Stat(out); err == nil { require.NoError(os.Remove(out)) diff --git a/pkg/qemu/qemu.go b/pkg/qemu/qemu.go index 489b0df..76acb5d 100644 --- a/pkg/qemu/qemu.go +++ b/pkg/qemu/qemu.go @@ -203,12 +203,10 @@ func (c *config) buildQemuCmdline() ([]string, error) { // Need to specify the vcpu type when running qemu on arm64 platform, for security reason, // the vcpu should be "host" instead of other names such as "cortex-a53"... - if c.arch == "aarch64" { - if runtime.GOARCH == "arm64" { - qemuArgs = append(qemuArgs, "-cpu", "host") - } else { - qemuArgs = append(qemuArgs, "-cpu", "cortex-a57") - } + if c.arch == "aarch64" && runtime.GOARCH != "arm64" { + qemuArgs = append(qemuArgs, "-cpu", "cortex-a57") + } else { + qemuArgs = append(qemuArgs, "-cpu", "host") } // goArch is the GOARCH equivalent of config.Arch diff --git a/templates/centos.Dockerfile b/templates/centos.Dockerfile index 79f9f82..319a46a 100644 --- a/templates/centos.Dockerfile +++ b/templates/centos.Dockerfile @@ -2,8 +2,12 @@ FROM {{ .Image }} USER root +{{ $version := atoi .Release.Version }} + +{{ if le $version 8 }} RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && \ sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* +{{ end }} RUN yum update -y @@ -36,7 +40,7 @@ RUN dracut --no-hostonly --regenerate-all --force {{- if not .Grub }} RUN cd /boot && \ - mv $(find . -name 'vmlinuz-*') /boot/vmlinuz && \ + mv $(find {{ if le $version 8 }}.{{ else }}/{{ end }} -name 'vmlinuz*') /boot/vmlinuz && \ mv $(find . -name 'initramfs-*.img') /boot/initrd.img {{- end }}