2011-05-19 20:17:10 +02:00
|
|
|
# Macros for Go module building.
|
|
|
|
#
|
|
|
|
# Copyright (c) 2011 Sascha Peilicke <saschpe@gmx.de>
|
|
|
|
#
|
|
|
|
|
2011-05-23 12:33:44 +02:00
|
|
|
%go_ver %(LC_ALL=C rpm -q --qf '%%{epoch}:%%{version}\\n' go | sed -e 's/ (none):/ /' -e 's/ 0:/ /' | grep -v "is not")
|
2011-05-20 11:29:51 +02:00
|
|
|
%go_arch GOARCH
|
2011-05-19 20:17:10 +02:00
|
|
|
|
|
|
|
%go_dir %{_libdir}/go
|
|
|
|
%go_sitedir %{_libdir}/go/pkg
|
2011-05-19 22:36:34 +02:00
|
|
|
%go_sitearch %{_libdir}/go/pkg/linux_%{go_arch}
|
2011-05-19 20:17:10 +02:00
|
|
|
|
2011-06-30 11:18:52 +02:00
|
|
|
%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")
|
2011-05-19 20:17:10 +02:00
|
|
|
|
2011-05-19 20:23:17 +02:00
|
|
|
%go_provides \
|
2011-05-21 14:19:45 +02:00
|
|
|
Provides: %{name}-devel = %{version} \
|
|
|
|
Provides: %{name}-devel-static = %{version}
|
2011-05-19 20:17:10 +02:00
|
|
|
|
2011-06-30 11:18:52 +02:00
|
|
|
%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')
|
|
|
|
|
2011-12-13 15:23:16 +01:00
|
|
|
%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
|
2012-01-25 04:57:43 +01:00
|
|
|
|
|
|
|
# "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() \
|
2012-01-28 17:28:41 +01:00
|
|
|
export GOPATH=%{_builddir}/go \
|
|
|
|
mkdir -p %{_builddir}/go/src/%1 && mkdir %{_builddir}/go/bin -p && mv ./* %{_builddir}/go/src/%1 \
|
2012-02-04 11:55:47 +01:00
|
|
|
mkdir -p %{_builddir}/go/pkg/linux_%{go_arch}/%1 \
|
2012-01-28 17:28:41 +01:00
|
|
|
cd ../ && rmdir %{_builddir}/%(basename %1) \
|
|
|
|
ln -s %{_builddir}/go/src/%1 %{_builddir}/%(basename %1) \
|
2012-01-25 04:57:43 +01:00
|
|
|
install -d %{buildroot}%{go_sitearch} \
|
|
|
|
install -d %{buildroot}%{_bindir} \
|
|
|
|
if [ %# -gt 1 ]; then \
|
2012-01-28 17:28:41 +01:00
|
|
|
if [ "%2" == "..." ]; then \
|
|
|
|
GOIMPORT=%1%2 \
|
|
|
|
else \
|
|
|
|
GOIMPORT=%1/%2 \
|
|
|
|
fi \
|
2012-01-25 04:57:43 +01:00
|
|
|
else \
|
|
|
|
GOIMPORT=%1 \
|
|
|
|
fi \
|
2012-03-06 05:25:38 +01:00
|
|
|
GOPATH=%{_builddir}/go go install -s -v -p 4 $GOIMPORT \
|
2012-03-05 18:07:14 +01:00
|
|
|
cp -arv %{_builddir}/go/pkg/linux_%{go_arch}/* %{buildroot}%{go_sitearch} \
|
2012-02-04 11:55:47 +01:00
|
|
|
TMPBIN=%{_builddir}/go/bin \
|
|
|
|
if [ "$(ls -A $TMPBIN)" ]; then \
|
|
|
|
install -m755 $TMPBIN/* %{buildroot}%{_bindir} \
|
|
|
|
fi \
|
2012-01-25 04:57:43 +01:00
|
|
|
%{nil}
|
|
|
|
|
|
|
|
%gotest() \
|
|
|
|
if [ %# -gt 1 ]; then \
|
2012-02-04 11:55:47 +01:00
|
|
|
if [ "%2" == "..." ]; then \
|
|
|
|
GOIMPORT=%1%2 \
|
|
|
|
else \
|
|
|
|
GOIMPORT=%1/%2 \
|
|
|
|
fi \
|
2012-01-25 04:57:43 +01:00
|
|
|
else \
|
|
|
|
GOIMPORT=%1 \
|
|
|
|
fi \
|
2012-01-28 17:28:41 +01:00
|
|
|
GOPATH=%{_builddir}/go \
|
2012-01-25 04:57:43 +01:00
|
|
|
go test $GOIMPORT \
|
|
|
|
%{nil}
|
2012-02-04 11:55:47 +01:00
|
|
|
|
|
|
|
%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}
|