Skip to content

Commit

Permalink
Don't run build-prep by default for create-srpm
Browse files Browse the repository at this point in the history
Deprecated the "--skip-build-prep" option, making it a no-op, and
build-prep is now skipped by default. The option "--do-build-prep" has
been added for users wanting previous behavior. We cannot remove
the option altogether because there're packages which make use
of this flag via eextgen.

The motivation is that users have been stumped by %prep failures because
of missing dependencies in the their environment. It's not obvious that
--skip-build-prep will workaround the problem.
  • Loading branch information
aajith-arista committed Jan 15, 2025
1 parent b27546c commit 54bbb71
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
8 changes: 5 additions & 3 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ var buildCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
repo, _ := cmd.Flags().GetString("repo")
pkg, _ := cmd.Flags().GetString("package")
skipBuildPrep, _ := cmd.Flags().GetBool("skip-build-prep")
doBuildPrep, _ := cmd.Flags().GetBool("do-build-prep")
noCheck, _ := cmd.Flags().GetBool("nocheck")
extraCreateSrpmArgs := impl.CreateSrpmExtraCmdlineArgs{
SkipBuildPrep: skipBuildPrep,
DoBuildPrep: doBuildPrep,
}
extraMockArgs := impl.MockExtraCmdlineArgs{
NoCheck: noCheck,
Expand All @@ -35,7 +35,9 @@ var buildCmd = &cobra.Command{
func init() {
buildCmd.Flags().StringP("repo", "r", "", "Repository name (OPTIONAL)")
buildCmd.Flags().StringP("package", "p", "", "package name (OPTIONAL)")
buildCmd.Flags().Bool("skip-build-prep", false, "Skips build-prep during createSrpm for cases where build-prep requires dependencies not in container (OPTIONAL)")
buildCmd.Flags().Bool("skip-build-prep", false, " DEPRECATED. No-op")
buildCmd.Flags().MarkHidden("skip-build-prep")
buildCmd.Flags().Bool("do-build-prep", false, "Runs build-prep on the created SRPM to make sure patches apply cleanly (OPTIONAL)")
buildCmd.Flags().Bool("nocheck", false, "Pass --nocheck to rpmbuild (OPTIONAL)")
rootCmd.AddCommand(buildCmd)
}
8 changes: 5 additions & 3 deletions cmd/create_srpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ In situations where multiple SRPMs need to be built in dependency order, the man
RunE: func(cmd *cobra.Command, args []string) error {
repo, _ := cmd.Flags().GetString("repo")
pkg, _ := cmd.Flags().GetString("package")
skipBuildPrep, _ := cmd.Flags().GetBool("skip-build-prep")
doBuildPrep, _ := cmd.Flags().GetBool("do-build-prep")
extraArgs := impl.CreateSrpmExtraCmdlineArgs{
SkipBuildPrep: skipBuildPrep,
DoBuildPrep: doBuildPrep,
}
err := impl.CreateSrpm(repo, pkg, extraArgs, selectExecutor())
return err
Expand All @@ -35,6 +35,8 @@ In situations where multiple SRPMs need to be built in dependency order, the man
func init() {
createSrpmCmd.Flags().StringP("repo", "r", "", "Repository name (OPTIONAL)")
createSrpmCmd.Flags().StringP("package", "p", "", "package name (OPTIONAL)")
createSrpmCmd.Flags().Bool("skip-build-prep", false, "Skips build-prep for cases where build-prep requires dependencies not in container(OPTIONAL)")
createSrpmCmd.Flags().Bool("skip-build-prep", false, " DEPRECATED. No-op")
createSrpmCmd.Flags().MarkHidden("skip-build-prep")
createSrpmCmd.Flags().Bool("do-build-prep", false, "Runs build-prep on the created SRPM to make sure patches apply cleanly (OPTIONAL)")
rootCmd.AddCommand(createSrpmCmd)
}
8 changes: 4 additions & 4 deletions impl/create_srpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type upstreamSrcSpec struct {
type srpmBuilder struct {
pkgSpec *manifest.Package
repo string
skipBuildPrep bool
doBuildPrep bool
errPrefixBase util.ErrPrefix
errPrefix util.ErrPrefix
upstreamSrc []upstreamSrcSpec
Expand All @@ -40,7 +40,7 @@ type srpmBuilder struct {

// CreateSrpmExtraCmdlineArgs is a bundle of extra args for impl.CreateSrpm
type CreateSrpmExtraCmdlineArgs struct {
SkipBuildPrep bool
DoBuildPrep bool
}

func (bldr *srpmBuilder) log(format string, a ...any) {
Expand Down Expand Up @@ -527,7 +527,7 @@ func (bldr *srpmBuilder) runStages() error {
return err
}

if !bldr.skipBuildPrep {
if bldr.doBuildPrep {
bldr.setupStageErrPrefix("build-prep")
if err := bldr.build(true); err != nil {
return err
Expand Down Expand Up @@ -588,7 +588,7 @@ func CreateSrpm(repo string, pkg string, extraArgs CreateSrpmExtraCmdlineArgs, e
bldr := srpmBuilder{
pkgSpec: &pkgSpec,
repo: repo,
skipBuildPrep: extraArgs.SkipBuildPrep,
doBuildPrep: extraArgs.DoBuildPrep,
errPrefixBase: errPrefixBase,
srcConfig: srcConfig,
executor: executor,
Expand Down
2 changes: 1 addition & 1 deletion manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type Multilib struct {
// the command name(mock/create-srpm) and the value is a list of extra-options.
//
// Valid options for mock are [ --nocheck ]
// Valid options for create-srpm are [ --skip-build-prep ]
// Valid options for create-srpm are [ --do-build-prep ]
//
// MultiLib specifies MultiLib spec to generate multilib. It's indexed by native-arch (i686/x86_64).
//
Expand Down
2 changes: 1 addition & 1 deletion manifest/testData/sampleManifest1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ package:
mock:
- "--nocheck"
create-srpm:
- "--skip-build-prep"
- "--do-build-prep"
external-dependencies:
glibc: code.arista.io/eos/eext/glibc
- name: binutils
Expand Down

0 comments on commit 54bbb71

Please sign in to comment.