@@ -26,32 +26,18 @@ import (
2626 "github.com/osbuild/images/pkg/bib/blueprintload"
2727 "github.com/osbuild/images/pkg/cloud"
2828 "github.com/osbuild/images/pkg/cloud/awscloud"
29- "github.com/osbuild/images/pkg/container"
30- "github.com/osbuild/images/pkg/depsolvednf"
3129 "github.com/osbuild/images/pkg/distro/bootc"
3230 "github.com/osbuild/images/pkg/experimentalflags"
3331 "github.com/osbuild/images/pkg/manifest"
3432 "github.com/osbuild/images/pkg/manifestgen"
35- "github.com/osbuild/images/pkg/osbuild"
3633 "github.com/osbuild/images/pkg/reporegistry"
3734 "github.com/osbuild/images/pkg/rpmmd"
3835
39- "github.com/osbuild/bootc-image-builder/bib/internal/imagetypes"
40- podman_container "github.com/osbuild/images/pkg/bib/container"
41- "github.com/osbuild/images/pkg/bib/osinfo"
42-
4336 "github.com/osbuild/image-builder-cli/pkg/progress"
4437 "github.com/osbuild/image-builder-cli/pkg/setup"
45- )
4638
47- // all possible locations for the bib's distro definitions
48- // ./data/defs and ./bib/data/defs are for development
49- // /usr/share/bootc-image-builder/defs is for the production, containerized version
50- var distroDefPaths = []string {
51- "./data/defs" ,
52- "./bib/data/defs" ,
53- "/usr/share/bootc-image-builder/defs" ,
54- }
39+ "github.com/osbuild/bootc-image-builder/bib/internal/imagetypes"
40+ )
5541
5642var (
5743 osGetuid = os .Getuid
@@ -71,63 +57,6 @@ func inContainerOrUnknown() bool {
7157 return err == nil
7258}
7359
74- func makeISOManifest (c * ManifestConfig , solver * depsolvednf.Solver , cacheRoot string ) (manifest.OSBuildManifest , map [string ][]rpmmd.RepoConfig , error ) {
75- rng := createRand ()
76- mani , err := manifestForISO (c , rng )
77- if err != nil {
78- return nil , nil , fmt .Errorf ("cannot get manifest: %w" , err )
79- }
80-
81- // depsolve packages
82- depsolvedSets := make (map [string ]depsolvednf.DepsolveResult )
83- depsolvedRepos := make (map [string ][]rpmmd.RepoConfig )
84- for name , pkgSet := range mani .GetPackageSetChains () {
85- res , err := solver .Depsolve (pkgSet , 0 )
86- if err != nil {
87- return nil , nil , fmt .Errorf ("cannot depsolve: %w" , err )
88- }
89- depsolvedSets [name ] = * res
90- depsolvedRepos [name ] = res .Repos
91- }
92-
93- // Resolve container - the normal case is that host and target
94- // architecture are the same. However it is possible to build
95- // cross-arch images by using qemu-user. This will run everything
96- // (including the build-root) with the target arch then, it
97- // is fast enough (given that it's mostly I/O and all I/O is
98- // run naively via syscall translation)
99-
100- // XXX: should NewResolver() take "arch.Arch"?
101- resolver := container .NewResolver (c .Architecture .String ())
102-
103- containerSpecs := make (map [string ][]container.Spec )
104- for plName , sourceSpecs := range mani .GetContainerSourceSpecs () {
105- for _ , c := range sourceSpecs {
106- resolver .Add (c )
107- }
108- specs , err := resolver .Finish ()
109- if err != nil {
110- return nil , nil , fmt .Errorf ("cannot resolve containers: %w" , err )
111- }
112- for _ , spec := range specs {
113- if spec .Arch != c .Architecture {
114- return nil , nil , fmt .Errorf ("image found is for unexpected architecture %q (expected %q), if that is intentional, please make sure --target-arch matches" , spec .Arch , c .Architecture )
115- }
116- }
117- containerSpecs [plName ] = specs
118- }
119-
120- var opts manifest.SerializeOptions
121- if c .UseLibrepo {
122- opts .RpmDownloader = osbuild .RpmDownloaderLibrepo
123- }
124- mf , err := mani .Serialize (depsolvedSets , containerSpecs , nil , & opts )
125- if err != nil {
126- return nil , nil , fmt .Errorf ("[ERROR] manifest serialization failed: %s" , err .Error ())
127- }
128- return mf , depsolvedRepos , nil
129- }
130-
13160func saveManifest (ms manifest.OSBuildManifest , fpath string ) (err error ) {
13261 b , err := json .MarshalIndent (ms , "" , " " )
13362 if err != nil {
@@ -271,99 +200,6 @@ func manifestFromCobraForDisk(imgref, buildImgref, imgTypeStr, rootFs, rpmCacheR
271200 return nil , nil , err
272201 }
273202 return buf .Bytes (), nil , nil
274-
275- }
276-
277- func manifestFromCobraForISO (imgref , buildImgref , imgTypeStr , rootFs , rpmCacheRoot string , config * blueprint.Blueprint , useLibrepo bool , cntArch arch.Arch ) ([]byte , * mTLSConfig , error ) {
278- container , err := podman_container .New (imgref )
279- if err != nil {
280- return nil , nil , err
281- }
282- defer func () {
283- if err := container .Stop (); err != nil {
284- logrus .Warnf ("error stopping container: %v" , err )
285- }
286- }()
287-
288- var rootfsType string
289- if rootFs != "" {
290- rootfsType = rootFs
291- } else {
292- rootfsType , err = container .DefaultRootfsType ()
293- if err != nil {
294- return nil , nil , fmt .Errorf ("cannot get rootfs type for container: %w" , err )
295- }
296- if rootfsType == "" {
297- return nil , nil , fmt .Errorf (`no default root filesystem type specified in container, please use "--rootfs" to set manually` )
298- }
299- }
300-
301- // Gather some data from the containers distro
302- sourceinfo , err := osinfo .Load (container .Root ())
303- if err != nil {
304- return nil , nil , err
305- }
306-
307- buildContainer := container
308- buildSourceinfo := sourceinfo
309- startedBuildContainer := false
310- defer func () {
311- if startedBuildContainer {
312- if err := buildContainer .Stop (); err != nil {
313- logrus .Warnf ("error stopping container: %v" , err )
314- }
315- }
316- }()
317-
318- if buildImgref != "" {
319- buildContainer , err = podman_container .New (buildImgref )
320- if err != nil {
321- return nil , nil , err
322- }
323- startedBuildContainer = true
324-
325- // Gather some data from the containers distro
326- buildSourceinfo , err = osinfo .Load (buildContainer .Root ())
327- if err != nil {
328- return nil , nil , err
329- }
330- } else {
331- buildImgref = imgref
332- }
333-
334- // This is needed just for RHEL and RHSM in most cases, but let's run it every time in case
335- // the image has some non-standard dnf plugins.
336- if err := buildContainer .InitDNF (); err != nil {
337- return nil , nil , err
338- }
339- solver , err := buildContainer .NewContainerSolver (rpmCacheRoot , cntArch , sourceinfo )
340- if err != nil {
341- return nil , nil , err
342- }
343-
344- manifestConfig := & ManifestConfig {
345- Architecture : cntArch ,
346- Config : config ,
347- Imgref : imgref ,
348- BuildImgref : buildImgref ,
349- DistroDefPaths : distroDefPaths ,
350- SourceInfo : sourceinfo ,
351- BuildSourceInfo : buildSourceinfo ,
352- RootFSType : rootfsType ,
353- UseLibrepo : useLibrepo ,
354- }
355-
356- manifest , repos , err := makeISOManifest (manifestConfig , solver , rpmCacheRoot )
357- if err != nil {
358- return nil , nil , err
359- }
360-
361- mTLS , err := extractTLSKeys (repos )
362- if err != nil {
363- return nil , nil , err
364- }
365-
366- return manifest , mTLS , nil
367203}
368204
369205func cmdManifest (cmd * cobra.Command , args []string ) error {
0 commit comments