diff --git a/pkg/build/extract.go b/pkg/build/extract.go index f374fdea..33d1b672 100644 --- a/pkg/build/extract.go +++ b/pkg/build/extract.go @@ -2,20 +2,29 @@ package build import ( "fmt" + "os" + "path/filepath" "github.com/suse-edge/edge-image-builder/pkg/log" ) - func (b *Builder) Extract() error { log.Audit("Generating image customization components...") if err := b.configureCombustion(b.context); err != nil { - log.Audit("Error configuring customization components, check the logs under the build directory for more information.") + log.Audit("Error configuring customization components, check the logs under the extract directory for more information.") return fmt.Errorf("configuring combustion: %w", err) } - log.Audit("Extract complete!") return nil +} + +func SetupExtractArtifactsDirectory(buildDir string) (artefactsDir string, err error) { + artefactsDir = filepath.Join(buildDir, "artefacts") + if err = os.MkdirAll(artefactsDir, os.ModePerm); err != nil { + return "", fmt.Errorf("creating an artefacts directory: %w", err) + } + + return artefactsDir, nil } \ No newline at end of file diff --git a/pkg/cli/build/extract.go b/pkg/cli/build/extract.go index aa706f96..c9adf164 100644 --- a/pkg/cli/build/extract.go +++ b/pkg/cli/build/extract.go @@ -56,15 +56,13 @@ func Extract(_ *cli.Context) error { os.Exit(1) } - combustionDir, artefactsDir, err := build.SetupCombustionDirectory(buildDir) + artefactsDir, err := build.SetupExtractArtifactsDirectory(buildDir) if err != nil { - log.Auditf("Setting up the combustion directory failed. %s", checkExtractLogMessage) - zap.S().Fatalf("Failed to create combustion directories: %s", err) + log.Auditf("Setting up the extract artifacts directory failed. %s", checkExtractLogMessage) + zap.S().Fatalf("Failed to create extract artifacts directories: %s", err) } - ctx := buildContext(buildDir, combustionDir, artefactsDir, args.ConfigDir, imageDefinition) - - ctx.ImageDefinition.OperatingSystem.Packages = image.Packages{} + ctx := buildContext(buildDir, "", artefactsDir, args.ConfigDir, imageDefinition) if cmdErr = validateImageDefinition(ctx); cmdErr != nil { cmd.LogError(cmdErr, checkExtractLogMessage) os.Exit(1) @@ -92,7 +90,6 @@ func Extract(_ *cli.Context) error { return nil } - // If the image definition requires it, starts the necessary services, returning an error in the event of failure. func bootstrapExtractDependencyServices(ctx *image.Context, rootDir string) *cmd.Error { if combustion.IsEmbeddedArtifactRegistryConfigured(ctx) {