-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Roman Mohr <[email protected]>
- Loading branch information
Showing
6 changed files
with
59 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ go_library( | |
"bazeldnf.go", | ||
"fetch.go", | ||
"init.go", | ||
"prune.go", | ||
"reduce.go", | ||
"resolve.go", | ||
"root.go", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/rmohr/bazeldnf/pkg/bazel" | ||
"github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
type pruneOpts struct { | ||
workspace string | ||
buildfile string | ||
} | ||
|
||
var pruneopts = pruneOpts{} | ||
|
||
func NewpruneCmd() *cobra.Command { | ||
|
||
pruneCmd := &cobra.Command{ | ||
Use: "prune", | ||
Short: "prunes unused RPM dependencies", | ||
RunE: func(cmd *cobra.Command, required []string) error { | ||
workspace, err := bazel.LoadWorkspace(pruneopts.workspace) | ||
if err != nil { | ||
return err | ||
} | ||
build, err := bazel.LoadBuild(pruneopts.buildfile) | ||
if err != nil { | ||
return err | ||
} | ||
bazel.PruneRPMs(build, workspace) | ||
err = bazel.WriteWorkspace(false, workspace, pruneopts.workspace) | ||
if err != nil { | ||
return err | ||
} | ||
err = bazel.WriteBuild(false, build, pruneopts.buildfile) | ||
if err != nil { | ||
return err | ||
} | ||
logrus.Info("Done.") | ||
return nil | ||
}, | ||
} | ||
|
||
pruneCmd.PersistentFlags().StringVarP(&pruneopts.workspace, "workspace", "w", "WORKSPACE", "Bazel workspace file") | ||
pruneCmd.PersistentFlags().StringVarP(&pruneopts.buildfile, "buildfile", "b", "rpm/BUILD.bazel", "Build file for RPMs") | ||
pruneCmd.MarkFlagRequired("name") | ||
return pruneCmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters