Skip to content
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
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ jobs:
- Jammy
- Noble
- Windows
- Almalinux8
- Almalinux9
- Rockylinux8
- Rockylinux9
- other
include:
- suite: other
skip: Mariner2|Azlinux3|Bookworm|Bullseye|Bionic|Focal|Jammy|Noble|Windows
skip: Mariner2|Azlinux3|Bookworm|Bullseye|Bionic|Focal|Jammy|Noble|Windows|Almalinux8|Almalinux9|Rockylinux8|Rockylinux9

# TODO: support diff/merge
# Right now this is handled by the e2e suite, but we can migrate that here.
Expand Down
4 changes: 4 additions & 0 deletions cmd/frontend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
"github.com/Azure/dalec/frontend/debug"
"github.com/Azure/dalec/targets/linux/deb/debian"
"github.com/Azure/dalec/targets/linux/deb/ubuntu"
"github.com/Azure/dalec/targets/linux/rpm/almalinux"
"github.com/Azure/dalec/targets/linux/rpm/azlinux"
"github.com/Azure/dalec/targets/linux/rpm/rockylinux"
"github.com/Azure/dalec/targets/windows"
"github.com/moby/buildkit/frontend/gateway/grpcclient"
"github.com/moby/buildkit/util/appcontext"
Expand Down Expand Up @@ -37,6 +39,8 @@ func main() {
frontend.WithBuiltinHandler(windows.DefaultTargetKey, windows.Handle),
ubuntu.Handlers,
debian.Handlers,
almalinux.Handlers,
rockylinux.Handlers,
frontend.WithTargetForwardingHandler,
)); err != nil {
bklog.L.WithError(err).Fatal("error running frontend")
Expand Down
31 changes: 31 additions & 0 deletions targets/linux/rpm/almalinux/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package almalinux

import (
"context"

"github.com/Azure/dalec"
"github.com/Azure/dalec/frontend"
gwclient "github.com/moby/buildkit/frontend/gateway/client"
)

var (
builderPackages = []string{
"rpm-build",
"ca-certificates",
}

targets = map[string]gwclient.BuildFunc{
v8TargetKey: ConfigV8.Handle,
v9TargetKey: ConfigV9.Handle,
}

defaultPlatformConfig = dalec.RepoPlatformConfig{
ConfigRoot: "/etc/yum.repos.d",
GPGKeyRoot: "/etc/pki/rpm-gpg",
ConfigExt: ".repo",
}
)

func Handlers(ctx context.Context, client gwclient.Client, m *frontend.BuildMux) error {
return frontend.LoadBuiltinTargets(targets)(ctx, client, m)
}
30 changes: 30 additions & 0 deletions targets/linux/rpm/almalinux/v8.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package almalinux

import (
"github.com/Azure/dalec/targets/linux/rpm/distro"
)

const (
v8TargetKey = "almalinux8"
dnfCacheNameV8 = "almalinux8-dnf-cache"

// v8Ref is the image ref used for the base worker image
v8Ref = "mcr.microsoft.com/mirror/docker/library/almalinux:8"
v8FullName = "AlmaLinux 8"
// v8WorkerContextName is the build context name that can be used to lookup
v8WorkerContextName = "dalec-almalinux8-worker"
)

var ConfigV8 = &distro.Config{
ImageRef: v8Ref,
ContextRef: v8WorkerContextName,

CacheName: dnfCacheNameV8,
CacheDir: "/var/cache/dnf",

ReleaseVer: "8",
BuilderPackages: builderPackages,
BasePackages: []string{"almalinux-release", "tzdata"},
RepoPlatformConfig: &defaultPlatformConfig,
InstallFunc: distro.DnfInstall,
}
30 changes: 30 additions & 0 deletions targets/linux/rpm/almalinux/v9.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package almalinux

import (
"github.com/Azure/dalec/targets/linux/rpm/distro"
)

const (
v9TargetKey = "almalinux9"
dnfCacheNameV9 = "almalinux9-dnf-cache"

// v9Ref is the image ref used for the base worker image
v9Ref = "mcr.microsoft.com/mirror/docker/library/almalinux:9"
v9FullName = "AlmaLinux 9"
// v9WorkerContextName is the build context name that can be used to lookup
v9WorkerContextName = "dalec-almalinux9-worker"
)

var ConfigV9 = &distro.Config{
ImageRef: v9Ref,
ContextRef: v9WorkerContextName,

CacheName: dnfCacheNameV9,
CacheDir: "/var/cache/dnf",

ReleaseVer: "9",
BuilderPackages: builderPackages,
BasePackages: []string{"almalinux-release", "tzdata"},
RepoPlatformConfig: &defaultPlatformConfig,
InstallFunc: distro.DnfInstall,
}
4 changes: 2 additions & 2 deletions targets/linux/rpm/distro/dnf_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func TdnfInstall(cfg *dnfInstallConfig, releaseVer string, pkgs []string) llb.Ru
cmdFlags := dnfInstallFlags(cfg)
// tdnf makecache is needed to ensure that the package metadata is up to date if extra repo
// config files have been mounted
cmdArgs := fmt.Sprintf("set -ex; tdnf makecache; tdnf install -y --refresh --releasever=%s %s %s", releaseVer, cmdFlags, strings.Join(pkgs, " "))
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, " "))

var runOpts []llb.RunOption

Expand Down Expand Up @@ -163,7 +163,7 @@ func DnfInstall(cfg *dnfInstallConfig, releaseVer string, pkgs []string) llb.Run
cmdFlags := dnfInstallFlags(cfg)
// tdnf makecache is needed to ensure that the package metadata is up to date if extra repo
// config files have been mounted
cmdArgs := fmt.Sprintf("set -ex; dnf makecache; dnf install -y --refresh --releasever=%s %s %s", releaseVer, cmdFlags, strings.Join(pkgs, " "))
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, " "))

var runOpts []llb.RunOption

Expand Down
31 changes: 31 additions & 0 deletions targets/linux/rpm/rockylinux/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package rockylinux

import (
"context"

"github.com/Azure/dalec"
"github.com/Azure/dalec/frontend"
gwclient "github.com/moby/buildkit/frontend/gateway/client"
)

var (
builderPackages = []string{
"rpm-build",
"ca-certificates",
}

targets = map[string]gwclient.BuildFunc{
v8TargetKey: ConfigV8.Handle,
v9TargetKey: ConfigV9.Handle,
}

defaultPlatformConfig = dalec.RepoPlatformConfig{
ConfigRoot: "/etc/yum.repos.d",
GPGKeyRoot: "/etc/pki/rpm-gpg",
ConfigExt: ".repo",
}
)

func Handlers(ctx context.Context, client gwclient.Client, m *frontend.BuildMux) error {
return frontend.LoadBuiltinTargets(targets)(ctx, client, m)
}
30 changes: 30 additions & 0 deletions targets/linux/rpm/rockylinux/v8.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package rockylinux

import (
"github.com/Azure/dalec/targets/linux/rpm/distro"
)

const (
v8TargetKey = "rockylinux8"
dnfCacheNameV8 = "rockylinux8-dnf-cache"

// v8Ref is the image ref used for the base worker image
v8Ref = "mcr.microsoft.com/mirror/docker/library/rockylinux:8"
v8FullName = "rockyLinux 8"
// v8WorkerContextName is the build context name that can be used to lookup
v8WorkerContextName = "dalec-rockylinux8-worker"
)

var ConfigV8 = &distro.Config{
ImageRef: v8Ref,
ContextRef: v8WorkerContextName,

CacheName: dnfCacheNameV8,
CacheDir: "/var/cache/dnf",

ReleaseVer: "8",
BuilderPackages: builderPackages,
BasePackages: []string{"rocky-release", "tzdata"},
RepoPlatformConfig: &defaultPlatformConfig,
InstallFunc: distro.DnfInstall,
}
30 changes: 30 additions & 0 deletions targets/linux/rpm/rockylinux/v9.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package rockylinux

import (
"github.com/Azure/dalec/targets/linux/rpm/distro"
)

const (
v9TargetKey = "rockylinux9"
dnfCacheNameV9 = "rockylinux9-dnf-cache"

// v9Ref is the image ref used for the base worker image
v9Ref = "mcr.microsoft.com/mirror/docker/library/rockylinux:9"
v9FullName = "rockyLinux 9"
// v9WorkerContextName is the build context name that can be used to lookup
v9WorkerContextName = "dalec-rockylinux9-worker"
)

var ConfigV9 = &distro.Config{
ImageRef: v9Ref,
ContextRef: v9WorkerContextName,

CacheName: dnfCacheNameV9,
CacheDir: "/var/cache/dnf",

ReleaseVer: "9",
BuilderPackages: append(builderPackages, "systemd-rpm-macros"),
BasePackages: []string{"rocky-release", "tzdata"},
RepoPlatformConfig: &defaultPlatformConfig,
InstallFunc: distro.DnfInstall,
}
42 changes: 42 additions & 0 deletions test/createrepo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package test

import (
"github.com/Azure/dalec"
"github.com/Azure/dalec/targets/linux/rpm/distro"
"github.com/moby/buildkit/client/llb"
)

func createYumRepo(installer *distro.Config) func(rpms llb.State, opts ...llb.StateOption) llb.StateOption {
return func(rpms llb.State, opts ...llb.StateOption) llb.StateOption {
return func(in llb.State) llb.State {
localRepo := []byte(`
[Local]
name=Local Repository
baseurl=file:///opt/repo
gpgcheck=0
priority=0
enabled=1
`)

pg := dalec.ProgressGroup("Install local repo for test")
withRepos := in.
Run(installer.Install([]string{"createrepo"}), pg).
File(llb.Mkdir("/opt/repo/RPMS", 0o755, llb.WithParents(true)), pg).
File(llb.Mkdir("/opt/repo/SRPMS", 0o755), pg).
File(llb.Mkfile("/etc/yum.repos.d/local.repo", 0o644, localRepo), pg).
Run(
llb.AddMount("/tmp/st", rpms, llb.Readonly),
dalec.ShArgs("cp /tmp/st/RPMS/$(uname -m)/* /opt/repo/RPMS/ && cp /tmp/st/SRPMS/* /opt/repo/SRPMS"),
pg,
).
Run(dalec.ShArgs("createrepo --compatibility /opt/repo"), pg).
Root()

for _, opt := range opts {
withRepos = withRepos.With(opt)
}

return withRepos
}
}
}
Loading