Skip to content

Commit

Permalink
Minor fixes to rpmtree command
Browse files Browse the repository at this point in the history
(1) The error checking at the beginning isn't necessary because we also
    want to support WORKSPACE mode.

(2) If we pass the default configname through to AddTree() then we'll
    generate the WORKSPACE file as if we had a lock file, which is not
    what we desire
  • Loading branch information
kellyma2 committed Dec 3, 2024
1 parent 3955774 commit a6770fb
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cmd/rpmtree.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"errors"
"fmt"
"os"

"github.com/bazelbuild/buildtools/build"
Expand Down Expand Up @@ -137,10 +137,6 @@ func NewRpmTreeCmd() *cobra.Command {
Short: "Writes a rpmtree rule and its rpmdependencies to bazel files",
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, required []string) error {
if rpmtreeopts.toMacro != "" && rpmtreeopts.lockfile != "" {
return errors.New("Must provide at most one of --lockfile --to-macro")
}

repos, err := repo.LoadRepoFiles(rpmtreeopts.repofiles)
if err != nil {
return err
Expand Down Expand Up @@ -173,9 +169,12 @@ func NewRpmTreeCmd() *cobra.Command {
}

var handler Handler
var configname string

if rpmtreeopts.toMacro != "" {
handler, err = NewMacroHandler(rpmtreeopts.toMacro)
} else if rpmtreeopts.lockfile != "" {
configname = rpmtreeopts.configname
handler, err = NewLockFileHandler(
rpmtreeopts.configname,
rpmtreeopts.lockfile,
Expand All @@ -198,7 +197,7 @@ func NewRpmTreeCmd() *cobra.Command {
return err
}

bazel.AddTree(rpmtreeopts.name, rpmtreeopts.configname, build, install, rpmtreeopts.arch, rpmtreeopts.public)
bazel.AddTree(rpmtreeopts.name, configname, build, install, rpmtreeopts.arch, rpmtreeopts.public)

handler.PruneRPMs(build)
logrus.Info("Writing bazel files.")
Expand Down

0 comments on commit a6770fb

Please sign in to comment.