From 6e54c731a4a9af9f0322db59db8b7d68b6cbe9f5 Mon Sep 17 00:00:00 2001 From: Adphi Date: Thu, 22 Jan 2026 09:51:04 +0100 Subject: [PATCH] feat: add AlmaLinux and Rocky Linux support Signed-off-by: Adphi --- .github/workflows/ci.yaml | 4 ++++ README.md | 2 ++ builder.go | 2 +- config.go | 2 +- config_test.go | 8 ++++++++ dockerfile.go | 4 ++-- e2e/e2e_test.go | 4 +++- grub.go | 4 ++-- grub_efi.go | 2 +- os_release.go | 22 ++++++++++++++++------ templates/centos.Dockerfile | 5 ++--- 11 files changed, 42 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6d07f7d..2da4eed 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -59,6 +59,8 @@ jobs: - alpine - centos - quay.io/centos/centos:stream + - almalinux + - rockylinux steps: - name: Free Disk Space (Ubuntu) @@ -112,6 +114,8 @@ jobs: - debian:13 - centos:8 - quay.io/centos/centos:stream10 + - almalinux:10 + - rockylinux:9 steps: - name: Free Disk Space (Ubuntu) uses: linka-cloud/free-disk-space@main diff --git a/README.md b/README.md index cfdc66f..a12f5ba 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ Working and tested: Luks support is available only on Debian buster+ - [x] Alpine - [x] CentOS (8+) +- [x] Rocky Linux +- [x] AlmaLinux Unsupported: diff --git a/builder.go b/builder.go index 3ada1dc..8ed0910 100644 --- a/builder.go +++ b/builder.go @@ -471,7 +471,7 @@ func (b *builder) cmdline(_ context.Context) string { switch b.osRelease.ID { case ReleaseAlpine: return b.config.Cmdline(RootUUID(b.rootUUID), "root=/dev/mapper/root", "cryptdm=root", "cryptroot=UUID="+b.cryptUUID, b.cmdLineExtra) - case ReleaseCentOS: + case ReleaseCentOS, ReleaseRocky, ReleaseAlmaLinux: return b.config.Cmdline(RootUUID(b.rootUUID), "rd.luks.name=UUID="+b.rootUUID+" rd.luks.uuid="+b.cryptUUID+" rd.luks.crypttab=0", b.cmdLineExtra) default: // for some versions of debian, the cryptopts parameter MUST contain all the following: target,source,key,opts... diff --git a/config.go b/config.go index 86b4596..12da528 100644 --- a/config.go +++ b/config.go @@ -80,7 +80,7 @@ func (r OSRelease) Config() (Config, error) { return configDebian, nil case ReleaseAlpine: return configAlpine, nil - case ReleaseCentOS: + case ReleaseCentOS, ReleaseRocky, ReleaseAlmaLinux: return configCentOS, nil default: return Config{}, fmt.Errorf("%s: distribution not supported", r.ID) diff --git a/config_test.go b/config_test.go index 1940a33..2317b35 100644 --- a/config_test.go +++ b/config_test.go @@ -137,6 +137,14 @@ func TestConfig(t *testing.T) { image: "quay.io/centos/centos:stream10", config: configCentOS, }, + { + image: "almalinux:10", + config: configCentOS, + }, + { + image: "rockylinux:9", + config: configCentOS, + }, } exec.SetDebug(true) diff --git a/dockerfile.go b/dockerfile.go index 2ffd251..4f91319 100644 --- a/dockerfile.go +++ b/dockerfile.go @@ -102,7 +102,7 @@ func NewDockerfile(release OSRelease, img, password string, networkManager Netwo if networkManager == NetworkManagerNetplan { return d, fmt.Errorf("netplan is not supported on alpine") } - case ReleaseCentOS: + case ReleaseCentOS, ReleaseRocky, ReleaseAlmaLinux: d.tmpl = centOSDockerfileTemplate net = NetworkManagerNone if networkManager != "" && networkManager != NetworkManagerNone { @@ -112,7 +112,7 @@ func NewDockerfile(release OSRelease, img, password string, networkManager Netwo return Dockerfile{}, fmt.Errorf("unsupported distribution: %s", release.ID) } if d.NetworkManager == "" { - if release.ID != ReleaseCentOS { + if release.ID != ReleaseCentOS && release.ID != ReleaseRocky && release.ID != ReleaseAlmaLinux { logrus.Warnf("no network manager specified, using distribution defaults: %s", net) } d.NetworkManager = net diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index dda5ba0..d349158 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -54,6 +54,8 @@ var ( {name: "debian:13", luks: "Please unlock disk root:"}, {name: "centos:8", luks: "Please enter passphrase for disk"}, {name: "quay.io/centos/centos:stream10", luks: "Please enter passphrase for disk"}, + {name: "almalinux:10", luks: "Please enter passphrase for disk"}, + {name: "rockylinux:9", luks: "Please enter passphrase for disk"}, } imgNames = func() []string { var imgs []string @@ -118,7 +120,7 @@ imgs: defer os.RemoveAll(dir) for _, img := range testImgs { - if strings.Contains(img.name, "centos") && tt.efi { + if (strings.Contains(img.name, "centos") || strings.Contains(img.name, "almalinux") || strings.Contains(img.name, "rocky")) && tt.efi { t.Skip("efi not supported for CentOS") } t.Run(img.name, func(t *testing.T) { diff --git a/grub.go b/grub.go index 06d9bf5..e853f4a 100644 --- a/grub.go +++ b/grub.go @@ -61,8 +61,8 @@ func (g grubProvider) New(c Config, r OSRelease, arch string) (Bootloader, error if arch != "x86_64" { return nil, fmt.Errorf("grub is only supported for amd64") } - if r.ID == ReleaseCentOS { - return nil, fmt.Errorf("grub (efi) is not supported for CentOS, use grub-bios instead") + if r.ID == ReleaseCentOS || r.ID == ReleaseRocky || r.ID == ReleaseAlmaLinux { + return nil, fmt.Errorf("grub (efi) is not supported for CentOS / Rocky / AlmaLinux, use grub-bios instead") } return grub{grubCommon: newGrubCommon(c, r)}, nil } diff --git a/grub_efi.go b/grub_efi.go index c57106e..4c3a83f 100644 --- a/grub_efi.go +++ b/grub_efi.go @@ -56,7 +56,7 @@ type grubEFIProvider struct { } func (g grubEFIProvider) New(c Config, r OSRelease, arch string) (Bootloader, error) { - if r.ID == ReleaseCentOS { + if r.ID == ReleaseCentOS || r.ID == ReleaseRocky || r.ID == ReleaseAlmaLinux { return nil, fmt.Errorf("grub-efi is not supported for CentOS, use grub-bios instead") } return grubEFI{grubCommon: newGrubCommon(c, r), arch: arch}, nil diff --git a/os_release.go b/os_release.go index 70a454b..a0f7197 100644 --- a/os_release.go +++ b/os_release.go @@ -26,12 +26,14 @@ import ( ) const ( - ReleaseUbuntu Release = "ubuntu" - ReleaseDebian Release = "debian" - ReleaseAlpine Release = "alpine" - ReleaseCentOS Release = "centos" - ReleaseRHEL Release = "rhel" - ReleaseKali Release = "kali" + ReleaseUbuntu Release = "ubuntu" + ReleaseDebian Release = "debian" + ReleaseAlpine Release = "alpine" + ReleaseCentOS Release = "centos" + ReleaseRHEL Release = "rhel" + ReleaseKali Release = "kali" + ReleaseRocky Release = "rocky" + ReleaseAlmaLinux Release = "almalinux" ) type Release string @@ -48,6 +50,10 @@ func (r Release) Supported() bool { return true case ReleaseCentOS: return true + case ReleaseRocky: + return true + case ReleaseAlmaLinux: + return true case ReleaseRHEL: return false default: @@ -79,6 +85,10 @@ func (r OSRelease) SupportsLUKS() bool { return true case ReleaseCentOS: return true + case ReleaseRocky: + return true + case ReleaseAlmaLinux: + return true case ReleaseAlpine: return true case ReleaseRHEL: diff --git a/templates/centos.Dockerfile b/templates/centos.Dockerfile index 904fd67..561c780 100644 --- a/templates/centos.Dockerfile +++ b/templates/centos.Dockerfile @@ -2,9 +2,7 @@ FROM {{ .Image }} AS rootfs USER root -{{ $version := atoi .Release.VersionID }} - -{{ if le $version 8 }} +{{ if and (eq .Release.ID "centos") (le (atoi .Release.VersionID) 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 }} @@ -19,6 +17,7 @@ RUN yum install -y \ systemctl enable NetworkManager && \ systemctl unmask systemd-remount-fs.service && \ systemctl unmask getty.target && \ + mkdir -p /boot && \ find /boot -type l -exec rm {} \; {{- if .GrubBIOS }}