#27 Port existing Go packages to the new macros
Opened 3 years ago by nim. Modified 3 years ago

Either:

  • let Fedora Go packagers adapt their specs to the new macros at their own pace, or
  • do a mass change followed by a mass rebuild (see next part).

A mass rebuild is safer but relies on the goodwill of every packager.

Why?

  • the new macros are mostly backwards compatible except for slight changes needed to fix bugs and manage multi-source and dynamic build dependencies.
  • two hours of quick and dirty midnight fixing were sufficient to get most existing packages to build in copr.
  • creating an intermediary GOPATH tree in %prep safely needs a lot more information about source archive structure that %(auto)setup exposes to rpm, so all the packages that were not ported cleanly to %forge(auto)setup, and used %autosetup workarounds (or similar) to unpack, will now fail hard
    • probably, about a score of those among the 700 existing packages

Functional overview

  • GOPATH setup is now done directly in %prep via %goprep instead of delaying it later with %gobuildroot.

    • necessary to support specs with multiple source archives
    • necessary to have a working GOPATH tree at the end of %prep that can be used by golist to compute dynamic build dependencies
    • that actually simplified the codebase and removed lots of buggy code
  • intermediary package build artifacts are now stored in %{gobuilddir}/src/ (for the GOPATH tree) and %{gobuilddir}/bin/ (for produced binaries)

    • that was necessary to support specs with multiple source archives, since they do not share the same tree root in %{_builddir}

Practically

Use %goprep

Replace the following

%prep
%forgesetup / %forgeautosetup / %setup / %autosetup

with

%prep
%goprep
%patchX -pY # as many as necessary 
%gogenbr -r

(see also go-rpm-macros RFE 3

That requires fixing the specs that workaround %forgesetup breakage with various flags or %(auto)setup calls. %goprep has the same requirements as %forgesetup but does much more than just unpacking sources. It can not be substituted with %(auto)setup.

Remove %gobuildroot calls

%gobuildroot is still provided as a compat macro for now but very lightly tested and likely to break soonish.

Use %{gobuilddir}/bin when building binaries

Change references to _bin/ to references to %{gobuilddir}/bin/

Replace %gochecks calls with %gocheck

Change %gochecks calls to %gocheck:

  • this is optional, they are aliased for now, and the aliasing is simple and not likely to break soon
  • however the clean-up is trivial to implement

Other changes

The new macro set permits more simplifications in existing spec files. However, those simplifications are not required to get existing specs to build. Therefore they are not listed here.

To get an idea of the new enhancements, take a look at the provided templates.


Metadata Update from @nim:
- Issue unmarked as blocking: #20
- Issue marked as depending on: #23

3 years ago

Wait, when will this be in effect?

@eclipseo You need to read the full plan in #20 . @jcajka asked to break it into issues, but you can’t really understand their logic individually.

If anyone is doing automated changes, please use rpmdev-bumpspec to bump the Release number. No manual changelog editing like the last time.

Login to comment on this ticket.

Metadata