google / go-licenses

A lightweight tool to report on the licenses used by a Go package and its dependencies. Highlight! Versioned external URL to licenses can be found at the same time.
Apache License 2.0
833 stars 125 forks source link

How to get licenses of just built package #118

Closed BastianZim closed 2 years ago

BastianZim commented 2 years ago

Hi everybody,

I have a question about extracting the license of a freshly built package.

Background is, that I would like to add this tool to the conda-forge docs to make it easier for maintainers to correctly include go licenses.

The collection of licenses would therefore be right after a package is built with the ideal process being the following:

  1. Conda-build builds the package

  2. go-licenses downloads all licenses

  3. conda-build includes the output folder in the package and finishes packaging it.

Step 1. and 3. is taken care of by our infrastructure but 2. fails with

Error: errors for ["github.com/mozilla/sops"]:
github.com/mozilla/sops: -: no required module provides package github.com/mozilla/sops; to add it:
    go get github.com/mozilla/sops

Logs: https://dev.azure.com/conda-forge/feedstock-builds/_build/results?buildId=479803&view=logs&jobId=656edd35-690f-5c53-9ba3-09c10d0bea97&j=656edd35-690f-5c53-9ba3-09c10d0bea97&t=e5c8ab1d-8ff9-5cae-b332-e15ae582ed2d

The script for this is:

script:
     - pushd {{ pkg_src }}
     - make install
     - go-licenses save "github.com/mozilla/sops" --save_path="go_licenses"

Ref: https://github.com/conda-forge/go-sops-feedstock/pull/9/files

And the PR where I tried this is https://github.com/conda-forge/go-sops-feedstock/pull/9

Therefore, my question would be:

  1. How do I need to include go-licenses in the workflow so that everything is captured?

  2. And additionally, the docs include / before the folder where the output is stored. Is that OS-specific, or is that correctly translated for Win? Ref: https://github.com/google/go-licenses#complying-with-license-terms

Bobgy commented 2 years ago

Hi @BastianZim, just sharing my guesses first:

  1. in the environment, can you build the same go package? go-licenses must be run in an environment with full go development env and dependencies are downloaded (go mod download)
  2. Is the root package "github.com/mozilla/sops" buildable as a binary? If not, you might want to choose between all subpackages "github.com/mozilla/sops/..." or specify the package of the built go binary explicitly "github.com/mozilla/sops/cmd/some-cli".
Bobgy commented 2 years ago
  1. And additionally, the docs include / before the folder where the output is stored. Is that OS-specific, or is that correctly translated for Win? Ref: https://github.com/google/go-licenses#complying-with-license-terms

Yes, that's OS-specific. I'm not sure whether go-licenses work properly in windows, recommend reporting a separate issue if you hit any problems.

Bobgy commented 2 years ago

FYI, I just revamped documentation in https://github.com/google/go-licenses/pull/111, if you still have anything unclear.

BastianZim commented 2 years ago

Working now with the new docs, thanks!