-
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.
Merge pull request #12 from rmohr/sandbox
Prepare bazeldnf for creating sandboxes for bazel
- Loading branch information
Showing
6 changed files
with
71 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ go_library( | |
"root.go", | ||
"rpm2tar.go", | ||
"rpmtree.go", | ||
"sandbox.go", | ||
"tar2files.go", | ||
"verify.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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/rmohr/bazeldnf/pkg/rpm" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
type sandboxOpts struct { | ||
tar string | ||
sandboxRoot string | ||
name string | ||
} | ||
|
||
var sandboxopts = sandboxOpts{} | ||
|
||
func NewSandboxCmd() *cobra.Command { | ||
|
||
sandboxCmd := &cobra.Command{ | ||
Use: "sandbox", | ||
Short: "Extract a set of RPMs to a specific location", | ||
RunE: func(cmd *cobra.Command, objects []string) error { | ||
rootDir := filepath.Join(sandboxopts.sandboxRoot, "sandbox", sandboxopts.name, "root") | ||
if err := os.RemoveAll(rootDir); err != nil { | ||
return fmt.Errorf("failed to do the initial cleanup on the sandbox: %v", err) | ||
} | ||
if err := os.MkdirAll(rootDir, os.ModePerm); err != nil { | ||
return fmt.Errorf("failed to create the sandbox base directory: %v", err) | ||
} | ||
return rpm.Untar(rootDir, sandboxopts.tar) | ||
}, | ||
} | ||
|
||
sandboxCmd.Flags().StringVarP(&sandboxopts.tar, "input", "i", "", "Tar file with all dependencies") | ||
sandboxCmd.Flags().StringVar(&sandboxopts.sandboxRoot, "sandbox", ".bazeldnf", "Root directory of the sandbox") | ||
sandboxCmd.Flags().StringVarP(&sandboxopts.name, "name", "n", "default", "Sandbox name") | ||
return sandboxCmd | ||
} |
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