+# NOTE: build needs >128 processes limit
# TODO
# - allow disabling tests (currently bcond exists just for showing which are test deps)
# - add verbose build output (currently dummy bcond)
# - fix CC containing spaces (ccache)
# - check if hg use at build time can be dropped
# - build all target archs, subpackage them: http://golang.org/doc/install/source#environment
+# or choose only useful crosscompilers?
# - subpackage -src files?
-# - subpackage for "shared"?
# Conditional build:
%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.
-%bcond_without cgo
+%bcond_without ext_linker # Build golang using external/internal (close to cgo disabled) linking
+%bcond_without cgo # cgo (importing C libraries) support
+%bcond_with bootstrap # bootstrap build
-%ifnarch %{ix86} %{x8664} %{arm} ppc64le aarch64
+%ifnarch %{ix86} %{x8664} %{arm} aarch64 mips64 mips64le ppc64le
%undefine with_shared
%undefine with_ext_linker
%undefine with_cgo
Summary: Go compiler and tools
Summary(pl.UTF-8): Kompilator języka Go i narzędzia
Name: golang
-Version: 1.6.2
+Version: 1.18.8
Release: 1
# 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: d1b50fa98d9a71eeee829051411e6207
+# Source0-md5: 4da6e6a0f709a4fe9f5b1033a8439a09
Patch0: ca-certs.patch
-Patch1: %{name}-binutils.patch
-Patch2: %{name}-1.2-verbose-build.patch
-Patch4: go1.5beta1-disable-TestGdbPython.patch
-Patch5: go1.5-zoneinfo_testing_only.patch
-URL: http://golang.org/
+Patch1: 0001-Don-t-use-the-bundled-tzdata-at-runtime-except-for-t.patch
+URL: https://golang.org/
BuildRequires: bash
+BuildRequires: rpm-build >= 4.6
BuildRequires: rpm-pythonprov
# The compiler is written in Go. Needs go(1.4+) compiler for build.
%if %{with bootstrap}
BuildRequires: glibc-static
BuildRequires: hostname
BuildRequires: pcre-devel
+BuildRequires: rpmbuild(macros) >= 2.007
BuildRequires: tzdata
%endif
Requires: ca-certificates
Conflicts: gcc-go
-ExclusiveArch: %{ix86} %{x8664} %{arm}
+ExclusiveArch: %{ix86} %{x8664} %{armv5} %{armv6} %{armv7} aarch64 mips mipsel mips64 mips64el ppc64 ppc64le riscv64 s390x
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%define no_install_post_strip 1
%ifarch %{x8664}
%define GOARCH amd64
%endif
+%ifarch %{armv5}
+%define GOARCH arm
+%define GOARM 5
+%endif
+%ifarch %{armv6}
+%define GOARCH arm
+%define GOARM 6
+%endif
+%ifarch %{armv7}
+%define GOARCH arm
+%define GOARM 7
+%endif
+%ifarch aarch64
+%define GOARCH arm64
+%endif
+%ifarch mipsel
+%define GOARCH mipsle
+%endif
+%ifarch mips64el
+%define GOARCH mips64le
+%endif
+%ifarch mips mips64 ppc64 ppc64le riscv64 s390x
+%define GOARCH %{_arch}
+%endif
%description
Go is an open source programming environment that makes it easy to
%package shared
Summary: Golang shared object libraries
+Summary(pl.UTF-8): Biblioteki obiektów współdzielonych dla języka Go
Group: Libraries
Requires: %{name} = %{version}-%{release}
%description shared
-Golang shared object libraries
+Golang shared object libraries.
+
+%description shared -l pl.UTF-8
+Biblioteki obiektów współdzielonych dla języka Go.
%package doc
-Summary: Manual for go
-Summary(fr.UTF-8): Documentation pour go
-Summary(it.UTF-8): Documentazione di go
-Summary(pl.UTF-8): Podręcznik dla go
+Summary: Documentation for Go language
+Summary(fr.UTF-8): Documentation pour Go
+Summary(it.UTF-8): Documentazione di Go
+Summary(pl.UTF-8): Dokumentacja do języka Go
Group: Documentation
-%if "%{_rpmversion}" >= "5"
BuildArch: noarch
-%endif
%description doc
-Documentation for go.
+Documentation for Go language.
%description doc -l fr.UTF-8
-Documentation pour go.
+Documentation pour Go.
%description doc -l it.UTF-8
-Documentazione di go.
+Documentazione di Go.
%description doc -l pl.UTF-8
-Dokumentacja do go.
+Dokumentacja do języka Go.
%prep
%setup -qc
-mv go/* .
+%{__mv} go/* .
%patch0 -p1
-#%patch1 -p1 seems outdated, compiler rewritten in .go instead of .c
-%patch2 -p1
-%patch4 -p1
-%patch5 -p1
+%patch1 -p1
+
+# clean patch backups
+find . -name '*.orig' | xargs -r %{__rm}
cat > env.sh <<'EOF'
# bootstrap compiler GOROOT
export GOOS=linux
export GOARCH=%{GOARCH}
-%if %{without external_linker}
+%{?GOARM:export GOARM=%{GOARM}}
+%ifarch %{ix86}
+%ifarch %{x86_with_sse2}
+export GO386=sse2
+%else
+export GO386=softfloat
+%endif
+%endif
+%if %{without ext_linker}
export GO_LDFLAGS="-linkmode internal"
%endif
%if %{with cgo}
export CC_FOR_TARGET="$CC"
EOF
+grep -rl '#!.*env bash' . | xargs %{__sed} -i -e '1{
+ s,^#!.*bin/env bash,#!%{__bash},
+}'
+
%if 0
# optflags for go tools build
nflags="\"$(echo '%{rpmcflags}' | sed -e 's/^[ ]*//;s/[ ]*$//;s/[ ]\+/ /g' -e 's/ /\",\"/g')\""
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
-
ln -sf %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/cgo $RPM_BUILD_ROOT%{_bindir}/cgo
-ln -sf %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/ebnflint $RPM_BUILD_ROOT%{_bindir}/ebnflint
-%ifarch %{ix86}
-tools="8a 8c 8g 8l"
-%endif
-%ifarch %{x8664}
-tools="6a 6c 6g 6l"
-%endif
-%ifarch %{arm}
-tools="5a 5c 5g 5l"
-%endif
-for tool in $tools; do
- ln -sf %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/$tool $RPM_BUILD_ROOT%{_bindir}/$tool
-done
+# FIXME: do we need whole sources, including build scripts?
+# for now, remove only non-Linux stuff
+%{__rm} \
+ $RPM_BUILD_ROOT%{_libdir}/%{name}/src/syscall/{mksyscall,mksysctl_openbsd,mksysnum_{dragonfly,freebsd,netbsd,openbsd}}.pl
+# ...and tests
+%{__rm} -r $RPM_BUILD_ROOT%{_libdir}/%{name}/src/internal/trace \
+ $RPM_BUILD_ROOT%{_libdir}/%{name}/misc/cgo/{errors,fortran,test*}
+find $RPM_BUILD_ROOT%{_libdir}/%{name} -name testdata -prune | xargs %{__rm} -r
+
+# unenvize remaining scripts
+%{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/*.bash
+%{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/syscall/*.sh
+%{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/cmd/vendor/golang.org/x/sys/unix/*.sh
+%{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/cmd/go/*.sh
+%{__sed} -i -e '1s,/usr/bin/env perl,/usr/bin/perl,' $RPM_BUILD_ROOT%{_libdir}/%{name}/src/syscall/*.pl
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(644,root,root,755)
%doc AUTHORS CONTRIBUTORS LICENSE
-%ifarch %{arm}
-%attr(755,root,root) %{_bindir}/5a
-%attr(755,root,root) %{_bindir}/5c
-%attr(755,root,root) %{_bindir}/5g
-%attr(755,root,root) %{_bindir}/5l
-%endif
-%ifarch %{x8664}
-%attr(755,root,root) %{_bindir}/6a
-%attr(755,root,root) %{_bindir}/6c
-%attr(755,root,root) %{_bindir}/6g
-%attr(755,root,root) %{_bindir}/6l
-%endif
-%ifarch %{ix86}
-%attr(755,root,root) %{_bindir}/8a
-%attr(755,root,root) %{_bindir}/8c
-%attr(755,root,root) %{_bindir}/8g
-%attr(755,root,root) %{_bindir}/8l
-%endif
%attr(755,root,root) %{_bindir}/cgo
-%attr(755,root,root) %{_bindir}/ebnflint
%attr(755,root,root) %{_bindir}/go
-%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/*
+%attr(755,root,root) %{_libdir}/%{name}/bin/go
+%attr(755,root,root) %{_libdir}/%{name}/bin/gofmt
%{_libdir}/%{name}/lib
%{_libdir}/%{name}/misc
%{_libdir}/%{name}/pkg/obj
%dir %{_libdir}/%{name}/pkg/tool
%dir %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}
-%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/*
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/addr2line
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/api
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/asm
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/buildid
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/cgo
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/compile
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/cover
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/dist
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/doc
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/fix
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/link
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/nm
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/objdump
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/pack
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/pprof
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/test2json
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/trace
+%attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/vet
-%{_libdir}/%{name}/pkg/bootstrap
%{_libdir}/%{name}/pkg/include
-%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
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/container
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/crypto
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/debug
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/encoding
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/go
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/hash
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/internal
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/io
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/math
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/mime
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/net
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/os
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/path
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/regexp
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/runtime
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/sync
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/text
-%{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/unicode
-%endif
-
%if %{with shared}
%files shared
%defattr(644,root,root,755)