Re: Packaging a go application

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Robert,

Thanks for the awesome write-up! This will help a lot.

I am unsure how I managed to miss your reply.

Cheers!

On 12/9/20 8:20 PM, Robert-André Mauchin wrote:

This gonna be tricky because of the Makefile we can't use because we do not support Go modules yet. And git.sr.ht is not a supported repo home.

First you should use go2rpm to get the basic structure of your SPEC:
go2rpm --stdout git.sr.ht/~sircmpwn/aerc -f https://git.sr.ht/~sircmpwn/aerc

Here's one modified to work with Drew's Makefile while keeping Fedora's flags for the binary compilation, and the handling git.sr.ht:

# Generated by go2rpm 1.3
%bcond_without check

# https://git.sr.ht/~sircmpwn/aerc
%global goipath         git.sr.ht/~sircmpwn/aerc
%global forgeurl        https://git.sr.ht/~sircmpwn/aerc
Version:                0.5.2
%global tag             0.5.2
# /!\ Prerelease to fix compilation with go-pgpmail
%global commit          b56a688589c946ff8224f3d9e2e73de2edbc39b4
%global repo            aerc
%global archivename     %{repo}-%{commit}
%global archiveext      tar.gz
%global archiveurl %{forgeurl}/archive/%{commit}.%{archiveext}
%global topdir          %{repo}-%{commit}
%global extractdir      %{repo}-%{commit}
%global scm             git

%gometa

%global common_description %{expand:
Aerc is an email client that runs in your terminal. It's highly
efficient and extensible, perfect for the discerning hacker.}

%global golicenses      LICENSE
%global godocs          doc README.md

Name:           aerc
Release:        1%{?dist}
Summary:        Email client for your terminal

License:        MIT
URL:            %{gourl}
Source0:        %{gosource}
# Disable building of aerc that we handle manually in the SPEC
Patch0:         aerc-fix-makefile.patch

BuildRequires:  scdoc
BuildRequires:  golang(git.sr.ht/~sircmpwn/getopt)
BuildRequires:  golang(git.sr.ht/~sircmpwn/tcell)
BuildRequires:  golang(git.sr.ht/~sircmpwn/tcell/views)
BuildRequires:  golang(github.com/brunnre8/go.notmuch)
BuildRequires:  golang(github.com/creack/pty)
BuildRequires:  golang(github.com/danwakefield/fnmatch)
BuildRequires:  golang(github.com/ddevault/go-libvterm)
BuildRequires:  golang(github.com/emersion/go-imap)
BuildRequires:  golang(github.com/emersion/go-imap-idle)
BuildRequires:  golang(github.com/emersion/go-imap-sortthread)
BuildRequires:  golang(github.com/emersion/go-imap/client)
BuildRequires:  golang(github.com/emersion/go-maildir)
BuildRequires:  golang(github.com/emersion/go-message)
BuildRequires:  golang(github.com/emersion/go-message/charset)
BuildRequires:  golang(github.com/emersion/go-message/mail)
BuildRequires:  golang(github.com/emersion/go-message/textproto)
BuildRequires:  golang(github.com/emersion/go-pgpmail)
BuildRequires:  golang(github.com/emersion/go-sasl)
BuildRequires:  golang(github.com/emersion/go-smtp)
BuildRequires:  golang(github.com/fsnotify/fsnotify)
BuildRequires:  golang(github.com/go-ini/ini)
BuildRequires:  golang(github.com/google/shlex)
BuildRequires:  golang(github.com/imdario/mergo)
BuildRequires:  golang(github.com/kyoh86/xdg)
BuildRequires:  golang(github.com/mattn/go-isatty)
BuildRequires:  golang(github.com/mattn/go-runewidth)
BuildRequires:  golang(github.com/miolini/datacounter)
BuildRequires:  golang(github.com/mitchellh/go-homedir)
BuildRequires:  golang(github.com/pkg/errors)
BuildRequires:  golang(github.com/ProtonMail/go-crypto/openpgp)
BuildRequires: golang(github.com/ProtonMail/go-crypto/openpgp/errors)
BuildRequires: golang(github.com/ProtonMail/go-crypto/openpgp/packet)
BuildRequires:  golang(github.com/riywo/loginshell)
BuildRequires:  golang(golang.org/x/oauth2)
Requires:       notmuch

%if %{with check}
# Tests
BuildRequires:  golang(github.com/stretchr/testify/assert)
%endif

%description
%{common_description}

%prep
%goprep
%patch0 -p1
# From go.mod replace statements:
# replace golang.org/x/crypto => github.com/ProtonMail/go-crypto v0.0.0-20200420072808-71bec3603bf3 # replace github.com/gdamore/tcell => git.sr.ht/~sircmpwn/tcell v0.0.0-20190807054800-3fdb6bc01a50 # replace github.com/zenhack/go.notmuch => github.com/brunnre8/go.notmuch v0.0.0-20201126061756-caa2daf7093c sed -i "s|golang.org/x/crypto|github.com/ProtonMail/go-crypto|" $(find . -name "*.go" -type f) sed -i "s|github.com/gdamore/tcell|git.sr.ht/~sircmpwn/tcell|" $(find . -name "*.go" -type f) sed -i "s|github.com/zenhack/go.notmuch|github.com/brunnre8/go.notmuch|" $(find . -name "*.go" -type f)

%build
export GOFLAGS=-tags=notmuch
export LDFLAGS="-X main.Prefix=%{_prefix} \
                -X main.ShareDir=%{_datadir}/aerc \
                -X main.Version=%{version} "
%gobuild -o %{gobuilddir}/bin/aerc %{goipath}

%install
install -m 0755 -vd                     %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
export PREFIX=%{_prefix}
%make_install

%if %{with check}
%check
%gocheck
%endif

%files
%license LICENSE
%doc doc README.md
%{_bindir}/*
%{_mandir}/man1/%{name}.1*
%{_mandir}/man1/%{name}-*.1.*
%{_datadir}/aerc

%changelog


Now the boring part is getting all the missing deps, and the missing deps's deps.
Here are the missing direct deps:

BuildRequires:  golang(git.sr.ht/~sircmpwn/getopt)
BuildRequires:  golang(git.sr.ht/~sircmpwn/tcell)
BuildRequires:  golang(github.com/brunnre8/go.notmuch)
BuildRequires:  golang(github.com/ddevault/go-libvterm)
BuildRequires:  golang(github.com/emersion/go-imap)
BuildRequires:  golang(github.com/emersion/go-imap-idle)
BuildRequires:  golang(github.com/emersion/go-imap-sortthread)
BuildRequires:  golang(github.com/emersion/go-maildir)
BuildRequires:  golang(github.com/emersion/go-message)
BuildRequires:  golang(github.com/emersion/go-pgpmail)
BuildRequires:  golang(github.com/emersion/go-sasl)
BuildRequires:  golang(github.com/emersion/go-smtp)
BuildRequires:  golang(github.com/kyoh86/xdg)
BuildRequires:  golang(github.com/miolini/datacounter)
BuildRequires:  golang(github.com/riywo/loginshell)
BuildRequires:  golang(github.com/ProtonMail/go-crypto)

You should use go2rpm to generate the SPECS and then set up a COPR to tests all the dependencies. Note that there are significant difficulties for a novice.

You'll find all the SPECS to help you here:
https://eclipseo.fedorapeople.org/aerc/

And a working COPR here:
https://copr.fedorainfracloud.org/coprs/eclipseo/aerc/

Read them all to grok what they are doing and make them your own.

I'n available for any questions regarding the packaging.

Happy hacking!

Robert-André


_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux