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.

79
go.spec
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 <silvan.calarco@mambasoft.it>
URL: https://golang.org
## GITSOURCE https://github.com/golang/go.git go1.10.1
Source: https://github.com/golang/go.git/go%{version}/go-%{version}.tar.bz2
Patch0: go-1.10.1-default-buildmode-pie.patch
License: BSD
@ -16,32 +14,23 @@ License: BSD
BuildRequires: glibc-devel
## AUTOBUILDREQ-END
BuildRequires: gcc-go >= 8.1.0
Provides: go
Provides: go-pie
#%if "%{with_pie}" == "1"
#Conflicts: go
#%else
#Conflicts: go-pie
#%endif
Obsoletes: go-pie
BuildRoot: %{_tmppath}/%{name}-%{version}-root
%description
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).
%debug_package
# 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
%prep
%setup -q
#%if "%{with_pie}" == "1"
#%patch0 -p1
#%endif
#-D -T
#:<< _EOF
%define _use_internal_dependency_generator 0
@ -61,17 +50,29 @@ _EOF
chmod +x %{_builddir}/go-%{version}/find_requires.sh
%build
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 GOROOT="$GOPATH"
export GOBIN="$GOROOT/bin"
# Use gcc-go as bootstrap compiler
export GOROOT_BOOTSTRAP=/
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
%endif
%install
@ -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
%clean
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
%if "%{with_pie}" == "1"
%files pie
%else
%post
/usr/sbin/alternatives --install \
%{_bindir}/go go %{_libdir}/go/bin/go 50
/usr/sbin/alternatives --install \
%{_bindir}/gofmt gofmt %{_libdir}/go/bin/gofmt 50
:
%preun
# 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
fi
:
%files
%endif
%defattr(-,root,root)
%{_bindir}/go-pie
%{_bindir}/gofmt-pie
%dir %{_libdir}/go
%{_libdir}/go/*
%dir %{_datadir}/doc/go
@ -114,6 +122,9 @@ rm -rf %{buildroot}%{_libdir}/go/src/*.rc
#%doc README.md
%changelog
* Sun Aug 16 2020 Silvan Calarco <silvan.calarco@mambasoft.it> 1.14.7-2mamba
- install alternatives for go and gofmt binaries
* Fri Aug 07 2020 Automatic Build System <autodist@mambasoft.it> 1.14.7-1mamba
- automatic version update by autodist