Bug 1788893 - Review Request: golang-github-google-gousb - Idiomatic Go bindings for libusb-1.0
Summary: Review Request: golang-github-google-gousb - Idiomatic Go bindings for libusb...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: Package Review
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Robert-André Mauchin 🐧
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1788637
TreeView+ depends on / blocked
 
Reported: 2020-01-08 10:25 UTC by Jakub Jelen
Modified: 2020-01-24 17:08 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-01-24 17:08:26 UTC
Type: ---
Embargoed:
zebob.m: fedora-review+


Attachments (Terms of Use)

Description Jakub Jelen 2020-01-08 10:25:20 UTC
Spec URL: https://jjelen.fedorapeople.org/golang-github-google-gousb.spec
SRPM URL: https://jjelen.fedorapeople.org/golang-github-google-gousb-0-0.1.20200108git18f4c1d.fc32.src.rpm
Description: The gousb package is an attempt at wrapping the libusb library into a Go-like binding.
Fedora Account System Username: jjelen

This package is needed for updating the yubihsm-connector to new version (bug #1788637).

Latest builds of both packages are in copr (Fedora 31+):

https://copr.fedorainfracloud.org/coprs/jjelen/yubihsm-shell/builds/

Comment 1 Jakub Jelen 2020-01-08 14:43:23 UTC
And if somebody more knowledgeable of go will be reviewing this, I could make use of some hints why the yubihsm-connector build is failing for me when it works fine locally:

https://copr.fedorainfracloud.org/coprs/jjelen/yubihsm-shell/build/1141273/

Comment 2 Robert-André Mauchin 🐧 2020-01-08 20:28:04 UTC
.20200108git18f4c1d8 is not needed in Release, it is computed automatically in dist macro.

 - Not needed, this is automatically added:

BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
BuildRequires:  go-rpm-macros

 - You're missing the license and docs:

%global common_description %{expand:
The gousb package is an attempt at wrapping the libusb library into a 
Go-like binding.}

%gometa

%global golicenses      LICENSE
%global godocs          AUTHORS CONTRIBUTING.md README.md


 - You need a Requires for pkgconfig(libusb) of the devel package

%global godevelheader %{expand:
Requires:       pkgconfig(libusb)}

Comment 3 Robert-André Mauchin 🐧 2020-01-08 21:07:02 UTC
(In reply to Jakub Jelen from comment #1)
> And if somebody more knowledgeable of go will be reviewing this, I could
> make use of some hints why the yubihsm-connector build is failing for me
> when it works fine locally:
> 
> https://copr.fedorainfracloud.org/coprs/jjelen/yubihsm-shell/build/1141273/

That's because you didn't Requires: pkgconfig(libusb)} so when it tries to build github.com/google/gousb it doesn't find the required devel files:

github.com/google/gousb
mkdir -p $WORK/b043/
cd /usr/share/gocode/src/github.com/google/gousb
pkg-config --cflags -- libusb-1.0
# pkg-config --cflags  -- libusb-1.0
Package libusb-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libusb-1.0.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libusb-1.0', required by 'virtual:world', not found
pkg-config: exit status 1

Comment 4 Jakub Jelen 2020-01-09 08:12:56 UTC
(In reply to Robert-André Mauchin from comment #2)
> .20200108git18f4c1d8 is not needed in Release, it is computed automatically
> in dist macro.

Right. I already figured this out, but did not update the spec file. Will update.

>  - Not needed, this is automatically added:
> 
> BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
> BuildRequires:  go-rpm-macros

Right. I figured this out too, but I forgot to remove it.

>  - You're missing the license and docs:
> 
> %global common_description %{expand:
> The gousb package is an attempt at wrapping the libusb library into a 
> Go-like binding.}
> 
> %gometa
> 
> %global golicenses      LICENSE
> %global godocs          AUTHORS CONTRIBUTING.md README.md

Thanks. I added that.

>  - You need a Requires for pkgconfig(libusb) of the devel package
> 
> %global godevelheader %{expand:
> Requires:       pkgconfig(libusb)}

Thank you very much. The updated spec file and srpm are here:

Spec URL: https://jjelen.fedorapeople.org/golang-github-google-gousb.spec
SRPM URL: https://jjelen.fedorapeople.org/golang-github-google-gousb-0-0.1.20200108git18f4c1d.fc32.src.rpm

Also checking the old go usb package that I did last year golang-github-thorduri-libusb, it is still not needed for anything else than yubihsm-connector so I guess I can retire it in the next release and mark this package as

  Obsoletes: golang-github-thorduri-libusb < 0-0.4

What do you think?

With these changes, the copr builds go fine:

https://copr.fedorainfracloud.org/coprs/jjelen/yubihsm-shell/builds/

But only if I allow internet access during build. Otherwise it fails with the following during "go generate". Do you have any tips for this issue from top of your head (I am sorry for stealing a topic a bit):

+ go generate
go: github.com/google/gousb.0-20190812193832-18f4c1d8a750: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /builddir/go/pkg/mod/cache/vcs/cc39ad3e0b2f5cf4389fa4743b421f443f8cb8378b0937fa336ad02ef8683e17: exit status 128:
	fatal: unable to access 'https://github.com/google/gousb/': Could not resolve host: github.com

Comment 5 Elliott Sales de Andrade 2020-01-10 05:54:03 UTC
They aren't the same, one shouldn't obsolete the other. (I ported yubihsm-connector from old to new gousb.)

Comment 6 Jakub Jelen 2020-01-10 09:08:13 UTC
(In reply to Elliott Sales de Andrade from comment #5)
> They aren't the same, one shouldn't obsolete the other. (I ported
> yubihsm-connector from old to new gousb.)

Thank you for your input. I know, that they are not the same, but getting the golang-github-thorduri-libusb was already questioned [1] as the upstream repository is archived.

At this moment, the only package requiring the old go libusb package is the yubihsm-connector and after having this new google gousb package, I will probably retired the old one from Fedora as it will be for no good use.

The Obsoletes here in RPM is mostly for the Fedora packaging processes so the old unneeded packages are not kept on the users machines forever. If in future, the package will become useful again, it can be built again (with new release version) and installed without any problem as the above obsoletes removes only the versions built so far.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1671450#c1

Comment 7 Robert-André Mauchin 🐧 2020-01-12 19:35:13 UTC
It's very unlikely this package is installed on end-user machines, It's mostly only used during the build process of yubihsm-connector on Koji. Don't add an Obsolete if they are not the same like Elliott said.

Comment 8 Robert-André Mauchin 🐧 2020-01-12 20:13:57 UTC
 - This line is not necessary as it is automatically added by Go packaging:

BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}

 - License ok
 - Latest version packaged
 - Builds in mock
 - No rpmlint errors
 - Conforms to Packaging Guidelines


Package approved.


(In reply to Jakub Jelen from comment #4)
> 
> With these changes, the copr builds go fine:
> 
> https://copr.fedorainfracloud.org/coprs/jjelen/yubihsm-shell/builds/
> 
> But only if I allow internet access during build. Otherwise it fails with
> the following during "go generate". Do you have any tips for this issue from
> top of your head (I am sorry for stealing a topic a bit):
> 
> + go generate
> go: github.com/google/gousb.0-20190812193832-18f4c1d8a750: invalid
> version: git fetch -f origin refs/heads/*:refs/heads/*
> refs/tags/*:refs/tags/* in
> /builddir/go/pkg/mod/cache/vcs/
> cc39ad3e0b2f5cf4389fa4743b421f443f8cb8378b0937fa336ad02ef8683e17: exit
> status 128:
> 	fatal: unable to access 'https://github.com/google/gousb/': Could not
> resolve host: github.com


yubihsm-connector use the new Go modules to build/vendor stuff, we are not yet compatible with modules in Fedora so we disable them.
However when running go generate, it will try to download the modules from the Internet. Try disabling go modules before running  Go generate:

export GO111MODULE=off

Comment 9 Jakub Jelen 2020-01-13 08:21:22 UTC
Thank you very much! Please, let me know if you will need some review in exchange.

I tried with the GO111MODULE=off, but it did not work (at least not on my Fedora 31):

  + GO111MODULE=off
  + go generate
  build flag -mod=vendor only valid when using modules
  main.go:94: running "go": exit status 1

Is there something else I can try, bug to fill or follow to keep updated on the progress? Anyway, we should follow this discussion in bug #1788637.

Comment 10 Gwyn Ciesla 2020-01-13 13:39:05 UTC
(fedscm-admin):  The Pagure repository was created at https://src.fedoraproject.org/rpms/golang-github-google-gousb

Comment 11 Robert-André Mauchin 🐧 2020-01-13 16:24:06 UTC
(In reply to Jakub Jelen from comment #9)
> Thank you very much! Please, let me know if you will need some review in
> exchange.
> 
> I tried with the GO111MODULE=off, but it did not work (at least not on my
> Fedora 31):
> 
>   + GO111MODULE=off
>   + go generate
>   build flag -mod=vendor only valid when using modules
>   main.go:94: running "go": exit status 1
> 
> Is there something else I can try, bug to fill or follow to keep updated on
> the progress? Anyway, we should follow this discussion in bug #1788637.

Try removing -mod=vendor from the generate command in main.go:

sed -i "s| -mod=vendor||" main.go

Comment 12 Jakub Jelen 2020-01-13 16:39:04 UTC
This look like it did the trick. The latest build looks like passing even without the internet access:

https://copr.fedorainfracloud.org/coprs/jjelen/yubihsm-shell/build/1144065/

Thank you for your help! I will update the package as soon as this dependency will be in repos.

Comment 13 Fedora Update System 2020-01-14 01:43:44 UTC
golang-github-google-gousb-0-0.1.20200108git18f4c1d.fc31 has been pushed to the Fedora 31 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-757e6438ec

Comment 14 Fedora Update System 2020-01-24 17:08:26 UTC
golang-github-google-gousb-0-0.1.20200108git18f4c1d.fc31 has been pushed to the Fedora 31 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.