1
0
mirror of https://github.com/golang/go synced 2024-11-21 21:04:41 -07:00

cmd/dist: fix pprof permissions

When installing pprof into the tools directory, it needs to
have execute permissions on unix-like systems.

Fixes issues 3077.

R=golang-dev, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/5675095
This commit is contained in:
Bobby Powers 2012-02-21 16:49:30 -05:00 committed by Russ Cox
parent 2110fadd12
commit d36426995a
7 changed files with 31 additions and 26 deletions

2
src/cmd/dist/a.h vendored
View File

@ -120,7 +120,7 @@ void runv(Buf *b, char *dir, int mode, Vec *argv);
void bgrunv(char *dir, int mode, Vec *argv); void bgrunv(char *dir, int mode, Vec *argv);
void bgwait(void); void bgwait(void);
bool streq(char*, char*); bool streq(char*, char*);
void writefile(Buf*, char*); void writefile(Buf*, char*, int);
void xatexit(void (*f)(void)); void xatexit(void (*f)(void));
void xexit(int); void xexit(int);
void xfree(void*); void xfree(void*);

24
src/cmd/dist/build.c vendored
View File

@ -27,7 +27,7 @@ char *slash; // / for unix, \ for windows
bool rebuildall = 0; bool rebuildall = 0;
static bool shouldbuild(char*, char*); static bool shouldbuild(char*, char*);
static void copy(char*, char*); static void copy(char*, char*, int);
static char *findgoversion(void); static char *findgoversion(void);
// The known architecture letters. // The known architecture letters.
@ -245,7 +245,7 @@ findgoversion(void)
bwriteb(&b, &bmore); bwriteb(&b, &bmore);
// Cache version. // Cache version.
writefile(&b, bstr(&path)); writefile(&b, bstr(&path), 0);
done: done:
p = btake(&b); p = btake(&b);
@ -567,7 +567,7 @@ install(char *dir)
// For misc/prof, copy into the tool directory and we're done. // For misc/prof, copy into the tool directory and we're done.
if(hasprefix(dir, "misc/")) { if(hasprefix(dir, "misc/")) {
copy(bpathf(&b, "%s/%s", tooldir, name), copy(bpathf(&b, "%s/%s", tooldir, name),
bpathf(&b1, "%s/misc/%s", goroot, name)); bpathf(&b1, "%s/misc/%s", goroot, name), 1);
goto out; goto out;
} }
@ -750,13 +750,13 @@ install(char *dir)
// For package runtime, copy some files into the work space. // For package runtime, copy some files into the work space.
if(streq(dir, "pkg/runtime")) { if(streq(dir, "pkg/runtime")) {
copy(bpathf(&b, "%s/arch_GOARCH.h", workdir), copy(bpathf(&b, "%s/arch_GOARCH.h", workdir),
bpathf(&b1, "%s/arch_%s.h", bstr(&path), goarch)); bpathf(&b1, "%s/arch_%s.h", bstr(&path), goarch), 0);
copy(bpathf(&b, "%s/defs_GOOS_GOARCH.h", workdir), copy(bpathf(&b, "%s/defs_GOOS_GOARCH.h", workdir),
bpathf(&b1, "%s/defs_%s_%s.h", bstr(&path), goos, goarch)); bpathf(&b1, "%s/defs_%s_%s.h", bstr(&path), goos, goarch), 0);
copy(bpathf(&b, "%s/os_GOOS.h", workdir), copy(bpathf(&b, "%s/os_GOOS.h", workdir),
bpathf(&b1, "%s/os_%s.h", bstr(&path), goos)); bpathf(&b1, "%s/os_%s.h", bstr(&path), goos), 0);
copy(bpathf(&b, "%s/signals_GOOS.h", workdir), copy(bpathf(&b, "%s/signals_GOOS.h", workdir),
bpathf(&b1, "%s/signals_%s.h", bstr(&path), goos)); bpathf(&b1, "%s/signals_%s.h", bstr(&path), goos), 0);
} }
// Generate any missing files; regenerate existing ones. // Generate any missing files; regenerate existing ones.
@ -789,7 +789,7 @@ install(char *dir)
// This one is generated. // This one is generated.
if(streq(dir, "pkg/runtime")) { if(streq(dir, "pkg/runtime")) {
copy(bpathf(&b, "%s/zasm_GOOS_GOARCH.h", workdir), copy(bpathf(&b, "%s/zasm_GOOS_GOARCH.h", workdir),
bpathf(&b1, "%s/zasm_%s_%s.h", bstr(&path), goos, goarch)); bpathf(&b1, "%s/zasm_%s_%s.h", bstr(&path), goos, goarch), 0);
} }
// Generate .c files from .goc files. // Generate .c files from .goc files.
@ -935,9 +935,9 @@ nobuild:
// for use by cgo compilation. // for use by cgo compilation.
if(streq(dir, "pkg/runtime")) { if(streq(dir, "pkg/runtime")) {
copy(bpathf(&b, "%s/pkg/%s_%s/cgocall.h", goroot, goos, goarch), copy(bpathf(&b, "%s/pkg/%s_%s/cgocall.h", goroot, goos, goarch),
bpathf(&b1, "%s/src/pkg/runtime/cgocall.h", goroot)); bpathf(&b1, "%s/src/pkg/runtime/cgocall.h", goroot), 0);
copy(bpathf(&b, "%s/pkg/%s_%s/runtime.h", goroot, goos, goarch), copy(bpathf(&b, "%s/pkg/%s_%s/runtime.h", goroot, goos, goarch),
bpathf(&b1, "%s/src/pkg/runtime/runtime.h", goroot)); bpathf(&b1, "%s/src/pkg/runtime/runtime.h", goroot), 0);
} }
@ -1051,7 +1051,7 @@ out:
// copy copies the file src to dst, via memory (so only good for small files). // copy copies the file src to dst, via memory (so only good for small files).
static void static void
copy(char *dst, char *src) copy(char *dst, char *src, int exec)
{ {
Buf b; Buf b;
@ -1060,7 +1060,7 @@ copy(char *dst, char *src)
binit(&b); binit(&b);
readfile(&b, src); readfile(&b, src);
writefile(&b, dst); writefile(&b, dst, exec);
bfree(&b); bfree(&b);
} }

View File

@ -55,7 +55,7 @@ gcopnames(char *dir, char *file)
bwritestr(&out, bprintf(&b, "};\n")); bwritestr(&out, bprintf(&b, "};\n"));
writefile(&out, file); writefile(&out, file, 0);
bfree(&in); bfree(&in);
bfree(&b); bfree(&b);
@ -97,7 +97,7 @@ mkenam(char *dir, char *file)
} }
} }
bwritestr(&out, "};\n"); bwritestr(&out, "};\n");
writefile(&out, file); writefile(&out, file, 0);
bfree(&b); bfree(&b);
bfree(&in); bfree(&in);

View File

@ -31,7 +31,7 @@ mkzversion(char *dir, char *file)
"const defaultGoroot = `%s`\n" "const defaultGoroot = `%s`\n"
"const theVersion = `%s`\n", goroot_final, goversion)); "const theVersion = `%s`\n", goroot_final, goversion));
writefile(&out, file); writefile(&out, file, 0);
bfree(&b); bfree(&b);
bfree(&out); bfree(&out);
@ -57,7 +57,7 @@ mkzgoarch(char *dir, char *file)
"\n" "\n"
"const theGoarch = `%s`\n", goarch)); "const theGoarch = `%s`\n", goarch));
writefile(&out, file); writefile(&out, file, 0);
bfree(&b); bfree(&b);
bfree(&out); bfree(&out);
@ -83,7 +83,7 @@ mkzgoos(char *dir, char *file)
"\n" "\n"
"const theGoos = `%s`\n", goos)); "const theGoos = `%s`\n", goos));
writefile(&out, file); writefile(&out, file, 0);
bfree(&b); bfree(&b);
bfree(&out); bfree(&out);
@ -235,8 +235,8 @@ ok:
} }
// Write both to file and to workdir/zasm_GOOS_GOARCH.h. // Write both to file and to workdir/zasm_GOOS_GOARCH.h.
writefile(&out, file); writefile(&out, file, 0);
writefile(&out, bprintf(&b, "%s/zasm_GOOS_GOARCH.h", workdir)); writefile(&out, bprintf(&b, "%s/zasm_GOOS_GOARCH.h", workdir), 0);
bfree(&in); bfree(&in);
bfree(&b); bfree(&b);
@ -334,7 +334,7 @@ mkzruntimedefs(char *dir, char *file)
bwritestr(&out, p); bwritestr(&out, p);
} }
writefile(&out, file); writefile(&out, file, 0);
bfree(&in); bfree(&in);
bfree(&b); bfree(&b);

View File

@ -731,5 +731,5 @@ goc2c(char *goc, char *c)
process_file(); process_file();
writefile(&out, c); writefile(&out, c, 0);
} }

9
src/cmd/dist/unix.c vendored
View File

@ -351,9 +351,10 @@ readfile(Buf *b, char *file)
close(fd); close(fd);
} }
// writefile writes b to the named file, creating it if needed. // writefile writes b to the named file, creating it if needed. if
// exec is non-zero, marks the file as executable.
void void
writefile(Buf *b, char *file) writefile(Buf *b, char *file, int exec)
{ {
int fd; int fd;
@ -362,9 +363,11 @@ writefile(Buf *b, char *file)
fatal("create %s: %s", file, strerror(errno)); fatal("create %s: %s", file, strerror(errno));
if(write(fd, b->p, b->len) != b->len) if(write(fd, b->p, b->len) != b->len)
fatal("short write: %s", strerror(errno)); fatal("short write: %s", strerror(errno));
if(exec)
fchmod(fd, 0755);
close(fd); close(fd);
} }
// xmkdir creates the directory p. // xmkdir creates the directory p.
void void
xmkdir(char *p) xmkdir(char *p)

View File

@ -539,12 +539,14 @@ readfile(Buf *b, char *file)
} }
void void
writefile(Buf *b, char *file) writefile(Buf *b, char *file, int exec)
{ {
HANDLE h; HANDLE h;
Rune *r; Rune *r;
DWORD n; DWORD n;
USED(exec);
if(vflag > 2) if(vflag > 2)
xprintf("write %s\n", file); xprintf("write %s\n", file);
torune(&r, file); torune(&r, file);