2
0
mirror of https://github.com/linka-cloud/d2vm.git synced 2026-01-24 02:25:04 +00:00

feat: add AlmaLinux and Rocky Linux support

Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
2026-01-22 09:51:04 +01:00
parent 1e58d4dc42
commit 6e54c731a4
11 changed files with 42 additions and 17 deletions

View File

@@ -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

View File

@@ -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:

View File

@@ -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...

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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) {

View File

@@ -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
}

View File

@@ -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

View File

@@ -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:

View File

@@ -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 }}