Compiling "crowdsec" (v.1.4.1) for aarch64 / arm64 (OpenWRT / FriendlyWRT 22.03)?

Build system: Ubuntu 22.04.1 LTS (5.15.0-48-generic) on x86_64
Host system: FriendlyWRT NanoPi R4SE running FriendlyWRT 22.03;

Hello,

Recently tried out FriendlyWRT which is a fork (?) of OpenWRT and got quite far using the existing package for OpenWRT;
crowdsec for OpenWRT 22.03;
/releases/packages-22.03/aarch64_cortex-a53/packages/crowdsec_1.3.0-3_aarch64_cortex-a53
however in OpenWRT 22.03 the package for “cs-firewall-bouncer” is missing as multiple people have reported but it exists on 21.02 (ex below is for 21.02.3);
releases/21.02.3/packages/aarch64_cortex-a53/packages/crowdsec-firewall-bouncer_0.0.21-3_aarch64_cortex-a53.ipk

I did get so far as to get both the agent and bouncer registered onto the web dashboard and installed multiple scenarios.
However when trying to simulate scenarios and list decisions using the instructions shown under “Simulation” in CrowdSec’s user guide no decisions were shown and I received an error when checking the log.
I didn’t save that error (sat late last night) and decided to see if it’s possible to compile the latest version for:
crowdsec (v.1.4.1);
for aarch64?

“cs-firewall-bouncer” seem to already have a precompiled version for “aarch64” which I believe was the one I installed when trying it out manually instead of trying out the package available in OpenWRT’s repo;

However since the agent that is available for 21.02 is 1.3.0.3 and the latest agent is 1.4.1 I would like to try and compile it from source.
This is my very first time trying to “make” something from source so be nice:

Using these general instructions on my Ubuntu VM;
https://jensd.be/1126/linux/cross-compiling-for-arm-or-aarch64-on-debian-or-ubuntu

  1. Downloading the source code for 1.4.1:
    wget https://github.com/crowdsecurity/crowdsec/archive/refs/tags/v1.4.1.tar.gz

  2. Installing necessary build-tools for crosscompiling aarch64 / arm64 on x86_64:
    sudo apt install gcc make gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu

  3. Extracting the compressed file:

tar -xf v1.4.1.tar.gz
cd crowdsec-1.4.1
  1. Trying to run “configure”;
    ./configure --build x86_64-pc-linux-gnu --host aarch64-linux-gnu
    returns
    bash: ./configure: No such file or directory

  2. Ok so no “configure”-file, lets try to run make “as-is” (“make”) which returns (log-snippet):

Building for linux
[...]
/bin/sh: 1: git: not found
/bin/sh: 1: go: not found
[...]
make[1]: *** [Makefile:29: build] Error 127
make: *** [Makefile:122: crowdsec] Error 2
  1. Ok so seem to be missing “go” and “git”, lets install them:
sudo apt-get install golang
sudo apt install git
  1. “make” now returns (log-snippet):
[...]
make -C ./plugins/notifications/dummy build --no-print-directory GOARCH=amd64 GOOS=linux RM="rm -rf" WIN_IGNORE_ERR="" CP="cp" CPR="cp -r" MKDIR="mkdir -p"
fatal: not a git repository (or any of the parent directories): .git

Err…well that (running “make” to make a native x86_64-build) didn’t (?) work I guess?
Any suggestions?

It might be well above someone who is just delving into this to do a crosscompilation of x86_64 to aarch64 / arm64 and even if the compilation would work it would require a lot more work?

Sorry for a long post and thanks for getting this far regardless of if you answer or not! / Karl

I’m not sure if you need to compile the bouncer yourself. As for OpenWrt 22.03.0 the bouncer package is missing, I figured out a workaround for me. See 22.03.0: workaround for running CrowdSec bouncer - Installing and Using OpenWrt - OpenWrt Forum .
I will probably spend some time for creating a crowdsec-bouncer package with uci configuration and maybe even a luci app for it. This because the standard rules created by the bouncer do not fit my needs.
But for your initial question: I see that the OpenWrt package in 21.02. is downloading a compiled bouncer and puts it into the package. Maybe this is also suitable for you?

Hello,

Thank you for your reply.

Since there is an “aarch64”-package for the latest cs-firewall-bouncer (see link in my first post) I was able to install it (unsure if my failure to get Crowdsec working was because of that the package isn’t customized for OprnWRT more then that is an “aarch64”-package).

So I was thinking more about the agent, I clarified my original post.

I did a factory reset of my OpenWRT device and it didn’t work right afterwards so need to reflash it and try Crowdsec again but I’ll keep your suggestion in mind, thanks!