-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsbuild.go
53 lines (48 loc) · 1.02 KB
/
sbuild.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"pault.ag/go/debian/version"
)
type sbuild struct {
dist string
logDir string
dryRun bool
extraDebs []string
}
func (s *sbuild) build(sourcePackage string, version *version.Version) *buildResult {
result := &buildResult{
src: sourcePackage,
version: version,
}
target := fmt.Sprintf("%s_%s", sourcePackage, version)
// TODO: discard resulting package immediately?
args := []string{
"--arch-all",
"--dist=" + s.dist,
"--nolog",
target,
}
for _, filename := range s.extraDebs {
args = append(args, fmt.Sprintf("--extra-package=%s", filename))
}
cmd := exec.Command("sbuild", args...)
if s.dryRun {
log.Printf(" commandline: %v\n", cmd.Args)
return result
}
buildlog, err := os.Create(filepath.Join(s.logDir, target))
defer buildlog.Close()
if err != nil {
result.err = err
return result
}
cmd.Stdout = buildlog
cmd.Stderr = buildlog
result.err = cmd.Run()
result.logFile = buildlog.Name()
return result
}