From 848960f1c8a75cfd3b742de5018ac2d90f5d0fa3 Mon Sep 17 00:00:00 2001 From: stephen mcquay Date: Fri, 2 Mar 2018 23:23:00 -0800 Subject: [PATCH] Use version in the .pkg filename --- pkg/pkg.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/pkg.go b/pkg/pkg.go index f9c4537..bdfc756 100644 --- a/pkg/pkg.go +++ b/pkg/pkg.go @@ -14,8 +14,10 @@ import ( "github.com/pkg/errors" "golang.org/x/crypto/openpgp" + yaml "gopkg.in/yaml.v2" "mcquay.me/fs" + "mcquay.me/pm" "mcquay.me/pm/keyring" ) @@ -88,6 +90,18 @@ func Create(key *openpgp.Entity, dir string) error { return fmt.Errorf("did not find meta.yaml") } + mf, err := os.Open(filepath.Join(dir, "meta.yaml")) + if err != nil { + return errors.Wrap(err, "opening metadata file") + } + md := pm.Meta{} + if err := yaml.NewDecoder(mf).Decode(&md); err != nil { + return errors.Wrap(err, "decoding metadata file") + } + if _, err := md.Valid(); err != nil { + return errors.Wrap(err, "invalid metadata") + } + f, err := os.Open(filepath.Join(dir, "root.tar.bz2")) if err != nil { return errors.Wrap(err, "opening overlay tarball") @@ -162,7 +176,7 @@ func Create(key *openpgp.Entity, dir string) error { sort.Strings(files) tn, pn := filepath.Split(dir) - tn = filepath.Join(tn, pn+".pkg") + tn = filepath.Join(tn, fmt.Sprintf("%v-%v.pkg", pn, md.Version)) tf, err := os.Create(tn) if err != nil { return errors.Wrap(err, "opening final .pkg")