---- golang-1.4.2/src/crypto/x509/root_unix.go~ 2015-05-21 11:15:20.000000000 +0300
-+++ golang-1.4.2/src/crypto/x509/root_unix.go 2015-05-21 11:15:26.427510756 +0300
-@@ -10,6 +10,7 @@
-
- // Possible certificate files; stop after finding one.
- var certFiles = []string{
-+ "/etc/certs/ca-certificates.crt", // PLD Linux
- "/etc/ssl/certs/ca-certificates.crt", // Debian/Ubuntu/Gentoo etc.
- "/etc/pki/tls/certs/ca-bundle.crt", // Fedora/RHEL
- "/etc/ssl/ca-bundle.pem", // OpenSUSE
+--- golang-1.6/src/crypto/x509/root_unix.go~ 2016-02-17 22:35:21.000000000 +0200
++++ golang-1.6/src/crypto/x509/root_unix.go 2016-04-05 13:04:44.231441583 +0300
+@@ -11,6 +11,7 @@
+ // Possible directories with certificate files; stop after successfully
+ // reading at least one file from a directory.
+ var certDirectories = []string{
++ "/etc/openssl/certs", // PLD Linux
+ "/etc/ssl/certs", // SLES10/SLES11, https://golang.org/issue/12139
+ "/system/etc/security/cacerts", // Android
+ }
--- /dev/null
+# we had been just removing the zoneinfo.zip, but that caused tests to fail for users that
+# later run `go test -a std`. This makes it only use the zoneinfo.zip where needed in tests.
+diff --git a/src/time/zoneinfo_unix.go b/src/time/zoneinfo_unix.go
+index ed9502d..c2569e7 100644
+--- a/src/time/zoneinfo_unix.go
++++ b/src/time/zoneinfo_unix.go
+@@ -32,14 +32,14 @@ var zoneDirs = []string{
+ "/usr/share/zoneinfo/",
+ "/usr/share/lib/zoneinfo/",
+ "/usr/lib/locale/TZ/",
+- runtime.GOROOT() + "/lib/time/zoneinfo.zip",
+ }
+
+ var origZoneDirs = zoneDirs
+
+ func forceZipFileForTesting(zipOnly bool) {
+- zoneDirs = make([]string, len(origZoneDirs))
++ zoneDirs = make([]string, len(origZoneDirs)+1)
+ copy(zoneDirs, origZoneDirs)
++ zoneDirs = append(zoneDirs, runtime.GOROOT()+"/lib/time/zoneinfo.zip")
+ if zipOnly {
+ for i := 0; i < len(zoneDirs)-1; i++ {
+ zoneDirs[i] = "/XXXNOEXIST"
# - check if hg use at build time can be dropped
# - build all target archs, subpackage them: http://golang.org/doc/install/source#environment
# - subpackage -src files?
+# - subpackage for "shared"?
# Conditional build:
-%bcond_without tests # build without tests [nop actually]
-%bcond_without verbose # verbose build (V=1)
+%bcond_without verbose # verbose build (V=1)
+%bcond_without tests # build without tests [nop actually]
+%bcond_without shared # Build golang shared objects for stdlib
+%bcond_without ext_linker # Build golang using external/internal(close to cgo disabled) linking.
+
+%ifnarch %{ix86} %{x8664} %{arm} ppc64le aarch64
+%undefine with_shared
+%undefine with_ext_linker
+%endif
Summary: Go compiler and tools
Summary(pl.UTF-8): Kompilator języka Go i narzędzia
Name: golang
-Version: 1.4.3
-Release: 1
-License: BSD
+Version: 1.6
+Release: 0.2
+# source tree includes several copies of Mark.Twain-Tom.Sawyer.txt under Public Domain
+License: BSD and Public Domain
Group: Development/Languages
# Source0Download: https://golang.org/dl/
Source0: https://storage.googleapis.com/golang/go%{version}.src.tar.gz
-# Source0-md5: dfb604511115dd402a77a553a5923a04
+# Source0-md5: e67833ea37fbc002fbe38efe6c1bcd98
Patch0: ca-certs.patch
Patch1: %{name}-binutils.patch
+Patch2: %{name}-1.2-verbose-build.patch
+Patch3: mmap-cgo-stackalign.patch
+Patch4: go1.5beta1-disable-TestGdbPython.patch
+Patch5: go1.5-zoneinfo_testing_only.patch
URL: http://golang.org/
BuildRequires: bash
BuildRequires: rpm-pythonprov
+# The compiler is written in Go. Needs go(1.4+) compiler for build.
+%if %{with bootstrap}
+BuildRequires: gcc-go >= 6:5
+%else
+BuildRequires: golang >= 1.4
+%endif
%if %{with tests}
+BuildRequires: glibc-static
BuildRequires: hostname
+BuildRequires: pcre-devel
BuildRequires: tzdata
%endif
Requires: ca-certificates
%define _enable_debug_packages 0
%define _noautoreqfiles %{_libdir}/%{name}/src
+%define goroot %{_libdir}/%{name}
+
%ifarch %{ix86}
%define GOARCH 386
%endif
%setup -qc
mv go/* .
%patch0 -p1
-%patch1 -p1
+#%patch1 -p1 seems outdated, compiler rewritten in .go instead of .c
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
cat > env.sh <<'EOF'
-export GOROOT=$(pwd)
-export GOROOT_FINAL=%{_libdir}/%{name}
+# bootstrap compiler GOROOT
+%if %{with bootstrap}
+export GOROOT_BOOTSTRAP=%{_prefix}
+%else
+export GOROOT_BOOTSTRAP=%{goroot}
+%endif
+export GOROOT_FINAL=%{goroot}
+
+export GOHOSTOS=linux
+export GOHOSTARCH=%{GOARCH}
export GOOS=linux
-export GOBIN=$GOROOT/bin
export GOARCH=%{GOARCH}
-export GOROOT_FINAL
-export MAKE="%{__make}"
+%if %{without external_linker}
+export GO_LDFLAGS="-linkmode internal"
+%endif
+%if %{without cgo_enabled}
+export CGO_ENABLED=0
+%endif
+
+# use our gcc options for this build, but store gcc as default for compiler
+export CFLAGS="%{rpmcflags}"
+export LDFLAGS="%{rpmldflags}"
+
CC="%{__cc}"
export CC="${CC#ccache }"
-
-export PATH="$PATH:$GOBIN"
+export CC_FOR_TARGET="$CC"
EOF
-install -d bin
-
+%if 0
# optflags for go tools build
nflags="\"$(echo '%{rpmcflags}' | sed -e 's/^[ ]*//;s/[ ]*$//;s/[ ]\+/ /g' -e 's/ /\",\"/g')\""
%{__sed} -i -e "s/\"-O2\"/$nflags/" src/cmd/dist/build.c
# NOTE: optflags used in gcc calls from go compiler are in src/cmd/go/build.go
+%endif
%build
. ./env.sh
-
cd src
-./all.bash
+./make.bash --no-clean
+cd ..
+
+# build shared std lib
+%if %{with shared}
+GOROOT=$(pwd) PATH=$(pwd)/bin:$PATH go install -buildmode=shared std
+%endif
%install
rm -rf $RPM_BUILD_ROOT
-GOROOT=$RPM_BUILD_ROOT%{_libdir}/%{name}
+GOROOT=$RPM_BUILD_ROOT%{goroot}
install -d $GOROOT/{misc,lib,src}
install -d $RPM_BUILD_ROOT%{_bindir}
-cp -a pkg include lib bin src $GOROOT
+cp -a pkg lib bin src VERSION $GOROOT
cp -a misc/cgo $GOROOT/misc
+
# kill Win32 and Plan9 scripts
find $GOROOT -name '*.bat' -o -name '*.rc' | xargs %{__rm}
+# https://github.com/golang/go/issues/4749
+find $GOROOT/src | xargs touch -r $GOROOT/VERSION
+# and level out all the built archives
+touch $GOROOT/pkg
+find $GOROOT/pkg | xargs touch -r $GOROOT/pkg
+
ln -sf %{_libdir}/%{name}/bin/go $RPM_BUILD_ROOT%{_bindir}/go
ln -sf %{_libdir}/%{name}/bin/godoc $RPM_BUILD_ROOT%{_bindir}/godoc
ln -sf %{_libdir}/%{name}/bin/gofmt $RPM_BUILD_ROOT%{_bindir}/gofmt
%files
%defattr(644,root,root,755)
-%doc AUTHORS CONTRIBUTORS LICENSE README
+%doc AUTHORS CONTRIBUTORS LICENSE
%ifarch %{arm}
%attr(755,root,root) %{_bindir}/5a
%attr(755,root,root) %{_bindir}/5c
%attr(755,root,root) %{_bindir}/godoc
%attr(755,root,root) %{_bindir}/gofmt
%dir %{_libdir}/%{name}
+%{_libdir}/%{name}/VERSION
%dir %{_libdir}/%{name}/bin
%attr(755,root,root) %{_libdir}/%{name}/bin/*
-%{_libdir}/%{name}/include
%{_libdir}/%{name}/lib
%{_libdir}/%{name}/misc
%{_libdir}/%{name}/src
%dir %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}
%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/*
-%ifarch %{x8664}
+%{_libdir}/%{name}/pkg/bootstrap
+%{_libdir}/%{name}/pkg/include
+
+%if %{with shared}
+%{_libdir}/%{name}/pkg/linux_%{GOARCH}_dynlink
+%endif
+
+%if 0
+#ifarch %{x8664}
%dir %{_libdir}/%{name}/pkg/linux_%{GOARCH}_race
%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/*.a
%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/compress
--- /dev/null
+# Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1304591
+# https://github.com/golang/go/issues/14384
+From 315f4c70f123cfbf061d097543af555547acd9c7 Mon Sep 17 00:00:00 2001
+From: Shenghou Ma <minux@golang.org>
+Date: Thu, 18 Feb 2016 16:29:39 -0500
+Subject: [PATCH] runtime: use correct psABI SP alignment before calling libc
+ mmap
+
+Fixes #14384.
+
+Change-Id: Ib025cf2d20754b4c2db52f0a8a4717fd303371d6
+Reviewed-on: https://go-review.googlesource.com/19660
+Run-TryBot: Minux Ma <minux@golang.org>
+TryBot-Result: Gobot Gobot <gobot@golang.org>
+Reviewed-by: Ian Lance Taylor <iant@golang.org>
+Reviewed-by: Austin Clements <austin@google.com>
+---
+ src/runtime/sys_linux_amd64.s | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/src/runtime/sys_linux_amd64.s b/src/runtime/sys_linux_amd64.s
+index aed85cb..f407078 100644
+--- a/src/runtime/sys_linux_amd64.s
++++ b/src/runtime/sys_linux_amd64.s
+@@ -258,7 +258,7 @@ TEXT runtime·sysMmap(SB),NOSPLIT,$0
+
+ // Call the function stored in _cgo_mmap using the GCC calling convention.
+ // This must be called on the system stack.
+-TEXT runtime·callCgoMmap(SB),NOSPLIT,$0
++TEXT runtime·callCgoMmap(SB),NOSPLIT,$16
+ MOVQ addr+0(FP), DI
+ MOVQ n+8(FP), SI
+ MOVL prot+16(FP), DX
+@@ -266,7 +266,11 @@ TEXT runtime·callCgoMmap(SB),NOSPLIT,$0
+ MOVL fd+24(FP), R8
+ MOVL off+28(FP), R9
+ MOVQ _cgo_mmap(SB), AX
++ MOVQ SP, BX
++ ANDQ $~15, SP // alignment as per amd64 psABI
++ MOVQ BX, 0(SP)
+ CALL AX
++ MOVQ 0(SP), SP
+ MOVQ AX, ret+32(FP)
+ RET
+