install alternatives for go and gofmt binaries [release 1.14.7-2mamba;Sun Aug 16 2020]

This commit is contained in:
Silvan Calarco 2024-01-05 23:18:57 +01:00
parent d089f30f00
commit a53c5d4621
2 changed files with 45 additions and 35 deletions

View File

@ -1,4 +1,3 @@
# go
The Go programming language.

View File

@ -1,14 +1,12 @@
%define with_pie 1
Name: go
Version: 1.14.7
Release: 1mamba
Release: 2mamba
Summary: The Go programming language
Group: Applications/Development
Vendor: openmamba
Distribution: openmamba
Packager: Silvan Calarco <>
## GITSOURCE go1.10.1
Patch0: go-1.10.1-default-buildmode-pie.patch
License: BSD
@ -16,32 +14,23 @@ License: BSD
BuildRequires: glibc-devel
BuildRequires: gcc-go >= 8.1.0
Provides: go
Provides: go-pie
#%if "%{with_pie}" == "1"
#Conflicts: go
#Conflicts: go-pie
Obsoletes: go-pie
BuildRoot: %{_tmppath}/%{name}-%{version}-root
The Go programming language.
%package pie
Group: Applications/Development
Summary: The Go programming language (with PIE enabled by default)
%description pie
The Go programming language (with PIE enabled by default).
# Fedora:
# 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
#% debug_package
%global __strip /bin/true
%setup -q
#%if "%{with_pie}" == "1"
#%patch0 -p1
#-D -T
#:<< _EOF
%define _use_internal_dependency_generator 0
@ -61,17 +50,29 @@ _EOF
chmod +x %{_builddir}/go-%{version}/
export GOPATH="`pwd`/"
#:<< _EOF
export GOPATH="%{_builddir}/"
export GOROOT="$PWD"
export GOROOT_FINAL=%{_libdir}/go
export GO_LDFLAGS="-linkmode internal"
export CGO_ENABLED=1
export GOBIN="$GOROOT/bin"
# Use gcc-go as bootstrap compiler
sed -i "s|\$GOROOT_BOOTSTRAP/bin/go|/usr/bin/gcc-go|" src/make.bash src/make.rc
sed -i "s|/bin/go|/usr/bin/go|" src/cmd/dist/buildtool.go
cd "$GOPATH/src"
# golang
#export GOROOT_BOOTSTRAP=%{_libdir}/go
cd src
./make.bash --no-clean -v
cd ..
PATH="$PWD/bin:$PATH" go install -v -buildmode=shared std
PATH="$GOBIN:$PATH" go install -v -buildmode=shared std
%ifarch x86_64
PATH="$GOBIN:$PATH" go install -v -race std
PATH="$PWD/bin:$PATH" go install -v -race std
@ -84,8 +85,6 @@ install -d %{buildroot}{%{_bindir},%{_libdir}/go,%{_docdir}/go}
cp -a bin pkg src lib misc %{buildroot}%{_libdir}/go
cp -r doc/* %{buildroot}%{_docdir}/go
ln -sf %{_libdir}/go/bin/go %{buildroot}%{_bindir}/go-pie
ln -sf %{_libdir}/go/bin/gofmt %{buildroot}%{_bindir}/gofmt-pie
ln -sf %{_docdir}/go %{buildroot}%{_libdir}/go/doc
install -Dm644 LICENSE %{buildroot}%{_datadir}/licenses/go/LICENSE
@ -98,14 +97,23 @@ rm -rf %{buildroot}%{_libdir}/go/src/*.rc
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
%if "%{with_pie}" == "1"
%files pie
/usr/sbin/alternatives --install \
%{_bindir}/go go %{_libdir}/go/bin/go 50
/usr/sbin/alternatives --install \
%{_bindir}/gofmt gofmt %{_libdir}/go/bin/gofmt 50
# erase
if [ $1 -eq 0 ]; then
/usr/sbin/update-alternatives --remove go %{_libdir}/go/bin/go
/usr/sbin/update-alternatives --remove gofmt %{_libdir}/go/bin/gofmt
%dir %{_libdir}/go
%dir %{_datadir}/doc/go
@ -114,6 +122,9 @@ rm -rf %{buildroot}%{_libdir}/go/src/*.rc
* Sun Aug 16 2020 Silvan Calarco <> 1.14.7-2mamba
- install alternatives for go and gofmt binaries
* Fri Aug 07 2020 Automatic Build System <> 1.14.7-1mamba
- automatic version update by autodist