Accepting request 108350 from home:andtecheu:go:weekly
OBS-URL: https://build.opensuse.org/request/show/108350 OBS-URL: https://build.opensuse.org/package/show/devel:languages:go/go?expand=0&rev=116
This commit is contained in:
parent
af9180be82
commit
44fd090477
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Mar 7 06:12:58 UTC 2012 - graham@andtech.eu
|
||||
|
||||
- update gotest/gofix macro
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Mar 6 04:20:18 UTC 2012 - graham@andtech.eu
|
||||
|
||||
|
8
go.spec
8
go.spec
@ -40,8 +40,9 @@ Patch3: go-build-dont-reinstall-stdlibs.patch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
BuildRequires: bison
|
||||
BuildRequires: ed
|
||||
BuildRequires: mercurial
|
||||
%if 0%{?suse_version} >= 1210
|
||||
BuildRequires: systemd
|
||||
%endif
|
||||
%if 0%{?suse_version} > 1020
|
||||
BuildRequires: fdupes
|
||||
Recommends: go-doc
|
||||
@ -182,26 +183,25 @@ ln -s %{_datadir}/go/src/pkg/runtime/{cgocall,runtime}.h %{buildroot}%{_libdir}/
|
||||
%fdupes %{buildroot}%{_prefix}
|
||||
%endif
|
||||
|
||||
|
||||
%pre
|
||||
%if 0%{?suse_version} >= 1210
|
||||
%service_add_pre godoc.service
|
||||
%endif
|
||||
|
||||
%post
|
||||
%if 0%{?suse_version} >= 1210
|
||||
%service_add_pre godoc.service
|
||||
%endif
|
||||
|
||||
%preun
|
||||
%if 0%{?suse_version} >= 1210
|
||||
%service_add_pre godoc.service
|
||||
%endif
|
||||
|
||||
%postun
|
||||
%if 0%{?suse_version} >= 1210
|
||||
%service_add_pre godoc.service
|
||||
%endif
|
||||
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%doc AUTHORS CONTRIBUTORS LICENSE PATENTS README
|
||||
|
151
macros.go
151
macros.go
@ -19,71 +19,124 @@ Provides: %{name}-devel-static = %{version}
|
||||
%go_disable_brp_strip_static_archive \
|
||||
%define __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib/rpm/[^/]*/?brp-strip-static-archive %{__strip}!!g')
|
||||
|
||||
%go_make \
|
||||
install -d %{buildroot}%{_bindir} \
|
||||
HOST_EXTRA_CFLAGS="%{optflags}" TARGDIR=%{buildroot}%{go_sitearch} GOBIN=%{buildroot}%{_bindir} gomake
|
||||
%go_make_install %{go_make} install
|
||||
%go_make_test %{go_make} test
|
||||
|
||||
# "go install/build" expects valid $GOROOT for std library packages and potentially
|
||||
# a valid $GOPATH with the expected GOPATH structure. Third party librarys need
|
||||
# to be built with their "importpath" option exactly matching the expected import
|
||||
# statement. This is important because the importpath will be baked into the library's
|
||||
# type definitions at compile time. This means the package source must exist either
|
||||
# inside a valid GOPATH or a relative path to the source must match the 'importpath'
|
||||
# option when 'go install' is called.
|
||||
#
|
||||
# See "go help install/importpath/gopath"
|
||||
|
||||
%goinstall() \
|
||||
# Prepare the expected Go package build environement.
|
||||
# We need a $GOPATH: go help gopath
|
||||
# We need a valid importpath: go help packages
|
||||
%goprep() \
|
||||
export GOPATH=%{_builddir}/go \
|
||||
mkdir -p %{_builddir}/go/src/%1 && mkdir %{_builddir}/go/bin -p && mv ./* %{_builddir}/go/src/%1 \
|
||||
mkdir -p %{_builddir}/go/pkg/linux_%{go_arch}/%1 \
|
||||
cd ../ && rmdir %{_builddir}/%(basename %1) \
|
||||
ln -s %{_builddir}/go/src/%1 %{_builddir}/%(basename %1) \
|
||||
if [ %# -eq 0 ]; then \
|
||||
echo "goprep: please specify a valid importpath, see: go help packages" \
|
||||
exit 1 \
|
||||
else \
|
||||
export IMPORTPATH=%1 \
|
||||
fi \
|
||||
# create the importpath and move the package there \
|
||||
mkdir -p $GOPATH/src/$IMPORTPATH && mv ./* $GOPATH/src/$IMPORTPATH \
|
||||
# now link the old location to the new (for compatibility) \
|
||||
cd %{_builddir} && rmdir %{_builddir}/%(basename %1) \
|
||||
ln -s $GOPATH/src/$IMPORTPATH %{_builddir}/%(basename %1) \
|
||||
# we'll be installing packages/binaries, make the targ dirs \
|
||||
install -d %{buildroot}%{go_sitearch} \
|
||||
install -d %{buildroot}%{_bindir} \
|
||||
if [ %# -gt 1 ]; then \
|
||||
if [ "%2" == "..." ]; then \
|
||||
GOIMPORT=%1%2 \
|
||||
else \
|
||||
GOIMPORT=%1/%2 \
|
||||
fi \
|
||||
%{nil}
|
||||
|
||||
# %%gobuild macro actually performs the command "go install", but the go
|
||||
# toolchain will install to the $GOPATH which allows us then customise the final
|
||||
# install for the distro default locations.
|
||||
#
|
||||
# gobuild accepts zero or more arguments. Each argument corresponds to
|
||||
# a modifier of the importpath. If no arguments are passed, this is equivalent
|
||||
# to the following go install statement:
|
||||
#
|
||||
# go install [importpath]
|
||||
#
|
||||
# Only the first or last arguement may be ONLY the wildcard argument "..."
|
||||
# if the wildcard argument is passed then the importpath expands to all packages
|
||||
# and binaries underneath it. If the argument contains only the wildcard no further
|
||||
# arguments are considered.
|
||||
#
|
||||
# If no wildcard argument is passed, go install will be invoked on each $arg
|
||||
# subdirectory under the importpath.
|
||||
#
|
||||
# Valid importpath modifier examples:
|
||||
#
|
||||
# example: %gobuild ...
|
||||
# command: go install importpath...
|
||||
#
|
||||
# example: %gobuild /...
|
||||
# command: go install importpath/... (All subdirs NOT including importpath)
|
||||
#
|
||||
# example: %gobuild foo...
|
||||
# command: go install importpath/foo... (All subdirs INCLUDING foo)
|
||||
#
|
||||
# example: %gobuild foo ... (same as foo...)
|
||||
# command: go install importpath/foo... (All subdirs INCLUDING foo)
|
||||
#
|
||||
# example: %gobuild foo/...
|
||||
# commands: go install importpath/foo/... (All subdirs NOT including foo)
|
||||
#
|
||||
# example: %gobuild foo bar
|
||||
# commands: go install importpath/foo
|
||||
# go install importpath/bar
|
||||
#
|
||||
# example: %gobuild foo ... bar
|
||||
# commands: go install importpath/foo... (bar is ignored)
|
||||
#
|
||||
# example: %gobuild foo bar... baz
|
||||
# commands: go install importpath/foo
|
||||
# go install importpath/bar...
|
||||
# go install importpath/baz
|
||||
#
|
||||
# See: go help install, go help packages
|
||||
%gobuild() \
|
||||
export BUILDFLAGS="-s -v -p 4" \
|
||||
MOD="" \
|
||||
if [ %# -gt 0 ]; then \
|
||||
for mod in %*; do \
|
||||
if [ $mod == "..." ]; then \
|
||||
MOD=$MOD... \
|
||||
go install $BUILDFLAGS $IMPORTPATH$MOD \
|
||||
break \
|
||||
else \
|
||||
MOD=/$mod \
|
||||
go install $BUILDFLAGS $IMPORTPATH$MOD \
|
||||
fi \
|
||||
done \
|
||||
else \
|
||||
GOIMPORT=%1 \
|
||||
go install $BUILDFLAGS $IMPORTPATH \
|
||||
fi \
|
||||
%{nil}
|
||||
|
||||
# Install all compiled packages and binaries to the buildroot
|
||||
%goinstall() \
|
||||
export GOPATH=%{_builddir}/go \
|
||||
TMPPKG=%{_builddir}/go/pkg \
|
||||
if [ "$(ls -A $TMPPKG)" ]; then \
|
||||
cp -ar %{_builddir}/go/pkg/linux_%{go_arch}/* %{buildroot}%{go_sitearch} \
|
||||
fi \
|
||||
GOPATH=%{_builddir}/go go install -s -v -p 4 $GOIMPORT \
|
||||
cp -arv %{_builddir}/go/pkg/linux_%{go_arch}/* %{buildroot}%{go_sitearch} \
|
||||
TMPBIN=%{_builddir}/go/bin \
|
||||
if [ "$(ls -A $TMPBIN)" ]; then \
|
||||
install -m755 $TMPBIN/* %{buildroot}%{_bindir} \
|
||||
fi \
|
||||
%{nil}
|
||||
|
||||
%gotest() \
|
||||
if [ %# -gt 1 ]; then \
|
||||
if [ "%2" == "..." ]; then \
|
||||
GOIMPORT=%1%2 \
|
||||
else \
|
||||
GOIMPORT=%1/%2 \
|
||||
fi \
|
||||
%gofix() \
|
||||
export GOPATH=%{_builddir}/go \
|
||||
if [ %# -eq 0 ]; then \
|
||||
echo "gofix: please specify a valid importpath, see: go help fix" \
|
||||
exit 1 \
|
||||
else \
|
||||
GOIMPORT=%1 \
|
||||
go fix %1... \
|
||||
fi \
|
||||
GOPATH=%{_builddir}/go \
|
||||
go test $GOIMPORT \
|
||||
%{nil}
|
||||
|
||||
%gofix() \
|
||||
if [ %# -gt 1 ]; then \
|
||||
if [ "%2" == "..." ]; then \
|
||||
GOIMPORT=%1%2 \
|
||||
else \
|
||||
GOIMPORT=%1/%2 \
|
||||
fi \
|
||||
%gotest() \
|
||||
export GOPATH=%{_builddir}/go \
|
||||
if [ %# -eq 0 ]; then \
|
||||
echo "gotest: please specify a valid importpath, see: go help test" \
|
||||
exit 1 \
|
||||
else \
|
||||
GOIMPORT=%1 \
|
||||
go test %1... \
|
||||
fi \
|
||||
GOPATH=%{_builddir}/go \
|
||||
go fix $GOIMPORT \
|
||||
%{nil}
|
Loading…
Reference in New Issue
Block a user