koenvervloesem / bazel-on-arm

Build the open source build tool Bazel for ARM on the Raspberry Pi
MIT License
89 stars 19 forks source link

Debian 9 support #2

Open bpatram opened 4 years ago

bpatram commented 4 years ago

Hi! Thank you for making this repo and managing these patches. This isn't a bug report! I am targeting an older version of Debian (9/stretch) than what is currently supported in this project (10/buster). I ran into a few snags but I figured I would share the workarounds I had to do to make it work in case someone else tries to do the same and wants to save some time figuring it out.

Issue 1: No OpenJDK 11 in the default repos Problem:

$ make requirements
E: Unable to locate package openjdk-11-jdk-headless
./scripts/install_requirements.sh: line 9: update-java-alternatives: command not found

Workaround: We can use the stretch-backports release channel repo to get OpenJDK 11. I had to change most of the install_requirements.sh script so instead of running make requirements, I had to run the following in its entirety. The path to my JVM may differ from you, if so, you can find out what your options are by running: update-java-alternatives -l.

$ echo "deb http://ftp.de.debian.org/debian stretch-backports main" | tee /etc/apt/sources.list
$ apt-get update
$ apt-get -t stretch-backports install -y openjdk-11-jdk-headless
$ apt-get install -y build-essential zip unzip libatomic1
$ update-java-alternatives -s java-1.11.0-openjdk-arm64

Note: I am targeting arm64, if you are using Raspbian the JVM should be: java-1.11.0-openjdk-armhf instead.

Issue 2: Missing build dependencies Problem:

$ make bazel
./scripts/build_bazel.sh: line 20: wget: command not found

...

$ make bazel
/usr/bin/env: 'python': No such file or directory
Target //src:bazel_nojdk failed to build

Workaround: Pretty simple fix, just needed to install wget and python.

$ apt-get install -y wget python3
$ ln -s /usr/bin/python3 /usr/bin/python
$ make bazel
koenvervloesem commented 4 years ago

Thanks for this detailed issue! I think it makes sense to integrate these changes in install_requirements.sh to support Debian/Raspbian Stretch.

But do I see it correctly that you're running this on ARM64? Because the OpenJDK you're installing is java-1.11.0-openjdk-arm64, while I'm installing java-1.11.0-openjdk-armhf. I don't think the patches in this repository are needed anymore for ARM64.

Also, I wouldn't symlink python to python3, this could cause some problems because most software still expects python to be python2. Apparently bazel works fine with python2, so maybe install that?

bpatram commented 4 years ago

But do I see it correctly that you're running this on ARM64? Because the OpenJDK you're installing is java-1.11.0-openjdk-arm64, while I'm installing java-1.11.0-openjdk-armhf. I don't think the patches in this repository are needed anymore for ARM64.

Noted! I recently upgraded to a Pi4 from a Pi3 so I honestly didn't put much thought towards the architecture change until you called it out here. I'm running Debian and not Raspbian. Raspbian is 32bit but Debian for Pi4 is 64bit which explains why I target arm64 and not armhf. I think this change would be needed if you used the beta 64bit version of Raspbian however.

Also, I wouldn't symlink python to python3, this could cause some problems because most software still expects python to be python2. Apparently bazel works fine with python2, so maybe install that?

I agree. My end goal is to compile grpc which needs python3. Bazel itself doesn't, so yes, python2 should work. I was having issues using an alias. I am building in a Docker container so I'm not too worried about affecting other applications, I just care about the binaries/build artifacts.