@@ -3,8 +3,6 @@ package main
33import (
44 "fmt"
55 "math/rand"
6- "strconv"
7- "strings"
86
97 "github.com/osbuild/blueprint/pkg/blueprint"
108 "github.com/osbuild/images/pkg/arch"
@@ -15,13 +13,13 @@ import (
1513 "github.com/osbuild/images/pkg/depsolvednf"
1614 "github.com/osbuild/images/pkg/disk"
1715 "github.com/osbuild/images/pkg/distro"
16+ "github.com/osbuild/images/pkg/distro/bootc"
1817 "github.com/osbuild/images/pkg/distro/defs"
1918 "github.com/osbuild/images/pkg/image"
2019 "github.com/osbuild/images/pkg/manifest"
2120 "github.com/osbuild/images/pkg/osbuild"
2221 "github.com/osbuild/images/pkg/platform"
2322 "github.com/osbuild/images/pkg/rpmmd"
24- "github.com/osbuild/images/pkg/runner"
2523 "github.com/sirupsen/logrus"
2624
2725 podman_container "github.com/osbuild/images/pkg/bib/container"
@@ -204,24 +202,6 @@ func makeISOManifest(c *ManifestConfig, solver *depsolvednf.Solver, cacheRoot st
204202 return mf , depsolvedRepos , nil
205203}
206204
207- func labelForISO (os * osinfo.OSRelease , arch * arch.Arch ) string {
208- switch os .ID {
209- case "fedora" :
210- return fmt .Sprintf ("Fedora-S-dvd-%s-%s" , arch , os .VersionID )
211- case "centos" :
212- labelTemplate := "CentOS-Stream-%s-BaseOS-%s"
213- if os .VersionID == "8" {
214- labelTemplate = "CentOS-Stream-%s-%s-dvd"
215- }
216- return fmt .Sprintf (labelTemplate , os .VersionID , arch )
217- case "rhel" :
218- version := strings .ReplaceAll (os .VersionID , "." , "-" )
219- return fmt .Sprintf ("RHEL-%s-BaseOS-%s" , version , arch )
220- default :
221- return fmt .Sprintf ("Container-Installer-%s" , arch )
222- }
223- }
224-
225205// newDistroYAMLFrom() returns the distroYAML for the given sourceInfo,
226206// if no direct match can be found it will it will use the ID_LIKE.
227207// This should ensure we work on every bootc image that puts a correct
@@ -310,7 +290,7 @@ func manifestForISO(c *ManifestConfig, rng *rand.Rand) (*manifest.Manifest, erro
310290
311291 img .InstallerCustomizations .Product = c .SourceInfo .OSRelease .Name
312292 img .InstallerCustomizations .OSVersion = c .SourceInfo .OSRelease .VersionID
313- img .InstallerCustomizations .ISOLabel = labelForISO (& c .SourceInfo .OSRelease , & c .Architecture )
293+ img .InstallerCustomizations .ISOLabel = bootc . LabelForISO (& c .SourceInfo .OSRelease , c .Architecture . String () )
314294 img .ExtraBasePackages = installerPkgSet
315295
316296 var customizations * blueprint.Customizations
@@ -366,7 +346,7 @@ func manifestForISO(c *ManifestConfig, rng *rand.Rand) (*manifest.Manifest, erro
366346
367347 mf := manifest .New ()
368348
369- foundDistro , foundRunner , err := getDistroAndRunner (c .SourceInfo .OSRelease )
349+ foundDistro , foundRunner , err := bootc . GetDistroAndRunner (c .SourceInfo .OSRelease )
370350 if err != nil {
371351 return nil , fmt .Errorf ("failed to infer distro and runner: %w" , err )
372352 }
@@ -375,64 +355,3 @@ func manifestForISO(c *ManifestConfig, rng *rand.Rand) (*manifest.Manifest, erro
375355 _ , err = img .InstantiateManifest (& mf , nil , foundRunner , rng )
376356 return & mf , err
377357}
378-
379- func getDistroAndRunner (osRelease osinfo.OSRelease ) (manifest.Distro , runner.Runner , error ) {
380- switch osRelease .ID {
381- case "fedora" :
382- version , err := strconv .ParseUint (osRelease .VersionID , 10 , 64 )
383- if err != nil {
384- return manifest .DISTRO_NULL , nil , fmt .Errorf ("cannot parse Fedora version (%s): %w" , osRelease .VersionID , err )
385- }
386-
387- return manifest .DISTRO_FEDORA , & runner.Fedora {
388- Version : version ,
389- }, nil
390- case "centos" :
391- version , err := strconv .ParseUint (osRelease .VersionID , 10 , 64 )
392- if err != nil {
393- return manifest .DISTRO_NULL , nil , fmt .Errorf ("cannot parse CentOS version (%s): %w" , osRelease .VersionID , err )
394- }
395- r := & runner.CentOS {
396- Version : version ,
397- }
398- switch version {
399- case 9 :
400- return manifest .DISTRO_EL9 , r , nil
401- case 10 :
402- return manifest .DISTRO_EL10 , r , nil
403- default :
404- logrus .Warnf ("Unknown CentOS version %d, using default distro for manifest generation" , version )
405- return manifest .DISTRO_NULL , r , nil
406- }
407-
408- case "rhel" :
409- versionParts := strings .Split (osRelease .VersionID , "." )
410- if len (versionParts ) != 2 {
411- return manifest .DISTRO_NULL , nil , fmt .Errorf ("invalid RHEL version format: %s" , osRelease .VersionID )
412- }
413- major , err := strconv .ParseUint (versionParts [0 ], 10 , 64 )
414- if err != nil {
415- return manifest .DISTRO_NULL , nil , fmt .Errorf ("cannot parse RHEL major version (%s): %w" , versionParts [0 ], err )
416- }
417- minor , err := strconv .ParseUint (versionParts [1 ], 10 , 64 )
418- if err != nil {
419- return manifest .DISTRO_NULL , nil , fmt .Errorf ("cannot parse RHEL minor version (%s): %w" , versionParts [1 ], err )
420- }
421- r := & runner.RHEL {
422- Major : major ,
423- Minor : minor ,
424- }
425- switch major {
426- case 9 :
427- return manifest .DISTRO_EL9 , r , nil
428- case 10 :
429- return manifest .DISTRO_EL10 , r , nil
430- default :
431- logrus .Warnf ("Unknown RHEL version %d, using default distro for manifest generation" , major )
432- return manifest .DISTRO_NULL , r , nil
433- }
434- }
435-
436- logrus .Warnf ("Unknown distro %s, using default runner" , osRelease .ID )
437- return manifest .DISTRO_NULL , & runner.Linux {}, nil
438- }
0 commit comments