diff --git a/internal/constants/constants.go b/internal/constants/constants.go index 335c57082e..81118222fa 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -62,6 +62,9 @@ const DisableUpdates = "ACTIVESTATE_CLI_DISABLE_UPDATES" // UpdateBranchEnvVarName is the env var that is used to override which branch to pull the update from const UpdateBranchEnvVarName = "ACTIVESTATE_CLI_UPDATE_BRANCH" +// InstallBuildDependencies is the env var that is used to override whether to install build dependencies +const InstallBuildDependencies = "ACTIVESTATE_CLI_INSTALL_BUILD_DEPENDENCIES" + // InternalConfigFileNameLegacy is effectively the same as InternalConfigName, but includes our preferred extension const InternalConfigFileNameLegacy = "config.yaml" diff --git a/pkg/platform/runtime/setup/setup.go b/pkg/platform/runtime/setup/setup.go index fdbe529733..0d20f4f561 100644 --- a/pkg/platform/runtime/setup/setup.go +++ b/pkg/platform/runtime/setup/setup.go @@ -385,11 +385,6 @@ func (s *Setup) fetchAndInstallArtifactsFromBuildPlan(installFunc artifactInstal var runtimeAndBuildtimeArtifacts artifact.Map var runtimeArtifacts artifact.Map // Artifacts required for the runtime to function - runtimeArtifacts, err = buildplan.NewMapFromBuildPlan(buildResult.Build) - if err != nil { - return nil, nil, errs.Wrap(err, "Failed to create artifact map from build plan") - } - // If the build is not ready, we need to get the runtime and buildtime closure if !buildResult.BuildReady { runtimeAndBuildtimeArtifacts, err = buildplan.NewBuildtimeMap(buildResult.Build) @@ -398,6 +393,23 @@ func (s *Setup) fetchAndInstallArtifactsFromBuildPlan(installFunc artifactInstal } } + // If we are installing build dependencies, then buildtime dependencies are also runtime dependencies + if strings.EqualFold(os.Getenv(constants.InstallBuildDependencies), "true") { + logging.Debug("Installing build dependencies") + if runtimeAndBuildtimeArtifacts == nil { + runtimeAndBuildtimeArtifacts, err = buildplan.NewBuildtimeMap(buildResult.Build) + if err != nil { + return nil, nil, errs.Wrap(err, "Failed to create artifact map from build plan") + } + } + runtimeArtifacts = runtimeAndBuildtimeArtifacts + } else { + runtimeArtifacts, err = buildplan.NewMapFromBuildPlan(buildResult.Build) + if err != nil { + return nil, nil, errs.Wrap(err, "Failed to create artifact map from build plan") + } + } + var setup Setuper if !buildResult.BuildReady { setup, err = s.selectSetupImplementation(buildResult.BuildEngine, runtimeAndBuildtimeArtifacts) diff --git a/test/integration/checkout_int_test.go b/test/integration/checkout_int_test.go index 9c35f2b52f..9f4fd36246 100644 --- a/test/integration/checkout_int_test.go +++ b/test/integration/checkout_int_test.go @@ -244,6 +244,26 @@ func (suite *CheckoutIntegrationTestSuite) TestCheckoutCaseInsensitive() { suite.Assert().NotContains(string(bytes), "ACTIVESTATE-CLI/SMALL-PYTHON", "kept incorrect namespace case") } +func (suite *CheckoutIntegrationTestSuite) TestCheckoutBuildtimeClosure() { + suite.OnlyRunForTags(tagsuite.Checkout) + + if runtime.GOOS != "linux" { + suite.T().Skip("Skipping buildtime closure test on non-linux platform") + } + + ts := e2e.New(suite.T(), false) + defer ts.Close() + + cp := ts.SpawnWithOpts( + e2e.OptArgs("checkout", "ActiveState-CLI/small-python"), + e2e.OptAppendEnv(constants.InstallBuildDependencies+"=true"), + e2e.OptAppendEnv(constants.DisableRuntime+"=false"), + ) + // Expect the number of build deps to be 27 which is more than the number of runtime deps. + cp.Expect("libxcrypt") + cp.ExpectExitCode(0) +} + func TestCheckoutIntegrationTestSuite(t *testing.T) { suite.Run(t, new(CheckoutIntegrationTestSuite)) }