fe40b5ed34
OBS-URL: https://build.opensuse.org/request/show/102665 OBS-URL: https://build.opensuse.org/package/show/devel:languages:go/go?expand=0&rev=109
89 lines
2.7 KiB
Go
89 lines
2.7 KiB
Go
# Macros for Go module building.
|
|
#
|
|
# Copyright (c) 2011 Sascha Peilicke <saschpe@gmx.de>
|
|
#
|
|
|
|
%go_ver %(LC_ALL=C rpm -q --qf '%%{epoch}:%%{version}\\n' go | sed -e 's/ (none):/ /' -e 's/ 0:/ /' | grep -v "is not")
|
|
%go_arch GOARCH
|
|
|
|
%go_dir %{_libdir}/go
|
|
%go_sitedir %{_libdir}/go/pkg
|
|
%go_sitearch %{_libdir}/go/pkg/linux_%{go_arch}
|
|
|
|
%go_requires %(echo '%*' | LC_ALL=C xargs -r rpm -q --qf 'Requires: %%{name} >= %%{epoch}:%%{version}\\n' | sed -e 's/ (none):/ /' -e 's/ 0:/ /' | grep -v "is not")
|
|
|
|
%go_provides \
|
|
Provides: %{name}-devel = %{version} \
|
|
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() \
|
|
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) \
|
|
install -d %{buildroot}%{go_sitearch} \
|
|
install -d %{buildroot}%{_bindir} \
|
|
if [ %# -gt 1 ]; then \
|
|
if [ "%2" == "..." ]; then \
|
|
GOIMPORT=%1%2 \
|
|
else \
|
|
GOIMPORT=%1/%2 \
|
|
fi \
|
|
else \
|
|
GOIMPORT=%1 \
|
|
fi \
|
|
GOPATH=%{_builddir}/go go install -s -v -x -p 4 $GOIMPORT \
|
|
cp -arv %{_builddir}/go/pkg/linux_%{go_arch}/%1 %{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 \
|
|
else \
|
|
GOIMPORT=%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 \
|
|
else \
|
|
GOIMPORT=%1 \
|
|
fi \
|
|
GOPATH=%{_builddir}/go \
|
|
go fix $GOIMPORT \
|
|
%{nil} |