You are not logged in.

#1 2018-02-22 14:41:01

marekhwd
Member
Registered: 2018-02-22
Posts: 7

Building Go app offline from source tarball with 3rd party deps

Hello. I'd like to create an ArchLinux package for the new Trezor daemon https://github.com/trezor/trezord-go which is written in Go. I've no experience with Go nor with ArchLinux packaging and I'm puzzled on how Go source dependency management work.

The package source is located here:
https://github.com/trezor/trezord-go/ar … 0.6.tar.gz

The source tarball seems to contain Trezor daemon sources plus dependencies in vendor:

% ls -F1
COPYING
Gopkg.lock
Gopkg.toml
README.md
release/
server/
trezord.go
usb/
vendor/
VERSION
wire/

% tree -L 3 vendor
vendor
├── github.com
│   ├── gorilla
│   │   ├── context
│   │   ├── handlers
│   │   └── mux
│   └── trezor
│       └── usbhid
└── gopkg.in
    └── natefinch
        └── lumberjack.v2

Now when I try to build the package I get error because the dependencies are not in a src directory.

% pwd
/home/marek/work/archpkgs/trezord-go/trezord-go-2.0.6.bak
% GOPATH=`pwd` go build 2>&1
trezord.go:10:2: cannot find package "github.com/trezor/trezord-go/server" in any of:
	/usr/lib/go/src/github.com/trezor/trezord-go/server (from $GOROOT)
	/home/marek/work/archpkgs/trezord-go/trezord-go-2.0.6.bak/src/github.com/trezor/trezord-go/server (from $GOPATH)
trezord.go:11:2: cannot find package "github.com/trezor/trezord-go/usb" in any of:
	/usr/lib/go/src/github.com/trezor/trezord-go/usb (from $GOROOT)
	/home/marek/work/archpkgs/trezord-go/trezord-go-2.0.6.bak/src/github.com/trezor/trezord-go/usb (from $GOPATH)
trezord.go:12:2: cannot find package "gopkg.in/natefinch/lumberjack.v2" in any of:
	/usr/lib/go/src/gopkg.in/natefinch/lumberjack.v2 (from $GOROOT)
	/home/marek/work/archpkgs/trezord-go/trezord-go-2.0.6.bak/src/gopkg.in/natefinch/lumberjack.v2 (from $GOPATH)

If I do `go get -d -v` first, then all the dependencies including Trezor sources will be downloaded into a src directory and the build command above will proceed successfully. But then, what's the point of distributing the source archive with dependencies when _everything_ is fetched from the Internet again?

What's the proper way to build this package offline? How do I make the Go build tool look into current and vendor directory for the sources?

Last edited by marekhwd (2018-02-22 14:41:50)

Offline

#2 2018-03-13 17:25:40

qrwteyrutiyoup
Member
From: Canada
Registered: 2017-12-26
Posts: 17

Re: Building Go app offline from source tarball with 3rd party deps

Take a look at a package with a similar structure, such as yay, to have some ideas:

https://aur.archlinux.org/cgit/aur.git/ … UILD?h=yay

Offline

#3 2018-03-14 16:47:02

jdarnold
Member
From: Medford MA USA
Registered: 2009-12-15
Posts: 485
Website

Re: Building Go app offline from source tarball with 3rd party deps

Have you checked this page:

https://wiki.archlinux.org/index.php/Creating_packages

In specific, at the bottom, there is a link to this page for creating Go packages:

https://wiki.archlinux.org/index.php/Go … guidelines

And a link to a tool for creating Go packages.

Offline

Board footer

Powered by FluxBB