Skip to content

Instantly share code, notes, and snippets.

@cemeyer
Created May 18, 2010 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cemeyer/404497 to your computer and use it in GitHub Desktop.
Save cemeyer/404497 to your computer and use it in GitHub Desktop.
# The libraries and binaries produced by this compiler are not compatible
# with coreutils strip (yet).
%global debug_package %{nil}
%global __spec_install_post /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot \
/usr/lib/rpm/redhat/brp-compress
Name: go
Version: 0
Release: 0.__RELEASE__%{?dist}
Summary: Go compiler and tools (gc)
Group: Development/Languages
License: BSD
URL: http://golang.org/
# This is built from upstream mercurial:
# hg clone -r release https://go.googlecode.com/hg/ go-src
# tar -cjf go-20100427.tar.bz2 go-src/
Source0: go-__RELEASE__.tar.bz2
# Patch away the need for environment variables:
Patch0: go-goos.c-no-envvars.diff
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: ed
BuildRequires: bison
ExclusiveArch: %ix86 x86_64
%package vim
Summary: go syntax files for vim
Group: Applications/Editors
Requires: vim-common
Requires: %{name} = %{version}-%{release}
%description vim
Go syntax for vim.
%package emacs
Summary: go syntax files for emacs
Group: Applications/Editors
Requires: emacs-common
Requires: %{name} = %{version}-%{release}
%description emacs
Go syntax for emacs.
%description
Go is a systems programming language that aims to be both fast and convenient.
%prep
%setup -q -n "go-src"
%patch0
%ifarch %ix86
%global GOARCH 386
%endif
%ifarch x86_64
%global GOARCH amd64
%endif
sed -i -e "s|__GOROOT__|%{_libdir}/go|g" \
-e "s|__GOARCH__|%{GOARCH}|g" \
src/lib9/goos.c
echo >README.Fedora <<EOM
This is a go package for Fedora. It notably differs from the standard
go set of binaries in that it ignores the environmental variables,
except for GOROOT. It uses GOROOT to allow the newly-built 6g to find
newly-built packages for other package imports during the build
process.
EOM
%build
export GOARCH GOROOT GOOS GOBIN
GOROOT="`pwd`"
GOOS=linux
GOBIN="$GOROOT/bin"
GOARCH="%{GOARCH}"
mkdir -p "$GOBIN"
cd src
sed -i -e 's|^\. \./env\.bash$||' ./make.bash
LC_ALL=C PATH="$PATH:$GOBIN" ./make.bash
%install
rm -rf $RPM_BUILD_ROOT
export GOARCH GOROOT GOOS GOBIN
GOROOT="$RPM_BUILD_ROOT%{_libdir}/go"
GOOS=linux
GOBIN="$GOROOT/bin"
GOARCH="%{GOARCH}"
install -Dm644 misc/bash/go $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d/go
install -Dm644 misc/emacs/go-mode-load.el $RPM_BUILD_ROOT%{_datadir}/emacs/site-lisp/go-mode-load.el
install -Dm644 misc/emacs/go-mode.el $RPM_BUILD_ROOT%{_datadir}/emacs/site-lisp/go-mode.el
install -Dm644 misc/vim/go.vim $RPM_BUILD_ROOT%{_datadir}/vim/vimfiles/syntax/go.vim
mkdir -p $GOROOT/{misc,lib}
mkdir -p $RPM_BUILD_ROOT%{_bindir}/
cp -r bin/* $RPM_BUILD_ROOT%{_bindir}/
cp -r pkg $GOROOT
rm $GOROOT/pkg/~place-holder~
cp -r lib/godoc $GOROOT/lib
find src/{pkg,cmd} -name \*.go -exec install -Dm644 '{}' "$GOROOT/{}" \;
install -Dm644 {,$GOROOT/}src/pkg/container/vector/Makefile
install -Dm644 {,$GOROOT/}favicon.ico
cp -r misc/cgo $GOROOT/misc
cp src/Make.{$GOARCH,cmd,common,pkg,conf} $GOROOT/src
cp src/pkg/runtime/{cgocall,runtime}.h $GOROOT/src/pkg/runtime
rm -f $RPM_BUILD_ROOT%{_bindir}/{hgpatch,quietgcc}
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
%doc AUTHORS CONTRIBUTORS LICENSE README doc/* README.Fedora
%{_libdir}/go
%ifarch %ix86
%{_bindir}/8*
%endif
%{_bindir}/6*
%{_bindir}/cgo
%{_bindir}/ebnflint
%{_bindir}/go*
%{_sysconfdir}/bash_completion.d/go
%files vim
%defattr(-,root,root,-)
%{_datadir}/vim/vimfiles/syntax/go.vim
%files emacs
%defattr(-,root,root,-)
%{_datadir}/emacs/site-lisp/go-mode*.el
%changelog
* Fri May 14 2010 Conrad Meyer <konrad@tylerc.org> - 0-0.20100504
- Fix the patch to allow GOROOT overrides during the build process
* Thu Apr 29 2010 Conrad Meyer <konrad@tylerc.org> - 0-0.20100427
- Initial Go hg release spec template.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment