mirror of
https://github.com/mudler/luet.git
synced 2025-07-02 02:01:56 +00:00
The BuildTree implementation was in parallel-build-tools, which actually makes sense to share in the compiler as can be used as another way to trigger builds. The CLI helpers were split in several CIs implementations. This moves a new layout where we expose several packages, as we will refactor things slowly.
38 lines
704 B
Go
38 lines
704 B
Go
package utils
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"os/exec"
|
|
"strings"
|
|
)
|
|
|
|
func RunSHOUT(stepName, bashFragment string) ([]byte, error) {
|
|
cmd := exec.Command("sh", "-s")
|
|
cmd.Stdin = strings.NewReader(bashWrap(bashFragment))
|
|
|
|
cmd.Env = os.Environ()
|
|
// log.Printf("Running in background: %v", stepName)
|
|
|
|
return cmd.CombinedOutput()
|
|
}
|
|
|
|
func RunSH(stepName, bashFragment string) error {
|
|
cmd := exec.Command("sh", "-s")
|
|
cmd.Stdin = strings.NewReader(bashWrap(bashFragment))
|
|
cmd.Stdout = os.Stdout
|
|
cmd.Stderr = os.Stderr
|
|
cmd.Env = os.Environ()
|
|
log.Printf("Running: %v (%v)", stepName, bashFragment)
|
|
|
|
return cmd.Run()
|
|
}
|
|
|
|
func bashWrap(cmd string) string {
|
|
return `
|
|
set -o errexit
|
|
set -o nounset
|
|
` + cmd + `
|
|
`
|
|
}
|