mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 09:39:08 +00:00
Merge pull request #1318 from justincormack/set-name
Add a --name cli option to the moby tool
This commit is contained in:
commit
657c97c4fb
22
main.go
22
main.go
@ -156,7 +156,7 @@ func containersInitrd(containers []*bytes.Buffer) (*bytes.Buffer, error) {
|
||||
return w, nil
|
||||
}
|
||||
|
||||
func build(m *Moby) {
|
||||
func build(m *Moby, name string) {
|
||||
containers := []*bytes.Buffer{}
|
||||
|
||||
// get kernel bzImage and initrd tarball from container
|
||||
@ -216,13 +216,7 @@ func build(m *Moby) {
|
||||
log.Fatalf("Failed to make initrd %v", err)
|
||||
}
|
||||
|
||||
base := filepath.Base(conf)
|
||||
ext := filepath.Ext(conf)
|
||||
if ext != "" {
|
||||
base = base[:len(base)-len(ext)]
|
||||
}
|
||||
|
||||
err = outputs(m, base, bzimage.Bytes(), initrd.Bytes())
|
||||
err = outputs(m, name, bzimage.Bytes(), initrd.Bytes())
|
||||
if err != nil {
|
||||
log.Fatalf("Error writing outputs: %v", err)
|
||||
}
|
||||
@ -231,10 +225,12 @@ func build(m *Moby) {
|
||||
var (
|
||||
conf string
|
||||
cmdline bool
|
||||
name string
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.BoolVar(&cmdline, "cmdline", false, "Print the kernel command line and exit")
|
||||
flag.StringVar(&name, "name", "", "Name to use for output files")
|
||||
flag.Parse()
|
||||
|
||||
conf = "moby.yaml"
|
||||
@ -242,6 +238,14 @@ func main() {
|
||||
conf = flag.Args()[0]
|
||||
}
|
||||
|
||||
if name == "" {
|
||||
name = filepath.Base(conf)
|
||||
ext := filepath.Ext(conf)
|
||||
if ext != "" {
|
||||
name = name[:len(name)-len(ext)]
|
||||
}
|
||||
}
|
||||
|
||||
config, err := ioutil.ReadFile(conf)
|
||||
if err != nil {
|
||||
log.Fatalf("Cannot open config file: %v", err)
|
||||
@ -257,5 +261,5 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
build(m)
|
||||
build(m, name)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user