~john-koepi/ubuntu/trusty/golang/default

« back to all changes in this revision

Viewing changes to misc/dashboard/builder/main.go

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-08-03 17:04:59 UTC
  • mfrom: (14.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110803170459-wzd99m3567y80ila
Tags: 1:59-1
* Imported Upstream version 59
* Refresh patches to a new release
* Fix FTBFS on ARM (Closes: #634270)
* Update version.bash to work with Debian packaging and not hg
  repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
)
61
61
 
62
62
var (
63
 
        goroot        string
64
 
        releaseRegexp = regexp.MustCompile(`^(release|weekly)\.[0-9\-.]+`)
 
63
        goroot      string
 
64
        binaryTagRe = regexp.MustCompile(`^(release\.r|weekly\.)[0-9\-.]+`)
 
65
        releaseRe   = regexp.MustCompile(`^release\.r[0-9\-.]+`)
65
66
)
66
67
 
67
68
func main() {
161
162
        b := &Builder{name: builder}
162
163
 
163
164
        // get goos/goarch from builder string
164
 
        s := strings.Split(builder, "-", 3)
 
165
        s := strings.SplitN(builder, "-", 3)
165
166
        if len(s) >= 2 {
166
167
                b.goos, b.goarch = s[0], s[1]
167
168
        } else {
177
178
        if err != nil {
178
179
                return nil, fmt.Errorf("readKeys %s (%s): %s", b.name, fn, err)
179
180
        }
180
 
        v := strings.Split(string(c), "\n", -1)
 
181
        v := strings.Split(string(c), "\n")
181
182
        b.key = v[0]
182
183
        if len(v) >= 3 {
183
184
                b.codeUsername, b.codePassword = v[1], v[2]
200
201
                        log.Println("hg pull failed:", err)
201
202
                        continue
202
203
                }
203
 
                hash, tag, err := firstTag(releaseRegexp)
 
204
                hash, tag, err := firstTag(releaseRe)
204
205
                if err != nil {
205
206
                        log.Println(err)
206
207
                        continue
321
322
        }
322
323
 
323
324
        // if this is a release, create tgz and upload to google code
324
 
        releaseHash, release, err := firstTag(releaseRegexp)
 
325
        releaseHash, release, err := firstTag(binaryTagRe)
325
326
        if hash == releaseHash {
326
327
                // clean out build state
327
328
                err = run(b.envv(), srcDir, "./clean.bash", "--nopkg")
357
358
                "GOROOT_FINAL=/usr/local/go",
358
359
        }
359
360
        for _, k := range extraEnv {
360
 
                e = append(e, k+"="+os.Getenv(k))
 
361
                s, err := os.Getenverror(k)
 
362
                if err == nil {
 
363
                        e = append(e, k+"="+s)
 
364
                }
361
365
        }
362
366
        return e
363
367
}
368
372
                "GOOS":         b.goos,
369
373
                "GOARCH":       b.goarch,
370
374
                "GOROOT_FINAL": "/c/go",
 
375
                // TODO(brainman): remove once we find make that does not hang.
 
376
                "MAKEFLAGS": "-j1",
371
377
        }
372
378
        for _, name := range extraEnv {
373
 
                start[name] = os.Getenv(name)
 
379
                s, err := os.Getenverror(name)
 
380
                if err == nil {
 
381
                        start[name] = s
 
382
                }
374
383
        }
375
384
        skip := map[string]bool{
376
385
                "GOBIN":   true,
384
393
                skip[name] = true
385
394
        }
386
395
        for _, kv := range os.Environ() {
387
 
                s := strings.Split(kv, "=", 2)
 
396
                s := strings.SplitN(kv, "=", 2)
388
397
                name := strings.ToUpper(s[0])
389
398
                switch {
390
399
                case name == "":
583
592
        if s == "" {
584
593
                return "", fmt.Errorf("cannot find revision")
585
594
        }
586
 
        if len(s) != 20 {
 
595
        if len(s) != 40 {
587
596
                return "", fmt.Errorf("hg returned invalid hash " + s)
588
597
        }
589
598
        return s, nil
594
603
// firstTag returns the hash and tag of the most recent tag matching re.
595
604
func firstTag(re *regexp.Regexp) (hash string, tag string, err os.Error) {
596
605
        o, _, err := runLog(nil, "", goroot, "hg", "tags")
597
 
        for _, l := range strings.Split(o, "\n", -1) {
 
606
        for _, l := range strings.Split(o, "\n") {
598
607
                if l == "" {
599
608
                        continue
600
609
                }
607
616
                        continue
608
617
                }
609
618
                tag = s[1]
610
 
                hash, err = fullHash(s[3])
 
619
                hash, err = fullHash(s[2])
611
620
                return
612
621
        }
613
622
        err = os.NewError("no matching tag found")