SPECS/go/go-1.9.spec
f4d17450
 
 %global goroot          /usr/lib/golang
 %global gopath          %{_datadir}/gocode
f36af574
 %ifarch aarch64
 %global gohostarch      arm64
 %else
d452e62f
 %global gohostarch      amd64
f36af574
 %endif
f4d17450
 
 # rpmbuild magic to keep from having meta dependency on libc.so.6
 %define _use_internal_dependency_generator 0
 %define __find_requires %{nil}
 
1a02949f
 Summary:        Go
12e8bdd7
 Name:           go
4a7cd69f
 Version:        1.9.4
8f56b626
 Release:        3%{?dist}
12e8bdd7
 License:        BSD
1ad84d08
 URL:            https://golang.org
12e8bdd7
 Group:          System Environment/Security
 Vendor:         VMware, Inc.
 Distribution:   Photon
4a7cd69f
 Source0:        https://dl.google.com/go/%{name}%{version}.src.tar.gz
 %define sha1    go=12b0ecee83525cd594f4fbf30380d4832e06f189
12e8bdd7
 Patch0:         go_imports_fix.patch
0a8faca3
 Patch1:         CVE-2018-7187.patch
12e8bdd7
 Requires:       glibc
8f56b626
 # to avoid cyclic dependency use prebuilt publish go rpm
 %define ExtraBuildRequires go
d452e62f
 
f4d17450
 %description
1a02949f
 Go is an open source programming language that makes it easy to build simple, reliable, and efficient software
f4d17450
 
 %prep
 %setup -qn %{name}
1f089607
 %patch0 -p1
0a8faca3
 %patch1 -p1
d452e62f
 
f4d17450
 %build
 export GOHOSTOS=linux
 export GOHOSTARCH=%{gohostarch}
1f089607
 export GOROOT_BOOTSTRAP=%{goroot}
 
 export GOROOT="`pwd`"
 export GOPATH=%{gopath}
 export GOROOT_FINAL=%{_bindir}/go
1a02949f
 rm -f  %{gopath}/src/runtime/*.c
f4d17450
 pushd src
 ./make.bash --no-clean
 popd
d452e62f
 
f4d17450
 %install
 rm -rf %{buildroot}
 
 mkdir -p %{buildroot}%{_bindir}
 mkdir -p %{buildroot}%{goroot}
 
1f089607
 cp -R api bin doc favicon.ico lib pkg robots.txt src misc VERSION %{buildroot}%{goroot}
f4d17450
 
 # remove the unnecessary zoneinfo file (Go will always use the system one first)
 rm -rfv %{buildroot}%{goroot}/lib/time
 
 # remove the doc Makefile
 rm -rfv %{buildroot}%{goroot}/doc/Makefile
 
 # put binaries to bindir, linked to the arch we're building,
 # leave the arch independent pieces in %{goroot}
 mkdir -p %{buildroot}%{goroot}/bin/linux_%{gohostarch}
f36af574
 ln -sfv ../go %{buildroot}%{goroot}/bin/linux_%{gohostarch}/go
 ln -sfv ../gofmt %{buildroot}%{goroot}/bin/linux_%{gohostarch}/gofmt
 ln -sfv %{goroot}/bin/gofmt %{buildroot}%{_bindir}/gofmt
 ln -sfv %{goroot}/bin/go %{buildroot}%{_bindir}/go
f4d17450
 
 # ensure these exist and are owned
 mkdir -p %{buildroot}%{gopath}/src/github.com/
 mkdir -p %{buildroot}%{gopath}/src/bitbucket.org/
 mkdir -p %{buildroot}%{gopath}/src/code.google.com/
 mkdir -p %{buildroot}%{gopath}/src/code.google.com/p/
 
f36af574
 install -vdm755 %{buildroot}/etc/profile.d
f4d17450
 cat >> %{buildroot}/etc/profile.d/go-exports.sh <<- "EOF"
 export GOROOT=%{goroot}
 export GOPATH=%{_datadir}/gocode
 export GOHOSTOS=linux
 export GOHOSTARCH=%{gohostarch}
 export GOOS=linux
 EOF
f36af574
 #chown -R root:root %{buildroot}/etc/profile.d/go-exports.sh
f4d17450
 
 
f36af574
 #%{_fixperms} %{buildroot}/*
d452e62f
 
4963c78f
 %post -p /sbin/ldconfig
d452e62f
 
4963c78f
 %postun
 /sbin/ldconfig
e8230c68
 if [ $1 -eq 0 ]; then
d45b7400
   #This is uninstall
   rm /etc/profile.d/go-exports.sh
   rm -rf /opt/%{name}
   exit 0
 fi
d452e62f
 
f4d17450
 %clean
 rm -rf %{buildroot}/*
d452e62f
 
f4d17450
 %files
 %defattr(-,root,root)
 %exclude %{goroot}/src/*.rc
 %exclude %{goroot}/include/plan9
 /etc/profile.d/go-exports.sh
 %{goroot}/*
1f089607
 %{gopath}/src
925f444a
 %exclude %{goroot}/src/pkg/debug/dwarf/testdata
 %exclude %{goroot}/src/pkg/debug/elf/testdata
f4d17450
 %{_bindir}/*
d452e62f
 
f4d17450
 %changelog
8f56b626
 *   Wed Oct 24 2018 Alexey Makhalov <amakhalov@vmware.com> 1.9.4-3
 -   Use extra build requires
0a8faca3
 *   Mon Apr 02 2018 Dheeraj Shetty <dheerajs@vmware.com> 1.9.4-2
 -   Fix for CVE-2018-7187
4a7cd69f
 *   Thu Mar 15 2018 Xiaolin Li <xiaolinl@vmware.com> 1.9.4-1
 -   Update to golang release v1.9.4
f36af574
 *   Tue Nov 14 2017 Alexey Makhalov <amakhalov@vmware.com> 1.9.1-2
 -   Aarch64 support
e3e4eb64
 *   Wed Nov 01 2017 Vinay Kulkarni <kulkarniv@vmware.com> 1.9.1-1
 -   Update to golang release v1.9.1
c3c4f3f6
 *   Wed May 31 2017 Xiaolin Li <xiaolinl@vmware.com> 1.8.1-2
 -   Remove mercurial from buildrequires and requires.
1ad84d08
 *   Tue Apr 11 2017 Danut Moraru <dmoraru@vmware.com> 1.8.1-1
 -   Update Golang to version 1.8.1, updated patch0
12e8bdd7
 *   Wed Dec 28 2016 Xiaolin Li <xiaolinl@vmware.com> 1.7.4-1
 -   Updated Golang to 1.7.4.
 *   Thu Oct 06 2016 ChangLee <changlee@vmware.com> 1.6.3-2
 -   Modified %check
 *   Wed Jul 27 2016 Anish Swaminathan <anishs@vmware.com> 1.6.3-1
 -   Update Golang to version 1.6.3 - fixes CVE 2016-5386
 *   Fri Jul 8 2016 Harish Udaiya Kumar <hudaiyakumar@vmware.com> 1.6.2-1
 -   Updated the Golang to version 1.6.2
 *   Thu Jun 2 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 1.4.2-5
1a02949f
 -   Fix script syntax
12e8bdd7
 *   Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 1.4.2-4
 -   GA - Bump release of all rpms
 *   Thu May 05 2016 Kumar Kaushik <kaushikk@vmware.com> 1.4.2-3
 -   Handling upgrade scenario pre/post/un scripts.
 *   Wed Dec 09 2015 Anish Swaminathan <anishs@vmware.com> 1.4.2-2
 -   Edit post script.
 *   Mon Aug 03 2015 Vinay Kulkarni <kulkarniv@vmware.com> 1.4.2-1
 -   Update to golang release version 1.4.2
 *   Fri Oct 17 2014 Divya Thaluru <dthaluru@vmware.com> 1.3.3-1
 -   Initial build.  First version