--- Portfile.orig	2012-07-22 01:54:56.000000000 -0700
+++ Portfile	2012-07-22 03:24:29.000000000 -0700
@@ -1,11 +1,11 @@
-# $Id: Portfile 95777 2012-07-22 08:52:35Z ryandesign@macports.org $
+# $Id: Portfile 86679 2011-10-31 18:47:38Z singingwolfboy@macports.org $
 
 PortSystem          1.0
 
 name                go
-epoch               1
-version             60.3
-revision            1
+conflicts           go-devel
+epoch               2
+version             1.0.2
 categories          lang
 platforms           darwin freebsd linux
 license             BSD
@@ -25,8 +25,8 @@
 
 homepage            http://golang.org/
 fetch.type          hg
-hg.url              https://go.googlecode.com/hg/
-hg.tag              release.r${version}
+hg.url              https://code.google.com/p/go
+hg.tag              ${name}${version}
 
 depends_build       bin:bison:bison \
                     bin:make:gmake \
@@ -34,7 +34,8 @@
                     bin:ed:ed
 
 set GOROOT          ${worksrcpath}
-set GOBIN           ${workpath}/bin
+set GOBIN           ${GOROOT}/bin
+set GOSRCDIR        lib/${name}${version}
 
 switch ${build_arch} {
     i386 {
@@ -68,54 +69,42 @@
 build.cmd           ./make.bash
 build.target    
 build.env           GOROOT=${GOROOT} GOBIN=${GOBIN} GOARCH=${GOARCH} \
-                    GOROOT_FINAL=${prefix}
+                    GOROOT_FINAL=${prefix}/${GOSRCDIR}
 use_parallel_build  no
 post-build {
     # remove mercurial extras
-    system "find ${worksrcpath} -type d -name .hg -print0 | xargs -0 rm -rf"
+    system "find ${worksrcpath} -type d -name '.hg*' -delete"
 }
 
 test.run            yes
 test.dir            ${worksrcpath}/src
 test.cmd            ./run.bash
 test.target 
-test.env            ${build.env}
+test.env            ${build.env} \
+                    PATH=${GOBIN}:${prefix}/bin:/bin:/usr/bin
 
 destroot {
-    # bin files
-    file delete ${destroot}${prefix}/bin
-    file copy ${GOBIN} ${destroot}${prefix}
-    # on Darwin, have to install and setgid; see ${GOROOT}/src/sudo.bash 
-    foreach i {prof cov} { 
-        xinstall -g procmod -m 2755 ${worksrcpath}/src/cmd/$i/${cmd_prefix}$i \
-            ${destroot}${prefix}/bin
-    } 
-        
-    # lib files
-    file delete -force ${destroot}${prefix}/lib
-    file copy ${worksrcpath}/lib ${destroot}${prefix}
-    
-    # compiled packages: violates mtree
-    file copy ${worksrcpath}/pkg ${destroot}${prefix}
+    # bin/pkg/src
+    file copy ${worksrcpath}/ ${destroot}${prefix}/${GOSRCDIR}
 
+    # bin symlinks
+    xinstall -m 755 -d ${destroot}${prefix}/bin
+    foreach f [glob -tails -directory ${destroot}${prefix}/${GOSRCDIR}/bin *] {
+        ln -s ../${GOSRCDIR}/bin/${f} ${destroot}${prefix}/bin
+    }
+    
     # do not install include files: see #30203
     
     # documentation
-    xinstall -m 755 -d ${destroot}${prefix}/share/doc/
-    file copy ${worksrcpath}/doc ${destroot}${prefix}/share/doc/${name}
+    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}${version}
+    file copy ${worksrcpath}/doc \
+        ${destroot}${prefix}/share/doc/${name}${version}
     xinstall -m 644 -W ${worksrcpath} favicon.ico \
-        ${destroot}${prefix}/share/doc/${name}/${name}.ico
-    # godoc command required documentation 
-    xinstall -m 755 -d ${destroot}${prefix}/src/go 
-    file copy ${worksrcpath} ${destroot}${prefix}/src/go 
-    system "cd ${destroot}${prefix}/src/${name}/${name}-${version}/src && ./clean.bash" 
-    file delete ${destroot}${prefix}/src/${name}/${name}-${version}/bin 
-    file delete ${destroot}${prefix}/src/${name}/${name}-${version}/pkg 
-    ln -s ${prefix}/src/${name}/${name}-${version}/src/pkg ${destroot}${prefix}/src/pkg 
-    # gomake command required makefiles 
-    foreach f [glob -tails -directory ${destroot}${prefix}/src/${name}/${name}-${version}/src/ Make.*] {
-        ln -s ${name}/${name}-${version}/src/${f} ${destroot}${prefix}/src
-    }
+        ${destroot}${prefix}/share/doc/${name}${version}/${name}.ico
+
+    # misc.
+    xinstall -m 755 -d ${destroot}${prefix}/share/${name}${version}
+    file copy ${worksrcpath}/misc ${destroot}${prefix}/share/${name}${version}
 
     # bash completion
     xinstall -m 755 -d ${destroot}${prefix}/etc/bash_completion.d
@@ -137,7 +126,6 @@
     xinstall -m 644 ${worksrcpath}/misc/vim/ftplugin/go/import.vim \
         ${vimdir}/ftplugin/go.vim
 }
-destroot.violate_mtree     yes
 
 platform darwin {
     build.env-append GOOS=darwin
@@ -154,4 +142,4 @@
 
 livecheck.type      regex
 livecheck.url       http://code.google.com/p/go/source/browse
-livecheck.regex     {>release\.r([0-9.]+)<}
+livecheck.regex     {>go(1\.[0-9.]+)<}
