Use version in the .pkg filename

This commit is contained in:
Stephen McQuay 2018-03-02 23:23:00 -08:00
parent 63c38d5e92
commit 848960f1c8
Signed by: sm
GPG Key ID: 4E4B72F479BA3CE5
1 changed files with 15 additions and 1 deletions

View File

@ -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")