diff --git a/Gopkg.lock b/Gopkg.lock index c1b2caab..3e212446 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -34,6 +34,18 @@ revision = "346938d642f2ec3594ed81d874461961cd0faa76" version = "v1.1.0" +[[projects]] + name = "github.com/gobuffalo/packr" + packages = ["."] + revision = "6434a292ac52e6964adebfdce3f9ce6d9f16be01" + version = "v1.10.4" + +[[projects]] + name = "github.com/pkg/errors" + packages = ["."] + revision = "645ef00459ed84a119197bfb8d8205042c6df63d" + version = "v0.8.0" + [[projects]] name = "github.com/pmezard/go-difflib" packages = ["difflib"] @@ -55,6 +67,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "ffaf7c3c47e735ab247f597b16bb415d7e97b9032be049472f0ec0dae4c0e522" + inputs-digest = "390b14a0b40ecd556f19ac89f571d9caa1af22832a33c9cc10174001c04ab386" solver-name = "gps-cdcl" solver-version = 1 diff --git a/cmd/nfpm/main.go b/cmd/nfpm/main.go index acb53e4c..d56aa8c0 100644 --- a/cmd/nfpm/main.go +++ b/cmd/nfpm/main.go @@ -6,6 +6,7 @@ import ( "os" "github.com/alecthomas/kingpin" + "github.com/gobuffalo/packr" "github.com/goreleaser/nfpm" _ "github.com/goreleaser/nfpm/deb" _ "github.com/goreleaser/nfpm/rpm" @@ -29,7 +30,7 @@ func main() { if err := initFile(*config); err != nil { kingpin.Fatalf(err.Error()) } - fmt.Printf("created empty config file at %s, edit at will\n", *config) + fmt.Printf("created config file from example: %s\n", *config) case pkgCmd.FullCommand(): if err := doPackage(*config, *format, *target); err != nil { kingpin.Fatalf(err.Error()) @@ -38,11 +39,8 @@ func main() { } func initFile(config string) error { - yml, err := yaml.Marshal(nfpm.Info{}) - if err != nil { - return err - } - return ioutil.WriteFile(config, yml, 0666) + box := packr.NewBox("./nfpm.yaml.example") + return ioutil.WriteFile(config, box.Bytes("."), 0666) } func doPackage(config, format, target string) error { diff --git a/cmd/nfpm/nfpm.yaml.example b/cmd/nfpm/nfpm.yaml.example new file mode 100644 index 00000000..d77cd931 --- /dev/null +++ b/cmd/nfpm/nfpm.yaml.example @@ -0,0 +1,29 @@ +name: "foo" +arch: "amd64" +platform: "linux" +version: "1.0.0" +section: "default" +priority: "extra" +replaces: +- foobar +provides: +- bar +depends: +- foo +- bar +conflicts: +- not-foo +- not-bar +maintainer: "John Doe " +description: | + FooBar is the great foo and bar software. + And this can be in multiple lines! +vendor: "FooBarCorp" +homepage: "http://eaxmple.com" +license: "MIT" +bindir: "/usr/local/bin" +files: + ./foo: "/usr/local/bin/foo" + ./bar: "/usr/local/bin/bar" +config_files: + ./foobar.conf: "/etc/foobar.conf" diff --git a/nfpm.go b/nfpm.go index 352c111b..ba8bd8ce 100644 --- a/nfpm.go +++ b/nfpm.go @@ -36,24 +36,24 @@ type Packager interface { // Info contains information about the package type Info struct { - Name string `yaml:"name"` - Arch string `yaml:"arch"` - Platform string `yaml:"platform"` - Version string `yaml:"version"` - Section string `yaml:"section"` - Priority string `yaml:"priority"` - Replaces []string `yaml:"replaces"` - Provides []string `yaml:"provides"` - Depends []string `yaml:"depends"` - Conflicts []string `yaml:"conflicts"` - Maintainer string `yaml:"maintainer"` - Description string `yaml:"description"` - Vendor string `yaml:"vendor"` - Homepage string `yaml:"homepage"` - License string `yaml:"license"` - Bindir string `yaml:"bindir"` - Files map[string]string `yaml:"files"` - ConfigFiles map[string]string `yaml:"config_files"` + Name string `yaml:"name,omitempty"` + Arch string `yaml:"arch,omitempty"` + Platform string `yaml:"platform,omitempty"` + Version string `yaml:"version,omitempty"` + Section string `yaml:"section,omitempty"` + Priority string `yaml:"priority,omitempty"` + Replaces []string `yaml:"replaces,omitempty"` + Provides []string `yaml:"provides,omitempty"` + Depends []string `yaml:"depends,omitempty"` + Conflicts []string `yaml:"conflicts,omitempty"` + Maintainer string `yaml:"maintainer,omitempty"` + Description string `yaml:"description,omitempty"` + Vendor string `yaml:"vendor,omitempty"` + Homepage string `yaml:"homepage,omitempty"` + License string `yaml:"license,omitempty"` + Bindir string `yaml:"bindir,omitempty"` + Files map[string]string `yaml:"files,omitempty"` + ConfigFiles map[string]string `yaml:"config_files,omitempty"` } // WithDefaults set some sane defaults into the given Info