So, a few years later, here is an update on my own answerā¦
The upcoming Pydio Cells 4 (currently available as a Release Candidate) now supports modules! Woo-hoo!
There are many wonderful advantages to having modules (as opposed to āvendorsā): one of which is making external tools such as xgo
reasonably redundant (at least in many scenarios).
So, grab the latest copy from github/pydio/cells
, clone it to wherever you wish (with modules, you donāt need to place them on a specific location any longer), and change the Makefile
by adding a new entry:
cross-go:
$(info Cross-compile & build for target '${GOOS}', architecture: '${GOARCH}':)
env GOOS=${GOOS} GOARCH=${GOARCH} go build -a -trimpath\
-ldflags "-X github.com/pydio/cells/v4/common.version=${CELLS_VERSION}\
-X github.com/pydio/cells/v4/common.BuildStamp=${TODAY}\
-X github.com/pydio/cells/v4/common.BuildRevision=${GITREV}"\
-o cells\
.
Back on the shell, all you need is to do:
$ export GOOS=linux
$ export GOARCH=arm64
$ make cross-go
Sit back, wait a bit, and enjoy
You should get a freshly compiled cells
on the same directory. You can check that itās built for the ārightā architecture:
$ file cells
cells: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, Go BuildID=<long string>, not stripped
The actual output might vary a bit across systems, but thatās what you get on an Intel Mac (as well as on an AMD chip running Linux); it should be reasonably accurate, though (assuming that you have a fairly recent version of file
installed in your system).
Remote-copy the executable to your Raspberry Pi, log in remotely, and run ./cells configure
as usually.
Thatās it!
Oh, BTWā¦ since the last time Iāve posted, I did get a Raspberry Pi Zero W, for a pet project (connecting it to an old APC Smart UPS so that I can read the battery status and push it into all devices and computers on our home network ), and Iāve been happily tinkering with running Go on it. But sometimes the poor Pi overheats and consumes all memory available on the small flash card when doing heavy-duty compilations, so Iām happy to do some cross-compilations instead. It works so well (and so quickly!) that Iām always amazed at the power of Go cross-compilation made easy.
Oh, and in my personal case, I also own a Synology NAS, which ā youāve guessed it! ā also has an ARM64 chip and runs a special version of Linux. I have been consistently compiling Go apps on it as well ā it has substantially more āraw powerā than the tiny Pi, but itās also not an environment designed for heavy-duty compilation! ā and, naturally enough, getting Pydio Cells on a home NAS makes a lot of sense, and for ages Iāve been terribly frustrated that most of my compilations would never terminate (mostly because of the issues with Cgo).
But now I can just cross-compile once on my Mac, and just push the resulting ARM64 binary to both the NAS and the Pi! Easy-peasy!
Extra bonus: aye, the same trick applies to cells-client
ā just make sure youāre using the v2
branch (you should, in any case!). Itās simply brilliant ā I had my Pi ātalkingā to my externally hosted Pydio Cells in a matter of seconds (after getting a key, etc. ā a process that is so easy to do nowadays)!
When I think back to the hours and days of frustration in dealing with complex compilation chains using the old vendor-based approachā¦ I can only sigh at the wasted time (and I never got any significant results).
These days, all it takes is a recent version of Go and the latest versions of Pydio Cells and CEC (aka cells-client
), since both support modules, and that means that the Go toolchain has all it needs to cross-compile everything to whatever OS and CPU architecture you wish.
Nowā¦ I need to do the same with the client-sync
CLIā¦ thatās a bit tougher, at the current stage of developmentā¦ but Iām sure that itās just a question of time!