Skip to content

Commit

Permalink
pkg/specgen: fix support for --rootfs on FreeBSD
Browse files Browse the repository at this point in the history
When using 'podman run --rootfs ...', the image passed to SpecGenToOCI
may be nil - in this case, fall back to "freebsd" for the container OS.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <[email protected]>
  • Loading branch information
dfr committed Jul 13, 2023
1 parent 69f112a commit e43127e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pkg/specgen/generate/oci_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ import (

// SpecGenToOCI returns the base configuration for the container.
func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runtime, rtc *config.Config, newImage *libimage.Image, mounts []spec.Mount, pod *libpod.Pod, finalCmd []string, compatibleOptions *libpod.InfraInherit) (*spec.Spec, error) {
inspectData, err := newImage.Inspect(ctx, nil)
if err != nil {
return nil, err
var imageOs string
if newImage != nil {
inspectData, err := newImage.Inspect(ctx, nil)
if err != nil {
return nil, err
}
imageOs = inspectData.Os
} else {
imageOs = "freebsd"
}
imageOs := inspectData.Os

if imageOs != "freebsd" && imageOs != "linux" {
return nil, fmt.Errorf("unsupported image OS: %s", imageOs)
Expand Down

0 comments on commit e43127e

Please sign in to comment.