Blame SPECS/go-rpm-macros.spec

ecdb77
%global forgeurl  https://pagure.io/go-rpm-macros
6e9160
Version:   3.2.0
ecdb77
%forgemeta
ecdb77
ecdb77
#https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/51
ecdb77
%global _spectemplatedir %{_datadir}/rpmdevtools/fedora
ecdb77
%global _docdir_fmt     %{name}
ecdb77
ecdb77
# Master definition that will be written to macro files
ecdb77
%global golang_arches   %{ix86} x86_64 %{arm} aarch64 ppc64le s390x
ecdb77
%global gccgo_arches    %{mips}
ecdb77
%if 0%{?rhel} >= 9
ecdb77
%global golang_arches   x86_64 aarch64 ppc64le s390x
ecdb77
%endif
ecdb77
# Go sources can contain arch-specific files and our macros will package the
ecdb77
# correct files for each architecture. Therefore, move gopath to _libdir and
ecdb77
# make Go devel packages archful
ecdb77
%global gopath          %{_datadir}/gocode
ecdb77
ecdb77
# whether to bundle golist or require it as a dependency
ecdb77
%global bundle_golist 1
ecdb77
ecdb77
%if 0%{?bundle_golist}
ecdb77
# do not create debuginfo packages when we add a build section
ecdb77
%global debug_package %{nil}
ecdb77
%global golist_version 0.10.1
ecdb77
%global golist_builddir %{_builddir}/golist-%{golist_version}/_build
ecdb77
%global golist_goipath pagure.io/golist
ecdb77
# where to bundle the golist executable
ecdb77
%global golist_execdir %{_libexecdir}/go-rpm-macros/
ecdb77
# define gobuild to avoid this package requiring itself to build
ecdb77
%define gobuild(o:) GO111MODULE=off go build -buildmode pie -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld '" -a -v %{?**};
ecdb77
%endif
ecdb77
ecdb77
ExclusiveArch: %{golang_arches} %{gccgo_arches}
ecdb77
ecdb77
Name:      go-rpm-macros
6e9160
Release:   1%{?dist}
ecdb77
Summary:   Build-stage rpm automation for Go packages
ecdb77
ecdb77
License:   GPLv3+
ecdb77
URL:       %{forgeurl}
ecdb77
Source0:   %{forgesource}
ecdb77
%if 0%{?bundle_golist}
ecdb77
Source1:   https://pagure.io/golist/archive/v%{golist_version}/golist-%{golist_version}.tar.gz
ecdb77
%endif
ecdb77
ecdb77
Requires:  go-srpm-macros = %{version}-%{release}
ecdb77
Requires:  go-filesystem  = %{version}-%{release}
ecdb77
ecdb77
%if 0%{?bundle_golist}
ecdb77
BuildRequires: golang
ecdb77
%else
ecdb77
Requires:  golist
ecdb77
%endif
ecdb77
ecdb77
%ifarch %{golang_arches}
ecdb77
Requires:  golang
ecdb77
Provides:  compiler(golang)
ecdb77
Provides:  compiler(go-compiler) = 2
ecdb77
Obsoletes: go-compilers-golang-compiler < %{version}-%{release}
ecdb77
%endif
ecdb77
ecdb77
%ifarch %{gccgo_arches}
ecdb77
Requires:  gcc-go
ecdb77
Provides:  compiler(gcc-go)
ecdb77
Provides:  compiler(go-compiler) = 1
ecdb77
Obsoletes: go-compilers-gcc-go-compiler < %{version}-%{release}
ecdb77
%endif
ecdb77
ecdb77
Patch0: update-default-gobuild-args.patch
ecdb77
# Replace golang-github-urfave-cli with a minimal
ecdb77
# command line parser backend to bootstrap golist
ecdb77
# without dependencies.
ecdb77
Patch1: golist-bootstrap-cli-no-vendor.patch
ecdb77
6e9160
# RHEL 8 only provides the macros.go-srpm file which includes gobuild and gotest.
6e9160
# C9S also only provides the macros.go-srpm file but it also follows upstream which includes gobuild and gotest in the macros.go-compilers-gcc.
6e9160
# For a simple fix, this patch ports both RHEL 8 macros to macros.go-srpm.
6e9160
# Resolves: rhbz#1965292
6e9160
Patch2: add-gobuild-and-gotest.patch
6e9160
ecdb77
%description
ecdb77
This package provides build-stage rpm automation to simplify the creation of Go
ecdb77
language (golang) packages.
ecdb77
ecdb77
It does not need to be included in the default build root: go-srpm-macros will
ecdb77
pull it in for Go packages only.
ecdb77
ecdb77
%package -n go-srpm-macros
ecdb77
Summary:   Source-stage rpm automation for Go packages
ecdb77
BuildArch: noarch
ecdb77
Requires:  redhat-rpm-config
ecdb77
ecdb77
%description -n go-srpm-macros
ecdb77
This package provides SRPM-stage rpm automation to simplify the creation of Go
ecdb77
language (golang) packages.
ecdb77
ecdb77
It limits itself to the automation subset required to create Go SRPM packages
ecdb77
and needs to be included in the default build root.
ecdb77
ecdb77
The rest of the automation is provided by the go-rpm-macros package, that
ecdb77
go-srpm-macros will pull in for Go packages only.
ecdb77
ecdb77
%package -n go-filesystem
ecdb77
Summary:   Directories used by Go packages
ecdb77
License:   Public Domain
ecdb77
ecdb77
%description -n go-filesystem
ecdb77
This package contains the basic directory layout used by Go packages.
ecdb77
ecdb77
%package -n go-rpm-templates
ecdb77
Summary:   RPM spec templates for Go packages
ecdb77
License:   MIT
ecdb77
BuildArch: noarch
ecdb77
Requires:  go-rpm-macros = %{version}-%{release}
ecdb77
#https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/51
ecdb77
#Requires:  redhat-rpm-templates
ecdb77
ecdb77
%description -n go-rpm-templates
ecdb77
This package contains documented rpm spec templates showcasing how to use the
ecdb77
macros provided by go-rpm-macros to create Go packages.
ecdb77
ecdb77
%prep
ecdb77
%forgesetup
ecdb77
ecdb77
%patch0 -p1
ecdb77
ecdb77
%writevars -f rpm/macros.d/macros.go-srpm golang_arches gccgo_arches gopath
ecdb77
for template in templates/rpm/*\.spec ; do
ecdb77
  target=$(echo "${template}" | sed "s|^\(.*\)\.spec$|\1-bare.spec|g")
ecdb77
  grep -v '^#' "${template}" > "${target}"
ecdb77
  touch -r "${template}" "${target}"
ecdb77
done
ecdb77
ecdb77
# unpack golist and patch
ecdb77
%if 0%{?bundle_golist}
ecdb77
pushd %{_builddir}
ecdb77
tar -xf %{_sourcedir}/golist-%{golist_version}.tar.gz
ecdb77
cd golist-%{golist_version}
ecdb77
%patch1 -p1
ecdb77
cp %{_builddir}/golist-%{golist_version}/LICENSE %{_builddir}/go-rpm-macros-%{version}/LICENSE-golist
ecdb77
popd
ecdb77
ecdb77
# create directory structure for a Go build
ecdb77
if [[ ! -e %{golist_builddir}/bin ]]; then
ecdb77
  install -m 0755 -vd %{golist_builddir}/bin
ecdb77
  export GOPATH=%{golist_builddir}:${GOPATH:+${GOPATH}:}/usr/share/gocode
ecdb77
fi
ecdb77
if [[ ! -e %{golist_builddir}/src/%{golist_goipath} ]]; then
ecdb77
  install -m 0755 -vd %{golist_builddir}/src/pagure.io
ecdb77
  ln -sf $(dirname %{golist_builddir}) %{golist_builddir}/src/%{golist_goipath}
ecdb77
ecdb77
fi
ecdb77
%endif
ecdb77
6e9160
%patch2 -p1
6e9160
ecdb77
%build
ecdb77
# build golist
ecdb77
%if 0%{?bundle_golist}
ecdb77
pushd %{golist_builddir}/src/%{golist_goipath}
ecdb77
export GOPATH=%{golist_builddir}:${GOPATH:+${GOPATH}:}/usr/share/gocode
ecdb77
for cmd in cmd/* ; do
ecdb77
  %gobuild -o %{golist_builddir}/bin/$(basename $cmd) %{golist_goipath}/$cmd
ecdb77
done
ecdb77
popd
ecdb77
%endif
ecdb77
ecdb77
%install
ecdb77
# Some of those probably do not work with gcc-go right now
ecdb77
# This is not intentional, but mips is not a primary Fedora architecture
ecdb77
# Patches and PRs are welcome
ecdb77
ecdb77
install -m 0755 -vd   %{buildroot}%{gopath}/src
ecdb77
ecdb77
install -m 0755 -vd   %{buildroot}%{_spectemplatedir}
ecdb77
ecdb77
if ls templates/rpm/*\.spec; then
ecdb77
  install -m 0644 -vp   templates/rpm/*spec \
ecdb77
                        %{buildroot}%{_spectemplatedir}
ecdb77
fi
ecdb77
ecdb77
install -m 0755 -vd   %{buildroot}%{_bindir}
ecdb77
install -m 0755 bin/* %{buildroot}%{_bindir}
ecdb77
ecdb77
install -m 0755 -vd   %{buildroot}%{rpmmacrodir}
ecdb77
install -m 0644 -vp   rpm/macros.d/macros.go-* \
ecdb77
                      %{buildroot}%{rpmmacrodir}
ecdb77
install -m 0755 -vd   %{buildroot}%{_rpmluadir}/fedora/srpm
ecdb77
install -m 0644 -vp   rpm/lua/srpm/*lua \
ecdb77
                      %{buildroot}%{_rpmluadir}/fedora/srpm
ecdb77
install -m 0755 -vd   %{buildroot}%{_rpmluadir}/fedora/rpm
ecdb77
install -m 0644 -vp   rpm/lua/rpm/*lua \
ecdb77
                      %{buildroot}%{_rpmluadir}/fedora/rpm
ecdb77
install -m 0755 -vd   %{buildroot}%{_rpmconfigdir}/fileattrs
ecdb77
install -m 0644 -vp   rpm/fileattrs/*.attr \
ecdb77
                      %{buildroot}%{_rpmconfigdir}/fileattrs/
ecdb77
install -m 0755 -vp   rpm/*\.{prov,deps} \
ecdb77
                      %{buildroot}%{_rpmconfigdir}/
ecdb77
ecdb77
%ifarch %{golang_arches}
ecdb77
install -m 0644 -vp   rpm/macros.d/macros.go-compilers-golang \
ecdb77
                      %{buildroot}%{_rpmconfigdir}/macros.d/macros.go-compiler-golang
ecdb77
%endif
ecdb77
ecdb77
%ifarch %{gccgo_arches}
ecdb77
install -m 0644 -vp   rpm/macros.d/macros.go-compilers-gcc \
ecdb77
                      %{buildroot}%{_rpmconfigdir}/macros.d/macros.go-compiler-gcc
ecdb77
%endif
ecdb77
ecdb77
# install golist
ecdb77
%if 0%{?bundle_golist}
ecdb77
install -m 0755 -vd                     %{buildroot}%{golist_execdir}
ecdb77
install -m 0755 -vp %{golist_builddir}/bin/* %{buildroot}%{golist_execdir}/
ecdb77
sed -i "s,golist,%{golist_execdir}/golist,g" %{buildroot}%{_bindir}/go-rpm-integration
ecdb77
%endif
ecdb77
ecdb77
%files
ecdb77
%license LICENSE.txt LICENSE-golist
ecdb77
%doc README.md
ecdb77
%{_bindir}/*
ecdb77
%{_rpmconfigdir}/fileattrs/*.attr
ecdb77
%{_rpmconfigdir}/*.prov
ecdb77
%{_rpmconfigdir}/*.deps
ecdb77
%{_rpmconfigdir}/macros.d/macros.go-rpm*
ecdb77
%{_rpmconfigdir}/macros.d/macros.go-compiler*
ecdb77
%{_rpmluadir}/fedora/rpm/*.lua
ecdb77
# package golist
ecdb77
%if 0%{?bundle_golist}
ecdb77
%{golist_execdir}/golist
ecdb77
%endif
ecdb77
ecdb77
%files -n go-srpm-macros
ecdb77
%license LICENSE.txt
ecdb77
%doc README.md
ecdb77
%{_rpmconfigdir}/macros.d/macros.go-srpm
ecdb77
%{_rpmluadir}/fedora/srpm/*.lua
ecdb77
ecdb77
%files -n go-filesystem
ecdb77
%dir %{gopath}
ecdb77
%dir %{gopath}/src
ecdb77
ecdb77
%files -n go-rpm-templates
ecdb77
%license LICENSE-templates.txt
ecdb77
%doc README.md
ecdb77
# https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/51
ecdb77
%dir %{dirname:%{_spectemplatedir}}
ecdb77
%dir %{_spectemplatedir}
ecdb77
%{_spectemplatedir}/*.spec
ecdb77
ecdb77
%changelog
6e9160
* Wed Nov 23 2022 Alejandro Sáez <asm@redhat.com> - 3.2.0-1
6e9160
- Update to 3.2.0
6e9160
- Add add-gobuild-and-gotest.patch
6e9160
- Resolves: rhbz#1965292
6e9160
6e9160
* Wed Jan 26 2022 Alejandro Sáez <asm@redhat.com> - 3.0.9-10
6e9160
- Fix typos in update-default-gobuild-args.patch
6e9160
- Related: rhbz#2043107
6e9160
ecdb77
* Tue Jan 18 2022 David Benoit <dbenoit@redhat.com> 3.0.9-9
ecdb77
- Delete remove-fedora-dependency-automation.patch
ecdb77
- Bundle golist in /usr/libexec
ecdb77
- Related: rhbz#2043107
ecdb77
ecdb77
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com>
ecdb77
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
ecdb77
  Related: rhbz#1991688
ecdb77
ecdb77
* Tue Aug 03 2021 David Benoit <dbenoit@redhat.com> 3.0.9-7
ecdb77
- Escape quotation marks in gobuildflags
ecdb77
- Resolves: rhbz#1988717
ecdb77
ecdb77
* Tue Jul 27 2021 David Benoit <dbenoit@redhat.com> 3.0.9-6
ecdb77
- Remove arch conditional on gocompilerflags
ecdb77
- Related: rhbz#1982298
ecdb77
ecdb77
* Fri Jul 23 2021 David Benoit <dbenoit@redhat.com> 3.0.9-5
ecdb77
- Remove fedora-specific Go dependency automation macros
ecdb77
- Remove dependency on golist
ecdb77
- Temporarily remove incompatible template spec files
ecdb77
- Update gobuild flags
ecdb77
- Resolves: rhbz#1982298
ecdb77
ecdb77
* Thu Apr 15 2021 Mohan Boddu <mboddu@redhat.com>
ecdb77
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
ecdb77
ecdb77
* Thu Feb 11 2021 Jeff Law  <law@redhat.com> - 3.0.9-3
ecdb77
- Drop 32 bit arches in EL 9 (originally from Petr Sabata)
ecdb77
ecdb77
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.9-2
ecdb77
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
ecdb77
ecdb77
* Thu Aug 13 2020 Neal Gompa <ngompa13@gmail.com> - 3.0.9-1
ecdb77
- Update to 3.0.9
ecdb77
ecdb77
* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.8-6
ecdb77
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
ecdb77
ecdb77
* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.8-5
ecdb77
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
ecdb77
ecdb77
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.8-4
ecdb77
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
ecdb77
ecdb77
* Wed Jun 05 2019 Nicolas Mailhot <nim@fedoraproject.org>
ecdb77
- 3.0.8-3
ecdb77
- initial Fedora import, for golist 0.10.0 and redhat-rpm-config 130