golang-cross/golang-cross.spec

210 lines
6.1 KiB
RPMSpec

# build ids are n ot currently generated:
# https://code.google.com/p/go/issues/detail?id=5238
#
# also, debuginfo extraction currently fails with
# "Failed to write file: invalid section alignment"
%global debug_package %{nil}
# we are shipping the full contents of src in the data subpackage, which
# contains binary-like things (ELF data for tests, etc)
%global _binaries_in_noarch_packages_terminate_build 0
# Don't alter timestamps of especially the .a files (or else go will rebuild later)
# Actually, don't strip at all since we are not even building debug packages and this corrupts the dwarf testdata
%global __strip /bin/true
# rpmbuild magic to keep from having meta dependency on libc.so.6
# % define _use_internal_dependency_generator 0
# % define __find_requires %{nil}
%global debug_package %{nil}
%global __spec_install_post /usr/lib/rpm/brp-compress
# %define _emacs_sitelispdir %{_datadir}/emacs/site-lisp
# %define _xemacs_sitelispdir %{_datadir}/xemacs/site-lisp
# %define _emacs_sitestartdir %{_datadir}/emacs/site-lisp
# %define _xemacs_sitestartdir %{_datadir}/xemacs/site-lisp
%define __noautoreq '/bin/rc|/usr/bin/awk|libc.so'
%define api 1.17
Name: golang-cross
Version: 1.17.2
Release: 1
Summary: The Go Programming Language
Group: Development/Other
License: BSD
URL: http://golang.org/
Source0: https://storage.googleapis.com/golang/go%{version}.src.tar.gz
Source3: macros.go
#bootstrap
Source10: https://storage.googleapis.com/golang/go%{version}.linux-amd64.tar.gz
Source11: https://storage.googleapis.com/golang/go%{version}.linux-386.tar.gz
# for hostname
BuildRequires: net-tools
BuildRequires: go >= 1.12
%rename go
# We strip the meta dependency, but go does require glibc.
# This is an odd issue, still looking for a better fix.
Requires: glibc
# Having godoc and the documentation separate was broken
Obsoletes: %{name}-godoc < 1.1-4
Obsoletes: %{name}-docs < 1.1-4
# RPM can't handle symlink -> dir with subpackages, so merge back
Obsoletes: %{name}-data < 1.1.1-4
ExclusiveArch: %{ix86} x86_64 %{arm} %{ppc64}
Source100: golang-gdbinit
Source101: golang-prelink.conf
Source102: %{name}.rpmlintrc
%description
%{summary}.
# Workaround old RPM bug of symlink-replaced-with-dir failure
%pretrans -p <lua>
for _,d in pairs({"api", "doc", "include", "lib", "src"}) do
path = "%{_libdir}/%{name}/" .. d
if posix.stat(path, "type") == "link" then
os.remove(path)
posix.mkdir(path)
end
end
%prep
#setup -q -n go
# setup go_arch (BSD-like scheme)
%ifarch %{ix86}
sed -i 's|GOARCH|386|' %{SOURCE3}
%define go_arch 386
%setup -q -a11 -T -c -n go-bootstrap
%endif
%ifarch x86_64
sed -i 's|GOARCH|amd64|' %{SOURCE3}
%define go_arch amd64
%setup -q -a10 -T -c -n go-bootstrap
%endif
%setup -q -n go
%build
export CFLAGS="${RPM_OPT_FLAGS/-Wstrict-aliasing=2/} -Wno-error"
export LDFLAGS="$RPM_LD_FLAGS"
# set up final install location
export GOROOT_FINAL=%{_libdir}/%{name}
#export GOROOT=$(pwd -P)
export GOROOT=$RPM_BUILD_DIR/go-bootstrap/go
export GOBIN="$GOROOT"/bin
export GOROOT_BOOTSTRAP=$GOROOT
# TODO use the system linker to get the system link flags and build-id
# when https://code.google.com/p/go/issues/detail?id=5221 is solved
#export GO_LDFLAGS="-linkmode external -extldflags $RPM_LD_FLAGS"
# build
#cd src
#./make.bash
#cd ..
pushd src
#/buildall.bash
#GOROOT_BOOTSTRAP=$GOROOT GOOS=linux GOARCH=arm GOARM=5 ./make.bash
#GOROOT_BOOTSTRAP=$GOROOT GOOS=linux GOARCH=arm GOARM=7 ./make.bash
#GOROOT_BOOTSTRAP=$GOROOT GOOS=linux GOARCH=arm64 ./make.bash
#GOROOT_BOOTSTRAP=$GOROOT GOOS=linux GOARCH=386 ./make.bash
#GOROOT_BOOTSTRAP=$GOROOT GOOS=linux GOARCH=amd64 ./make.bash
#GOROOT_BOOTSTRAP=$GOROOT GOOS=linux GOARCH=ppc64 ./make.bash
#GOROOT_BOOTSTRAP=$GOROOT GOOS=linux GOARCH=mips64 ./make.bash
go env CGO_ENABLED
CGO_ENABLED=1 GOROOT_BOOTSTRAP=$GOROOT GOOS=android ./make.bash
go env CGO_ENABLED
popd
# build static version of documentation
export PATH="$PATH":"$GOROOT"/bin
#cd doc
#make
#cd ..
%check
export GOROOT=$(pwd -P)
export PATH="$PATH":"$GOROOT"/bin
cd src
# For now test 3729,5603 doesn't pass so skiping it
perl -pi -e 's/!windows/!windows,!linux/' ../misc/cgo/test/issue3729.go
perl -pi -e 's/func Test3729/\/\/func Test3729/' ../misc/cgo/test/cgo_test.go
perl -pi -e 's/^package/\/\/ +build !linux
package/' ../misc/cgo/test/issue5603.go
perl -pi -e 's/func Test5603/\/\/func Test5603/' ../misc/cgo/test/cgo_test.go
#./run.bash --no-rebuild
cd ..
%install
# create the top level directories
install -d %{buildroot}%{_bindir}
install -d %{buildroot}%{_libdir}/%{name}
# remove all .bat
pushd src
rm -f *.bat
popd
# install everything into libdir (until symlink problems are fixed)
# https://code.google.com/p/go/issues/detail?id=5830
#cp -av api bin doc favicon.ico include lib pkg robots.txt src %{buildroot}%{_libdir}/%{name}
cp -av bin lib src pkg %{buildroot}%{_libdir}/%{name}
# remove the unnecessary zoneinfo file (Go will always use the system one first)
rm -rfv %{buildroot}%{_libdir}/%{name}/lib/time
# remove the doc Makefile
rm -rfv %{buildroot}%{_libdir}/%{name}/doc/Makefile
# add symlinks for binaries
pushd %{buildroot}%{_bindir}
for z in %{buildroot}%{_libdir}/%{name}/bin/*
do ln -s %{_libdir}/%{name}/bin/$(basename $z)
done
popd
# gdbinit
#mkdir -p %{buildroot}%{_sysconfdir}/gdbinit.d
install -d %{buildroot}%{_sysconfdir}/gdbinit.d
cp -av %{SOURCE100} %{buildroot}%{_sysconfdir}/gdbinit.d/golang
# prelink blacklist
#mkdir -p %{buildroot}%{_sysconfdir}/prelink.conf.d
install -d %{buildroot}%{_sysconfdir}/prelink.conf.d
cp -av %{SOURCE101} %{buildroot}%{_sysconfdir}/prelink.conf.d/golang.conf
# install RPM macros ($GOARCH prepared in %%prep section)
install -Dm644 %{SOURCE3} %{buildroot}%{_sysconfdir}/rpm/macros.go
%files
#doc api/ doc/ AUTHORS CONTRIBUTORS LICENSE PATENTS VERSION README.md.tct
%doc LICENSE README.md
# go files
%{_libdir}/%{name}
%{_bindir}
# bin symlinks
#{_bindir}/go
#%{_bindir}/godoc
#{_bindir}/gofmt
# gdbinit (for gdb debugging)
%{_sysconfdir}/gdbinit.d
# prelink blacklist
%{_sysconfdir}/prelink.conf.d
# ROM macros
%config %{_sysconfdir}/rpm/macros.go