From cd24f6ed2307948de8c54cb8869395848066fe8f Mon Sep 17 00:00:00 2001 From: Sergey Zhemoitel Date: Wed, 26 Jul 2017 20:19:58 +0300 Subject: [PATCH] Imported from SRPM --- .abf.yml | 4 + golang-cross.rpmlintrc | 7 ++ golang-cross.spec | 205 +++++++++++++++++++++++++++++++++++++++++ golang-gdbinit | 2 + golang-prelink.conf | 3 + macros.go | 151 ++++++++++++++++++++++++++++++ 6 files changed, 372 insertions(+) create mode 100644 .abf.yml create mode 100644 golang-cross.rpmlintrc create mode 100644 golang-cross.spec create mode 100644 golang-gdbinit create mode 100644 golang-prelink.conf create mode 100644 macros.go diff --git a/.abf.yml b/.abf.yml new file mode 100644 index 0000000..0cfad5a --- /dev/null +++ b/.abf.yml @@ -0,0 +1,4 @@ +sources: + go1.8.linux-386.tar.gz: 9f75b977b3b8ea50ec4ed3068689b3680d27299b + go1.8.linux-amd64.tar.gz: a93fe8fc245e3554f956bc823f30ef4eb23c2068 + go1.8.src.tar.gz: 37945c372140c3a46c2c5b4b9ce382b6c8d88811 diff --git a/golang-cross.rpmlintrc b/golang-cross.rpmlintrc new file mode 100644 index 0000000..fbe8c45 --- /dev/null +++ b/golang-cross.rpmlintrc @@ -0,0 +1,7 @@ +addFilter("binaryinfo-readelf-failed") # go binaries are suposedly ELF-compliant +addFilter("statically-linked-binary") # go doesn't yet support dynamic linking +addFilter("unstripped-binary-or-object") # doesnt like stripping +addFilter("devel-file-in-non-devel-package") +addFilter("E: missing-PT_GNU_STACK-section") +addFilter("E: standard-dir-owned-by-package") +addFilter("E: zero-length") diff --git a/golang-cross.spec b/golang-cross.spec new file mode 100644 index 0000000..25fae40 --- /dev/null +++ b/golang-cross.spec @@ -0,0 +1,205 @@ +# 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.8 + +Name: golang-cross +Version: 1.8.3 +Release: 1 +Summary: The Go Programming Language +Group: Development/Other +License: BSD +URL: http://golang.org/ +Source0: https://storage.googleapis.com/golang/go%{api}.src.tar.gz +Source3: macros.go +#bootstrap +Source10: https://storage.googleapis.com/golang/go%{api}.linux-amd64.tar.gz +Source11: https://storage.googleapis.com/golang/go%{api}.linux-386.tar.gz +# for hostname +BuildRequires: net-tools +BuildRequires: go >= 1.5 + +%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 +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 +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=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 +GOROOT_BOOTSTRAP=$GOROOT GOOS=android ./make.bash +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 robots.txt %{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 + diff --git a/golang-gdbinit b/golang-gdbinit new file mode 100644 index 0000000..0a32958 --- /dev/null +++ b/golang-gdbinit @@ -0,0 +1,2 @@ +add-auto-load-safe-path /usr/lib/golang/src/pkg/runtime/runtime-gdb.py +add-auto-load-safe-path /usr/lib64/golang/src/pkg/runtime/runtime-gdb.py diff --git a/golang-prelink.conf b/golang-prelink.conf new file mode 100644 index 0000000..471e8e6 --- /dev/null +++ b/golang-prelink.conf @@ -0,0 +1,3 @@ +# there are ELF files in src which are testdata and shouldn't be modified +-b /usr/lib/golang/src +-b /usr/lib64/golang/src diff --git a/macros.go b/macros.go new file mode 100644 index 0000000..31c0698 --- /dev/null +++ b/macros.go @@ -0,0 +1,151 @@ +# Macros for Go module building. +# +# Copyrigh: (c) 2011 Sascha Peilicke +# + +%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 386 +%go_build_ver %(go version | sed 's/^go version //' | tr -d ' ') + +%go_dir %{_libdir}/go +%go_sitedir %{_libdir}/go/pkg +%go_sitearch %{_libdir}/go/pkg/linux_%{go_arch} + +%go_requires Requires: go-devel = %go_build_ver + +%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') + + +# 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 \ +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} \ +%{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" \ +export GOBIN=%{_builddir}/go/bin \ +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 \ + 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 \ +TMPBIN=%{_builddir}/go/bin \ +if [ "$(ls -A $TMPBIN)" ]; then \ + install -m755 $TMPBIN/* %{buildroot}%{_bindir} \ +fi \ +%{nil} + +%gofix() \ +export GOPATH=%{_builddir}/go \ +if [ %# -eq 0 ]; then \ + echo "gofix: please specify a valid importpath, see: go help fix" \ + exit 1 \ +else \ + go fix %1... \ +fi \ +%{nil} + +%gotest() \ +export GOPATH=%{_builddir}/go \ +if [ %# -eq 0 ]; then \ + echo "gotest: please specify a valid importpath, see: go help test" \ + exit 1 \ +else \ + go test %1... \ +fi \ +%{nil} + +%godoc() \ +install -d %{buildroot}%{_datadir}/go/src/pkg \ +cd %{_builddir}/go/src \ +find . -name *.go -exec install -Dm644 \{\} %{buildroot}%{_datadir}/go/src/pkg/\{\} \\; \ +%{nil} +