%global forgeurl https://gitlab.com/eclipseo/gomod-rpm-macros Version: 0.1.1 %global debug_package %nil %forgemeta # Master definition that will be written to macro files %global golang_arches_future x86_64 %{arm} aarch64 ppc64le s390x riscv64 %global golang_arches %{ix86} %{golang_arches_future} %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 %global goproxy %{_datadir}/gocode/pkg/ Name: gomod-rpm-macros Release: %autorelease Summary: Build-stage rpm automation for Go modular packages License: GPL-3.0-or-later URL: %{forgeurl} Source: %{forgesource} Requires: forgeng-rpm-macros Requires: gomod-srpm-macros = %{?epoch:%{epoch}:}%{version}-%{release} Requires: gomod-filesystem = %{?epoch:%{epoch}:}%{version}-%{release} Requires: modist Requires: redhat-rpm-config >= 293 %ifarch %{golang_arches} Requires: golang Provides: compiler(golang) Provides: compiler(go-compiler) = 2 Obsoletes: go-compilers-golang-compiler < %{?epoch:%{epoch}:}%{version}-%{release} %endif %ifarch %{gccgo_arches} Requires: gcc-go Provides: compiler(gcc-go) Provides: compiler(go-compiler) = 1 Obsoletes: go-compilers-gcc-go-compiler < %{?epoch:%{epoch}:}%{version}-%{release} %endif %description This package provides build-stage rpm automation to simplify the creation of Go language (Golang) modular packages. It does not need to be included in the default build root: gomod-srpm-macros will pull it in for Go packages only. %package -n gomod-srpm-macros Summary: Source-stage rpm automation for Go modular packages BuildArch: noarch Requires: redhat-rpm-config >= 293 # macros.forge and forge.lua were split into a separate package. # redhat-rpm-config pulls in forge-srpm-macros but better to explicitly Require # it. Requires: forgeng-srpm-macros %description -n gomod-srpm-macros This package provides SRPM-stage rpm automation to simplify the creation of Go language (Golang) modular 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 gomod-rpm-macros package, that gomod-srpm-macros will pull in for Go packages only. %package -n gomod-filesystem Summary: Directories used by Go modular packages License: LicenseRef-Fedora-Public-Domain %description -n gomod-filesystem This package contains the basic directory layout used by Go packages. # %%package -n gomod-rpm-templates # Summary: RPM spec templates for Go modular packages # License: MIT # gomod-rpm-macros only exists on some architectures, so this package cannot be noarch # Requires: gomod-rpm-macros = %%{?epoch:%%{epoch}:}%%{version}-%%{release} # %%description -n gomod-rpm-templates # This package contains documented rpm spec templates showcasing how to use the # macros provided by gomod-rpm-macros to create Go packages. %prep %forgeautosetup -p1 %writevars -f rpm/macros.d/macros.gomod-srpm golang_arches golang_arches_future gccgo_arches gopath goproxy # 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 %install install -m 0755 -vd %{buildroot}%{rpmmacrodir} install -m 0755 -vd %{buildroot}%{_rpmluadir}/fedora/srpm install -m 0644 -vp rpm/lua/fedora/srpm/*lua \ %{buildroot}%{_rpmluadir}/fedora/srpm %ifarch %{golang_arches} %{gccgo_arches} install -m 0755 -vd %{buildroot}%{gopath}/src install -m 0755 -vd %{buildroot}%{goproxy}/ # install -m 0755 -vd %%{buildroot}%%{_spectemplatedir} # install -m 0644 -vp templates/rpm/*spec \ # %%{buildroot}%%{_spectemplatedir} install -m 0644 -vp rpm/macros.d/macros.gomod-*rpm* \ %{buildroot}%{rpmmacrodir} install -m 0755 -vd %{buildroot}%{_rpmluadir}/fedora/rpm install -m 0644 -vp rpm/lua/fedora/rpm/*lua \ %{buildroot}%{_rpmluadir}/fedora/rpm install -m 0755 -vd %{buildroot}%{_rpmconfigdir}/fileattrs install -m 0644 -vp rpm/fileattrs/*.attr \ %{buildroot}%{_rpmconfigdir}/fileattrs/ install -m 0755 -vp rpm/*.prov \ %{buildroot}%{_rpmconfigdir}/ %else install -m 0644 -vp rpm/macros.d/macros.gomod-srpm \ %{buildroot}%{rpmmacrodir} %endif %ifarch %{golang_arches} install -m 0644 -vp rpm/macros.d/macros.gomod-compilers-golang{,-pie} \ %{buildroot}%{_rpmconfigdir}/macros.d/ %endif %ifarch %{gccgo_arches} install -m 0644 -vp rpm/macros.d/macros.gomod-compilers-gcc \ %{buildroot}%{_rpmconfigdir}/macros.d/ %endif %ifarch %{golang_arches} %{gccgo_arches} %files %license LICENSE.txt %doc README.md %{_rpmconfigdir}/fileattrs/*.attr %{_rpmconfigdir}/*.prov %{_rpmmacrodir}/macros.gomod-rpm* %{_rpmmacrodir}/macros.gomod-compiler* %{_rpmluadir}/fedora/rpm/*.lua # %%files -n gomod-rpm-templates # %%license LICENSE-templates.txt # %%doc README.md # %%doc NEWS.md # %%dir %%{dirname:%%{_spectemplatedir}} # %%dir %%{_spectemplatedir} # %%{_spectemplatedir}/*.spec %files -n gomod-filesystem %dir %{gopath} %dir %{gopath}/src %dir %{goproxy} %endif %files -n gomod-srpm-macros %license LICENSE.txt %doc README.md %{_rpmmacrodir}/macros.gomod-srpm %{_rpmluadir}/fedora/srpm/*.lua %changelog %autochangelog