This repository has been archived by the owner on Feb 17, 2023. It is now read-only.
/
main.go
116 lines (95 loc) · 2.5 KB
/
main.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package main
import (
"fmt"
"os"
"pault.ag/go/debian/control"
// "pault.ag/go/fancytext"
"pault.ag/go/nmr/helpers"
"pault.ag/go/reprepro"
)
func main() {
arch := os.Args[1]
repoRoot := os.Args[2]
params := os.Args[3:]
repreproRepo := reprepro.NewRepo(repoRoot)
log, err := repreproRepo.ParseLogEntry(params)
if err != nil {
panic(err)
}
arches := log.Changes.Architectures
// insane hack here. ignore me.
fmt.Printf("Got: %s %s\n", log.Action, log.Changes.Architectures)
if log.Action != "accepted" || arches[0].CPU != "source" || len(arches) != 1 {
fmt.Printf("Ignoring: %s %s\n", log.Action, log.Changes.Architectures)
return
}
// Right, let's run a build.
dsc, err := log.Changes.GetDSC()
if err != nil {
panic(err)
}
complete, err := Tempdir()
if err != nil {
panic(err)
}
defer complete()
ftbfs, err := BuildPackage(dsc.Filename, arch, log.Suite, repoRoot, true)
fmt.Printf("FTBFS: %s", ftbfs)
fmt.Printf("Error: %s", err)
}
func BuildPackage(dscFile, arch, suite, repoRoot string, verbose bool) (bool, error) {
// done := fancytext.FormatSpinner(fmt.Sprintf("%%s - building %s", dscFile))
// defer done()
incomingLocation, err := GetIncoming(repoRoot, suite)
if err != nil {
return false, err
}
dsc, err := control.ParseDscFile(dscFile)
if err != nil {
return false, err
}
source := dsc.Source
version := dsc.Version
cmd, err := SbuildCommand(suite, suite, arch, dscFile, repoRoot, verbose)
if err != nil {
return false, err
}
err = cmd.Run()
ftbfs := err != nil
changesFile := helpers.Filename(source, version, arch, "changes")
logPath := helpers.Filename(source, version, arch, "build")
if ftbfs {
return true, nil
// fmt.Printf(" FTBFS!\n")
// return
// changes, err := helpers.LogChangesFromDsc(logPath, dscFile, suite, arch)
// if err != nil {
// panic(err)
// }
// fd, err := os.Create(changesFile)
// if err != nil {
// panic(err)
// }
// defer fd.Close()
// _, err = fd.Write([]byte(changes))
// if err != nil {
// panic(err)
// }
} else {
helpers.AppendLogToChanges(logPath, changesFile, arch)
}
if IsArchAllArch(repoRoot, arch) && dsc.HasArchAll() {
archAllLogPath := helpers.Filename(source, version, "all", "build")
Copy(logPath, archAllLogPath)
helpers.AppendLogToChanges(archAllLogPath, changesFile, "all")
}
changes, err := control.ParseChangesFile(changesFile)
if err != nil {
return ftbfs, err
}
err = changes.Copy(incomingLocation)
if err != nil {
return ftbfs, err
}
return ftbfs, nil
}