You are not logged in.

#1 2012-03-30 17:34:50

Bellum
Member
Registered: 2011-08-24
Posts: 230

[SOLVED] Packaging go projects

So I started looking at go yesterday. The day after they made these massive changes to the build system, apparently; lucky me. big_smile

I found a project that was updated recently, and I'm trying to make a package out of it so I can figure this thing out, but I'm having problems.

# vim:set ts=2 sw=2 et:
# Maintainer: Aaron P <aaronbpaden at that google place>
pkgname=mdtwm
pkgver=20120329
pkgrel=1
pkgdesc="Mouse-Driven Tiling WM written in Go"
url="https://github.com/ziutek/mdtwm"
arch=('x86_64' 'i686')
license=('BSD')
makedepends=('go')
conflicts=()
replaces=()
backup=()

build() {
  GOPATH=${srcdir}
  go get github.com/ziutek/mdtwm
}

#package() {
#}

I've played around with changing GOPATH and GOROOT, but whatever I do, either I get a permission denied error because go is trying to access /usr/lib/go/src/pkg/github.com, or I get the source to download but it can't find the standard library stuff. Anyone got any ideas, here?

Last edited by Bellum (2012-04-01 02:20:32)

Offline

#2 2012-03-31 04:32:09

Bellum
Member
Registered: 2011-08-24
Posts: 230

Re: [SOLVED] Packaging go projects

Feel free to make stuff up if you have no idea; mayble it'll help me figure it out. tongue

Offline

#3 2012-03-31 05:00:41

Jristz
Member
From: America/Santiago
Registered: 2011-06-11
Posts: 1,048

Re: [SOLVED] Packaging go projects

is github right?
isnot supposed to git clone the repo after the building this?


Lenovo ThinkPad L420 modified
:: Intel i7 2560QM :: 8 GB RAM :: SSD 256 GB ::
:: DVD read+Writter :: 3 USB 3.0 Expresa Card ::
:: a Favulous 1 mins lasting Io-Li battery ::cry::

Offline

#4 2012-03-31 05:26:50

Bellum
Member
Registered: 2011-08-24
Posts: 230

Re: [SOLVED] Packaging go projects

No, go's build tools are peculiar in that they can suck source right off the internet like some magical vacuum cleaner. It's getting the source code just fine, but the build fails because of permission issues or because of the GOROOT or GOPATH, I can't quite figure it out.

(well, ok, no, that version of the PKGBUILD isn't correctly grabbing the source, but you can use this one

# vim:set ts=2 sw=2 et:6
# Maintainer: Aaron P <aaronbpaden at that google place>
pkgname=mdtwm
pkgver=20120329
pkgrel=1
pkgdesc="Mouse-Driven Tiling WM written in Go"
url="https://github.com/ziutek/mdtwm"
arch=('x86_64' 'i686')
license=('BSD')
makedepends=('go')
conflicts=()
replaces=()
backup=()

build() {
  GOROOT=${srcdir}
  go get github.com/ziutek/mdtwm
}

#package() {
#}

to demonstrate this deep wizardry, it just can't find the std go libs in that case )

Offline

#5 2012-03-31 05:38:21

Bellum
Member
Registered: 2011-08-24
Posts: 230

Re: [SOLVED] Packaging go projects

I've also tried

$GOROOT=${srcdir}:${GOROOT}

But that just creates a directory called "src:" for some reason. hmm

Offline

#6 2012-03-31 05:43:36

Jristz
Member
From: America/Santiago
Registered: 2011-06-11
Posts: 1,048

Re: [SOLVED] Packaging go projects

and set the goroot AND the goopath?
maybe using bot can work?

and try to use the github...maybe the problem maybe in the "magical momment" of fetching the source to compile by go.....or use gcc-go


Lenovo ThinkPad L420 modified
:: Intel i7 2560QM :: 8 GB RAM :: SSD 256 GB ::
:: DVD read+Writter :: 3 USB 3.0 Expresa Card ::
:: a Favulous 1 mins lasting Io-Li battery ::cry::

Offline

#7 2012-03-31 06:06:18

Bellum
Member
Registered: 2011-08-24
Posts: 230

Re: [SOLVED] Packaging go projects

Go retrieves the source just fine. The problem seems to be that I set GOROOT so that it isn't trying to write the source to /usr/lib/go/..., and it handles that correctly. But then it can't find the libs in /usr/lib/go/...!

The docs say you can delimit paths with a colon, but for some reason the PKGBUILD isn't behaving like shell. if I say GOROOT=${srcdir}:${GOROOT} I get back ${srcdir}:.


Wait, lemme try in shell....

Ok, no, that doesn't work. tongue Still can't find the libs.


Still, I'd rather be able to build PKGBUILDs that work with the official compiler.

Offline

#8 2012-03-31 06:23:02

Awebb
Member
Registered: 2010-05-06
Posts: 6,688

Re: [SOLVED] Packaging go projects

The problem seems to be that you don't post any real errors, but just your paraphrasing. smile

Offline

#9 2012-03-31 14:50:26

Bellum
Member
Registered: 2011-08-24
Posts: 230

Re: [SOLVED] Packaging go projects

Absolutely right, Awebb. I'll repeat myself using slightly different wording again. smile

package github.com/ziutek/mdtwm: mkdir /usr/lib/go/src/pkg/github.com: permission denied

^ That is if GOROOT is the default value (/usr/lib/go). The reason you get that error is because go is trying to write the source code it's fetching to $GOROOT/src/pkg/.

If you change $GOROOT to $srcdir you get the following error:

package github.com/ziutek/mdtwm
	imports bufio: unrecognized import path "bufio"
package github.com/ziutek/mdtwm
	imports bytes: unrecognized import path "bytes"
package github.com/ziutek/mdtwm
	imports encoding/json: unrecognized import path "encoding/json"
package github.com/ziutek/mdtwm
	imports errors: unrecognized import path "errors"
package github.com/ziutek/mdtwm
	imports fmt: unrecognized import path "fmt"
package github.com/ziutek/mdtwm
	imports io: unrecognized import path "io"
package github.com/ziutek/mdtwm
	imports net: unrecognized import path "net"
package github.com/ziutek/mdtwm
	imports os: unrecognized import path "os"
package github.com/ziutek/mdtwm
	imports runtime: unrecognized import path "runtime"
package github.com/ziutek/mdtwm
	imports strconv: unrecognized import path "strconv"
package github.com/ziutek/mdtwm
	imports strings: unrecognized import path "strings"
package github.com/ziutek/mdtwm
	imports log: unrecognized import path "log"
package github.com/ziutek/mdtwm
	imports math: unrecognized import path "math"
package github.com/ziutek/mdtwm
	imports os/exec: unrecognized import path "os/exec"
package github.com/ziutek/mdtwm
	imports os/signal: unrecognized import path "os/signal"
package github.com/ziutek/mdtwm
	imports path/filepath: unrecognized import path "path/filepath"
package github.com/ziutek/mdtwm
	imports reflect: unrecognized import path "reflect"
package github.com/ziutek/mdtwm
	imports syscall: unrecognized import path "syscall"
package github.com/ziutek/mdtwm
	imports time: unrecognized import path "time"
package github.com/ziutek/mdtwm
	imports unicode/utf16: unrecognized import path "unicode/utf16"
package github.com/ziutek/mdtwm
	imports unsafe: unrecognized import path "unsafe"

These are libs that come with go and that can be found at /usr/lib/go/src/pkg

Last edited by Bellum (2012-03-31 14:51:32)

Offline

#10 2012-03-31 17:29:07

fflarex
Member
Registered: 2007-09-15
Posts: 466

Re: [SOLVED] Packaging go projects

Try this:

mkdir -p ${srcdir}/usr/lib/go/{bin,pkg,src}
export GOROOT=/usr/lib/go
export GOPATH=${srcdir}/usr/lib/go
mkdir -p $GOPATH/src/github.com/ziutek/mdtwm
cd $GOPATH/src/github.com/ziutek/mdtwm
git clone git://github.com/ziutek/mdtwm.git
go install github.com/ziutek/mdtwm

The important bits you were missing were not exporting your environment variables and not creating the bin, pkg, and src directories under GOPATH.

Also, 'go install' does not download anything automatically (like dependencies) for you like 'go get' does. So, that's the command you really should be using for quality control in your packages.

As you may have guessed, binaries will end up in /usr/lib/go/bin. Libraries will be in /usr/lib/go/pkg. Sources will be installed in /usr/lib/go/src. The simplest thing would be to leave everything there, but then the binaries won't be in your PATH and the source will be included in the package as well. These are both very odd properties compared to most packages. I'm not sure if any Arch packagers have thought about how to handle this, but it's a bit of a conundrum since go is very strict about the directory structure. I'm really not sure where everything should get put. Maybe just delete the sources and move the binaries to /usr/bin?

Last edited by fflarex (2012-03-31 17:57:58)

Offline

#11 2012-04-01 02:20:08

Bellum
Member
Registered: 2011-08-24
Posts: 230

Re: [SOLVED] Packaging go projects

That clears things up a lot, thanks. It turns out mdtwm is like dwm in that it reqiures you to edit the source to configure, so I'm not sure how useful an aur package would be, but next time I need to make one I'll know how. big_smile

Offline

Board footer

Powered by FluxBB