Implements pre/post install scripts
This commit is contained in:
parent
56eebc8c34
commit
509433dd3d
@ -10,6 +10,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
@ -69,6 +70,14 @@ func Install(root string, pkgs []string) error {
|
||||
}
|
||||
return errors.Wrap(err, "verifying pkg contents")
|
||||
}
|
||||
|
||||
if err := script(root, m, "pre-install"); err != nil {
|
||||
return errors.Wrap(err, "pre-install")
|
||||
}
|
||||
|
||||
if err := script(root, m, "post-install"); err != nil {
|
||||
return errors.Wrap(err, "pre-install")
|
||||
}
|
||||
}
|
||||
return errors.New("NYI")
|
||||
}
|
||||
@ -252,3 +261,14 @@ type close struct {
|
||||
func (close) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func script(root string, m pm.Meta, name string) error {
|
||||
bin := filepath.Join(root, installed, string(m.Name), "bin", name)
|
||||
if !fs.Exists(bin) {
|
||||
return nil
|
||||
}
|
||||
cmd := exec.Command(bin)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
return cmd.Run()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user