From c34e16dbbc567a086f6e0ca0181a1419086a8811 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Feb 06 2024 01:56:12 +0000 Subject: %goprep: allow using %autosetup for automatic source unpacking This allows combining %goprep and %autopatch without issues. It also allows packagers use %autosetup's SCM functionality. For the reasons outlined in https://pagure.io/go-rpm-macros/issue/3, there is no option to use -p1 or otherwise automatically apply patches using %goprep. Add a separate %autopatch -p1 call for that. The go2rpm template already adds this by default. --- diff --git a/rpm/macros.d/macros.go-rpm b/rpm/macros.d/macros.go-rpm index 8890023..e4dfee4 100644 --- a/rpm/macros.d/macros.go-rpm +++ b/rpm/macros.d/macros.go-rpm @@ -132,13 +132,19 @@ cd "%{mybuilddir}/src/%{mygoipath}" # -k keep the vendor directory, do not delete it # -e use extracted archives, do not perform %setup-like # operations +# -A run %autosetup -N instead of %setup. +# run %autopatch -p1 separately to apply patches +# -S pass an SCM name to %autosetup; implies -A # -v be verbose -%goprep(z:ai:b:s:kerv) %{lua: +%goprep(z:ai:b:s:kervS:A) %{lua: local fedora = require "fedora.common" local extract = (rpm.expand("%{-e}") == "") +-- Use autosetup if either -A or -S is passed +local autosetup = (rpm.expand("%{-A}%{-S}") ~= "") local installdeps = (rpm.expand("%{-r}") == "") local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "") local setupflags = rpm.expand("%{!-v:-q}") +local autosetupflags = rpm.expand("%{-v} %{-S}") local gomkdirflags = rpm.expand("%{?-i} %{?-b} %{?-s} %{-k} %{-v}") local buildrequires = {} local function process(suffix) @@ -147,7 +153,8 @@ local function process(suffix) zsuffix = "-z " .. suffix .. " " end if extract then - print(rpm.expand("%setup " .. setupflags .. " %{?forgesetupargs" .. suffix .. "}\\n")) + setup = autosetup and ("%autosetup -N " .. autosetupflags) or ("%setup " .. setupflags) + print(rpm.expand(setup .." %{?forgesetupargs" .. suffix .. "}\\n")) end print( rpm.expand("%gomkdir " .. zsuffix .. gomkdirflags .. "\\n")) end