]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: fix pprof permissions
authorBobby Powers <bobbypowers@gmail.com>
Tue, 21 Feb 2012 21:49:30 +0000 (16:49 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 21 Feb 2012 21:49:30 +0000 (16:49 -0500)
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

src/cmd/dist/a.h
src/cmd/dist/build.c
src/cmd/dist/buildgc.c
src/cmd/dist/buildruntime.c
src/cmd/dist/goc2c.c
src/cmd/dist/unix.c
src/cmd/dist/windows.c

index 3fbace3f6d23bc5c609a8b46c5ba84d866aa1ec7..c19b1f46855f9e3df4426fadaa39b73692cfd325 100644 (file)
@@ -120,7 +120,7 @@ void        runv(Buf *b, char *dir, int mode, Vec *argv);
 void   bgrunv(char *dir, int mode, Vec *argv);
 void   bgwait(void);
 bool   streq(char*, char*);
-void   writefile(Buf*, char*);
+void   writefile(Buf*, char*, int);
 void   xatexit(void (*f)(void));
 void   xexit(int);
 void   xfree(void*);
index 260a9df6c47ecbea3f91c293cbc9938264284572..7285b47bfa3947676aee703f8152fbe19ce71192 100644 (file)
@@ -27,7 +27,7 @@ char *slash;  // / for unix, \ for windows
 bool   rebuildall = 0;
 
 static bool shouldbuild(char*, char*);
-static void copy(char*, char*);
+static void copy(char*, char*, int);
 static char *findgoversion(void);
 
 // The known architecture letters.
@@ -245,7 +245,7 @@ findgoversion(void)
                bwriteb(&b, &bmore);
 
        // Cache version.
-       writefile(&b, bstr(&path));
+       writefile(&b, bstr(&path), 0);
 
 done:
        p = btake(&b);
@@ -567,7 +567,7 @@ install(char *dir)
        // For misc/prof, copy into the tool directory and we're done.
        if(hasprefix(dir, "misc/")) {
                copy(bpathf(&b, "%s/%s", tooldir, name),
-                       bpathf(&b1, "%s/misc/%s", goroot, name));
+                       bpathf(&b1, "%s/misc/%s", goroot, name), 1);
                goto out;
        }
 
@@ -750,13 +750,13 @@ install(char *dir)
        // For package runtime, copy some files into the work space.
        if(streq(dir, "pkg/runtime")) {
                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),
-                       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),
-                       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),
-                       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.
@@ -789,7 +789,7 @@ install(char *dir)
        // This one is generated.
        if(streq(dir, "pkg/runtime")) {
                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.
@@ -935,9 +935,9 @@ nobuild:
        // for use by cgo compilation.
        if(streq(dir, "pkg/runtime")) {
                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),
-                       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).
 static void
-copy(char *dst, char *src)
+copy(char *dst, char *src, int exec)
 {
        Buf b;
        
@@ -1060,7 +1060,7 @@ copy(char *dst, char *src)
 
        binit(&b);
        readfile(&b, src);
-       writefile(&b, dst);
+       writefile(&b, dst, exec);
        bfree(&b);
 }
 
index 1c1d4a1d4f3737d0b3171cf2256071cbd3df232f..da38760c6618b11c1766ac49e61c0429740c3c36 100644 (file)
@@ -55,7 +55,7 @@ gcopnames(char *dir, char *file)
        
        bwritestr(&out, bprintf(&b, "};\n"));
 
-       writefile(&out, file);
+       writefile(&out, file, 0);
 
        bfree(&in);
        bfree(&b);
@@ -97,7 +97,7 @@ mkenam(char *dir, char *file)
                }
        }
        bwritestr(&out, "};\n");
-       writefile(&out, file);
+       writefile(&out, file, 0);
 
        bfree(&b);
        bfree(&in);
index 03ebd345fd910a5b6fbadb2d95578de1409467bc..a0c62010d6fe1d86622eaa695146d832325ed331 100644 (file)
@@ -31,7 +31,7 @@ mkzversion(char *dir, char *file)
                "const defaultGoroot = `%s`\n"
                "const theVersion = `%s`\n", goroot_final, goversion));
 
-       writefile(&out, file);
+       writefile(&out, file, 0);
        
        bfree(&b);
        bfree(&out);
@@ -57,7 +57,7 @@ mkzgoarch(char *dir, char *file)
                "\n"
                "const theGoarch = `%s`\n", goarch));
 
-       writefile(&out, file);
+       writefile(&out, file, 0);
        
        bfree(&b);
        bfree(&out);
@@ -83,7 +83,7 @@ mkzgoos(char *dir, char *file)
                "\n"
                "const theGoos = `%s`\n", goos));
 
-       writefile(&out, file);
+       writefile(&out, file, 0);
        
        bfree(&b);
        bfree(&out);
@@ -235,8 +235,8 @@ ok:
        }
        
        // Write both to file and to workdir/zasm_GOOS_GOARCH.h.
-       writefile(&out, file);
-       writefile(&out, bprintf(&b, "%s/zasm_GOOS_GOARCH.h", workdir));
+       writefile(&out, file, 0);
+       writefile(&out, bprintf(&b, "%s/zasm_GOOS_GOARCH.h", workdir), 0);
 
        bfree(&in);
        bfree(&b);
@@ -334,7 +334,7 @@ mkzruntimedefs(char *dir, char *file)
                bwritestr(&out, p);
        }
        
-       writefile(&out, file);
+       writefile(&out, file, 0);
 
        bfree(&in);
        bfree(&b);
index 2443c30b10b3c18702f34034ba3a81add935a4f1..22f72f8b50d0d3e362f78be14db311d2356e3fcf 100644 (file)
@@ -731,5 +731,5 @@ goc2c(char *goc, char *c)
 
        process_file();
        
-       writefile(&out, c);
+       writefile(&out, c, 0);
 }
index 5aedbed18d1432f98937abbd48972242b74543e4..76622a4d886dd4757014ec1cf79c3f25abb3107f 100644 (file)
@@ -351,9 +351,10 @@ readfile(Buf *b, char *file)
        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
-writefile(Buf *b, char *file)
+writefile(Buf *b, char *file, int exec)
 {
        int fd;
        
@@ -362,9 +363,11 @@ writefile(Buf *b, char *file)
                fatal("create %s: %s", file, strerror(errno));
        if(write(fd, b->p, b->len) != b->len)
                fatal("short write: %s", strerror(errno));
+       if(exec)
+               fchmod(fd, 0755);
        close(fd);
 }
-       
+
 // xmkdir creates the directory p.
 void
 xmkdir(char *p)
index aa961eb6cf791118e8bc918f010c7568d509dba8..557e4b00311c4d0183c5b8a8ed4aec342d4367c6 100644 (file)
@@ -539,12 +539,14 @@ readfile(Buf *b, char *file)
 }
 
 void
-writefile(Buf *b, char *file)
+writefile(Buf *b, char *file, int exec)
 {
        HANDLE h;
        Rune *r;
        DWORD n;
 
+       USED(exec);
+
        if(vflag > 2)
                xprintf("write %s\n", file);
        torune(&r, file);