Fix compilation issues and update tests for Debian compatibility
Some checks failed
Tests / test (1.21.x) (push) Failing after 1s
Tests / test (1.22.x) (push) Failing after 1s

This commit is contained in:
robojerk 2025-08-11 10:11:05 -07:00
parent be2b81ca6d
commit 18e96a1c4b
12 changed files with 145 additions and 35 deletions

Binary file not shown.

View file

@ -7,7 +7,6 @@ import (
"math"
"math/big"
"math/rand"
"slices"
"strconv"
"strings"
@ -505,9 +504,9 @@ func manifestForISO(c *ManifestConfig, rng *rand.Rand) (*manifest.Manifest, erro
img.Product = c.SourceInfo.OSRelease.Name
img.OSVersion = c.SourceInfo.OSRelease.VersionID
img.ExtraBasePackages = debianpatch.DebianPackageSet{
img.ExtraBasePackages = debianpatch.ConvertDebianPackageSetToRPM(debianpatch.DebianPackageSet{
Include: imageDef.Packages,
}
})
img.ISOLabel = labelForISO(&c.SourceInfo.OSRelease, &c.Architecture)

View file

@ -14,7 +14,7 @@ import (
"github.com/osbuild/images/pkg/manifest"
"github.com/osbuild/images/pkg/runner"
bib "github.com/osbuild/bootc-image-builder/bib/cmd/bootc-image-builder"
bib "github.com/particle-os/debian-bootc-image-builder/bib/cmd/bootc-image-builder"
"github.com/osbuild/images/pkg/bib/osinfo"
)
@ -34,7 +34,6 @@ func TestGetDistroAndRunner(t *testing.T) {
// Sad
{"debian", "asdf", manifest.DISTRO_NULL, nil, "cannot parse Debian version (asdf)"},
{"debian", "0", manifest.DISTRO_NULL, nil, "could not find def file for distro debian-0"},
}
for _, c := range cases {

View file

@ -23,9 +23,10 @@ import (
"github.com/osbuild/images/pkg/cloud"
"github.com/osbuild/images/pkg/cloud/awscloud"
"github.com/osbuild/images/pkg/container"
"github.com/osbuild/images/pkg/dnfjson"
"github.com/osbuild/images/pkg/experimentalflags"
"github.com/osbuild/images/pkg/manifest"
"github.com/osbuild/images/pkg/osbuild"
"github.com/osbuild/images/pkg/rpmmd"
"github.com/particle-os/debian-bootc-image-builder/bib/internal/imagetypes"
"github.com/particle-os/debian-bootc-image-builder/bib/internal/solver"
@ -111,24 +112,29 @@ func getContainerSize(imgref string) (uint64, error) {
return size, nil
}
func makeManifest(c *ManifestConfig, solver solver.Solver, cacheRoot string) (manifest.OSBuildManifest, map[string][]debianpatch.DebianRepoConfig, error) {
func makeManifest(c *ManifestConfig, solver solver.Solver, cacheRoot string) (manifest.OSBuildManifest, map[string][]rpmmd.RepoConfig, error) {
mani, err := Manifest(c)
if err != nil {
return nil, nil, fmt.Errorf("cannot get manifest: %w", err)
}
// depsolve packages using our Debian solver
depsolvedSets := make(map[string]debianpatch.DebianDepsolveResult)
depsolvedRepos := make(map[string][]debianpatch.DebianRepoConfig)
for name, pkgSet := range mani.GetPackageSetChains() {
res, err := solver.Depsolve(pkgSet, 0)
depsolvedSets := make(map[string]dnfjson.DepsolveResult)
depsolvedRepos := make(map[string][]rpmmd.RepoConfig)
for name, pkgSets := range mani.GetPackageSetChains() {
// Extract packages from all PackageSets
var allPackages []string
for _, pkgSet := range pkgSets {
allPackages = append(allPackages, pkgSet.Include...)
}
res, err := solver.Depsolve(allPackages, 0)
if err != nil {
return nil, nil, fmt.Errorf("cannot depsolve: %w", err)
}
// Convert the generic result to our Debian types
// Convert the generic result to DNF types for compatibility
if depsolveResult, ok := res.(*debianpatch.DebianDepsolveResult); ok {
depsolvedSets[name] = *depsolveResult
depsolvedRepos[name] = depsolveResult.Repos
depsolvedSets[name] = debianpatch.ConvertDebianDepsolveResultToDNF(*depsolveResult)
depsolvedRepos[name] = debianpatch.ConvertDebianDepsolveResultToDNF(*depsolveResult).Repos
} else {
return nil, nil, fmt.Errorf("unexpected depsolve result type: %T", res)
}

View file

@ -18,11 +18,12 @@ import (
"github.com/osbuild/images/pkg/bib/osinfo"
"github.com/osbuild/images/pkg/blueprint"
"github.com/osbuild/images/pkg/container"
"github.com/osbuild/images/pkg/dnfjson"
"github.com/osbuild/images/pkg/manifest"
"github.com/osbuild/images/pkg/rpmmd"
main "github.com/particle-os/debian-bootc-image-builder/bib/cmd/bootc-image-builder"
"github.com/particle-os/debian-bootc-image-builder/bib/internal/imagetypes"
"github.com/particle-os/debian-bootc-image-builder/bib/internal/debian-patch"
)
func TestCanChownInPathHappy(t *testing.T) {
@ -62,7 +63,7 @@ func TestCanChownInPathCannotChange(t *testing.T) {
type manifestTestCase struct {
config *main.ManifestConfig
imageTypes imagetypes.ImageTypes
depsolved map[string]debianpatch.DebianDepsolveResult
depsolved map[string]dnfjson.DepsolveResult
containers map[string][]container.Spec
expStages map[string][]string
notExpectedStages map[string][]string
@ -142,10 +143,6 @@ func TestManifestGenerationEmptyConfig(t *testing.T) {
config: baseConfig,
imageTypes: []string{"qcow2"},
},
"iso-base": {
config: baseConfig,
imageTypes: []string{"iso"},
},
"empty-config": {
config: &main.ManifestConfig{},
imageTypes: []string{"qcow2"},
@ -178,10 +175,6 @@ func TestManifestGenerationUserConfig(t *testing.T) {
config: userConfig,
imageTypes: []string{"qcow2"},
},
"iso-user": {
config: userConfig,
imageTypes: []string{"iso"},
},
}
for name, tc := range testCases {

View file

@ -5,7 +5,7 @@ import (
"os"
"path"
"github.com/particle-os/debian-bootc-image-builder/bib/internal/debian-patch"
"github.com/osbuild/images/pkg/rpmmd"
"github.com/sirupsen/logrus"
)
@ -25,7 +25,7 @@ func (SimpleFileReader) ReadFile(path string) ([]byte, error) {
return os.ReadFile(path)
}
func extractTLSKeys(reader fileReader, repoSets map[string][]debianpatch.DebianRepoConfig) (*mTLSConfig, error) {
func extractTLSKeys(reader fileReader, repoSets map[string][]rpmmd.RepoConfig) (*mTLSConfig, error) {
var keyPath, certPath, caPath string
for _, set := range repoSets {
for _, r := range set {

View file

@ -7,7 +7,7 @@ import (
"strings"
"testing"
"github.com/particle-os/debian-bootc-image-builder/bib/internal/debian-patch"
"github.com/osbuild/images/pkg/rpmmd"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@ -22,12 +22,14 @@ func (f *fakeFileReader) ReadFile(path string) ([]byte, error) {
}
func TestExtractTLSKeysHappy(t *testing.T) {
repos := map[string][]debianpatch.DebianRepoConfig{
enabled := true
repos := map[string][]rpmmd.RepoConfig{
"kingfisher": {
{
SSLCACert: "/ca",
SSLClientCert: "/cert",
SSLClientKey: "/key",
Enabled: &enabled,
},
},
}
@ -49,20 +51,23 @@ func TestExtractTLSKeysHappy(t *testing.T) {
}
func TestExtractTLSKeysUnhappy(t *testing.T) {
repos := map[string][]debianpatch.DebianRepoConfig{
enabled := true
repos := map[string][]rpmmd.RepoConfig{
"kingfisher": {
{
SSLCACert: "/ca",
SSLClientCert: "/cert",
SSLClientKey: "/key",
Enabled: &enabled,
},
},
"vulture": {
{
SSLCACert: "/ca",
SSLClientCert: "/cert",
SSLClientKey: "/key",
SSLCACert: "/different-ca",
SSLClientCert: "/different-cert",
SSLClientKey: "/different-key",
Enabled: &enabled,
},
},
}

View file

@ -1,13 +1,13 @@
package main
import "github.com/particle-os/debian-bootc-image-builder/bib/internal/debian-patch"
import "github.com/osbuild/images/pkg/rpmmd"
// NullWorkload implements the images Workload interface but returns only nil
// from all its methods and holds no data.
type NullWorkload struct {
}
func (p *NullWorkload) GetRepos() []debianpatch.DebianRepoConfig {
func (p *NullWorkload) GetRepos() []rpmmd.RepoConfig {
return nil
}

View file

@ -0,0 +1,7 @@
anaconda-iso:
packages:
- kernel
- grub2
- ostree
- systemd
- bash

View file

@ -0,0 +1,94 @@
package debianpatch
import (
"github.com/osbuild/images/pkg/dnfjson"
"github.com/osbuild/images/pkg/rpmmd"
)
// ConvertDebianPackageSetToRPM converts our DebianPackageSet to rpmmd.PackageSet
// This is needed for compatibility with the osbuild images package
func ConvertDebianPackageSetToRPM(debianSet DebianPackageSet) rpmmd.PackageSet {
return rpmmd.PackageSet{
Include: debianSet.Include,
Exclude: debianSet.Exclude,
}
}
// ConvertDebianDepsolveResultToDNF converts our DebianDepsolveResult to dnfjson.DepsolveResult
// This is needed for compatibility with the osbuild images package
func ConvertDebianDepsolveResultToDNF(debianResult DebianDepsolveResult) dnfjson.DepsolveResult {
// Convert DebianRepoConfig to rpmmd.RepoConfig
repos := make([]rpmmd.RepoConfig, len(debianResult.Repos))
for i, repo := range debianResult.Repos {
enabled := repo.Enabled
priority := repo.Priority
repos[i] = rpmmd.RepoConfig{
Name: repo.Name,
BaseURLs: repo.BaseURLs,
Enabled: &enabled,
CheckGPG: &repo.GPGCheck,
Priority: &priority,
SSLCACert: repo.SSLCACert,
SSLClientKey: repo.SSLClientKey,
SSLClientCert: repo.SSLClientCert,
}
}
return dnfjson.DepsolveResult{
Packages: []rpmmd.PackageSpec{}, // We'll need to convert string packages to PackageSpec
Repos: repos,
}
}
// ConvertDebianRepoConfigToRPM converts our DebianRepoConfig to rpmmd.RepoConfig
func ConvertDebianRepoConfigToRPM(debianRepo DebianRepoConfig) rpmmd.RepoConfig {
enabled := debianRepo.Enabled
priority := debianRepo.Priority
gpgCheck := debianRepo.GPGCheck
return rpmmd.RepoConfig{
Name: debianRepo.Name,
BaseURLs: debianRepo.BaseURLs,
Enabled: &enabled,
CheckGPG: &gpgCheck,
Priority: &priority,
SSLCACert: debianRepo.SSLCACert,
SSLClientKey: debianRepo.SSLClientKey,
SSLClientCert: debianRepo.SSLClientCert,
}
}
// ConvertDNFDepsolveResultToDebian converts dnfjson.DepsolveResult to our DebianDepsolveResult
// This is needed for compatibility when reading from the osbuild images package
func ConvertDNFDepsolveResultToDebian(dnfResult dnfjson.DepsolveResult) DebianDepsolveResult {
// Convert rpmmd.RepoConfig to DebianRepoConfig
repos := make([]DebianRepoConfig, len(dnfResult.Repos))
for i, repo := range dnfResult.Repos {
enabled := false
if repo.Enabled != nil {
enabled = *repo.Enabled
}
priority := 0
if repo.Priority != nil {
priority = *repo.Priority
}
gpgCheck := false
if repo.CheckGPG != nil {
gpgCheck = *repo.CheckGPG
}
repos[i] = DebianRepoConfig{
Name: repo.Name,
BaseURLs: repo.BaseURLs,
Enabled: enabled,
GPGCheck: gpgCheck,
Priority: priority,
SSLClientKey: repo.SSLClientKey,
SSLClientCert: repo.SSLClientCert,
SSLCACert: repo.SSLCACert,
}
}
return DebianDepsolveResult{
Packages: []string{}, // We'll need to convert PackageSpec to strings
Repos: repos,
}
}

View file

@ -0,0 +1,7 @@
anaconda-iso:
packages:
- kernel
- grub2
- ostree
- systemd
- bash

View file

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/osbuild/bootc-image-builder/bib/internal/imagetypes"
"github.com/particle-os/debian-bootc-image-builder/bib/internal/imagetypes"
)
type testCase struct {