Browse Source

golang-1.5.2-1

git-svn-id: http://trac.vinelinux.org/repos/projects/specs@9887 ec354946-7b23-47d6-9f5a-488ba84defc7
tomop 8 years ago
parent
commit
2431cb3910
1 changed files with 342 additions and 88 deletions
  1. 342 88
      g/golang/golang-vl.spec

+ 342 - 88
g/golang/golang-vl.spec

@@ -1,3 +1,10 @@
+# Define arches for PA and SA
+%global golang_arches   %{ix86} x86_64
+%global go_arches       %{golang_arches}
+
+# Where to set GOPATH for builds
+%global gopath          %{_datadir}/gocode
+
 # build ids are not currently generated:
 # https://code.google.com/p/go/issues/detail?id=5238
 #
@@ -10,64 +17,181 @@
 %global _binaries_in_noarch_packages_terminate_build 0
 
 # Do not check any files in doc or src for requires
-%global __requires_exclude_from ^(%{_datadir}|%{_libdir})/%{name}/(doc|src)/.*$
+#global __requires_exclude_from ^(%{_datadir}|/usr/lib)/%{name}/(doc|src)/.*$
 
 # Don't alter timestamps of especially the .a files (or else go will rebuild later)
 # Actually, don't strip at all since we are not even building debug packages and this corrupts the dwarf testdata
 %global __strip /bin/true
 
 # rpmbuild magic to keep from having meta dependency on libc.so.6
-%define _use_internal_dependency_generator 0
-%define __find_requires %{nil}
-%global debug_package %{nil}
-%global __spec_install_post /usr/lib/rpm/check-rpaths   /usr/lib/rpm/check-buildroot  \
+%global __requires_exclude_from ^.*$
+%global __spec_install_post /usr/lib/rpm/check-rpaths \
+  /usr/lib/rpm/check-buildroot \
   /usr/lib/rpm/brp-compress
 
+# Golang build options.
+
+# Buid golang using external/internal(close to cgo disabled) linking.
+%global external_linker 1
+
+# Build golang with cgo enabled/disabled(later equals more or less to internal linking).
+%global cgo_enabled 1
+
+# Use golang/gcc-go as bootstrap compiler
+%global golang_bootstrap 1
+
+# boostrap(with internal linking) using gcc-go fails due to bug in tests(https://github.com/golang/go/issues/12629)
+# make check not to fail due to it
+
+# Controls what ever we fails on failed tests
+%global fail_on_tests 1
+
+# TODO get more support for shared objects
+# Build golang shared objects for stdlib
+%ifarch x86_64
+%global shared 1
+%else
+%global shared 0
+%endif
+
+# Fedora GOROOT
+%global goroot          /usr/lib/%{name}
+
+%ifarch x86_64
+%global gohostarch  amd64
+%endif
+%ifarch %{ix86}
+%global gohostarch  386
+%endif
+
+%global go_api 1.5
+%global go_version 1.5.2
+
 Name:           golang
-Version:        1.2
-Release:        2%{?_dist_release}
+Version:        %{go_version}
+Release:        1%{?_dist_release}
 Summary:        The Go Programming Language
 Summary(ja):    プログラミング言語 Go
-
-License:        BSD
+# source tree includes several copies of Mark.Twain-Tom.Sawyer.txt under Public Domain
+License:        BSD and Public Domain
 Group:          Development/Languages
 URL:            http://golang.org/
 
-Source0:        https://go.googlecode.com/files/go%{version}.src.tar.gz
-Source100:      golang-gdbinit
-Source101:      golang-prelink.conf
+# pre-processed by source.sh to make Mark.Twain-Tom.Sawyer.txt free again
+Source0:        https://storage.googleapis.com/golang/go%{go_version}.src.tar.gz
+
+# original removed by source.sh, replace by version from golang master branch with license scrubbed
+Source1:        Mark.Twain-Tom.Sawyer.txt.bz2
+
+# The compiler is written in Go. Needs go(1.4+) compiler for build.
+BuildRequires:  golang > 1.4
+BuildRequires:  net-tools
+
+# for tests
+BuildRequires:  pcre-devel, glibc-static
+
+Provides:       go = %{version}-%{release}
+Requires:       %{name}-bin
+Requires:       %{name}-src = %{version}-%{release}
 
 Patch0:         golang-1.2-verbose-build.patch
+
 # https://bugzilla.redhat.com/show_bug.cgi?id=1038683
-Patch2:         golang-1.2-remove-ECC-p224.patch
-# disable flaky test for now
-# http://code.google.com/p/go/issues/detail?id=6522
-Patch3:         ./golang-1.2-skipCpuProfileTest.patch
+Patch1:         golang-1.2-remove-ECC-p224.patch
+# Accept x509 certs with negative serial
+# https://bugzilla.redhat.com/show_bug.cgi?id=1290543
+# https://github.com/golang/go/issues/8265
+Patch2:         bz1290543.patch
 
-BuildRoot:      %{_tmppath}/%{name}-%{version}-root
-# 'hostname' command
-BuildRequires:  net-tools
+# use the arch dependent path in the bootstrap
+Patch212:       golang-1.5-bootstrap-binary-path.patch
 
-# We strip the meta dependency, but go does require glibc.
-# This is an odd issue, still looking for a better fix.
-Requires:       glibc
+# disable TestGdbPython
+# https://github.com/golang/go/issues/11214
+Patch213:       go1.5beta1-disable-TestGdbPython.patch
+
+# disable  TestCloneNEWUSERAndRemapNoRootDisableSetgroups
+# this is not possible in the limitied build chroot
+Patch214:       go1.5beta2-disable-TestCloneNEWUSERAndRemapNoRootDisableSetgroups.patch
+
+# 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.
+Patch215:       ./go1.5-zoneinfo_testing_only.patch
+
+# https://bugzilla.redhat.com/show_bug.cgi?id=1271709
+Patch216:       ./golang-1.5.1-a3156aaa12.patch
 
-ExclusiveArch:  %{ix86} x86_64
+# These are the only RHEL/Fedora architectures that we compile this package for
+ExclusiveArch:  %{golang_arches}
+
+Source100:      golang-gdbinit
+Source101:      golang-prelink.conf
+Source102:      macros.golang
 
 %description
 %{summary}.
 
+%package       docs
+Summary:       Golang compiler docs
+Requires:      %{name} = %{version}-%{release}
+BuildArch:     noarch
+Obsoletes:     %{name}-docs < 1.1-4
+
+%description   docs
+%{summary}.
+
+%package       misc
+Summary:       Golang compiler miscellaneous sources
+Requires:      %{name} = %{version}-%{release}
+BuildArch:     noarch
+
+%description   misc
+%{summary}.
+
+%package       tests
+Summary:       Golang compiler tests for stdlib
+Requires:      %{name} = %{version}-%{release}
+BuildArch:     noarch
+
+%description   tests
+%{summary}.
+
+%package        src
+Summary:        Golang compiler source tree
+BuildArch:      noarch
+%description    src
+%{summary}
+
+%package        bin
+Summary:        Golang core compiler tools
+Requires:       go = %{version}-%{release}
+Requires(post): %{_sbindir}/update-alternatives
+Requires(postun): %{_sbindir}/update-alternatives
+
+# We strip the meta dependency, but go does require glibc.
+# This is an odd issue, still looking for a better fix.
+Requires:       glibc
+Requires:       gcc
+%description    bin
+%{summary}
 
 # Workaround old RPM bug of symlink-replaced-with-dir failure
 %pretrans -p <lua>
 for _,d in pairs({"api", "doc", "include", "lib", "src"}) do
-  path = "%{_libdir}/%{name}/" .. d
+  path = "%{goroot}/" .. d
   if posix.stat(path, "type") == "link" then
     os.remove(path)
     posix.mkdir(path)
   end
 end
 
+%if %{shared}
+%package        shared
+Summary:        Golang shared object libraries
+
+%description    shared
+%{summary}.
+%endif
 
 %prep
 %setup -q -n go
@@ -76,101 +200,207 @@ end
 %patch0 -p1
 
 # remove the P224 curve
+%patch1 -p1
+
 %patch2 -p1
 
-# skip flaky test
-%patch3 -p1
+# use the arch dependent path in the bootstrap
+%patch212 -p1
 
-# create a [dirty] gcc wrapper to allow us to build with our own flags
-# (dirty because it is spoofing 'gcc' since CC value is stored in the go tool)
-# TODO: remove this and just set CFLAGS/LDFLAGS once upstream supports it
-# https://code.google.com/p/go/issues/detail?id=6882
-mkdir -p zz
-echo -e "#!/bin/sh\n/usr/bin/gcc $RPM_OPT_FLAGS $RPM_LD_FLAGS \"\$@\"" > ./zz/gcc
-chmod +x ./zz/gcc
+# disable TestGdbPython
+%patch213 -p1
 
-%build
-# set up final install location
-export GOROOT_FINAL=%{_libdir}/%{name}
+# disable TestCloneNEWUSERAndRemapNoRootDisableSetgroups
+%patch214 -p1
 
-# TODO use the system linker to get the system link flags and build-id
-# when https://code.google.com/p/go/issues/detail?id=5221 is solved
-#export GO_LDFLAGS="-linkmode external -extldflags $RPM_LD_FLAGS"
+%patch216 -p1
 
-# build
-cd src
-# use our gcc wrapper
-PATH="$(pwd -P)/../zz:$PATH" CC="gcc" ./make.bash
-cd ..
+cp %{SOURCE1} "$(pwd)/src/compress/bzip2/testdata/Mark.Twain-Tom.Sawyer.txt.bz2"
 
-%check
-export GOROOT=$(pwd -P)
-export PATH="$PATH":"$GOROOT"/bin
-cd src
-# not using our 'gcc' since the CFLAGS fails crash_cgo_test.go due to unused variables
-# https://code.google.com/p/go/issues/detail?id=6883
-./run.bash --no-rebuild
-cd ..
+%build
+# bootstrap compiler GOROOT
+%if !%{golang_bootstrap}
+export GOROOT_BOOTSTRAP=/
+%else
+export GOROOT_BOOTSTRAP=%{goroot}
+%endif
 
+# set up final install location
+export GOROOT_FINAL=%{goroot}
+
+export GOHOSTOS=linux
+export GOHOSTARCH=%{gohostarch}
+
+pushd src
+# use our gcc options for this build, but store gcc as default for compiler
+export CFLAGS="$RPM_OPT_FLAGS"
+export LDFLAGS="$RPM_LD_FLAGS"
+export CC="gcc"
+export CC_FOR_TARGET="gcc"
+export GOOS=linux
+export GOARCH=%{gohostarch}
+%if !%{external_linker}
+export GO_LDFLAGS="-linkmode internal"
+%endif
+%if !%{cgo_enabled}
+export CGO_ENABLED=0
+%endif
+./make.bash --no-clean
+popd
+
+# build shared std lib
+%if %{shared}
+GOROOT=$(pwd) PATH=$(pwd)/bin:$PATH go install -buildmode=shared std
+%endif
 
 %install
 rm -rf $RPM_BUILD_ROOT
 
 # create the top level directories
 mkdir -p $RPM_BUILD_ROOT%{_bindir}
-mkdir -p $RPM_BUILD_ROOT%{_libdir}/%{name}
+mkdir -p $RPM_BUILD_ROOT%{goroot}
 
 # install everything into libdir (until symlink problems are fixed)
 # https://code.google.com/p/go/issues/detail?id=5830
-cp -av api bin doc favicon.ico include lib pkg robots.txt src \
-   $RPM_BUILD_ROOT%{_libdir}/%{name}
-
-# remove the unnecessary zoneinfo file (Go will always use the system one first)
-rm -rfv $RPM_BUILD_ROOT%{_libdir}/%{name}/lib/time
-
-# remove the doc Makefile
-rm -rfv $RPM_BUILD_ROOT%{_libdir}/%{name}/doc/Makefile
-
-# put binaries to bindir
-pushd $RPM_BUILD_ROOT%{_bindir}
-for z in $RPM_BUILD_ROOT%{_libdir}/%{name}/bin/*
-  do mv $RPM_BUILD_ROOT%{_libdir}/%{name}/bin/$(basename $z) .
-done
+cp -apv api bin doc favicon.ico lib pkg robots.txt src misc test VERSION \
+   $RPM_BUILD_ROOT%{goroot}
+
+# bz1099206
+find $RPM_BUILD_ROOT%{goroot}/src -exec touch -r $RPM_BUILD_ROOT%{goroot}/VERSION "{}" \;
+# and level out all the built archives
+touch $RPM_BUILD_ROOT%{goroot}/pkg
+find $RPM_BUILD_ROOT%{goroot}/pkg -exec touch -r $RPM_BUILD_ROOT%{goroot}/pkg "{}" \;
+# generate the spec file ownership of this source tree and packages
+cwd=$(pwd)
+src_list=$cwd/go-src.list
+pkg_list=$cwd/go-pkg.list
+shared_list=$cwd/go-shared.list
+misc_list=$cwd/go-misc.list
+docs_list=$cwd/go-docs.list
+tests_list=$cwd/go-tests.list
+rm -f $src_list $pkg_list $docs_list $misc_list $tests_list $shared_list
+touch $src_list $pkg_list $docs_list $misc_list $tests_list $shared_list
+pushd $RPM_BUILD_ROOT%{goroot}
+        find src/ -type d -a \( ! -name testdata -a ! -ipath '*/testdata/*' \) -printf '%%%dir %{goroot}/%p\n' >> $src_list
+        find src/ ! -type d -a \( ! -ipath '*/testdata/*' -a ! -name '*_test*.go' \) -printf '%{goroot}/%p\n' >> $src_list
+
+        find bin/ pkg/ -type d -a ! -path '*_dynlink/*' -printf '%%%dir %{goroot}/%p\n' >> $pkg_list
+        find bin/ pkg/ ! -type d -a ! -path '*_dynlink/*' -printf '%{goroot}/%p\n' >> $pkg_list
+
+        find doc/ -type d -printf '%%%dir %{goroot}/%p\n' >> $docs_list
+        find doc/ ! -type d -printf '%{goroot}/%p\n' >> $docs_list
+
+        find misc/ -type d -printf '%%%dir %{goroot}/%p\n' >> $misc_list
+        find misc/ ! -type d -printf '%{goroot}/%p\n' >> $misc_list
+
+%if %{shared}
+        find pkg/*_dynlink/ -type d -printf '%%%dir %{goroot}/%p\n' >> $shared_list
+        find pkg/*_dynlink/ ! -type d -printf '%{goroot}/%p\n' >> $shared_list
+%endif
+
+        find test/ -type d -printf '%%%dir %{goroot}/%p\n' >> $tests_list
+        find test/ ! -type d -printf '%{goroot}/%p\n' >> $tests_list
+        find src/ -type d -a \( -name testdata -o -ipath '*/testdata/*' \) -printf '%%%dir %{goroot}/%p\n' >> $tests_list
+        find src/ ! -type d -a \( -ipath '*/testdata/*' -o -name '*_test*.go' \)  -printf '%{goroot}/%p\n' >> $tests_list
+        # this is only the zoneinfo.zip
+        find lib/ -type d -printf '%%%dir %{goroot}/%p\n' >> $tests_list
+        find lib/ ! -type d -printf '%{goroot}/%p\n' >> $tests_list
 popd
 
-# misc/bash
-mkdir -p $RPM_BUILD_ROOT%{_datadir}/bash-completion/completions
-cp -av misc/bash/go $RPM_BUILD_ROOT%{_datadir}/bash-completion/completions
-for z in 8l 6l 5l 8g 6g 5g gofmt gccgo
-  do ln -s go $RPM_BUILD_ROOT%{_datadir}/bash-completion/completions/$z
-done
-
-# misc/zsh
-mkdir -p $RPM_BUILD_ROOT%{_datadir}/zsh/site-functions
-cp -av misc/zsh/go $RPM_BUILD_ROOT%{_datadir}/zsh/site-functions
+# remove the doc Makefile
+rm -rfv $RPM_BUILD_ROOT%{goroot}/doc/Makefile
+
+# put binaries to bindir, linked to the arch we're building,
+# leave the arch independent pieces in %{goroot}
+mkdir -p $RPM_BUILD_ROOT%{goroot}/bin/linux_%{gohostarch}
+ln -sf %{goroot}/bin/go $RPM_BUILD_ROOT%{goroot}/bin/linux_%{gohostarch}/go
+ln -sf %{goroot}/bin/gofmt $RPM_BUILD_ROOT%{goroot}/bin/linux_%{gohostarch}/gofmt
+
+# ensure these exist and are owned
+mkdir -p $RPM_BUILD_ROOT%{gopath}/src/github.com
+mkdir -p $RPM_BUILD_ROOT%{gopath}/src/bitbucket.org
+mkdir -p $RPM_BUILD_ROOT%{gopath}/src/code.google.com/p
+mkdir -p $RPM_BUILD_ROOT%{gopath}/src/golang.org/x
+
+# make sure these files exist and point to alternatives
+rm -f $RPM_BUILD_ROOT%{_bindir}/go
+ln -sf /etc/alternatives/go $RPM_BUILD_ROOT%{_bindir}/go
+rm -f $RPM_BUILD_ROOT%{_bindir}/gofmt
+ln -sf /etc/alternatives/gofmt $RPM_BUILD_ROOT%{_bindir}/gofmt
 
 # gdbinit
 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/gdbinit.d
-cp -av %{SOURCE100} $RPM_BUILD_ROOT%{_sysconfdir}/gdbinit.d/golang
+cp -av %{SOURCE100} $RPM_BUILD_ROOT%{_sysconfdir}/gdbinit.d/golang.gdb
 
 # prelink blacklist
 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/prelink.conf.d
 cp -av %{SOURCE101} $RPM_BUILD_ROOT%{_sysconfdir}/prelink.conf.d/golang.conf
 
+# rpm macros
+mkdir -p %{buildroot}
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rpm
+cp -av %{SOURCE102} $RPM_BUILD_ROOT%{_sysconfdir}/rpm/macros.golang
+
+
+%check
+export GOROOT=$(pwd -P)
+export PATH="$GOROOT"/bin:"$PATH"
+cd src
+
+export CC="gcc"
+export CFLAGS="$RPM_OPT_FLAGS"
+export LDFLAGS="$RPM_LD_FLAGS"
+%if !%{external_linker}
+export GO_LDFLAGS="-linkmode internal"
+%endif
+%if !%{cgo_enabled} || !%{external_linker}
+export CGO_ENABLED=0
+%endif
+%if %{fail_on_tests}
+./run.bash --no-rebuild -v -v -v -k
+%else
+./run.bash --no-rebuild -v -v -v -k || :
+%endif
+cd ..
+
+
+%post bin
+%{_sbindir}/update-alternatives --install %{_bindir}/go \
+        go %{goroot}/bin/go 90 \
+        --slave %{_bindir}/gofmt gofmt %{goroot}/bin/gofmt
+
+%preun bin
+if [ $1 = 0 ]; then
+        %{_sbindir}/update-alternatives --remove go %{goroot}/bin/go
+fi
+
 
 %files
-%doc AUTHORS CONTRIBUTORS LICENSE PATENTS VERSION
+%doc AUTHORS CONTRIBUTORS LICENSE PATENTS
+# VERSION has to be present in the GOROOT, for `go install std` to work
+%doc %{goroot}/VERSION
+%dir %{goroot}/doc
+%doc %{goroot}/doc/*
 
 # go files
-%{_libdir}/%{name}
-
-# binary executables
-%{_bindir}/go
-%{_bindir}/gofmt
+%dir %{goroot}
+%exclude %{goroot}/bin/
+%exclude %{goroot}/pkg/
+%exclude %{goroot}/src/
+%exclude %{goroot}/doc/
+%exclude %{goroot}/misc/
+%{goroot}/*
+
+# ensure directory ownership, so they are cleaned up if empty
+%dir %{gopath}
+%dir %{gopath}/src
+%dir %{gopath}/src/github.com/
+%dir %{gopath}/src/bitbucket.org/
+%dir %{gopath}/src/code.google.com/
+%dir %{gopath}/src/code.google.com/p/
+%dir %{gopath}/src/golang.org
+%dir %{gopath}/src/golang.org/x
 
-# autocomplete
-%{_datadir}/bash-completion
-%{_datadir}/zsh
 
 # gdbinit (for gdb debugging)
 %{_sysconfdir}/gdbinit.d
@@ -178,7 +408,31 @@ cp -av %{SOURCE101} $RPM_BUILD_ROOT%{_sysconfdir}/prelink.conf.d/golang.conf
 # prelink blacklist
 %{_sysconfdir}/prelink.conf.d
 
+%{_sysconfdir}/rpm/macros.golang
+
+%files -f go-src.list src
+
+%files -f go-docs.list docs
+
+%files -f go-misc.list misc
+
+%files -f go-tests.list tests
+
+%files -f go-pkg.list bin
+%{_bindir}/go
+%{_bindir}/gofmt
+
+%if %{shared}
+%files -f go-shared.list shared
+%endif
+
 %changelog
+* Mon Dec 21 2015 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.5.2-1
+- new upstream release.
+
+* Sun Mar  8 2015 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.4.2-1
+- new upstream release.
+
 * Mon Dec 15 2014 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 1.2-2
 - added Group tag
 
@@ -186,7 +440,7 @@ cp -av %{SOURCE101} $RPM_BUILD_ROOT%{_sysconfdir}/prelink.conf.d/golang.conf
 - initial build for Vine Linux
 - drop emacs and vim package
 
-* Thu Jan 24 2014 Vincent Batts <vbatts@redhat.com> 1.2-4
+* Fri Jan 24 2014 Vincent Batts <vbatts@redhat.com> 1.2-4
 - skip a flaky test that is sporadically failing on the build server
 
 * Thu Jan 16 2014 Vincent Batts <vbatts@redhat.com> 1.2-3