From dce2cfd4e4fceeb34e6ca0cfff1a3e50cb8aa7077c4f4f2ec66bbb062e7e2894 Mon Sep 17 00:00:00 2001 From: Marguerite Su Date: Thu, 18 Sep 2014 09:18:45 +0000 Subject: [PATCH] Accepting request 250058 from home:cbosdonnat:branches:devel:languages:go - Removed extra src folder in /usr/share/go/contrib: the goal is to transform this folder into a proper entry for GOPATH. This folder is now linked to %{_libdir}/go/contrib - go requires gcc to build sources using cgo - tools-packaging.patch: Allow building cover and vet tools in $GOROOT_TARGET/pkg/tool instead of $GOROOT/pkg/tool. This will allow building go tools as a separate package OBS-URL: https://build.opensuse.org/request/show/250058 OBS-URL: https://build.opensuse.org/package/show/devel:languages:go/go?expand=0&rev=194 --- go.changes | 11 +++++++++++ go.spec | 16 ++++++++++------ macros.go | 4 ++-- tools-packaging.patch | 19 +++++++++++++++++++ 4 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 tools-packaging.patch diff --git a/go.changes b/go.changes index 6c06beb..6a7df0d 100644 --- a/go.changes +++ b/go.changes @@ -1,3 +1,14 @@ +------------------------------------------------------------------- +Tue Sep 16 15:15:20 UTC 2014 - cbosdonnat@suse.com + +- Removed extra src folder in /usr/share/go/contrib: the goal is to + transform this folder into a proper entry for GOPATH. This folder + is now linked to %{_libdir}/go/contrib +- go requires gcc to build sources using cgo +- tools-packaging.patch: Allow building cover and vet tools in + $GOROOT_TARGET/pkg/tool instead of $GOROOT/pkg/tool. This will + allow building go tools as a separate package + ------------------------------------------------------------------- Tue Sep 9 14:56:06 UTC 2014 - i@marguerite.su diff --git a/go.spec b/go.spec index d5e50b1..a33a13e 100644 --- a/go.spec +++ b/go.spec @@ -28,7 +28,7 @@ Source0: http://golang.org/dl/go%{version}.src.tar.gz Source1: go-rpmlintrc Source2: go.sh Source3: macros.go -Source6: go-wiki-gadget.xml +Source4: go-wiki-gadget.xml Source5: README-openSUSE # PATCH-FIX-OPENSUSE add -s flag to 'go install' (don't rebuild/install std libs) Patch1: go-build-dont-reinstall-stdlibs.patch @@ -39,6 +39,8 @@ Patch2: allow-binary-only-packages.patch Patch3: verbose-build.patch # PATCH-FIX-OPENSUSE BNC#776058 Patch4: go-install-dont-reinstall-stdlibs.patch +# PATCH-FIX-OPENSUSE enable writing tools outside $GOROOT/pkg/tool for packaging +Patch5: tools-packaging.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: rpm %if 0%{?suse_version} >= 1210 @@ -53,6 +55,7 @@ Recommends: go-doc BuildRequires: rpm >= 4.11.1 %endif %endif +Requires: gcc Provides: go-devel = %{name}%{version} Provides: go-devel-static = %{name}%{version} Obsoletes: go-devel < %{name}%{version} @@ -95,6 +98,7 @@ Emacs syntax highlighting scheme for the Go programming language. %patch2 -p1 %patch3 -p1 %patch4 -p1 +%patch5 -p1 cp %{SOURCE5} . # setup go_arch (BSD-like scheme) @@ -146,13 +150,13 @@ install -Dm644 misc/vim/ftdetect/gofiletype.vim %{buildroot}%{_datadir}/vim/site # locations for third party libraries, see README-openSUSE for info about locations. install -d %{buildroot}%{_libdir}/go/contrib/pkg/linux_%{go_arch} -install -d %{buildroot}%{_datadir}/go/contrib/src/pkg -install -d %{buildroot}%{_datadir}/go/contrib/src/cmd +install -d %{buildroot}%{_libdir}/go/contrib/cmd +install -d %{buildroot}%{_libdir}/go/contrib/src install -Dm644 README-openSUSE %{buildroot}%{_libdir}/go/contrib/ -ln -s %{_libdir}/go/contrib/README-openSUSE %{buildroot}%{_datadir}/go/contrib/README-openSUSE +install -d %{buildroot}%{_datadir}/go +ln -s %{_libdir}/go/contrib/ %{buildroot}%{_datadir}/go/ # source files for go install, godoc, etc -install -d %{buildroot}%{_datadir}/go for ext in *.{go,c,h,s,S,py}; do find src -name ${ext} -exec install -Dm644 \{\} %{buildroot}%{_datadir}/go/\{\} \; done @@ -207,7 +211,7 @@ ln -s %{_datadir}/go/src/pkg/runtime/{cgocall,runtime}.h %{buildroot}%{_libdir}/ %endif %{_datadir}/go/ %{_bindir}/go* -%{_libdir}/go/ +%{_libdir}/go # bash completion seems broken #%%config %{_sysconfdir}/bash_completion.d/go.sh %config %{_sysconfdir}/profile.d/go.sh diff --git a/macros.go b/macros.go index 42ce5ed..0894f50 100644 --- a/macros.go +++ b/macros.go @@ -13,7 +13,7 @@ %go_sitedir %{_libdir}/go/pkg %go_sitearch %{_libdir}/go/pkg/linux_%{go_arch} %go_contribdir %{_libdir}/go/contrib/pkg/linux_%{go_arch} -%go_contribsrcdir %{_datadir}/go/contrib/src/pkg +%go_contribsrcdir %{_datadir}/go/contrib/src %go_tooldir %{_datadir}/go/pkg/tool/linux_%{go_arch} %go_exclusivearch \ @@ -181,4 +181,4 @@ Requires: %{-n:%{-n*}}%{!-n:%{name}} = %{version} \ %{-r:Requires: %{-r*}} \ %description %{-n:-n %{-n*}-}doc \ This package provides API, examples and documentation \ -for package %{name}. \ No newline at end of file +for package %{name}. diff --git a/tools-packaging.patch b/tools-packaging.patch new file mode 100644 index 0000000..03bb8c0 --- /dev/null +++ b/tools-packaging.patch @@ -0,0 +1,19 @@ +Index: go/src/cmd/go/pkg.go +=================================================================== +--- go.orig/src/cmd/go/pkg.go ++++ go/src/cmd/go/pkg.go +@@ -398,7 +398,13 @@ func (p *Package) load(stk *importStack, + if goTools[p.ImportPath] == toTool { + // This is for 'go tool'. + // Override all the usual logic and force it into the tool directory. +- p.target = filepath.Join(gorootPkg, "tool", full) ++ // If GOROOT_TARGET is set, then write to it for packaging purpose ++ gorootTarget := os.Getenv("GOROOT_TARGET") ++ if gorootTarget == "" { ++ p.target = filepath.Join(gorootPkg, "tool", full) ++ } else { ++ p.target = filepath.Join(gorootTarget, "pkg/tool", full) ++ } + } + if p.target != "" && buildContext.GOOS == "windows" { + p.target += ".exe"