Skip to content

Commit 8d2465a

Browse files
committed
go/misc/makerelease: pin go-tour repo to a specific revision
We're about to commit some wide-sweeping changes to the go-tour and I would rather not include them in Go 1.2.1, which is due in the next week or so. Also fix the makerelease tool; it has been broken since it was renamed from bindist. LGTM=campoy R=campoy CC=golang-codereviews https://golang.org/cl/68780043
1 parent ea34ca7 commit 8d2465a

File tree

1 file changed

+44
-29
lines changed

1 file changed

+44
-29
lines changed

misc/makerelease/makerelease.go

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ import (
3232
var (
3333
tag = flag.String("tag", "release", "mercurial tag to check out")
3434
toolTag = flag.String("tool", defaultToolTag, "go.tools tag to check out")
35+
tourTag = flag.String("tour", defaultTourTag, "go-tour tag to check out")
3536
repo = flag.String("repo", "https://code.google.com/p/go", "repo URL")
3637
verbose = flag.Bool("v", false, "verbose output")
37-
upload = flag.Bool("upload", true, "upload resulting files to Google Code")
38+
upload = flag.Bool("upload", false, "upload resulting files to Google Code")
3839
wxsFile = flag.String("wxs", "", "path to custom installer.wxs")
3940
addLabel = flag.String("label", "", "additional label to apply to file when uploading")
4041
includeRace = flag.Bool("race", true, "build race detector packages")
@@ -50,6 +51,7 @@ const (
5051
toolPath = "code.google.com/p/go.tools"
5152
tourPath = "code.google.com/p/go-tour"
5253
defaultToolTag = "release-branch.go1.2"
54+
defaultTourTag = "release-branch.go1.2"
5355
)
5456

5557
// Import paths for tool commands.
@@ -267,15 +269,7 @@ func (b *Build) Do() error {
267269
if err != nil {
268270
return err
269271
}
270-
err = b.tools()
271-
if err != nil {
272-
return err
273-
}
274-
err = b.blog()
275-
if err != nil {
276-
return err
277-
}
278-
err = b.tour()
272+
err = b.extras()
279273
}
280274
if err != nil {
281275
return err
@@ -286,13 +280,13 @@ func (b *Build) Do() error {
286280
version string // "weekly.2012-03-04"
287281
fullVersion []byte // "weekly.2012-03-04 9353aa1efdf3"
288282
)
289-
pat := filepath.Join(b.root, "pkg/tool/*/makerelease*") // trailing * for .exe
283+
pat := filepath.Join(b.root, "pkg/tool/*/dist*") // trailing * for .exe
290284
m, err := filepath.Glob(pat)
291285
if err != nil {
292286
return err
293287
}
294288
if len(m) == 0 {
295-
return fmt.Errorf("couldn't find makerelease in %q", pat)
289+
return fmt.Errorf("couldn't find dist in %q", pat)
296290
}
297291
fullVersion, err = b.run("", m[0], "version")
298292
if err != nil {
@@ -349,9 +343,11 @@ func (b *Build) Do() error {
349343
err = makeTar(targ, work)
350344
targs = append(targs, targ)
351345

346+
makerelease := filepath.Join(runtime.GOROOT(), "misc/makerelease")
347+
352348
// build pkg
353349
// arrange work so it's laid out as the dest filesystem
354-
etc := filepath.Join(b.root, "misc/makerelease/darwin/etc")
350+
etc := filepath.Join(makerelease, "darwin/etc")
355351
_, err = b.run(work, "cp", "-r", etc, ".")
356352
if err != nil {
357353
return err
@@ -371,7 +367,6 @@ func (b *Build) Do() error {
371367
return err
372368
}
373369
defer os.RemoveAll(pkgdest)
374-
makerelease := filepath.Join(runtime.GOROOT(), "misc/makerelease")
375370
_, err = b.run("", "pkgbuild",
376371
"--identifier", "com.googlecode.go",
377372
"--version", version,
@@ -460,26 +455,44 @@ func (b *Build) Do() error {
460455
return err
461456
}
462457

463-
func (b *Build) tools() error {
458+
// extras fetches the go.tools, go.blog, and go-tour repositories,
459+
// builds them and copies the resulting binaries and static assets
460+
// to the new GOROOT.
461+
func (b *Build) extras() error {
464462
defer b.cleanGopath()
465463

466-
// Fetch the tool packages (without building/installing).
467-
args := append([]string{"get", "-d"}, toolPaths...)
468-
_, err := b.run(b.gopath, filepath.Join(b.root, "bin", "go"), args...)
469-
if err != nil {
464+
if err := b.tools(); err != nil {
465+
return err
466+
}
467+
if err := b.blog(); err != nil {
470468
return err
471469
}
470+
return b.tour()
471+
}
472472

473-
// Update the repo to the revision specified by -tool.
474-
repoPath := filepath.Join(b.gopath, "src", filepath.FromSlash(toolPath))
475-
_, err = b.run(repoPath, "hg", "update", *toolTag)
473+
func (b *Build) get(repoPath, revision string) error {
474+
// Fetch the packages (without building/installing).
475+
_, err := b.run(b.gopath, filepath.Join(b.root, "bin", "go"),
476+
"get", "-d", repoPath+"/...")
476477
if err != nil {
477478
return err
478479
}
479480

481+
// Update the repo to the specified revision.
482+
p := filepath.Join(b.gopath, "src", filepath.FromSlash(repoPath))
483+
_, err = b.run(p, "hg", "update", revision)
484+
return err
485+
}
486+
487+
func (b *Build) tools() error {
488+
// Fetch the go.tools repository.
489+
if err := b.get(toolPath, *toolTag); err != nil {
490+
return err
491+
}
492+
480493
// Install tools.
481-
args = append([]string{"install"}, toolPaths...)
482-
_, err = b.run(b.gopath, filepath.Join(b.root, "bin", "go"), args...)
494+
args := append([]string{"install"}, toolPaths...)
495+
_, err := b.run(b.gopath, filepath.Join(b.root, "bin", "go"), args...)
483496
if err != nil {
484497
return err
485498
}
@@ -508,8 +521,6 @@ func (b *Build) tools() error {
508521
}
509522

510523
func (b *Build) blog() error {
511-
defer b.cleanGopath()
512-
513524
// Fetch the blog repository.
514525
_, err := b.run(b.gopath, filepath.Join(b.root, "bin", "go"), "get", "-d", blogPath+"/blog")
515526
if err != nil {
@@ -523,10 +534,14 @@ func (b *Build) blog() error {
523534
}
524535

525536
func (b *Build) tour() error {
526-
defer b.cleanGopath()
537+
// Fetch the go-tour repository.
538+
if err := b.get(tourPath, *tourTag); err != nil {
539+
return err
540+
}
527541

528-
// go get the gotour package.
529-
_, err := b.run(b.gopath, filepath.Join(b.root, "bin", "go"), "get", tourPath+"/gotour")
542+
// Build tour binary.
543+
_, err := b.run(b.gopath, filepath.Join(b.root, "bin", "go"),
544+
"install", tourPath+"/gotour")
530545
if err != nil {
531546
return err
532547
}

0 commit comments

Comments
 (0)