| 29 |
29 |
| 30 type Repository struct { |
30 type Repository struct { |
| 31 Path string `xml:"path"` |
31 Path string `xml:"path"` |
| 32 BuildEnvs string `xml:"buildenvs"` |
32 BuildEnvs string `xml:"buildenvs"` |
| 33 Build []struct { |
33 Build []struct { |
| 34 IsPlatform string `xml:"isplatform,attr"` |
34 IsPlatform string `xml:"isplatform,attr"` |
| 35 NotPlatform string `xml:"not,attr"` |
35 NotPlatform string `xml:"not,attr"` |
| |
36 NotList []string |
| 36 Test []string `xml:"test"` |
37 Test []string `xml:"test"` |
| 37 Var []struct { |
38 Var []struct { |
| 38 Name string `xml:"name,attr"` |
39 Name string `xml:"name,attr"` |
| 39 Value string `xml:",chardata"` |
40 Value string `xml:",chardata"` |
| 40 } |
41 } |
| 57 config.BuildEnvMap = make(map[string]BuildEnv) |
58 config.BuildEnvMap = make(map[string]BuildEnv) |
| 58 for _, env := range config.BuildEnv { |
59 for _, env := range config.BuildEnv { |
| 59 config.BuildEnvMap[env.Name] = env |
60 config.BuildEnvMap[env.Name] = env |
| 60 } |
61 } |
| 61 |
62 |
| |
63 for ri := range config.Repository { |
| |
64 for bi := range config.Repository[ri].Build { |
| |
65 build := &config.Repository[ri].Build[bi] |
| |
66 build.NotList = strings.Split(build.NotPlatform, ",") |
| |
67 } |
| |
68 } |
| |
69 |
| 62 templateStr, err := os.ReadFile("build.template") |
70 templateStr, err := os.ReadFile("build.template") |
| 63 if err != nil { |
71 if err != nil { |
| 64 log.Fatal(err) |
72 log.Fatal(err) |
| 65 } |
73 } |
| 66 |
74 |
| 67 tpl, err := template.New("").Parse(string(templateStr)) |
75 funcs := template.FuncMap{ |
| |
76 "add": func(i int, n int) int { |
| |
77 return i + n |
| |
78 }, |
| |
79 "sub": func(i int, n int) int { |
| |
80 return i - n |
| |
81 }, |
| |
82 } |
| |
83 |
| |
84 tpl, err := template.New("").Funcs(funcs).Parse(string(templateStr)) |
| 68 if err != nil { |
85 if err != nil { |
| 69 log.Fatal(err) |
86 log.Fatal(err) |
| 70 } |
87 } |
| 71 |
88 |
| 72 err = os.Mkdir("tmp", 0755) |
89 err = os.Mkdir("tmp", 0755) |
| 203 // upload build.tar.gz |
220 // upload build.tar.gz |
| 204 // extract build.tar.gz on the buildenv host and run build.sh |
221 // extract build.tar.gz on the buildenv host and run build.sh |
| 205 |
222 |
| 206 // upload using scp |
223 // upload using scp |
| 207 cmd := exec.Command("scp", path.Join(tmp_dir, "build.tar.gz"), env.Host+":") |
224 cmd := exec.Command("scp", path.Join(tmp_dir, "build.tar.gz"), env.Host+":") |
| |
225 log.Print("scp: ", cmd.Args) |
| 208 if err := cmd.Run(); err != nil { |
226 if err := cmd.Run(); err != nil { |
| 209 log.Print("cannot copy build env to ", env.Host) |
227 log.Print("cannot copy build env to ", env.Host) |
| 210 continue |
228 continue |
| 211 } |
229 } |
| 212 |
230 |