2018-02-26 19:58:28 -08:00
|
|
|
package pkg
|
|
|
|
|
2018-02-26 20:02:23 -08:00
|
|
|
import (
|
|
|
|
"fmt"
|
2018-02-26 20:07:47 -08:00
|
|
|
"log"
|
2018-02-26 20:02:23 -08:00
|
|
|
|
2018-02-26 20:07:47 -08:00
|
|
|
"github.com/pkg/errors"
|
2018-02-26 20:02:23 -08:00
|
|
|
"mcquay.me/fs"
|
2018-02-26 20:07:47 -08:00
|
|
|
"mcquay.me/pm/keyring"
|
2018-02-26 20:02:23 -08:00
|
|
|
)
|
2018-02-26 19:58:28 -08:00
|
|
|
|
|
|
|
// Create traverses the contents of dir and emits a valid pkg, signed by id
|
2018-02-26 20:07:47 -08:00
|
|
|
func Create(root, id, dir string) error {
|
2018-02-26 20:02:23 -08:00
|
|
|
if !fs.Exists(dir) {
|
|
|
|
return fmt.Errorf("%q: doesn't exist", dir)
|
|
|
|
}
|
|
|
|
if !fs.IsDir(dir) {
|
|
|
|
return fmt.Errorf("%q: is not a directory", dir)
|
|
|
|
}
|
2018-02-26 20:07:47 -08:00
|
|
|
e, err := keyring.FindSecretEntity(dir, id)
|
|
|
|
if err != nil {
|
|
|
|
return errors.Wrap(err, "find secret key")
|
|
|
|
}
|
|
|
|
log.Printf("found key: %v", e.PrimaryKey.KeyIdShortString())
|
2018-02-26 19:58:28 -08:00
|
|
|
return fmt.Errorf("creating package from %q for %q: NYI", dir, id)
|
|
|
|
}
|