@@ -32,6 +32,11 @@ const containerSizeToDiskSizeMultiplier = 2
3232const diskSizeMinimum = 10 * 1024 * 1024 * 1024 // 10GB
3333const imageMetaXattr = "user.bootc.meta"
3434
35+ // DiskImageConfig defines configuration for the
36+ type DiskImageConfig struct {
37+ Filesystem string
38+ }
39+
3540// diskFromContainerMeta is serialized to JSON in a user xattr on a disk image
3641type diskFromContainerMeta struct {
3742 // imageDigest is the digested sha256 of the container that was used to build this disk
@@ -96,7 +101,7 @@ func (p *BootcDisk) GetCreatedAt() time.Time {
96101 return p .CreatedAt
97102}
98103
99- func (p * BootcDisk ) Install (quiet bool ) (err error ) {
104+ func (p * BootcDisk ) Install (quiet bool , config DiskImageConfig ) (err error ) {
100105 p .CreatedAt = time .Now ()
101106
102107 err = p .pullImage ()
@@ -125,7 +130,7 @@ func (p *BootcDisk) Install(quiet bool) (err error) {
125130 return fmt .Errorf ("error while making bootc disk directory: %w" , err )
126131 }
127132
128- err = p .getOrInstallImageToDisk (quiet )
133+ err = p .getOrInstallImageToDisk (quiet , config )
129134 if err != nil {
130135 return
131136 }
@@ -149,15 +154,15 @@ func (p *BootcDisk) Cleanup() (err error) {
149154}
150155
151156// getOrInstallImageToDisk checks if the disk is present and if not, installs the image to a new disk
152- func (p * BootcDisk ) getOrInstallImageToDisk (quiet bool ) error {
157+ func (p * BootcDisk ) getOrInstallImageToDisk (quiet bool , diskConfig DiskImageConfig ) error {
153158 diskPath := filepath .Join (p .Directory , config .DiskImage )
154159 f , err := os .Open (diskPath )
155160 if err != nil {
156161 if ! errors .Is (err , os .ErrNotExist ) {
157162 return err
158163 }
159164 logrus .Debugf ("No existing disk image found" )
160- return p .bootcInstallImageToDisk (quiet )
165+ return p .bootcInstallImageToDisk (quiet , diskConfig )
161166 }
162167 logrus .Debug ("Found existing disk image, comparing digest" )
163168 defer f .Close ()
@@ -167,21 +172,21 @@ func (p *BootcDisk) getOrInstallImageToDisk(quiet bool) error {
167172 // If there's no xattr, just remove it
168173 os .Remove (diskPath )
169174 logrus .Debugf ("No %s xattr found" , imageMetaXattr )
170- return p .bootcInstallImageToDisk (quiet )
175+ return p .bootcInstallImageToDisk (quiet , diskConfig )
171176 }
172177 bufTrimmed := buf [:len ]
173178 var serializedMeta diskFromContainerMeta
174179 if err := json .Unmarshal (bufTrimmed , & serializedMeta ); err != nil {
175180 logrus .Warnf ("failed to parse serialized meta from %s (%v) %v" , diskPath , buf , err )
176- return p .bootcInstallImageToDisk (quiet )
181+ return p .bootcInstallImageToDisk (quiet , diskConfig )
177182 }
178183
179184 logrus .Debugf ("previous disk digest: %s current digest: %s" , serializedMeta .ImageDigest , p .ImageId )
180185 if serializedMeta .ImageDigest == p .ImageId {
181186 return nil
182187 }
183188
184- return p .bootcInstallImageToDisk (quiet )
189+ return p .bootcInstallImageToDisk (quiet , diskConfig )
185190}
186191
187192func align (size int64 , align int64 ) int64 {
@@ -193,7 +198,7 @@ func align(size int64, align int64) int64 {
193198}
194199
195200// bootcInstallImageToDisk creates a disk image from a bootc container
196- func (p * BootcDisk ) bootcInstallImageToDisk (quiet bool ) (err error ) {
201+ func (p * BootcDisk ) bootcInstallImageToDisk (quiet bool , diskConfig DiskImageConfig ) (err error ) {
197202 fmt .Printf ("Executing `bootc install to-disk` from container image %s to create disk image\n " , p .RepoTag )
198203 p .file , err = os .CreateTemp (p .Directory , "podman-bootc-tempdisk" )
199204 if err != nil {
@@ -218,7 +223,7 @@ func (p *BootcDisk) bootcInstallImageToDisk(quiet bool) (err error) {
218223 }
219224 }()
220225
221- err = p .runInstallContainer (quiet )
226+ err = p .runInstallContainer (quiet , diskConfig )
222227 if err != nil {
223228 return fmt .Errorf ("failed to create disk image: %w" , err )
224229 }
@@ -272,8 +277,8 @@ func (p *BootcDisk) pullImage() (err error) {
272277}
273278
274279// runInstallContainer runs the bootc installer in a container to create a disk image
275- func (p * BootcDisk ) runInstallContainer (quiet bool ) (err error ) {
276- createResponse , err := p .createInstallContainer ()
280+ func (p * BootcDisk ) runInstallContainer (quiet bool , config DiskImageConfig ) (err error ) {
281+ createResponse , err := p .createInstallContainer (config )
277282 if err != nil {
278283 return fmt .Errorf ("failed to create container: %w" , err )
279284 }
@@ -355,7 +360,7 @@ func (p *BootcDisk) runInstallContainer(quiet bool) (err error) {
355360}
356361
357362// createInstallContainer creates a container to run the bootc installer
358- func (p * BootcDisk ) createInstallContainer () (createResponse types.ContainerCreateResponse , err error ) {
363+ func (p * BootcDisk ) createInstallContainer (config DiskImageConfig ) (createResponse types.ContainerCreateResponse , err error ) {
359364 privileged := true
360365 autoRemove := true
361366 labelNested := true
@@ -365,12 +370,18 @@ func (p *BootcDisk) createInstallContainer() (createResponse types.ContainerCrea
365370 targetEnv ["RUST_LOG" ] = v
366371 }
367372
373+ bootcInstallArgs := []string {
374+ "bootc" , "install" , "to-disk" , "--via-loopback" , "--generic-image" ,
375+ "--skip-fetch-check" ,
376+ }
377+ if config .Filesystem != "" {
378+ bootcInstallArgs = append (bootcInstallArgs , "--filesystem" , config .Filesystem )
379+ }
380+ bootcInstallArgs = append (bootcInstallArgs , "/output/" + filepath .Base (p .file .Name ()))
381+
368382 s := & specgen.SpecGenerator {
369383 ContainerBasicConfig : specgen.ContainerBasicConfig {
370- Command : []string {
371- "bootc" , "install" , "to-disk" , "--via-loopback" , "--generic-image" ,
372- "--skip-fetch-check" , "/output/" + filepath .Base (p .file .Name ()),
373- },
384+ Command : bootcInstallArgs ,
374385 PidNS : specgen.Namespace {NSMode : specgen .Host },
375386 Remove : & autoRemove ,
376387 Annotations : map [string ]string {"io.podman.annotations.label" : "type:unconfined_t" },
0 commit comments