Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyinstaller-based binary for ARM (raspberry pi) #1018

Closed
nelg opened this issue May 5, 2016 · 41 comments
Closed

pyinstaller-based binary for ARM (raspberry pi) #1018

nelg opened this issue May 5, 2016 · 41 comments

Comments

@nelg
Copy link

nelg commented May 5, 2016

Hi,

The pyinstaller-based binaries for borg are very useful. However, it would be nice if the was one available for the raspberry pi. (armv6l)

Glen

@ThomasWaldmann
Copy link
Member

ThomasWaldmann commented May 7, 2016

Not sure if creating a single-file binary is possible with pyinstaller, someone with a raspberry pi 1 would have to check. The development section of the docs describes how this is usually done, the Vagrantfile has some practically tested code.

Maybe these binaries could be also useful on other ARM based hardware, where installing borg otherwise is difficult to impossible (like some NAS devices).

@ThomasWaldmann ThomasWaldmann changed the title pre-compiled for arm (raspberry pi) pyinstaller-based binary for ARM (raspberry pi) May 7, 2016
@ThomasWaldmann
Copy link
Member

ThomasWaldmann commented May 7, 2016

BTW, a note about running on low-memory systems: borg needs quite some memory for the dedup hashtable and also for the files cache, so be careful. There's a formula in the docs to estimate RAM needs.

@nelg
Copy link
Author

nelg commented May 9, 2016

As a side note, I've run borg backup on arch on the raspberry pi, without major issues, backing up a fairly small set of files (< 2GB).

@ThomasWaldmann
Copy link
Member

ThomasWaldmann commented May 9, 2016

I removed all comments from this ticket dealing with the raspian package - dist packages are what #105 deals with.

@bauerj
Copy link
Contributor

bauerj commented Jul 3, 2016

Not sure if creating a single-file binary is possible with pyinstaller, someone with a raspberry pi 1 would have to check.

I was able to successfully build a pyinstaller based armhf-binary of the 1.0.3 release 🎉 . You can download it here: borg-armhf (9.0MB) ⬇️

I did a quick test (only the basic commands) that showed the binary works on a raspberry pi without Python 3.

The linked libraries seem to be the ARM versions of what the official binaries are linked against:

bauerj@zero:~ $ ldd borg-armhf
        /usr/lib/arm-linux-gnueabihf/libarmmem.so (0xb6f40000)
        libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xb6f1b000)
        libz.so.1 => /lib/arm-linux-gnueabihf/libz.so.1 (0xb6ef4000)
        libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6db3000)
        /lib/ld-linux-armhf.so.3 (0x7f578000)

I built this binary on my Raspberry Pi so I was unable to use vagrant to build the binary (seems like using QEMU with vagrant wouldn't be a good idea 😯 ). The process was pretty straight-forward, although quite slow due to the limited amount of processing power and the need to compile most of the dependencies (including Python itself).

I guess the goal is to have official ARM binaries on the release page so the following issues need to be addressed:

  1. It seems like you (the borg developers) don't have an ARM device which means that you can't generate the binary yourself. (Is that correct?)
  2. The build process I used is very manual (e.g. copy-and-pasting the correct lines from the Vagrantfile).
  3. Currently, unit tests are not run against ARM hardware (at least not automatically) so a failing ARM build would only be noticed after the release.

Any ideas?

@enkore
Copy link
Contributor

enkore commented Jul 3, 2016

While Vagrant + QEMU is probably not viable, Linux-on-QEMU should be. We used it before for powerpc (although that's very slow, but we got dedicated hardware now). Some more exotic tests (ie. not on Travis) tests are run here, if the speed of QEMU is feasible I might add it there.

One can also run a subset of the tests against a compiled Borg binary. It must be named borg.exe and be on the PATH for this. This is what the Vagrantfile also does.


I'm not sure if precompiled ARM binaries make a lot of sense, there are many ARM flavours. Since Borg is in Debian and most people seem to use that on RPis those should have packages available?

@PlasmaPower
Copy link
Contributor

@enkore I'm assuming you're passing -enable-kvm to it? That will speed it up a lot.

@bauerj
Copy link
Contributor

bauerj commented Jul 3, 2016

Sounds good, I think builds could also be produced on scaleway's ARM servers if QEMU turns out to be too slow.

@bauerj
Copy link
Contributor

bauerj commented Jul 3, 2016

So the only issue that's left is finding a way to use the logic from the Vagrantfile without using Vagrant. As the syntax seems to be Ruby, maybe a Ruby script could be written?

@PlasmaPower
Copy link
Contributor

Why exactly can't we use Vagrant? vagrant-libvirt is a thing (libvirt is a qemu manager).

@bauerj
Copy link
Contributor

bauerj commented Jul 3, 2016

That project seems not to be stable yet and I couldn't find any ARM image for it.

@bauerj
Copy link
Contributor

bauerj commented Jul 9, 2016

I'm not sure if precompiled ARM binaries make a lot of sense, there are many ARM flavours. Since Borg is in Debian and most people seem to use that on RPis those should have packages available?

Of course, with a Raspberry Pi you can just install python3, pip and then borg (it seems not to be included in Raspbian Jessie). My goal is to ultimately use borg on a NAS that's running a custom (Linux based) OS built by the hardware producer. There is no easy way to install python3 on that device and I don't want to break things by trying it.

I agree that that is probably an edge-case and most people who want to backup to such a device could just resort to rsync or even sftp. But you will probably agree that borg will outperform possible alternatives 😉

As to the different ARM flavours, most NAS seem to use armel, Raspberry Pi uses armhf. I guess those would make the most sense to have binaries for.

@alexmbird
Copy link

@bauerj before discovering this I spent an hour trying to roll my own pyinstaller binary, but couldn't get the resulting bin to work correctly. Could you post your version of pyinstaller and the command line you used?

@bauerj
Copy link
Contributor

bauerj commented Jul 11, 2016

Sure. I'm using PyInstaller 3.1.1, this is essentially what I executed:

  ARCH=$(uname -m)
  PYTHON="3.5.2"
  curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
  apt-get install -y libssl-dev libacl1-dev liblz4-dev libfuse-dev fuse pkg-config
  apt-get install -y fakeroot build-essential git
  apt-get install -y zlib1g-dev libbz2-dev libncurses5-dev libreadline-dev liblzma-dev libsqlite3-dev
  env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install -v $PYTHON
  pyenv shell $PYTHON
  cd /opt
  git clone https://github.com/borgbackup/borg/
  cd borg
  git checkout 1.0.3
  pip install -r requirements.d/development.txt
  cd /opt
  git clone https://github.com/pyinstaller/pyinstaller.git
  cd pyinstaller
  git checkout v3.1.1
  cd bootloader
  python ./waf all --no-lsb
  cd ..
  pip install -e .
  cd /opt/borg
  pip install -e .
  LD_LIBRARY_PATH=~/.pyenv/versions/$PYTHON/lib/ pyinstaller -F -n borg-$ARCH --clean borg/__main__.py

I hope that helps.

@bmarwell
Copy link

bmarwell commented Aug 4, 2016

I'd like to test on armv7, banana pi. I installed open media vault, which only has python 3.2 support.

Can I cross compile from another computer, or do you have such a binary yet? Thanks.

@bauerj
Copy link
Contributor

bauerj commented Aug 4, 2016

You can test this binary here: https://bauerj.eu/borg-armhf

Please report whether it worked or not.

@bmarwell
Copy link

bmarwell commented Aug 5, 2016

Sadly, it did not.

root@openmediavault:~/Download# ./borg-armhf 
Error loading Python lib '/tmp/_MEIIgQFen/libpython3.5m.so.1.0': /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.17' not found (required by /tmp/_MEIIgQFen/libpython3.5m.so.1.0)

ldd:

root@openmediavault:~/Download# ldd borg-armhf
        libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xb6f42000)
        libz.so.1 => /lib/arm-linux-gnueabihf/libz.so.1 (0xb6f28000)
        libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6e41000)
        /lib/ld-linux-armhf.so.3 (0xb6f55000)
        libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6e1d000)

Thanks for your efforts so far!

@enkore
Copy link
Contributor

enkore commented Aug 5, 2016

Try pyenv. I use it on the odroid C2 running the ARM64 tests. It compiles on the machine it's running, so it'll take a while.

@bmarwell
Copy link

bmarwell commented Aug 5, 2016

Try pyenv. I use it on the odroid C2 running the ARM64 tests. It compiles on the machine it's running, so it'll take a while.

I'm not sure this is what I want. It takes a lot of time, upgrading is much more complicated. I'll see into it anyway.

@bauerj
Copy link
Contributor

bauerj commented Aug 5, 2016

Well, as long as there are no official ARM binary builds it would be even harder to update the binary 😉

@enkore
Copy link
Contributor

enkore commented Aug 5, 2016

I'm not sure this is what I want. It takes a lot of time, upgrading is much more complicated. I'll see into it anyway.

I see what you mean. Especially on such weakly devices one would really rather have binary (Python, Borg) packages available. If that's not the case, though, then there are not that many options. I guess it's possible to cross-compile python, but it probably takes longer to setup the cross-compiling environment than just building it on the ARM.

iirc Python 3.x took about an hour or so on the C2 to build.

@bmarwell
Copy link

bmarwell commented Aug 6, 2016

Pyenv and pip install took a while. Anyway, can I somehow provide a standalone binary to others?

@bauerj
Copy link
Contributor

bauerj commented Aug 6, 2016

Sure!

Here are the commands I used to create a binary on the Raspberry Pi (of course you can skip the pyenv part). It would have worked on your device too if it wasn't for the old glibc version your OS uses.

@bmarwell
Copy link

bmarwell commented Aug 8, 2016

@bauerj You were missing a pip install -e . in pyinstaller, otherwise it'd say "pyinstaller: not found".

Other than that, Banana Pi is armv7l. Please try this binary found in this folder. Please give me some information if this works for others: https://goo.gl/rEI49A.

@kzar
Copy link

kzar commented Oct 7, 2016

@bmhm Your linked 1.0.6 armv7l build is the only one I've found that will run on my Synology DS416, thanks for that. Any chance you could create a new one for borg 1.0.7, that would mean I could avoid positional argument warnings.

@bauerj
Copy link
Contributor

bauerj commented Oct 7, 2016

@kzar It would be nice if you could test the 1.0.7 binary here: https://borg.bauerj.eu/ (armv6 should hopefully work for you)

➡️ ➡️ ➡️ There will also be future versions avaiable here: 📂 https://borg.bauerj.eu/ ⬅️ ⬅️ ⬅️

@kzar
Copy link

kzar commented Oct 7, 2016

@bauerj Wow, that's service! Thanks it seems to be running fine, my first borg backup is now underway. I'll let you know if it completes (will likely be some hours unfortunately).

@kzar
Copy link

kzar commented Oct 7, 2016

@bauerj Well it keeps stalling when I attempt to do my first backup. It starts off happily and at some point silently stops transferring. I then have to C-c the process. It's likely nothing to do with your build, I'm planning to investigate a little more tomorrow to see if I can get it working.

@kzar
Copy link

kzar commented Oct 10, 2016

@baurej My problem looks unrelated to your Borg build, rather issue #636. (I could reproduce the problem with just SCP too, it reliably drops after about 1gig has transferred.) I've not been able to do a big test with your build therefore, but it did at least run and work initially. Thanks again for the help, Dave.

@enkore
Copy link
Contributor

enkore commented Oct 10, 2016

If it happens with scp as well, then it's likely an issue outside of Borg.

Wild speculation:

  • 1 GB could be the kernel running out of cache memory, so it starts writing to disk which is often slow with ARM boards
  • Perhaps a power dissipation problem? My odroid c2 board regularly locks up under load if no additional cooling (fan) is provided
  • More recent versions of SSH support chacha20-poly1305 which tends to be much faster than anything else on ARM (less CPU load, less heat). You can see what your connection is using by ssh -v ..., the lines kex: server->client cipher: and kex: client->server cipher: tell this.

@kzar
Copy link

kzar commented Oct 19, 2016

OK so I found that if I connect via my VPN the connection doesn't drop, don't ask me why. @bauerj Your build seems to be working nicely so far.

@bauerj
Copy link
Contributor

bauerj commented Oct 19, 2016

Great! 🎉 Thanks for testing.

@ThomasWaldmann
Copy link
Member

@bauerj https://github.com/borgbackup/borg/pull/2076/files this change will be in 1.0.10*.

As you are building for ARM, you likely will compile the pyinstaller bootloader on your own (thus the inclusion of the fixed x64/x86 bootloaders makes no difference for you). But please make sure that the bootloader source you use has the same fixes.

It might be also worthwile doing an additional binary made with pyinstaller 3.2.1.

@bauerj
Copy link
Contributor

bauerj commented Jan 22, 2017

Thanks for the heads-up!

I don't know how to interpret the last sentence though. Should I do another 1.0.9 binary with pyinstaller 3.2.1 or should I do two releases (one with your fork and one with pyinstaller 3.2.1) for 1.0.10?

@ThomasWaldmann
Copy link
Member

I meant the upcoming 1.0.10 release (likely in a few days).
I will do the official release (x86/x64) binaries using the current Vagrantfile.
Additionally, I'll do some experimental x64 binary using pyi 3.2.1.

@milkey-mouse
Copy link
Contributor

FWIW you could always cross-compile for ARM using something like this.

@kzar
Copy link

kzar commented Nov 8, 2017

Any chance of a 1.1.X build @bauerj?

@bauerj
Copy link
Contributor

bauerj commented Nov 8, 2017

There you go: https://borg.bauerj.eu/

@kzar
Copy link

kzar commented Nov 8, 2017

Awesome, thanks. Seems to work so far, doing a backup now.

@noplanman
Copy link

Just to let everybody here know, that I've managed to set up a docker solution for building binaries for all types of architectures.

Take a look here: https://git.feneas.org/noplanman/borg-binary-builder

I'm also looking into a solution for providing signed binaries directly, without requiring to do the whole docker operation for every new version.

@ThomasWaldmann
Copy link
Member

as the arm binaries are linked from the docs now, the borg-binary-builder from community repo, i guess there is nothing left to do for this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants