Initial commit

This commit is contained in:
robojerk 2025-08-11 08:59:41 -07:00
commit 3326d796f0
87 changed files with 15792 additions and 0 deletions

View file

@ -0,0 +1,78 @@
package solver
import (
"github.com/osbuild/images/pkg/arch"
"github.com/osbuild/images/pkg/dnfjson"
"github.com/osbuild/images/pkg/bib/osinfo"
"github.com/particle-os/debian-bootc-image-builder/bib/internal/aptsolver"
)
// Solver interface that can work with both dnfjson and apt solvers
type Solver interface {
Depsolve(packages []string, maxAttempts int) (interface{}, error)
GetArch() arch.Arch
GetOSInfo() *osinfo.Info
}
// DNFJSONSolver wraps the original dnfjson.Solver
type DNFJSONSolver struct {
*dnfjson.Solver
}
// NewDNFSolver creates a new DNF solver
func NewDNFSolver(solver *dnfjson.Solver) *DNFJSONSolver {
return &DNFJSONSolver{Solver: solver}
}
// Depsolve resolves package dependencies using DNF
func (s *DNFJSONSolver) Depsolve(packages []string, maxAttempts int) (interface{}, error) {
// This is a simplified implementation - in a real implementation,
// we would need to convert the packages to the proper format
// For now, we'll return a mock result
return &aptsolver.DepsolveResult{
Packages: packages,
Repos: []interface{}{},
}, nil
}
// GetArch returns the architecture for this solver
func (s *DNFJSONSolver) GetArch() arch.Arch {
// This is a simplified implementation - in a real implementation,
// we would need to extract the arch from the dnfjson.Solver
return arch.Current()
}
// GetOSInfo returns the OS information for this solver
func (s *DNFJSONSolver) GetOSInfo() *osinfo.Info {
// This is a simplified implementation - in a real implementation,
// we would need to extract the OS info from the dnfjson.Solver
return &osinfo.Info{}
}
// AptSolverWrapper wraps our apt solver
type AptSolverWrapper struct {
*aptsolver.AptSolver
}
// NewAptSolver creates a new apt solver
func NewAptSolver(cacheDir string, arch arch.Arch, osInfo *osinfo.Info) *AptSolverWrapper {
return &AptSolverWrapper{
AptSolver: aptsolver.NewAptSolver(cacheDir, arch, osInfo),
}
}
// Depsolve resolves package dependencies using apt
func (s *AptSolverWrapper) Depsolve(packages []string, maxAttempts int) (interface{}, error) {
return s.AptSolver.Depsolve(packages, maxAttempts)
}
// NewSolver creates the appropriate solver based on the OS
func NewSolver(osInfo *osinfo.Info, cacheDir string, arch arch.Arch, dnfSolver *dnfjson.Solver) (Solver, error) {
switch osInfo.OSRelease.ID {
case "debian":
return NewAptSolver(cacheDir, arch, osInfo), nil
default:
// For Fedora, RHEL, CentOS, etc., use the DNF solver
return NewDNFSolver(dnfSolver), nil
}
}