Skip to content

Commit a54568b

Browse files
committed
Add support for Rocky and Alma Linux 8/9
Signed-off-by: Brian Goff <[email protected]>
1 parent bbfaf2c commit a54568b

File tree

13 files changed

+424
-49
lines changed

13 files changed

+424
-49
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,14 @@ jobs:
7979
- Jammy
8080
- Noble
8181
- Windows
82+
- Almalinux8
83+
- Almalinux9
84+
- Rockylinux8
85+
- Rockylinux9
8286
- other
8387
include:
8488
- suite: other
85-
skip: Mariner2|Azlinux3|Bookworm|Bullseye|Bionic|Focal|Jammy|Noble|Windows
89+
skip: Mariner2|Azlinux3|Bookworm|Bullseye|Bionic|Focal|Jammy|Noble|Windows|Almalinux8|Almalinux9|Rockylinux8|Rockylinux9
8690

8791
# TODO: support diff/merge
8892
# Right now this is handled by the e2e suite, but we can migrate that here.

cmd/frontend/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import (
88
"github.com/Azure/dalec/frontend/debug"
99
"github.com/Azure/dalec/targets/linux/deb/debian"
1010
"github.com/Azure/dalec/targets/linux/deb/ubuntu"
11+
"github.com/Azure/dalec/targets/linux/rpm/almalinux"
1112
"github.com/Azure/dalec/targets/linux/rpm/azlinux"
13+
"github.com/Azure/dalec/targets/linux/rpm/rockylinux"
1214
"github.com/Azure/dalec/targets/windows"
1315
"github.com/moby/buildkit/frontend/gateway/grpcclient"
1416
"github.com/moby/buildkit/util/appcontext"
@@ -37,6 +39,8 @@ func main() {
3739
frontend.WithBuiltinHandler(windows.DefaultTargetKey, windows.Handle),
3840
ubuntu.Handlers,
3941
debian.Handlers,
42+
almalinux.Handlers,
43+
rockylinux.Handlers,
4044
frontend.WithTargetForwardingHandler,
4145
)); err != nil {
4246
bklog.L.WithError(err).Fatal("error running frontend")

targets/linux/rpm/almalinux/common.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package almalinux
2+
3+
import (
4+
"context"
5+
6+
"github.com/Azure/dalec"
7+
"github.com/Azure/dalec/frontend"
8+
gwclient "github.com/moby/buildkit/frontend/gateway/client"
9+
)
10+
11+
var (
12+
builderPackages = []string{
13+
"rpm-build",
14+
"ca-certificates",
15+
}
16+
17+
targets = map[string]gwclient.BuildFunc{
18+
v8TargetKey: ConfigV8.Handle,
19+
v9TargetKey: ConfigV9.Handle,
20+
}
21+
22+
defaultPlatformConfig = dalec.RepoPlatformConfig{
23+
ConfigRoot: "/etc/yum.repos.d",
24+
GPGKeyRoot: "/etc/pki/rpm-gpg",
25+
ConfigExt: ".repo",
26+
}
27+
)
28+
29+
func Handlers(ctx context.Context, client gwclient.Client, m *frontend.BuildMux) error {
30+
return frontend.LoadBuiltinTargets(targets)(ctx, client, m)
31+
}

targets/linux/rpm/almalinux/v8.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package almalinux
2+
3+
import (
4+
"github.com/Azure/dalec/targets/linux/rpm/distro"
5+
)
6+
7+
const (
8+
v8TargetKey = "almalinux8"
9+
dnfCacheNameV8 = "v8-dnf-cache"
10+
11+
// v8Ref is the image ref used for the base worker image
12+
v8Ref = "mcr.microsoft.com/mirror/docker/library/almalinux:8"
13+
v8FullName = "AlmaLinux 8"
14+
// v8WorkerContextName is the build context name that can be used to lookup
15+
v8WorkerContextName = "dalec-almalinux8-worker"
16+
)
17+
18+
var ConfigV8 = &distro.Config{
19+
ImageRef: v8Ref,
20+
ContextRef: v8WorkerContextName,
21+
22+
CacheName: dnfCacheNameV8,
23+
CacheDir: "/var/cache/dnf",
24+
25+
ReleaseVer: "8",
26+
BuilderPackages: builderPackages,
27+
BasePackages: []string{"almalinux-release", "tzdata"},
28+
RepoPlatformConfig: &defaultPlatformConfig,
29+
InstallFunc: distro.DnfInstall,
30+
}

targets/linux/rpm/almalinux/v9.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package almalinux
2+
3+
import (
4+
"github.com/Azure/dalec/targets/linux/rpm/distro"
5+
)
6+
7+
const (
8+
v9TargetKey = "almalinux9"
9+
dnfCacheNameV9 = "almalinux9-dnf-cache"
10+
11+
// v9Ref is the image ref used for the base worker image
12+
v9Ref = "mcr.microsoft.com/mirror/docker/library/almalinux:9"
13+
v9FullName = "AlmaLinux 9"
14+
// v9WorkerContextName is the build context name that can be used to lookup
15+
v9WorkerContextName = "dalec-almalinux9-worker"
16+
)
17+
18+
var ConfigV9 = &distro.Config{
19+
ImageRef: v9Ref,
20+
ContextRef: v9WorkerContextName,
21+
22+
CacheName: dnfCacheNameV9,
23+
CacheDir: "/var/cache/dnf",
24+
25+
ReleaseVer: "9",
26+
BuilderPackages: builderPackages,
27+
BasePackages: []string{"almalinux-release", "tzdata"},
28+
RepoPlatformConfig: &defaultPlatformConfig,
29+
InstallFunc: distro.DnfInstall,
30+
}

targets/linux/rpm/distro/dnf_install.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func TdnfInstall(cfg *dnfInstallConfig, releaseVer string, pkgs []string) llb.Ru
134134
cmdFlags := dnfInstallFlags(cfg)
135135
// tdnf makecache is needed to ensure that the package metadata is up to date if extra repo
136136
// config files have been mounted
137-
cmdArgs := fmt.Sprintf("set -ex; tdnf makecache; tdnf install -y --refresh --releasever=%s %s %s", releaseVer, cmdFlags, strings.Join(pkgs, " "))
137+
cmdArgs := fmt.Sprintf("set -ex; tdnf makecache -y; tdnf install -y --refresh --setopt=varsdir=/etc/dnf/vars --releasever=%s %s %s", releaseVer, cmdFlags, strings.Join(pkgs, " "))
138138

139139
var runOpts []llb.RunOption
140140

@@ -163,7 +163,7 @@ func DnfInstall(cfg *dnfInstallConfig, releaseVer string, pkgs []string) llb.Run
163163
cmdFlags := dnfInstallFlags(cfg)
164164
// tdnf makecache is needed to ensure that the package metadata is up to date if extra repo
165165
// config files have been mounted
166-
cmdArgs := fmt.Sprintf("set -ex; dnf makecache; dnf install -y --refresh --releasever=%s %s %s", releaseVer, cmdFlags, strings.Join(pkgs, " "))
166+
cmdArgs := fmt.Sprintf("set -ex; dnf makecache -y; dnf install -y --refresh --releasever=%s --setopt=varsdir=/etc/dnf/vars %s %s", releaseVer, cmdFlags, strings.Join(pkgs, " "))
167167

168168
var runOpts []llb.RunOption
169169

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package rockylinux
2+
3+
import (
4+
"context"
5+
6+
"github.com/Azure/dalec"
7+
"github.com/Azure/dalec/frontend"
8+
gwclient "github.com/moby/buildkit/frontend/gateway/client"
9+
)
10+
11+
var (
12+
builderPackages = []string{
13+
"rpm-build",
14+
"ca-certificates",
15+
}
16+
17+
targets = map[string]gwclient.BuildFunc{
18+
v8TargetKey: ConfigV8.Handle,
19+
v9TargetKey: ConfigV9.Handle,
20+
}
21+
22+
defaultPlatformConfig = dalec.RepoPlatformConfig{
23+
ConfigRoot: "/etc/yum.repos.d",
24+
GPGKeyRoot: "/etc/pki/rpm-gpg",
25+
ConfigExt: ".repo",
26+
}
27+
)
28+
29+
func Handlers(ctx context.Context, client gwclient.Client, m *frontend.BuildMux) error {
30+
return frontend.LoadBuiltinTargets(targets)(ctx, client, m)
31+
}

targets/linux/rpm/rockylinux/v8.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package rockylinux
2+
3+
import (
4+
"github.com/Azure/dalec/targets/linux/rpm/distro"
5+
)
6+
7+
const (
8+
v8TargetKey = "rockylinux8"
9+
dnfCacheNameV8 = "rockylinux8-dnf-cache"
10+
11+
// v8Ref is the image ref used for the base worker image
12+
v8Ref = "mcr.microsoft.com/mirror/docker/library/rockylinux:8"
13+
v8FullName = "rockyLinux 8"
14+
// v8WorkerContextName is the build context name that can be used to lookup
15+
v8WorkerContextName = "dalec-rockylinux8-worker"
16+
)
17+
18+
var ConfigV8 = &distro.Config{
19+
ImageRef: v8Ref,
20+
ContextRef: v8WorkerContextName,
21+
22+
CacheName: dnfCacheNameV8,
23+
CacheDir: "/var/cache/dnf",
24+
25+
ReleaseVer: "8",
26+
BuilderPackages: builderPackages,
27+
BasePackages: []string{"rocky-release", "tzdata"},
28+
RepoPlatformConfig: &defaultPlatformConfig,
29+
InstallFunc: distro.DnfInstall,
30+
}

targets/linux/rpm/rockylinux/v9.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package rockylinux
2+
3+
import (
4+
"github.com/Azure/dalec/targets/linux/rpm/distro"
5+
)
6+
7+
const (
8+
v9TargetKey = "rockylinux9"
9+
dnfCacheNameV9 = "rockylinux9-dnf-cache"
10+
11+
// v9Ref is the image ref used for the base worker image
12+
v9Ref = "mcr.microsoft.com/mirror/docker/library/rockylinux:9"
13+
v9FullName = "rockyLinux 9"
14+
// v9WorkerContextName is the build context name that can be used to lookup
15+
v9WorkerContextName = "dalec-rockylinux9-worker"
16+
)
17+
18+
var ConfigV9 = &distro.Config{
19+
ImageRef: v9Ref,
20+
ContextRef: v9WorkerContextName,
21+
22+
CacheName: dnfCacheNameV9,
23+
CacheDir: "/var/cache/dnf",
24+
25+
ReleaseVer: "9",
26+
BuilderPackages: append(builderPackages, "systemd-rpm-macros"),
27+
BasePackages: []string{"rocky-release", "tzdata"},
28+
RepoPlatformConfig: &defaultPlatformConfig,
29+
InstallFunc: distro.DnfInstall,
30+
}

test/almalinux_test.go

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/Azure/dalec/targets/linux/rpm/almalinux"
7+
)
8+
9+
func TestAlmalinux9(t *testing.T) {
10+
t.Parallel()
11+
12+
ctx := startTestSpan(baseCtx, t)
13+
testLinuxDistro(ctx, t, testLinuxConfig{
14+
Target: targetConfig{
15+
Package: "almalinux9/rpm",
16+
Container: "almalinux9/container",
17+
Worker: "almalinux9/worker",
18+
FormatDepEqual: func(v, _ string) string {
19+
return v
20+
},
21+
ListExpectedSignFiles: azlinuxListSignFiles("el9"),
22+
},
23+
LicenseDir: "/usr/share/licenses",
24+
SystemdDir: struct {
25+
Units string
26+
Targets string
27+
}{
28+
Units: "/usr/lib/systemd",
29+
Targets: "/etc/systemd/system",
30+
},
31+
Libdir: "/usr/lib64",
32+
Worker: workerConfig{
33+
ContextName: almalinux.ConfigV9.ContextRef,
34+
CreateRepo: createYumRepo(almalinux.ConfigV9),
35+
SignRepo: signRepoAzLinux,
36+
TestRepoConfig: azlinuxTestRepoConfig,
37+
Constraints: azlinuxConstraints,
38+
},
39+
Release: OSRelease{
40+
ID: "almalinux",
41+
VersionID: "9",
42+
},
43+
})
44+
}
45+
46+
func TestAlmalinux8(t *testing.T) {
47+
t.Parallel()
48+
49+
ctx := startTestSpan(baseCtx, t)
50+
testLinuxDistro(ctx, t, testLinuxConfig{
51+
Target: targetConfig{
52+
Package: "almalinux8/rpm",
53+
Container: "almalinux8/container",
54+
Worker: "almalinux8/worker",
55+
FormatDepEqual: func(v, _ string) string {
56+
return v
57+
},
58+
ListExpectedSignFiles: azlinuxListSignFiles("el8"),
59+
},
60+
LicenseDir: "/usr/share/licenses",
61+
SystemdDir: struct {
62+
Units string
63+
Targets string
64+
}{
65+
Units: "/usr/lib/systemd",
66+
Targets: "/etc/systemd/system",
67+
},
68+
Libdir: "/usr/lib64",
69+
Worker: workerConfig{
70+
ContextName: almalinux.ConfigV8.ContextRef,
71+
CreateRepo: createYumRepo(almalinux.ConfigV8),
72+
SignRepo: signRepoAzLinux,
73+
TestRepoConfig: azlinuxTestRepoConfig,
74+
Constraints: azlinuxConstraints,
75+
},
76+
Release: OSRelease{
77+
ID: "almalinux",
78+
VersionID: "8",
79+
},
80+
})
81+
}

0 commit comments

Comments
 (0)