go-rpm-macros/SPECS/go-rpm-macros.spec

361 lines
11 KiB
RPMSpec
Raw Normal View History

2021-11-03 17:00:17 +00:00
%global forgeurl https://pagure.io/go-rpm-macros
2024-09-30 15:35:40 +00:00
Version: 3.6.0
2021-11-03 17:00:17 +00:00
%forgemeta
#https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/51
%global _spectemplatedir %{_datadir}/rpmdevtools/fedora
%global _docdir_fmt %{name}
# Master definition that will be written to macro files
2023-09-21 18:42:00 +00:00
%global golang_arches_future x86_64 %{arm} aarch64 ppc64le s390x
%global golang_arches %{ix86} %{golang_arches_future}
2021-11-03 17:00:17 +00:00
%global gccgo_arches %{mips}
%if 0%{?rhel} >= 9
%global golang_arches x86_64 aarch64 ppc64le s390x
%endif
# Go sources can contain arch-specific files and our macros will package the
# correct files for each architecture. Therefore, move gopath to _libdir and
# make Go devel packages archful
%global gopath %{_datadir}/gocode
2022-03-01 12:02:05 +00:00
%global bundle_golist 1
2024-09-30 15:35:40 +00:00
%global golist_version 0.10.4
2025-03-11 07:19:06 +00:00
%if 0%{?bundle_golist}
%global golist_builddir golist-%{golist_version}
2022-03-01 12:02:05 +00:00
%global golist_goipath pagure.io/golist
# where to bundle the golist executable
2025-03-11 07:19:06 +00:00
%global golist_execdir %{_libexecdir}/go-rpm-macros
2022-03-01 12:02:05 +00:00
# define gobuild to avoid this package requiring itself to build
2025-03-11 07:19:06 +00:00
%undefine _auto_set_build_flags
%global _dwz_low_mem_die_limit 0
%define gobuild(o:) GO111MODULE=on go build -buildmode pie -compiler gc -tags="rpm_crashtraceback ${GO_BUILDTAGS-${BUILDTAGS-}}" -a -v -x -ldflags "${GO_LDFLAGS-${LDFLAGS-}} -B 0x$(echo "%{name}-%{version}-%{release}-${SOURCE_DATE_EPOCH:-}" | sha1sum | cut -d ' ' -f1) -compressdwarf=false -linkmode=external -extldflags '%{build_ldflags}'" %{?**};
%else
%global debug_package %{nil}
2022-03-01 12:02:05 +00:00
%endif
2021-11-03 17:00:17 +00:00
ExclusiveArch: %{golang_arches} %{gccgo_arches}
Name: go-rpm-macros
2025-03-11 07:19:06 +00:00
Release: 7%{?dist}
2021-11-03 17:00:17 +00:00
Summary: Build-stage rpm automation for Go packages
License: GPLv3+
URL: %{forgeurl}
2022-03-01 12:02:05 +00:00
Source0: %{forgesource}
%if 0%{?bundle_golist}
Source1: https://pagure.io/golist/archive/v%{golist_version}/golist-%{golist_version}.tar.gz
%endif
2021-11-03 17:00:17 +00:00
Requires: go-srpm-macros = %{version}-%{release}
Requires: go-filesystem = %{version}-%{release}
2022-03-01 12:02:05 +00:00
%if 0%{?bundle_golist}
BuildRequires: golang
2025-03-11 07:19:06 +00:00
Provides: bundled(golist) = %{golist_version}
2022-03-01 12:02:05 +00:00
%else
Requires: golist
%endif
2021-11-03 17:00:17 +00:00
%ifarch %{golang_arches}
Requires: golang
Provides: compiler(golang)
Provides: compiler(go-compiler) = 2
Obsoletes: go-compilers-golang-compiler < %{version}-%{release}
%endif
%ifarch %{gccgo_arches}
Requires: gcc-go
Provides: compiler(gcc-go)
Provides: compiler(go-compiler) = 1
Obsoletes: go-compilers-gcc-go-compiler < %{version}-%{release}
%endif
2022-03-01 12:02:05 +00:00
# Replace golang-github-urfave-cli with a minimal
# command line parser backend to bootstrap golist
# without dependencies.
Patch1: golist-bootstrap-cli-no-vendor.patch
2024-09-30 15:35:40 +00:00
# Add libexec to PATH in order to launch golist in every script
Patch2: 0001-Add-libexec-to-path-for-EPEL9-golist.patch
2022-03-01 12:02:05 +00:00
2023-03-28 10:10:34 +00:00
# RHEL 8 only provides the macros.go-srpm file which includes gobuild and gotest.
# 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.
# For a simple fix, this patch ports both RHEL 8 macros to macros.go-srpm.
2024-03-28 10:18:19 +00:00
# This also sets the GOAMD64 variable to v2
2023-03-28 10:10:34 +00:00
# Resolves: rhbz#1965292
2024-03-28 10:18:19 +00:00
# Resolves: RHEL-5529
2024-09-30 15:35:40 +00:00
Patch3: add-gobuild-and-gotest.patch
# Remove when rpm >= 4.17.0
Patch4: remove-isdefined-function.patch
2023-03-28 10:10:34 +00:00
2021-11-03 17:00:17 +00:00
%description
This package provides build-stage rpm automation to simplify the creation of Go
language (golang) packages.
It does not need to be included in the default build root: go-srpm-macros will
pull it in for Go packages only.
%package -n go-srpm-macros
Summary: Source-stage rpm automation for Go packages
BuildArch: noarch
Requires: redhat-rpm-config
%description -n go-srpm-macros
This package provides SRPM-stage rpm automation to simplify the creation of Go
language (golang) packages.
It limits itself to the automation subset required to create Go SRPM packages
and needs to be included in the default build root.
The rest of the automation is provided by the go-rpm-macros package, that
go-srpm-macros will pull in for Go packages only.
%package -n go-filesystem
Summary: Directories used by Go packages
License: Public Domain
%description -n go-filesystem
This package contains the basic directory layout used by Go packages.
%package -n go-rpm-templates
Summary: RPM spec templates for Go packages
License: MIT
BuildArch: noarch
Requires: go-rpm-macros = %{version}-%{release}
#https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/51
#Requires: redhat-rpm-templates
%description -n go-rpm-templates
This package contains documented rpm spec templates showcasing how to use the
macros provided by go-rpm-macros to create Go packages.
%prep
%forgesetup
2023-09-21 18:42:00 +00:00
%writevars -f rpm/macros.d/macros.go-srpm golang_arches golang_arches_future gccgo_arches gopath
2022-03-01 12:02:05 +00:00
for template in templates/rpm/*\.spec ; do
target=$(echo "${template}" | sed "s|^\(.*\)\.spec$|\1-bare.spec|g")
grep -v '^#' "${template}" > "${target}"
touch -r "${template}" "${target}"
done
# unpack golist and patch
%if 0%{?bundle_golist}
2024-09-30 15:35:40 +00:00
# Add libexec to PATH
%patch2 -p1
2025-03-11 07:19:06 +00:00
tar -xf %{SOURCE1}
pushd %{golist_builddir}
2022-03-01 12:02:05 +00:00
%patch1 -p1
popd
2025-03-11 07:19:06 +00:00
cp %{golist_builddir}/LICENSE LICENSE-golist
2022-03-01 12:02:05 +00:00
%endif
2024-09-30 15:35:40 +00:00
%patch3 -p1
%patch4 -p1
2023-03-28 10:10:34 +00:00
2022-03-01 12:02:05 +00:00
%build
# build golist
%if 0%{?bundle_golist}
2025-03-11 07:19:06 +00:00
pushd %{golist_builddir}
go mod init %{golist_goipath} && go mod tidy
2022-03-01 12:02:05 +00:00
for cmd in cmd/* ; do
2025-03-11 07:19:06 +00:00
%gobuild -o bin/$(basename $cmd) ./$cmd
2022-03-01 12:02:05 +00:00
done
popd
%endif
2021-11-03 17:00:17 +00:00
%install
2025-03-11 07:19:06 +00:00
install -m 0755 -vd %{buildroot}%{rpmmacrodir}
install -m 0755 -vd %{buildroot}%{_rpmluadir}/fedora/srpm
install -m 0644 -vp rpm/lua/srpm/*lua \
%{buildroot}%{_rpmluadir}/fedora/srpm
%ifarch %{golang_arches} %{gccgo_arches}
2021-11-03 17:00:17 +00:00
# Some of those probably do not work with gcc-go right now
# This is not intentional, but mips is not a primary Fedora architecture
# Patches and PRs are welcome
install -m 0755 -vd %{buildroot}%{gopath}/src
install -m 0755 -vd %{buildroot}%{_spectemplatedir}
2025-03-11 07:19:06 +00:00
install -m 0644 -vp templates/rpm/*spec \
%{buildroot}%{_spectemplatedir}
2021-11-03 17:00:17 +00:00
2022-03-01 12:02:05 +00:00
install -m 0755 -vd %{buildroot}%{_bindir}
install -m 0755 bin/* %{buildroot}%{_bindir}
2025-03-11 07:19:06 +00:00
install -m 0644 -vp rpm/macros.d/macros.go-*rpm* \
2021-11-03 17:00:17 +00:00
%{buildroot}%{rpmmacrodir}
install -m 0755 -vd %{buildroot}%{_rpmluadir}/fedora/rpm
install -m 0644 -vp rpm/lua/rpm/*lua \
%{buildroot}%{_rpmluadir}/fedora/rpm
install -m 0755 -vd %{buildroot}%{_rpmconfigdir}/fileattrs
install -m 0644 -vp rpm/fileattrs/*.attr \
%{buildroot}%{_rpmconfigdir}/fileattrs/
2022-03-01 12:02:05 +00:00
install -m 0755 -vp rpm/*\.{prov,deps} \
%{buildroot}%{_rpmconfigdir}/
2025-03-11 07:19:06 +00:00
%else
install -m 0644 -vp rpm/macros.d/macros.go-srpm \
%{buildroot}%{rpmmacrodir}
%endif
2021-11-03 17:00:17 +00:00
%ifarch %{golang_arches}
2025-03-11 07:19:06 +00:00
install -m 0644 -vp rpm/macros.d/macros.go-compilers-golang{,-pie} \
%{buildroot}%{_rpmconfigdir}/macros.d/
2021-11-03 17:00:17 +00:00
%endif
%ifarch %{gccgo_arches}
install -m 0644 -vp rpm/macros.d/macros.go-compilers-gcc \
2025-03-11 07:19:06 +00:00
%{buildroot}%{_rpmconfigdir}/macros.d/
2021-11-03 17:00:17 +00:00
%endif
2022-03-01 12:02:05 +00:00
# install golist
%if 0%{?bundle_golist}
install -m 0755 -vd %{buildroot}%{golist_execdir}
install -m 0755 -vp %{golist_builddir}/bin/* %{buildroot}%{golist_execdir}/
2025-03-11 07:19:06 +00:00
sed -i "s,golist ,%{golist_execdir}/golist ,g" \
%{buildroot}%{_bindir}/go-rpm-integration \
%{buildroot}%{_rpmconfigdir}/gosymlink.deps \
%{buildroot}%{_rpmmacrodir}/macros.go-rpm
2022-03-01 12:02:05 +00:00
%endif
2025-03-11 07:19:06 +00:00
%ifarch %{golang_arches} %{gccgo_arches}
2021-11-03 17:00:17 +00:00
%files
2025-03-11 07:19:06 +00:00
%license LICENSE.txt
%if %{defined bundle_golist}
%license LICENSE-golist
%endif
2021-11-03 17:00:17 +00:00
%doc README.md
2022-03-01 12:02:05 +00:00
%{_bindir}/*
2021-11-03 17:00:17 +00:00
%{_rpmconfigdir}/fileattrs/*.attr
2022-03-01 12:02:05 +00:00
%{_rpmconfigdir}/*.prov
%{_rpmconfigdir}/*.deps
2025-03-11 07:19:06 +00:00
%{_rpmmacrodir}/macros.go-rpm*
%{_rpmmacrodir}/macros.go-compiler*
2021-11-03 17:00:17 +00:00
%{_rpmluadir}/fedora/rpm/*.lua
2022-03-01 12:02:05 +00:00
# package golist
%if 0%{?bundle_golist}
%{golist_execdir}/golist
%endif
2021-11-03 17:00:17 +00:00
%files -n go-rpm-templates
%license LICENSE-templates.txt
%doc README.md
# https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/51
%dir %{dirname:%{_spectemplatedir}}
%dir %{_spectemplatedir}
2022-03-01 12:02:05 +00:00
%{_spectemplatedir}/*.spec
2021-11-03 17:00:17 +00:00
2025-03-11 07:19:06 +00:00
%files -n go-filesystem
%dir %{gopath}
%dir %{gopath}/src
%endif
# we only build go-srpm-macros on all architectures
%files -n go-srpm-macros
%license LICENSE.txt
%doc README.md
%{_rpmmacrodir}/macros.go-srpm
%{_rpmluadir}/fedora/srpm/*.lua
2021-11-03 17:00:17 +00:00
%changelog
2025-03-11 07:19:06 +00:00
* Wed Nov 13 2024 Alejandro Sáez <asm@redhat.com>
- Revert go-rpm-templates to noarch
- Resolves: RHEL-67300
- Related: RHEL-52226
* Wed Nov 06 2024 Alejandro Sáez <asm@redhat.com> - 3.6.0-6
- Add back again ExclusiveArch, it was removed by mistake.
- Resolves: RHEL-52226
* Mon Nov 04 2024 Alejandro Sáez <asm@redhat.com> - 3.6.0-5
- Make golist non optional
- Resolves: RHEL-52226
* Thu Oct 31 2024 Alejandro Sáez <asm@redhat.com> - 3.6.0-4
- Enable debuginfo package
- Resolves: RHEL-52226
2024-09-30 15:35:40 +00:00
* Wed Jul 31 2024 Alejandro Sáez <asm@redhat.com> - 3.6.0-3
- Fix typo in add-gobuild-and-gotest.patch
- Resolves: RHEL-7437
* Wed Jul 31 2024 Alejandro Sáez <asm@redhat.com> - 3.6.0-2
- Remove rpm.isdefined function
- Resolves: RHEL-51368
* Mon Jul 29 2024 Alejandro Sáez <asm@redhat.com> - 3.6.0-1
- Update to 3.6.0
- Revert the usage of rpmautospec, check git's history
- Resolves: RHEL-14963
2024-03-28 10:18:19 +00:00
* Fri Sep 22 2023 Alejandro Sáez <asm@redhat.com> - 3.2.0-3
- Update add-gobuild-and-gotest.patch to add GOPPC64 and GOAMD64
- Resolves: RHEL-5529
2023-09-21 18:42:00 +00:00
* Fri Jul 28 2023 Alejandro Sáez <asm@redhat.com> - 3.2.0-2
- Add golang_arches_future
- Resolves: rhbz#2227224
2023-03-28 10:10:34 +00:00
* Wed Nov 23 2022 Alejandro Sáez <asm@redhat.com> - 3.2.0-1
- Update to 3.2.0
- Add add-gobuild-and-gotest.patch
- Resolves: rhbz#1965292
* Wed Jan 26 2022 Alejandro Sáez <asm@redhat.com> - 3.0.9-10
- Fix typos in update-default-gobuild-args.patch
- Related: rhbz#2043107
2022-03-01 12:02:05 +00:00
* Tue Jan 18 2022 David Benoit <dbenoit@redhat.com> 3.0.9-9
- Delete remove-fedora-dependency-automation.patch
- Bundle golist in /usr/libexec
- Related: rhbz#2043107
2021-11-03 17:00:17 +00:00
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com>
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
2022-03-01 12:02:05 +00:00
* Tue Aug 03 2021 David Benoit <dbenoit@redhat.com> 3.0.9-7
2021-11-03 17:00:17 +00:00
- Escape quotation marks in gobuildflags
- Resolves: rhbz#1988717
* Tue Jul 27 2021 David Benoit <dbenoit@redhat.com> 3.0.9-6
- Remove arch conditional on gocompilerflags
- Related: rhbz#1982298
* Fri Jul 23 2021 David Benoit <dbenoit@redhat.com> 3.0.9-5
- Remove fedora-specific Go dependency automation macros
- Remove dependency on golist
- Temporarily remove incompatible template spec files
- Update gobuild flags
- Resolves: rhbz#1982298
* Thu Apr 15 2021 Mohan Boddu <mboddu@redhat.com>
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Thu Feb 11 2021 Jeff Law <law@redhat.com> - 3.0.9-3
- Drop 32 bit arches in EL 9 (originally from Petr Sabata)
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.9-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Thu Aug 13 2020 Neal Gompa <ngompa13@gmail.com> - 3.0.9-1
- Update to 3.0.9
* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.8-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.8-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.8-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Wed Jun 05 2019 Nicolas Mailhot <nim@fedoraproject.org>
- 3.0.8-3
- initial Fedora import, for golist 0.10.0 and redhat-rpm-config 130